🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.windows.x.pex
8 messages
8 total messages Started by Keith Baccki Wed, 04 Nov 1992 19:22
Drawing into DrawingArea widget
#4
Author: Keith Baccki
Date: Wed, 04 Nov 1992 19:22
52 lines
2133 bytes
	Hello, I'm working with DEC PHIGS ver. 2.3A on a
DECstation 5000/133 with PXG+ hardware. I am writing code
that is half PHIGS and half Motif, and I am having trouble
drawing non-PHIGS graphics into an initialized Drawing Area
widget. Sounds pretty idiotic, but I've even had more experienced
X coders look at my code and shrug there shoulders. Anyway,
here's the basic structure:

 	    application shell widget
		     /     \
                    /       \
    PHIGS output widget   Form Dialog
				\
				 \
			      Drawing Area				


	Drawing something into the Drawing Area should be a
trivial task, but nonetheless the following pieces of code
do NOTHING in the window:

      XtSetArg(...);   /* bunch of these... NOTE: height = 650 */
                       /*                          width = 400 */
      ionwindow =XmCreateFormDialog(toplevelshell,"ionwindow",arglist,6);
      XtManageChild(ionwindow);

      XtSetArg(...);   /* Few more... NOTE: requested height = 460 */
	               /*                        "     width = 400 */
      iondrawable = XmCreateDrawingArea(ionwindow,"iondrawable",arglist,4);
      XtManageChild(iondrawable);

      gcvalues.foreground = BlackPixel(display,DefaultScreen(display));
      gcvalues.background = WhitePixel(display,DefaultScreen(display));

      gc = XCreateGC(display,XtWindow(iondrawable),GCForeground | GCBackground, &gcvalues);

      XFillRectangle(display,XtWindow(iondrawable),gc,(Position)50,(Position)50,(Dimension)200,(Dimension)200);
      XDrawLine(display,XtWindow(iondrawable),gc,(Position)
100,(Position) 100,(Position) 300,(Position) 150);
      XFlush(display);



Any suggestions? Am I missing something?


			Thanks in advance,

					Keith Baccki

					kiki@bass.bu.edu
Re: Drawing into DrawingArea widget
#5
Author: Rich Thomson
Date: Wed, 04 Nov 1992 23:48
14 lines
1038 bytes
In article <100607@bu.edu>
	kiki@bass.bu.edu (Keith Baccki) writes:

>      gc = XCreateGC(display,XtWindow(iondrawable),GCForeground | GCBackground, &gcvalues);

Don't use XCreateGC when using the Intrinsics; always use XtCreateGC.
This helps sharing of GCs between widgets and the application.

						-- Rich
-- 
	Repeal the personal income tax; vote Libertarian in 1992.
Disclaimer: I speak for myself, except as noted; Copyright 1992 Rich Thomson
UUCP: ...!uunet!dsd.es.com!rthomson			Rich Thomson
Internet: rthomson@dsd.es.com	IRC: _Rich_		PEXt Programmer
Re: Drawing into DrawingArea widget
#165
Author: Sonja Orlavski
Date: Fri, 06 Nov 1992 01:17
27 lines
1658 bytes
Keith Baccki (kiki@bass.bu.edu) wrote:
: 
: 	Drawing something into the Drawing Area should be a
: trivial task, but nonetheless the following pieces of code
: do NOTHING in the window:
: 
:       XFillRectangle(display,XtWindow(iondrawable),gc,(Position)50,(Position)50,(Dimension)200,(Dimension)200);
:       XDrawLine(display,XtWindow(iondrawable),gc,(Position)
: 100,(Position) 100,(Position) 300,(Position) 150);
:       XFlush(display);

I'm almost certain that this is your problem.  You need to be doing these
commands in response to an Expose event (i.e. do an XtAddEventHandler to
your drawing area and put these commands into the event handler).
Otherwise, you're drawing into the window before it's shown up on the
screen.

You probably don't need the XFlush.

			-Devin

--
Devin Hooker (RP90)  (SotM 7/91)  DoD #0034  devin@boulder.colorado.edu  ------
"It's being both that's a bitch."                                      --\--- /
"I wanted to take my brain to hell and back and see what I had left."  \  \ //
"This howling in the distance, it's a captivating sound.                \  \/
        Can't tell if it's ecstasy or pain..."  -DW                      \/
