Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!snorkelwacker!bloom-beacon!convex.UUCP!root From: root@convex.UUCP (Superuser) Newsgroups: comp.windows.x Subject: Lost mail for you Message-ID: <9006071729.AA15254@sushi> Date: 7 Jun 90 17:29:17 GMT Sender: root@athena.mit.edu (Wizard A. Root) Organization: The Internet Lines: 52 From pescadero.stanford.edu!expo.lcs.mit.edu!xpert-mailer Thu May 31 17:43:58 1990 remote from convex Received: by sushi (5.51/7.0) id AA00388; Thu, 31 May 90 17:43:58 CDT Received: by convex.COM (5.51/4.7) id AA00548; Thu, 31 May 90 18:06:29 CDT Received: from Erebus.Stanford.EDU by uxc.cso.uiuc.edu with SMTP (5.62+/IDA-1.2.8) id AA03504; Thu, 31 May 90 17:39:15 -0500 Received: from Hanauma.Stanford.EDU by erebus.Stanford.EDU with TCP; Thu, 31 May 90 15:26:41 PDT Received: by hanauma.stanford.edu (5.51/7.0) id AA24460; Thu, 31 May 90 15:39:02 PDT Received: from EXPO.LCS.MIT.EDU by Pescadero.Stanford.EDU (5.59/25-eef) id AA19023; Thu, 31 May 90 15:37:57 PDT Received: by expo.lcs.mit.edu; Thu, 31 May 90 13:32:10 EDT Received: by expo.lcs.mit.edu; Thu, 31 May 90 13:31:51 EDT From: convex!expo.lcs.mit.edu!kit (Chris D. Peterson) Message-Id: <9005311731.AA17900@expo.lcs.mit.edu> To: JONES@wharton.upenn.edu Cc: xpert@expo.lcs.mit.edu, kit@expo.lcs.mit.edu Subject: Re: XCreateGC vs XtGetGC In-Reply-To: Your message of 25 May 90 15:17:33 GMT. <25261@netnews.upenn.edu> Date: Thu, 31 May 90 13:31:50 -0400 > Originally I put it in the Initialize method for the widget, but it choked > because the widget was not yet realized. XtGetGC worked just fine (at least > the GC was created). > I suspect that I should call XCreateGC in the Realize\ > method for the widget, but wanted to know if that was correct. Putting the CreateGC call in the initialize procedure it probabally the best solution. It solves few other problems too, such as saving server resources for unrealized widget, and saving round trips when performing an XtSetValues on the color of an unrealized widget. If I were writing a widget I would try to put all my Server resource creation code into Realize. If you do this, remember that you will have to make a few XtIsRealized() checks in SetValues() and other places since the GC may not exist yet. If you really want to create your GC's at Initialization time then you can just use the RootWindow of the widget's screen when creating your GC. The only reason for the window (well, drawable actually) argument to XtCreateGC is so that the depth of your GC will match the depth of the GC you are operating on. BTW: Don't forget to add a destroy proc to your widget so that the GC is freed when the widget is destroyed. Chris D. Peterson MIT X Consortium Net: kit@expo.lcs.mit.edu Phone: (617) 253 - 9608 Address: MIT - Room NE43-213