[comp.windows.x] a couple o' questions

sam@uncle-bens.rice.edu (Samuel R Johnson) (12/18/90)

hello.  i've been not keeping up wih this group since last summer,
so i apologize if any of this has been covered previously...

two questions:

with Xt, Athena - is there any *clean* way to get a command widget to
display a pixmap?  like, maybe a happy face or a frog or something?

also with Xt, Athena - i realize this is taboo, but sometimes i'd really
like to just draw into a widget with Xlib routines for one reason or 
another.  when i try to do an

   XDrawRectangle(XtDisplay(w),XtWindow(w),XtGetGC(w,0,&val),
      0, 0, width, height);

i get nothing.  thinking that perhaps the colors are set incorrectly (invisibly)
for the widget in its GC, i tried creating my own

   gc = XCreateGC(XtDisplay(w),XtWindow(w),None,NULL); /* defaults */
   XDrawRectangle(XtDisplay(w),XtWindow(w),gc,
      0, 0, width, height);

but still see nothing.  any ideas?

thanks a bunch.

-Sam
sam@owlnet.rice.edu

etaylor@wilkins.iaims.bcm.tmc.edu (Eric Taylor) (12/19/90)

In article <1990Dec18.142305.23701@rice.edu>, sam@uncle-bens.rice.edu (Samuel R Johnson) writes:
|> hello.  i've been not keeping up wih this group since last summer,
|> so i apologize if any of this has been covered previously...
|> 
|> two questions:
|> 
|> with Xt, Athena - is there any *clean* way to get a command widget to
|> display a pixmap?  like, maybe a happy face or a frog or something?

	XtNbitmap resource.
|> 
|> also with Xt, Athena - i realize this is taboo, but sometimes i'd really
|> like to just draw into a widget with Xlib routines for one reason or 
|> another.  when i try to do an
|> 
|>    XDrawRectangle(XtDisplay(w),XtWindow(w),XtGetGC(w,0,&val),
|>       0, 0, width, height);
|> 
|> i get nothing.  thinking that perhaps the colors are set incorrectly (invisibly)

	You are using XtGetGC all wrong.  First of all, you are passing
0 as the flag list.  This means you will be getting a GC with nothing
in it.  You did not tell it which members of the XGCValues you wanted
to use.  You should create this GC beforehand so that you can free it
up later.  Here, you can never free it up.

|> for the widget in its GC, i tried creating my own
|> 
|>    gc = XCreateGC(XtDisplay(w),XtWindow(w),None,NULL); /* defaults */
|>    XDrawRectangle(XtDisplay(w),XtWindow(w),gc,
|>       0, 0, width, height);

This uses the Default GC settings which are unpredictable.  Why not
set the foreground explicitly?

|> 
|> but still see nothing.  any ideas?
|> 
|> thanks a bunch.
|> 
|> -Sam
|> sam@owlnet.rice.edu
--
					Eric Taylor
					Baylor College of Medicine
					etaylor@wilkins.bcm.tmc.edu
					(713) 798-3776

mouse@LIGHTNING.MCRCIM.MCGILL.EDU (12/19/90)

>>    gc = XCreateGC(XtDisplay(w),XtWindow(w),None,NULL); /* defaults */
> This uses the Default GC settings which are unpredictable.

Not at all - only the font is in any sense unpredictable, unless the
implementation is seriously buggy.  From the Xlib document:

	The default GC values are:
	
	_________________________________________________________________________________
	Component            Default
	_________________________________________________________________________________
	function             GXcopy
	plane_mask           All ones
	foreground           0
	background           1
	line_width           0
	line_style           LineSolid
	cap_style            CapButt
	join_style           JoinMiter
	fill_style           FillSolid
	fill_rule            EvenOddRule
	arc_mode             ArcPieSlice
	tile                 Pixmap of unspecified size filled with foreground pixel
	                     (that is, client specified pixel if any, else 0)
	                     (subsequent changes to foreground do not affect this pixmap)
	stipple              Pixmap of unspecified size filled with ones
	ts_x_origin          0
	ts_y_origin          0
	font                 <implementation dependent>
	subwindow_mode       ClipByChildren
	graphics_exposures   True
	clip_x_origin        0
	clip_y_origin        0
	clip_mask            None
	dash_offset          0
	dashes               4 (that is, the list [4, 4])
	_________________________________________________________________________________
	
	Note that foreground and background are not set to any
	values likely to be useful in a window.

					der Mouse

			old: mcgill-vision!mouse
			new: mouse@larry.mcrcim.mcgill.edu