Re: Drawing into DrawingArea widget
#166
Author: Rich Thomson
Date: Fri, 06 Nov 1992 06:05
20 lines
1424 bytes
In article <1992Nov6.011714.21164@colorado.edu>
	devin@frodo.Colorado.EDU (Sonja Orlavski) writes:
>You need to be doing these
>commands in response to an Expose event (i.e. do an XtAddEventHandler to
>your drawing area and put these commands into the event handler).
>Otherwise, you're drawing into the window before it's shown up on the
>screen.

Oh, good point.  But there is no need to drop down to the level of
XtAddEventHandler; the Motif DrawingArea widget has a redraw callback
called XmNexposeCallback.  You still need to use the Xt GC management
functions, though, or you will end up conflicting with the GCs used
by the widget implementation.

						-- Rich
-- 
		      Don't blame me; I voted Libertarian
Disclaimer: I speak for myself, except as noted; Copyright 1992 Rich Thomson
UUCP: ...!uunet!dsd.es.com!rthomson			Rich Thomson
Internet: rthomson@dsd.es.com	IRC: _Rich_		PEXt Programmer
Re: Drawing into DrawingArea widget
#167
Author: Stefan Schwarz
Date: Fri, 06 Nov 1992 09:54
58 lines
2776 bytes
kiki@bass.bu.edu (Keith Baccki) writes:


>	Hello, I'm working with DEC PHIGS ver. 2.3A on a
>DECstation 5000/133 with PXG+ hardware. I am writing code
>that is half PHIGS and half Motif, and I am having trouble
>drawing non-PHIGS graphics into an initialized Drawing Area
>widget. Sounds pretty idiotic, but I've even had more experienced
>X coders look at my code and shrug there shoulders. Anyway,
>here's the basic structure:

> 	    application shell widget
>		     /     \
>                    /       \
>    PHIGS output widget   Form Dialog
>				\
>				 \
>			      Drawing Area				


>	Drawing something into the Drawing Area should be a
>trivial task, but nonetheless the following pieces of code
>do NOTHING in the window:

>      XtSetArg(...);   /* bunch of these... NOTE: height = 650 */
>                       /*                          width = 400 */
>      ionwindow =XmCreateFormDialog(toplevelshell,"ionwindow",arglist,6);
>      XtManageChild(ionwindow);

>      XtSetArg(...);   /* Few more... NOTE: requested height = 460 */
>	               /*                        "     width = 400 */
>      iondrawable = XmCreateDrawingArea(ionwindow,"iondrawable",arglist,4);
>      XtManageChild(iondrawable);

>      gcvalues.foreground = BlackPixel(display,DefaultScreen(display));
>      gcvalues.background = WhitePixel(display,DefaultScreen(display));

>      gc = XCreateGC(display,XtWindow(iondrawable),GCForeground | GCBackground, &gcvalues);

>      XFillRectangle(display,XtWindow(iondrawable),gc,(Position)50,(Position)50,(Dimension)200,(Dimension)200);
>      XDrawLine(display,XtWindow(iondrawable),gc,(Position)
>100,(Position) 100,(Position) 300,(Position) 150);
>      XFlush(display);

Be aware between the difference of managing a widget and creating the
corresponding window. Only after mapping the window is visible and it
makes sense to do some output.
And further, XtWindow(widget) in the code above could return 0, because the
window doesn't exist at this time.
So, draw only in case of expose-events or wait until you receive a map-notify
for the drawing area.

Stefan
-- 
__
Stefan Schwarz                            University of the armed forces
Laboratory for graphical data processing  W-8014 Neubiberg, FRG
--
Re: Drawing into DrawingArea widget
#168
Author: Keith Baccki
Date: Fri, 06 Nov 1992 19:23
11 lines
775 bytes
	Thanks a million to all who responded. The Expose event
was the problem - so I just added a callback for drawing.

P.S. It works with XCreateGC, but to be consistent I tried using
     the Xt version - however, I couldn't find it in out Xt ref.
     manual. What's the proper syntax?

		Thanks again,

				keith
Re: Drawing into DrawingArea widget
#169
Author: Rich Thomson
Date: Fri, 06 Nov 1992 22:10
61 lines
2658 bytes
In article <100874@bu.edu>
	kiki@bass.bu.edu (Keith Baccki) writes:
