1 
2 /*	$Id: tixUnixDraw.c,v 1.1.1.1 2000/05/17 11:08:54 idiscovery Exp $	*/
3 
4 /*
5  * tixUnixDraw.c --
6  *
7  *	Implement the Unix specific function calls for drawing.
8  *
9  * Copyright (c) 1996, Expert Interface Technologies
10  *
11  * See the file "license.terms" for information on usage and redistribution
12  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
13  *
14  */
15 
16 #include "tixPort.h"
17 #include "tixUnixInt.h"
18 
19 
20 /*
21  *----------------------------------------------------------------------
22  * TixpDrawTmpLine --
23  *
24  *	Draws a "temporary" line between the two points. The line can be
25  *	removed by calling the function again with the same parameters.
26  *
27  * Results:
28  *	Standard Tcl result.
29  *
30  * Side effects:
31  *	A line is XOR'ed onto the screen.
32  *----------------------------------------------------------------------
33  */
34 void
TixpDrawTmpLine(x1,y1,x2,y2,tkwin)35 TixpDrawTmpLine(x1, y1, x2, y2, tkwin)
36     int x1;
37     int y1;
38     int x2;
39     int y2;
40     Tk_Window tkwin;
41 {
42     GC gc;
43     XGCValues values;
44     unsigned long valuemask = GCForeground | GCSubwindowMode | GCFunction;
45     Window winId;		/* The Window to draw into. */
46     Tk_Window toplevel;		/* Toplevel containing the tkwin. */
47     int rootx1, rooty1;		/* Root x and y of the toplevel window. */
48     int rootx2, rooty2;
49 
50     for (toplevel=tkwin; !Tk_IsTopLevel(toplevel);
51 	    toplevel=Tk_Parent(toplevel)) {
52 	;
53     }
54 
55     Tk_GetRootCoords(toplevel, &rootx1, &rooty1);
56     rootx2 = rootx1 + Tk_Width(toplevel)  - 1;
57     rooty2 = rooty1 + Tk_Height(toplevel) - 1;
58 
59     if (x1 >= rootx1 && x2 <= rootx2 &&	y1 >= rooty1 && y2 <= rooty2) {
60 	/*
61 	 * The line is completely inside the toplevel containing
62 	 * tkwin. It's better to draw into this window because on some
63 	 * X servers, especially PC X Servers running on Windows,
64 	 * drawing into the root window shows no effect.
65 	 */
66 	winId = Tk_WindowId(toplevel);
67 	x1 -= rootx1;
68 	y1 -= rooty1;
69 	x2 -= rootx1;
70 	y2 -= rooty1;
71     } else {
72 	winId = XRootWindow(Tk_Display(tkwin), Tk_ScreenNumber(tkwin));
73     }
74 
75     values.foreground	  = 0xff;
76     values.subwindow_mode = IncludeInferiors;
77     values.function	  = GXxor;
78 
79     gc = XCreateGC(Tk_Display(tkwin), winId, valuemask, &values);
80     XDrawLine(Tk_Display(tkwin), winId, gc, x1, y1, x2, y2);
81     XFreeGC(Tk_Display(tkwin), gc);
82 }
83 
84 /*----------------------------------------------------------------------
85  * TixpDrawAnchorLines --
86  *
87  *	See comments near Tix_DrawAnchorLines.
88  *----------------------------------------------------------------------
89  */
90 
TixpDrawAnchorLines(display,drawable,gc,x,y,w,h)91 void TixpDrawAnchorLines(display, drawable, gc, x, y, w, h)
92     Display *display;
93     Drawable drawable;
94     GC gc;
95     int x;
96     int y;
97     int w;
98     int h;
99 {
100     XPoint points[4];
101 
102     if (w < 1) {
103 	w = 1;
104     }
105     if (h < 1) {
106 	h = 1;
107     }
108 
109     XDrawRectangle(display, drawable, gc, x, y, w-1, h-1);
110 
111     /*
112      * Draw these points so that the corners will not be rounded
113      */
114     points[0].x = x;
115     points[0].y = y;
116     points[1].x = x + w - 1;
117     points[1].y = y;
118     points[2].x = x;
119     points[2].y = y + h - 1;
120     points[3].x = x + w - 1;
121     points[3].y = y + h - 1;
122 
123     XDrawPoints(display, drawable, gc, points, 4, CoordModeOrigin);
124 }
125 
126 
127