chiark / gitweb /
debian/changelog: start -4~
[vtwm.git] / gc.c
1 /*****************************************************************************/
2 /**       Copyright 1988 by Evans & Sutherland Computer Corporation,        **/
3 /**                          Salt Lake City, Utah                           **/
4 /**  Portions Copyright 1989 by the Massachusetts Institute of Technology   **/
5 /**                        Cambridge, Massachusetts                         **/
6 /**                                                                         **/
7 /**                           All Rights Reserved                           **/
8 /**                                                                         **/
9 /**    Permission to use, copy, modify, and distribute this software and    **/
10 /**    its documentation  for  any  purpose  and  without  fee is hereby    **/
11 /**    granted, provided that the above copyright notice appear  in  all    **/
12 /**    copies and that both  that  copyright  notice  and  this  permis-    **/
13 /**    sion  notice appear in supporting  documentation,  and  that  the    **/
14 /**    names of Evans & Sutherland and M.I.T. not be used in advertising    **/
15 /**    in publicity pertaining to distribution of the  software  without    **/
16 /**    specific, written prior permission.                                  **/
17 /**                                                                         **/
18 /**    EVANS & SUTHERLAND AND M.I.T. DISCLAIM ALL WARRANTIES WITH REGARD    **/
19 /**    TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES  OF  MERCHANT-    **/
20 /**    ABILITY  AND  FITNESS,  IN  NO  EVENT SHALL EVANS & SUTHERLAND OR    **/
21 /**    M.I.T. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL  DAM-    **/
22 /**    AGES OR  ANY DAMAGES WHATSOEVER  RESULTING FROM LOSS OF USE, DATA    **/
23 /**    OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER    **/
24 /**    TORTIOUS ACTION, ARISING OUT OF OR IN  CONNECTION  WITH  THE  USE    **/
25 /**    OR PERFORMANCE OF THIS SOFTWARE.                                     **/
26 /*****************************************************************************/
27
28
29 /**********************************************************************
30  *
31  * $XConsortium: gc.c,v 1.22 91/01/09 17:13:12 rws Exp $
32  *
33  * Open the fonts and create the GCs
34  *
35  * 31-Mar-88 Tom LaStrange        Initial Version.
36  *
37  * Do the necessary modification to be integrated in ctwm.
38  * Can no longer be used for the standard twm.
39  *
40  * 22-April-92 Claude Lecommandeur.
41  *
42  *
43  **********************************************************************/
44
45 #include <stdio.h>
46 #include "twm.h"
47 #include "util.h"
48 #include "screen.h"
49
50 /***********************************************************************
51  *
52  *  Procedure:
53  *      CreateGCs - open fonts and create all the needed GC's.  I only
54  *                  want to do this once, hence the first_time flag.
55  *
56  ***********************************************************************
57  */
58
59 void
60 CreateGCs()
61 {
62     static ScreenInfo *prevScr = NULL;
63     XGCValues       gcv;
64     unsigned long   gcm;
65     static unsigned char greypattern [] = {0x0f, 0x05, 0x0f, 0x0a};
66     Pixmap        greypixmap;
67     static char dashlist [2] = {1, 1};
68
69     if (!Scr->FirstTime || prevScr == Scr)
70         return;
71
72     prevScr = Scr;
73
74     /* create GC's */
75
76     gcm = 0;
77     gcm |= GCFunction;      gcv.function = GXxor;
78     gcm |= GCLineWidth;     gcv.line_width = 0;
79     gcm |= GCForeground;    gcv.foreground = Scr->XORvalue;
80     gcm |= GCSubwindowMode; gcv.subwindow_mode = IncludeInferiors;
81
82     Scr->DrawGC = XCreateGC(dpy, Scr->Root, gcm, &gcv);
83
84     gcm = 0;
85     gcm |= GCForeground;    gcv.foreground = Scr->MenuC.fore;
86     gcm |= GCBackground;    gcv.background = Scr->MenuC.back;
87 /* djhjr - 9/14/03 */
88 #ifndef NO_I18N_SUPPORT
89     if (!use_fontset)
90     {
91         gcm |= GCFont;      gcv.font =  Scr->MenuFont.font->fid;
92     }
93 #else
94     gcm |= GCFont;          gcv.font =  Scr->MenuFont.font->fid;
95 #endif
96
97     Scr->MenuGC = XCreateGC(dpy, Scr->Root, gcm, &gcv);
98
99     gcm = 0;
100     gcm |= GCPlaneMask;     gcv.plane_mask = AllPlanes;
101     /*
102      * Prevent GraphicsExpose and NoExpose events.  We'd only get NoExpose
103      * events anyway;  they cause BadWindow errors from XGetWindowAttributes
104      * call in FindScreenInfo (events.c) (since drawable is a pixmap).
105      */
106     gcm |= GCGraphicsExposures;  gcv.graphics_exposures = False;
107     gcm |= GCLineWidth;     gcv.line_width = 0;
108
109     Scr->NormalGC = XCreateGC(dpy, Scr->Root, gcm, &gcv);
110
111     greypixmap = XCreatePixmapFromBitmapData(dpy, Scr->Root,
112                                 (char *) greypattern, 4, 4, 1, 0, 1);
113
114     gcm  = 0;
115     gcm |= GCStipple;           gcv.stipple    = greypixmap;
116     gcm |= GCFillStyle;         gcv.fill_style = FillOpaqueStippled;
117     gcm |= GCForeground;        gcv.foreground = Scr->Black;
118     gcm |= GCBackground;        gcv.background = Scr->White;
119     Scr->GreyGC = XCreateGC (dpy, Scr->Root, gcm, &gcv);
120     XSetDashes (dpy, Scr->GreyGC, 1, dashlist, 2);
121
122     if (Scr->BeNiceToColormap) {
123         gcm  = 0;
124         gcm |= GCLineStyle;
125         gcv.line_style = LineDoubleDash;
126         Scr->ShadGC = XCreateGC (dpy, Scr->Root, gcm, &gcv);
127         XSetDashes (dpy, Scr->ShadGC, 0, dashlist, 2);
128     }
129 }