>P.S. It works with XCreateGC, but to be consistent I tried using
>     the Xt version - however, I couldn't find it in out Xt ref.
>     manual. What's the proper syntax?

The two calls I found in my Xt man pages are XtGetGC and XtReleaseGC.

XtGetGC(3Xt)        RISC/os Reference Manual         XtGetGC(3Xt)

NAME
     XtGetGC, XtReleaseGC - obtain and destroy a sharable GC

SYNTAX
     GC XtGetGC(w, value mask, values)
           Widget w;
           XtGCMask value mask;
           XGCValues *values;

     void XtReleaseGC(w, gc)
           Widget w;
           GC gc;

ARGUMENTS
     gc        Specifies the GC to be deallocated.

     values    Specifies the actual values for this GC.

     value mask
               Specifies which fields of the values are speci-
               fied.

     w         Specifies the widget.

DESCRIPTION
     The XtGetGC function returns a sharable, read-only GC.  The
     parameters to this function are the same as those for
     XCreateGC except that a widget is passed instead of a
     display.  XtGetGC shares only GCs in which all values in the
     GC returned by XCreateGC are the same.  In particular, it
     does not use the value mask provided to determine which
     fields of the GC a widget considers relevant.  The
     value mask is used only to tell the server which fields
     should be filled in with widget data and which it should
     fill in with default values.  For further information about
     value mask and values, see XCreateGC in the Xlib - C
     Language X Interface.

     The XtReleaseGC function deallocate the specified shared GC.

SEE ALSO
     X Toolkit Intrinsics - C Language Interface
     Xlib - C Language X Interface

                         Printed 11/6/92  1 September 1988 Page 1

-- 
		      Don't blame me; I voted Libertarian
Disclaimer: I speak for myself, except as noted; Copyright 1992 Rich Thomson
UUCP: ...!uunet!dsd.es.com!rthomson			Rich Thomson
Internet: rthomson@dsd.es.com	IRC: _Rich_		PEXt Programmer
Re: Drawing into DrawingArea widget
#170
Author: Paul D Johnston
Date: Fri, 06 Nov 1992 22:20
46 lines
2561 bytes
In article <100607@bu.edu> kiki@bass.bu.edu (Keith Baccki) writes:
>
>	Drawing something into the Drawing Area should be a
>trivial task, but nonetheless the following pieces of code
>do NOTHING in the window:
>
>      XtSetArg(...);   /* bunch of these... NOTE: height = 650 */
>                       /*                          width = 400 */
>      ionwindow =XmCreateFormDialog(toplevelshell,"ionwindow",arglist,6);
>      XtManageChild(ionwindow);
>
>      XtSetArg(...);   /* Few more... NOTE: requested height = 460 */
>	               /*                        "     width = 400 */
>      iondrawable = XmCreateDrawingArea(ionwindow,"iondrawable",arglist,4);
>      XtManageChild(iondrawable);
>
>      gcvalues.foreground = BlackPixel(display,DefaultScreen(display));
>      gcvalues.background = WhitePixel(display,DefaultScreen(display));
>
>      gc = XCreateGC(display,XtWindow(iondrawable),GCForeground | GCBackground, &gcvalues);
>
>      XFillRectangle(display,XtWindow(iondrawable),gc,(Position)50,(Position)50,(Dimension)200,(Dimension)200);
>      XDrawLine(display,XtWindow(iondrawable),gc,(Position)
>100,(Position) 100,(Position) 300,(Position) 150);
>      XFlush(display);
>
>Any suggestions? Am I missing something?
>
>
   If this is the exact order of your code, then the problem is that your're
trying to draw into a window (drawable) that hasn't been mapped 
(i.e., realized) yet.  An Expose event is automatically generated (and the
window is erased) when a window is first mapped.  The stuff you drew gets
erased when the DrawingArea is realized.  Add the code that does the 
drawing to an XmNexposeCallback for the DrawingArea and your stuff will
appear in the window every time an Expose event is generated (especially
after the first Expose event).

			- Hope this helps,
			  Paul D. Johnston

-- 
==============================================================================
| Paul D. Johnston			|			|	     |
| paulj@gdwest.gd.com  (619) 592-5150	| My opinions are not	| God Rules! |
| GDE Systems, Inc., San Diego, CA.	| shared by anyone.	|	     |
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads