1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
|
/*
* xtwstr.c
*/
/*
* Copyright (c) 1989 Software Research Associates, Inc.
*
* 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 permission notice appear in supporting
* documentation, and that the name of Software Research Associates not be
* used in advertising or publicity pertaining to distribution of the
* software without specific, written prior permission. Software Research
* Associates makes no representations about the suitability of this software
* for any purpose. It is provided "as is" without express or implied
* warranty.
*
* Author: Makoto Ishisone, Software Research Associates, Inc., Japan
* ishisone@sra.co.jp
*/
#ifndef lint
static char *rcsid = "$Id: xtwstr.c,v 2.3 1991/10/02 04:27:04 ishisone Rel $";
#endif
#include <X11/Intrinsic.h>
#include "WStr.h"
#include "XWStr.h"
#define IS2B(f) (((f)->max_byte1 > 0) || ((f)->max_char_or_byte2 > 255))
XWSGC
XtWSGetGCSet(w, mask, values, fontG0, fontG1, fontG2, fontG3)
Widget w;
unsigned long mask;
XGCValues *values;
XFontStruct *fontG0;
XFontStruct *fontG1;
XFontStruct *fontG2;
XFontStruct *fontG3;
{
XGCValues gcval;
XWSGC gcset;
int i;
gcset = (XWSGC)XtMalloc(sizeof(XWSGCSet));
gcset->fe[0].font = fontG0;
gcset->fe[1].font = fontG1;
gcset->fe[2].font = fontG2;
gcset->fe[3].font = fontG3;
gcval = *values;
mask |= GCFont;
for (i = 0; i < 4; i++) {
if (gcset->fe[i].font != NULL) {
gcval.font = (gcset->fe[i].font)->fid;
gcset->fe[i].gc = XtGetGC(w, mask, &gcval);
gcset->fe[i].flag = GCCREAT;
if (IS2B(gcset->fe[i].font))
gcset->fe[i].flag |= TWOB;
} else {
gcset->fe[i].gc = NULL;
}
}
return gcset;
}
void
XtWSDestroyGCSet(gcset)
XWSGC gcset;
{
int i;
int flag;
for (i = 0; i < 4; i++) {
if (gcset->fe[i].gc == NULL)
continue;
flag = gcset->fe[i].flag;
if (flag & GCCREAT)
XtDestroyGC(gcset->fe[i].gc);
/* can't free XFontStruct data allocated by XWSSetGCSet()
* because I can't figure out which display is used.
* if (flag & FONTQUERY)
* XFreeFont(???, gcset->fe[i].font);
*/
}
XtFree((char *)gcset);
}
void
XtWSReleaseGCSet(w, gcset)
Widget w;
XWSGC gcset;
{
int i;
int flag;
for (i = 0; i < 4; i++) {
if (gcset->fe[i].gc == NULL)
continue;
flag = gcset->fe[i].flag;
if (flag & GCCREAT)
XtReleaseGC(w, gcset->fe[i].gc);
if (flag & FONTQUERY)
XFreeFont(XtDisplay(w), gcset->fe[i].font);
}
XtFree((char *)gcset);
}
|