Article View: comp.windows.x.pex
Article #170Re: Drawing into DrawingArea widget
From: Paul D Johnston
Date: Fri, 06 Nov 1992 22:20
Date: Fri, 06 Nov 1992 22:20
46 lines
2561 bytes
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. | |
Technical Details
Message-ID:
<1992Nov6.222012.29415@gdwest.gd.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!charon.amdahl.com!pacbell.com!sgiblab!zaphod.mps.ohio-state.edu!cs.utexas.edu!sun-barr!olivea!charnel!rat!ucselx!gdwest!pauljReferences:
<100607@bu.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!charon.amdahl.com!pacbell.com!sgiblab!zaphod.mps.ohio-state.edu!cs.utexas.edu!sun-barr!olivea!charnel!rat!ucselx!gdwest!paulj From: paulj@gdwest.gd.com (Paul D Johnston) Newsgroups: comp.windows.x.pex Subject: Re: Drawing into DrawingArea widget Message-ID: <1992Nov6.222012.29415@gdwest.gd.com> Date: 6 Nov 92 22:20:12 GMT References: <100607@bu.edu> Organization: General Dynamics Corp. Lines: 46