home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
unix
/
volume15
/
twm
/
part01
/
gc.c
< prev
next >
Wrap
C/C++ Source or Header
|
1988-06-12
|
6KB
|
169 lines
/*****************************************************************************/
/** Copyright 1988 by Evans & Sutherland Computer Corporation, **/
/** Salt Lake City, Utah **/
/** **/
/** All Rights Reserved **/
/** **/
/** Permission to use, copy, modify, and distribute this software and **/
/** its documentation for any purpose and without fee is hereby **/
/** granted, provided that the above copyright notice appear in all **/
/** copies and that both that copyright notice and this permis- **/
/** sion notice appear in supporting documentation, and that the **/
/** name of Evans & Sutherland not be used in advertising or publi- **/
/** city pertaining to distribution of the software without specif- **/
/** ic, written prior permission. **/
/** **/
/** EVANS & SUTHERLAND DISCLAIMS ALL WARRANTIES WITH REGARD TO **/
/** THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILI- **/
/** TY AND FITNESS, IN NO EVENT SHALL EVANS & SUTHERLAND BE LIABLE **/
/** FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAM- **/
/** AGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, **/
/** WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS **/
/** ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PER- **/
/** FORMANCE OF THIS SOFTWARE. **/
/*****************************************************************************/
/**********************************************************************
*
* $Header: gc.c,v 1.3 88/04/15 07:09:38 tlastran Exp $
*
* Open the fonts and create the GCs
*
* 31-Mar-88 Tom LaStrange Initial Version.
*
**********************************************************************/
#ifndef lint
static char RCSinfo[]=
"$Header: gc.c,v 1.3 88/04/15 07:09:38 tlastran Exp $";
#endif lint
#include <stdio.h>
#include "twm.h"
/***********************************************************************
*
* Procedure:
* CreateGCs - open fonts and create all the needed GC's. I only
* want to do this once, hence the first_time flag.
*
***********************************************************************
*/
void
CreateGCs()
{
static int first_time = TRUE;
XGCValues gcv;
unsigned long gcm, mask;
if (!first_time)
return;
first_time = FALSE;
/* open fonts */
TitleBarFont = XLoadQueryFont(dpy, TitleBarFontName);
TitleBarFontHeight = TitleBarFont->ascent + TitleBarFont->descent;
if (TitleBarFontHeight < TITLE_BAR_FONT_HEIGHT)
{
TitleBarY = (TITLE_BAR_FONT_HEIGHT - TitleBarFontHeight)/2 +
TITLE_BAR_SPACE + TitleBarFont->ascent;
}
else
{
TitleBarY = TITLE_BAR_SPACE + TitleBarFont->ascent;
}
MenuFont = XLoadQueryFont(dpy, MenuFontName);
MenuFontHeight = MenuFont->ascent + MenuFont->descent;
MenuY = MenuFont->ascent + 1;
IconFont = XLoadQueryFont(dpy, IconFontName);
IconFontHeight = IconFont->ascent + IconFont->descent;
VersionFont = XLoadQueryFont(dpy, VersionFontName);
VersionFontHeight = VersionFont->ascent + VersionFont->descent;
SizeFont = XLoadQueryFont(dpy, SizeFontName);
SizeFontHeight = SizeFont->ascent + SizeFont->descent;
/* create GC's */
if (ReverseVideo)
{
Background = BlackPixel(dpy, DefaultScreen(dpy));
Foreground = WhitePixel(dpy, DefaultScreen(dpy));
}
else
{
Foreground = BlackPixel(dpy, DefaultScreen(dpy));
Background = WhitePixel(dpy, DefaultScreen(dpy));
}
mask = Foreground ^ Background;
gcm = 0;
gcm |= GCFont; gcv.font = TitleBarFont->fid;
gcm |= GCPlaneMask; gcv.plane_mask = mask;
gcm |= GCForeground; gcv.foreground = Foreground;
gcm |= GCBackground; gcv.background = Background;
TitleNormalGC = XCreateGC(dpy, Root, gcm, &gcv);
gcm = 0;
gcm |= GCFont; gcv.font = MenuFont->fid;
gcm |= GCPlaneMask; gcv.plane_mask = mask;
gcm |= GCForeground; gcv.foreground = Foreground;
gcm |= GCBackground; gcv.background = Background;
MenuNormalGC = XCreateGC(dpy, Root, gcm, &gcv);
gcv.foreground = Background;
gcv.background = Foreground;
MenuReverseGC = XCreateGC(dpy, Root, gcm, &gcv);
gcm = 0;
gcm |= GCFunction; gcv.function = GXxor;
gcm |= GCFont; gcv.font = MenuFont->fid;
gcm |= GCPlaneMask; gcv.plane_mask = mask;
gcm |= GCForeground; gcv.foreground = mask;
gcm |= GCBackground; gcv.background = Background;
MenuXorGC = XCreateGC(dpy, Root, gcm, &gcv);
gcm = 0;
gcm |= GCFunction; gcv.function = GXxor;
gcm |= GCLineWidth; gcv.line_width = 0;
gcm |= GCForeground; gcv.foreground = mask;
gcm |= GCPlaneMask; gcv.plane_mask = mask;
gcm |= GCSubwindowMode; gcv.subwindow_mode = IncludeInferiors;
DrawGC = XCreateGC(dpy, Root, gcm, &gcv);
gcm = 0;
gcm |= GCFont; gcv.font = IconFont->fid;
gcm |= GCPlaneMask; gcv.plane_mask = mask;
gcm |= GCForeground; gcv.foreground = Foreground;
gcm |= GCBackground; gcv.background = Background;
IconNormalGC = XCreateGC(dpy, Root, gcm, &gcv);
gcm = 0;
gcm |= GCFont; gcv.font = VersionFont->fid;
gcm |= GCPlaneMask; gcv.plane_mask = mask;
gcm |= GCForeground; gcv.foreground = Foreground;
gcm |= GCBackground; gcv.background = Background;
VersionNormalGC = XCreateGC(dpy, Root, gcm, &gcv);
gcm = 0;
gcm |= GCFont; gcv.font = SizeFont->fid;
gcm |= GCPlaneMask; gcv.plane_mask = mask;
gcm |= GCForeground; gcv.foreground = Foreground;
gcm |= GCBackground; gcv.background = Background;
SizeNormalGC = XCreateGC(dpy, Root, gcm, &gcv);
}