comparison lib/xtwstr.c @ 0:92745d501b9a

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