* Ada and X/Motif @ 1997-06-03 0:00 markovi 1997-06-04 0:00 ` Martin C. Carlisle ` (2 more replies) 0 siblings, 3 replies; 6+ messages in thread From: markovi @ 1997-06-03 0:00 UTC (permalink / raw) -- I am programming a user interface in Ada using X/Motif routines. The interface between X and Ada is implemented through X bindings. I have the following problem: to create a colormap, allocate colors and store a color I call consequently the bindings for XCreateColormap, XAllocColorCells and XStoreColor. When these functions are called in the main ada routine, they work properly. If I call any (or all) of the above functions in a separate procedure and then call this procedure in the main routine, the XStoreColor function does not store the color in the colormap. There is no error message, just the function does not do what it is supposed to do. Any help? Thanks! ------ Uliyana Markova Array Systems Computing Inc. 1120 Finch Ave.West, 8th floor Toronto, Ontario M3J 3H7 e-mail: uliyana@array.ca ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Ada and X/Motif 1997-06-03 0:00 Ada and X/Motif markovi @ 1997-06-04 0:00 ` Martin C. Carlisle 1997-06-04 0:00 ` jim hopper 1997-06-09 0:00 ` Christopher Green 2 siblings, 0 replies; 6+ messages in thread From: Martin C. Carlisle @ 1997-06-04 0:00 UTC (permalink / raw) >If I call any (or all) of the above functions in a separate procedure >and then call this procedure in the main routine, the XStoreColor >function does not store the color in the colormap. There is no error >message, just the function does not do what it is supposed to do. Any >help? Given that you don't mention what X binding you are using, this is very difficult to guess. I'll venture two suggestions from my experience with Win32 bindings. 1) If the binding is yours, you may need to add something like pragma Convention(Stdcall,XStoreColor); 2) You may have forgotten to call some important initialization routine (I had similar behavior under Win32 when I forgot InitCommonControls) --Martin -- Martin C. Carlisle, Computer Science, US Air Force Academy mcc@cs.usafa.af.mil, http://www.usafa.af.mil/dfcs/bios/carlisle.html DISCLAIMER: This content in no way reflects the opinions, standard or policy of the US Air Force Academy or the United States Government. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Ada and X/Motif 1997-06-03 0:00 Ada and X/Motif markovi 1997-06-04 0:00 ` Martin C. Carlisle @ 1997-06-04 0:00 ` jim hopper 1997-06-09 0:00 ` Christopher Green 2 siblings, 0 replies; 6+ messages in thread From: jim hopper @ 1997-06-04 0:00 UTC (permalink / raw) Have you looked at Xforms?? its a gui builder and library that makes building x gui's very simple. there is a nice extension to it that converts the c code xforms spits out to ada95. its available on a wide variety of platforms (shameless plug : I just ported it to mac for use with gnat on the Mac, download from the xforms site) and has excellent documentation. i know this isn't a direct answer but using this toolkit may allow you to do what you want with less work. http://bragg.phys.uwm.edu/xforms <== xforms home ftp://ocsystems.com/xada/aforms-0.8.11.tar.gz <== aforms source http://www.ocsystems.com/xada/xforms1.html <== x ada web site jim hopper -------- In article <3394CED4.2BF7@interlog.com> markovi@interlog.com writes: > I am programming a user interface in Ada using X/Motif routines. The > interface between X and Ada is implemented through X bindings. > I have the following problem: to create a colormap, allocate colors > and store a color I call consequently the bindings for > XCreateColormap, XAllocColorCells and XStoreColor. When these > functions are called in the main ada routine, they work properly. > If I call any (or all) of the above functions in a separate procedure > and then call this procedure in the main routine, the XStoreColor > function does not store the color in the colormap. There is no error > message, just the function does not do what it is supposed to do. Any > help? ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Ada and X/Motif 1997-06-03 0:00 Ada and X/Motif markovi 1997-06-04 0:00 ` Martin C. Carlisle 1997-06-04 0:00 ` jim hopper @ 1997-06-09 0:00 ` Christopher Green 1997-06-10 0:00 ` Jeff W. Boote 1997-06-10 0:00 ` Uliyana Markova 2 siblings, 2 replies; 6+ messages in thread From: Christopher Green @ 1997-06-09 0:00 UTC (permalink / raw) In article <3394CED4.2BF7@interlog.com>, Uliyana Markova <markovi@interlog.com> wrote: >I am programming a user interface in Ada using X/Motif routines. The >interface between X and Ada is implemented through X bindings. >I have the following problem: to create a colormap, allocate colors >and store a color I call consequently the bindings for >XCreateColormap, XAllocColorCells and XStoreColor. When these >functions are called in the main ada routine, they work properly. >If I call any (or all) of the above functions in a separate procedure >and then call this procedure in the main routine, the XStoreColor >function does not store the color in the colormap. There is no error >message, just the function does not do what it is supposed to do. Any >help? Any chance you could post or email an example, and provide information on what Ada compiler, set of bindings, and X11 implementation you are using? Since XStoreColor() does not return a status to indicate whether it succeeded, the only way to determine whether the color was stored is to observe it on the display. For this to happen, the colormap must also have been installed; XSetWindowColormap() does this (actually, the window manager detects the colormap change and installs the color- map). So either XSetWindowColormap() must also be called in the sub- program; or the subprogram must return the colormap, and the main pro- gram must call XSetWindowColormap(). Just as a place to start looking, I'd look for variables that may not be correctly passed between main and subprogram, or variables that do not have an adequate lifetime when the binding functions are called from the subprogram. Remember that many X Window System objects are represented by C pointers, and a C pointer to a local variable becomes a dangling pointer when the subprogram returns. Chris Green Email cgreen@atc.com Advanced Technology Center Phone (714) 583-9119 22982 Mill Creek Drive ext. 220 Laguna Hills, CA 92653 Fax (714) 583-9213 ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Ada and X/Motif 1997-06-09 0:00 ` Christopher Green @ 1997-06-10 0:00 ` Jeff W. Boote 1997-06-10 0:00 ` Uliyana Markova 1 sibling, 0 replies; 6+ messages in thread From: Jeff W. Boote @ 1997-06-10 0:00 UTC (permalink / raw) Christopher Green (cgreen@yosemite.atc.com) wrote: :> Since XStoreColor() does not return a status to indicate whether it :> succeeded, the only way to determine whether the color was stored is :> to observe it on the display. Or call XQueryColor. jeff -- Jeff W. Boote <boote@ucar.edu> *************************************** Scientific Computing Division * There are more things in heaven and * National Center for Atmospheric Research * earth, Horatio, Than are dreamt of * Boulder * in your philosophy. Hamlet * *************************************** ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Ada and X/Motif 1997-06-09 0:00 ` Christopher Green 1997-06-10 0:00 ` Jeff W. Boote @ 1997-06-10 0:00 ` Uliyana Markova 1 sibling, 0 replies; 6+ messages in thread From: Uliyana Markova @ 1997-06-10 0:00 UTC (permalink / raw) Christopher Green wrote: > > In article <3394CED4.2BF7@interlog.com>, Uliyana Markova <markovi@interlog.com> wrote : > >I am programming a user interface in Ada using X/Motif routines. The > >interface between X and Ada is implemented through X bindings. > >I have the following problem: to create a colormap, allocate colors > >and store a color I call consequently the bindings for > >XCreateColormap, XAllocColorCells and XStoreColor. When these > >functions are called in the main ada routine, they work properly. > >If I call any (or all) of the above functions in a separate procedure > >and then call this procedure in the main routine, the XStoreColor > >function does not store the color in the colormap. There is no error > >message, just the function does not do what it is supposed to do. Any > >help? > > Any chance you could post or email an example, and provide information > on what Ada compiler, set of bindings, and X11 implementation you are > using? Thanks a lot for responding. I am sorry I did not specify the versions on a first place. I am using X11 Release 5, the ada compiler is VADSself Version 6.2.3-0 and the ada bindings are downloaded from the DEC's web site. Here is an example of one of a version that does not work. ------------------------------ with X_Lib; with Xt; with X; with Xm_String; with System; package Color_Pkg is procedure Color; end Color_Pkg; package body Color_Pkg is colormap : X.Colormap_Type; pixel_cells : X_Lib.Vector_Of_Colormap_Index_Type ( 1..256 ) := ( others => X_Lib.Colormap_Index_Init); package Manipulate_Colormap is new Xt.Manipulate_Avt ( X.Colormap_Type ); procedure Color is plane_masks : X_Lib.Vector_Of_Plane_Mask_Type ( 1..0 ); dpy : X_Lib.Display_Type; screen_num : X_Lib.Screen_Number_Type; Visual_Info : X_Lib.Visual_Info_Type; toplevel : Ip_Toplevel.Toplevel_Widget; al : Xt.Arg_List_Type ( 0..0 ); color : X_Lib.Color_Type; color_test : X_Lib.Color_Type; success : Boolean; begin -- application initialize - create toplevel widget dpy := Xt.Display ( Xt.Widget_Type ( toplevel) ); screen_num := X_Lib.Screen_Number_Of_Screen ( X_Lib.Default_Screen_Of_Display ( dpy ) ); X_Lib.Match_Visual_Info ( success, dpy, screen_num, X_Lib.Depth_Type ( 8), X_Lib.Pseudo_Color, Visual_Info ); if ( success ) then colormap := X_Lib.Create_Colormap ( dpy, X_Lib.Default_Root_Window ( dpy ), Visual_Info.Visual.all, X_Lib.All_Of_Them ); end if; X_Lib.Alloc_Color_Cells ( success, dpy, colormap, False, plane_masks ( 1..0 ), pixel_cells ); al ( 0 ) := ( Xm_String.NColormap_Ptr, Manipulate_Colormap.To_Avt ( colormap ) ); Xt.Set_Values ( Xt.Widget_Type ( toplevel ), al ( 0..0 ) ); color.pixel := X_Lib.Colormap_Index_Type ( pixel_cells ( 4 ) ); color.Do_Red := True; color.Do_Green := True; color.Do_Blue := True; color.Red := X_Lib.Color_Intensity_Unsigned_Short_Subtype ( 65535 ); color.Green := X_Lib.Color_Intensity_Unsigned_Short_Subtype ( 0 ); color.Blue := X_Lib.Color_Intensity_Unsigned_Short_Subtype ( 0 ); X_Lib.Store_Color ( dpy, colormap, color); color_test.pixel := X_Lib.Colormap_Index_Type ( pixel_cells ( 4 ) ); -- returns always black color X_Lib.Query_Color ( dpy, colormap, color1 ); -- realize toplevel and start the event loop end Color; end Color_Pkg; with Color_Pkg; procedure Color is begin Color_pkg.Color; end Color; Note that a new colormap is installed. All it's entries contain the black color ( r=0, g=0, b=0 ). Uliyana Markova ------ Array Systems Computing Inc. 1120 Finch Ave. West, 8th Floor North York, Ontario, Canada M3J 3H7 Tel.: 416-736-0900 ext 280 e-mail: uliyana@array.ca ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~1997-06-10 0:00 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 1997-06-03 0:00 Ada and X/Motif markovi 1997-06-04 0:00 ` Martin C. Carlisle 1997-06-04 0:00 ` jim hopper 1997-06-09 0:00 ` Christopher Green 1997-06-10 0:00 ` Jeff W. Boote 1997-06-10 0:00 ` Uliyana Markova
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox