beckman@iuvax.cs.indiana.edu (01/19/89)
I am using the HP Widget set. How do I use the Xlib graphic primitives within a widget to draw lines, boxes, etc. I haven't had any success. I have tried lots of different things, the most recent being this: Display *dpy; Drawable win; GC gc; dpy = XtDisplay(widget) win = XtWindow(widget); gc = XtGetGC(widget); XDrawLine(dpy,win,gc,0,0,100,100); Could you please help me out? -Pete beckman@cs.iuvax.indiana.edu
ben@hpcvlx.HP.COM (Benjamin Ellsworth) (01/20/89)
I'm in a hurry, so this is going to be terse. XtGetGC is entirely wrong. Get the window, display, etc. of the widget and create your own GC with regular Xlib calls. Then draw using that GC, and the widget's window, display, etc. You should have no trouble getting stuff on the screen. You will have trouble if you generate an exposure event in the widget's window. The widget may overwrite your pretty drawings. Good Luck! ----------------------------------------------------------------------- Benjamin Ellsworth | ben%hpcvlx@hplabs.hp.com | INTERNET Hewlett-Packard Company | {backbone}!hplabs!hpcvlx!ben | UUCP 1000 N.E. Circle | (USA) (503) 750-4980 | FAX Corvallis, OR 97330 | (USA) (503) 757-2000 | VOICE ----------------------------------------------------------------------- All relevant disclaimers apply. -----------------------------------------------------------------------
olaf@TUB.BITNET (Olaf Heimburger) (01/20/89)
> Date: Thu, 19 Jan 89 12:56:00 GMT > Reply-To: tub!xpert%ATHENA.MIT.EDU > Sender: XPERT distribution list <tub!XPERT%TCSVM.BITNET> > Comments: Warning -- original Sender: tag was xpert-request@ATHENA.MIT.EDU > From: tub!beckman%IUVAX.CS.INDIANA.EDU > Comments: To: xpert@athena.mit.edu > > > I am using the HP Widget set. How do I use the Xlib graphic primitives > within a widget to draw lines, boxes, etc. I haven't had any success. > I have tried lots of different things, the most recent being this: > > Display *dpy; > Drawable win; > GC gc; > > dpy = XtDisplay(widget) > win = XtWindow(widget); > gc = XtGetGC(widget); > > XDrawLine(dpy,win,gc,0,0,100,100); > > Could you please help me out? -Pete beckman@cs.iuvax.indiana.edu You use XtGetGC in the wrong way. Look in the X Intrinsics at section ``Sharing Graphics Contexts''. XtGetGC is defined as follows GC XtGetGC (w, value_mask, values) Widget w; XtGCMask value_mask; XGCValues *values; When you replace gc = XtGetGC (widget); with XGCValues Values; XtGCMask Mask; /* ... */ Values.foreground = widget->core.border_pixel; Values.background = widget->core.background_pixel; Mask = GCForeground | GCBackground; gc = XtGetGC (widget, Mask, &Values); it should work. Olaf ------------------------------------------------------------------------ It's for youhou. ------------------------------------------------------------------------ Olaf Heimburger, <olaf@tub.UUCP> <olaf@db0tui6.BITNET> <olaf@tub.BITNET> Technical University of Berlin (West), Department of Computer Science uucp to tub: ...!pyramid!tub!olaf (from the US, only) ...!mcvax!unido!tub!olaf (from Europe only) ------------------------------------------------------------------------
kit@ATHENA.MIT.EDU (Chris D. Peterson) (01/27/89)
> From: beckman@iuvax.cs.indiana.edu > I am using the HP Widget set. How do I use the Xlib graphic primitives > within a widget to draw lines, boxes, etc. I haven't had any success. > I have tried lots of different things, the most recent being this: > > Display *dpy; > Drawable win; > GC gc; > > dpy = XtDisplay(widget) > win = XtWindow(widget); > gc = XtGetGC(widget); > > XDrawLine(dpy,win,gc,0,0,100,100); This is relatively common problem that many people run into when beginning to program in X because X is an asynchronous environment. This is necessary to achieve network transparency and not be horribly slow. Here are some concepts that you need to be aware of when programming in X. 1) X is a client server model, all application programs are clients that because X has a standard protocol are able to talk to any X server. 2) Because X is an asynchronous environment you are never sure when your X functions will actually be processed by the X server. 3) X does not remember what is drawn into the window, and it is the client's responsibility to repair any damage done to his window. 4) Since window managers can intercept mapping events you are never sure when you client's windows will actually get mapped, unless you are looking for the correct events. Thus the program above may end up drawing the line before the window is visible on the screen. All good X clients are responsible for repainting their contents when these contents become damaged. The server will notify the client that some part of his window is damaged and that it needs to be repainted by issuing an Expose event on that window for each rectangular region that has been damaged. Clever clients will only repaint the particular region of the screen that has been damaged. Clients that are not quite this clever can repaint the entire window when an expose event is received for a particular window. It is important to check the exposure count field (count == 0) to make sure that you do not repaint the window more often than necessary. If you are using the X toolkit the easiest way to receive expose events is either: 1) Add an entry in the translation table and register an action that should be performed on that entry. 2) Us XtAddEventHandler to register a function that should be called when an exposure event is received. References: Xlib Manual Chapter 8 : Events and Event Handling. Xtk Manual Chapter 7 : Event Management. Chapter 10 : Translation Management. Appendix B : Translation Table Syntax. Chris D. Peterson MIT X Consortium / Project Athena Net: kit@athena.mit.edu Phone: (617) 253 - 1326 USMail: MIT - Room E40-321 77 Massachusetts Ave. Cambridge, MA 02139
dar@belltec.UUCP (Dimitri Rotow) (01/28/89)
I'm working in our X11R2 environment for 386 UNIX boxes and I'd like to create some new fonts. Because we draw a 1660 x 1200 display on a 19" monitor the existing fonts do not provide as wide a selection as I'd like given the resultant 125x115 dpi density. I feel a little dumb for not being able to find the answer by cruising through the literature, but for the life of me I can't figure out how to create a new font. Are there any good tools out there? Does anyone know of more "large" fonts for X11? Thank you in advance for help. - dimitri rotow, Bell Tech, 415-659-9097, ..!pacbell!belltec!dar
rws@EXPO.LCS.MIT.EDU (Bob Scheifler) (01/29/89)
I feel a little dumb for not being able to find the answer by cruising through the literature, but for the life of me I can't figure out how to create a new font. Are there any good tools out there? The telephone? Typewriter and paper? There are no great tools provided in our distribution for creating new font source files. You can look in R3 in contrib/fonts/utils for some simple tools, including one to convert MetaFont GF files to BDF. If you want quality tuned fonts, in BDF format, at resolutions that match your displays, the best suggestion I can make is that you go to font vendors and ask for them (and be willing to pay for them). For example, the two font vendors (Adobe and Bitstream) who donated fonts for R3 should be able to help you.