annotate etc/tests/external-widget/test-ew-xlib.c @ 4903:70089046adef

fix compile problems in intl-encap* under VS6 -------------------- ChangeLog entries follow: -------------------- lib-src/ChangeLog addition: 2010-01-30 Ben Wing <ben@xemacs.org> * make-mswin-unicode.pl: Make it possible to specify an overridden prototype in cases where either Cygwin or Visual Studio has errors in their headers that can be corrected by falling back to a less qualified type (typically without const). src/ChangeLog addition: 2010-01-30 Ben Wing <ben@xemacs.org> * intl-auto-encap-win32.c: * intl-auto-encap-win32.c (qxeExtractAssociatedIcon): * intl-auto-encap-win32.c (qxeExtractIconEx): * intl-auto-encap-win32.c (qxeCreateMDIWindow): * intl-auto-encap-win32.c (qxeCreateWindowStation): * intl-auto-encap-win32.c (qxeDdeCreateStringHandle): * intl-auto-encap-win32.c (qxeAbortSystemShutdown): * intl-auto-encap-win32.c (qxeRegConnectRegistry): * intl-auto-encap-win32.c (qxeGetICMProfile): * intl-auto-encap-win32.h: Rebuild. * intl-encap-win32.c: * intl-encap-win32.c (qxeUpdateICMRegKey): Delete manual definitions of functions with former errors in Cygwin headers but no longer. Use "override" with some functions where Cygwin or VS6 accidentally omits a const declaration or includes an extra one. Use "no" on SendMessageTimeout, which has an error in the VS6 prototype (you could manually fix this with an ifdef to split the Cygwin vs. VS6 calls, if we ever actually used this function).
author Ben Wing <ben@xemacs.org>
date Sat, 30 Jan 2010 20:34:23 -0600
parents 03ab78e48ef6
children ba07c880114a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4894
03ab78e48ef6 Add copyright and license information based on Ben's recollections.
Jerry James <james@xemacs.org>
parents: 2
diff changeset
1 /* Test external widget code in Motif.
03ab78e48ef6 Add copyright and license information based on Ben's recollections.
Jerry James <james@xemacs.org>
parents: 2
diff changeset
2 Copyright (C) 1989 O'Reilly and Associates, Inc.
03ab78e48ef6 Add copyright and license information based on Ben's recollections.
Jerry James <james@xemacs.org>
parents: 2
diff changeset
3 Copyright (C) 1993 Ben Wing.
03ab78e48ef6 Add copyright and license information based on Ben's recollections.
Jerry James <james@xemacs.org>
parents: 2
diff changeset
4
03ab78e48ef6 Add copyright and license information based on Ben's recollections.
Jerry James <james@xemacs.org>
parents: 2
diff changeset
5 This file is part of XEmacs.
03ab78e48ef6 Add copyright and license information based on Ben's recollections.
Jerry James <james@xemacs.org>
parents: 2
diff changeset
6
03ab78e48ef6 Add copyright and license information based on Ben's recollections.
Jerry James <james@xemacs.org>
parents: 2
diff changeset
7 XEmacs is free software; you can redistribute it and/or modify it
03ab78e48ef6 Add copyright and license information based on Ben's recollections.
Jerry James <james@xemacs.org>
parents: 2
diff changeset
8 under the terms of the GNU General Public License as published by the
03ab78e48ef6 Add copyright and license information based on Ben's recollections.
Jerry James <james@xemacs.org>
parents: 2
diff changeset
9 Free Software Foundation; either version 2, or (at your option) any
03ab78e48ef6 Add copyright and license information based on Ben's recollections.
Jerry James <james@xemacs.org>
parents: 2
diff changeset
10 later version.
03ab78e48ef6 Add copyright and license information based on Ben's recollections.
Jerry James <james@xemacs.org>
parents: 2
diff changeset
11
03ab78e48ef6 Add copyright and license information based on Ben's recollections.
Jerry James <james@xemacs.org>
parents: 2
diff changeset
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT
03ab78e48ef6 Add copyright and license information based on Ben's recollections.
Jerry James <james@xemacs.org>
parents: 2
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
03ab78e48ef6 Add copyright and license information based on Ben's recollections.
Jerry James <james@xemacs.org>
parents: 2
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
03ab78e48ef6 Add copyright and license information based on Ben's recollections.
Jerry James <james@xemacs.org>
parents: 2
diff changeset
15 for more details.
03ab78e48ef6 Add copyright and license information based on Ben's recollections.
Jerry James <james@xemacs.org>
parents: 2
diff changeset
16
03ab78e48ef6 Add copyright and license information based on Ben's recollections.
Jerry James <james@xemacs.org>
parents: 2
diff changeset
17 You should have received a copy of the GNU General Public License
03ab78e48ef6 Add copyright and license information based on Ben's recollections.
Jerry James <james@xemacs.org>
parents: 2
diff changeset
18 along with XEmacs; see the file COPYING. If not, write to
03ab78e48ef6 Add copyright and license information based on Ben's recollections.
Jerry James <james@xemacs.org>
parents: 2
diff changeset
19 the Free Software Foundation, Inc., 51 Franklin St - Fifth Floor,
03ab78e48ef6 Add copyright and license information based on Ben's recollections.
Jerry James <james@xemacs.org>
parents: 2
diff changeset
20 Boston, MA 02110-1301, USA. */
03ab78e48ef6 Add copyright and license information based on Ben's recollections.
Jerry James <james@xemacs.org>
parents: 2
diff changeset
21
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
22 #include <X11/Xlib.h>
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
23 #include <X11/Xutil.h>
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
24 #include <X11/Xos.h>
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
25 #include <X11/Xatom.h>
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
26
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
27 #include <stdio.h>
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
28
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
29 #define BITMAPDEPTH 1
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
30 #define TOO_SMALL 0
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
31 #define BIG_ENOUGH 1
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
32
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
33 /* These are used as arguments to nearly every Xlib routine, so it saves
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
34 * routine arguments to declare them global. If there were
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
35 * additional source files, they would be declared extern there. */
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
36 Display *display;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
37 int screen_num;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
38
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
39 static char *progname; /* name this program was invoked by */
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
40
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
41 void main(argc, argv)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
42 int argc;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
43 char **argv;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
44 {
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
45 Window topwin, win, win2;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
46 unsigned int width, height; /* window size */
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
47 int x, y; /* window position */
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
48 unsigned int border_width = 4; /* four pixels */
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
49 unsigned int display_width, display_height;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
50 char *window_name = "Basic Window Program";
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
51 char *icon_name = "basicwin";
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
52 XSizeHints size_hints;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
53 int count;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
54 XEvent report;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
55 GC gc;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
56 XFontStruct *font_info;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
57 char *display_name = NULL;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
58 int window_size = BIG_ENOUGH; /* or TOO_SMALL to display contents */
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
59
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
60 progname = argv[0];
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
61
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
62 /* connect to X server */
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
63 if ( (display=XOpenDisplay(display_name)) == NULL )
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
64 {
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
65 (void) fprintf( stderr, "%s: cannot connect to X server %s\n",
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
66 progname, XDisplayName(display_name));
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
67 exit( -1 );
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
68 }
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
69
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
70 /* get screen size from display structure macro */
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
71 screen_num = DefaultScreen(display);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
72 display_width = DisplayWidth(display, screen_num);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
73 display_height = DisplayHeight(display, screen_num);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
74
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
75 /* Note that in a real application, x and y would default to 0
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
76 * but would be settable from the command line or resource database.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
77 */
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
78 x = y = 0;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
79
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
80 /* size window with enough room for text */
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
81 width = display_width/2, height = display_height/3;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
82
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
83 /* ------------------------------------------------------------ */
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
84
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
85 /* create top-level window */
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
86 topwin = XCreateSimpleWindow(display, RootWindow(display,screen_num),
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
87 x, y, width, 2*height, border_width,
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
88 BlackPixel(display, screen_num),
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
89 WhitePixel(display,screen_num));
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
90
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
91 /* Set size hints for window manager. The window manager may
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
92 * override these settings. Note that in a real
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
93 * application if size or position were set by the user
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
94 * the flags would be UPosition and USize, and these would
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
95 * override the window manager's preferences for this window. */
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
96
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
97 /* x, y, width, and height hints are now taken from
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
98 * the actual settings of the window when mapped. Note
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
99 * that PPosition and PSize must be specified anyway. */
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
100
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
101 size_hints.flags = PPosition | PSize | PMinSize;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
102 size_hints.min_width = 300;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
103 size_hints.min_height = 200;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
104
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
105 {
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
106 XWMHints wm_hints;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
107 XClassHint class_hints;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
108
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
109 /* format of the window name and icon name
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
110 * arguments has changed in R4 */
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
111 XTextProperty windowName, iconName;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
112
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
113 /* These calls store window_name and icon_name into
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
114 * XTextProperty structures and set their other
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
115 * fields properly. */
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
116 if (XStringListToTextProperty(&window_name, 1, &windowName) == 0) {
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
117 (void) fprintf( stderr, "%s: structure allocation for windowName failed.\n",
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
118 progname);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
119 exit(-1);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
120 }
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
121
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
122 if (XStringListToTextProperty(&icon_name, 1, &iconName) == 0) {
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
123 (void) fprintf( stderr, "%s: structure allocation for iconName failed.\n",
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
124 progname);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
125 exit(-1);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
126 }
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
127
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
128 wm_hints.initial_state = NormalState;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
129 wm_hints.input = True;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
130 wm_hints.flags = StateHint | InputHint;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
131
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
132 class_hints.res_name = progname;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
133 class_hints.res_class = "Basicwin";
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
134
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
135 XSetWMProperties(display, topwin, &windowName, &iconName,
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
136 argv, argc, &size_hints, &wm_hints,
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
137 &class_hints);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
138 }
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
139
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
140 /* ------------------------------------------------------------ */
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
141
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
142 /* create the window we're in charge of */
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
143
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
144 win = XCreateSimpleWindow(display, topwin,
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
145 x, y, width, height, border_width, BlackPixel(display,
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
146 screen_num), WhitePixel(display,screen_num));
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
147
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
148 /* Select event types wanted */
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
149 XSelectInput(display, win, ExposureMask | KeyPressMask |
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
150 ButtonPressMask | StructureNotifyMask);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
151
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
152 load_font(&font_info);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
153
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
154 /* create GC for text and drawing */
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
155 getGC(win, &gc, font_info);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
156
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
157 /* ------------------------------------------------------------ */
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
158
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
159 /* create the external-client window */
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
160
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
161 win2 = XCreateSimpleWindow(display, topwin,
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
162 x, y+height, width, height, border_width,
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
163 BlackPixel(display, screen_num),
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
164 WhitePixel(display,screen_num));
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
165 printf("external window: %d\n", win2);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
166 ExternalClientInitialize(display, win2);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
167
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
168 /* ------------------------------------------------------------ */
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
169
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
170 /* Display windows */
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
171 XMapWindow(display, topwin);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
172 XMapWindow(display, win);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
173 XMapWindow(display, win2);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
174
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
175 /* get events, use first to display text and graphics */
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
176 while (1) {
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
177 XNextEvent(display, &report);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
178 if (report.xany.window == win2)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
179 ExternalClientEventHandler(display, win2, &report);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
180 else
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
181 switch (report.type) {
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
182 case Expose:
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
183 /* unless this is the last contiguous expose,
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
184 * don't draw the window */
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
185 if (report.xexpose.count != 0)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
186 break;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
187
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
188 /* if window too small to use */
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
189 if (window_size == TOO_SMALL)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
190 TooSmall(win, gc, font_info);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
191 else {
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
192 /* place text in window */
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
193 draw_text(win, gc, font_info, width, height);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
194
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
195 /* place graphics in window, */
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
196 draw_graphics(win, gc, width, height);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
197 }
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
198 break;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
199 case ConfigureNotify:
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
200 /* window has been resized, change width and
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
201 * height to send to draw_text and draw_graphics
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
202 * in next Expose */
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
203 width = report.xconfigure.width;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
204 height = report.xconfigure.height;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
205 if ((width < size_hints.min_width) ||
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
206 (height < size_hints.min_height))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
207 window_size = TOO_SMALL;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
208 else
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
209 window_size = BIG_ENOUGH;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
210 break;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
211 case ButtonPress:
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
212 /* trickle down into KeyPress (no break) */
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
213 case KeyPress:
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
214 XUnloadFont(display, font_info->fid);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
215 XFreeGC(display, gc);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
216 XCloseDisplay(display);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
217 exit(1);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
218 default:
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
219 /* all events selected by StructureNotifyMask
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
220 * except ConfigureNotify are thrown away here,
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
221 * since nothing is done with them */
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
222 break;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
223 } /* end switch */
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
224 } /* end while */
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
225 }
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
226
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
227 getGC(win, gc, font_info)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
228 Window win;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
229 GC *gc;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
230 XFontStruct *font_info;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
231 {
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
232 unsigned long valuemask = 0; /* ignore XGCvalues and use defaults */
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
233 XGCValues values;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
234 unsigned int line_width = 6;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
235 int line_style = LineOnOffDash;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
236 int cap_style = CapRound;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
237 int join_style = JoinRound;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
238 int dash_offset = 0;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
239 static char dash_list[] = {12, 24};
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
240 int list_length = 2;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
241
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
242 /* Create default Graphics Context */
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
243 *gc = XCreateGC(display, win, valuemask, &values);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
244
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
245 /* specify font */
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
246 XSetFont(display, *gc, font_info->fid);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
247
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
248 /* specify black foreground since default window background is
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
249 * white and default foreground is undefined. */
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
250 XSetForeground(display, *gc, BlackPixel(display,screen_num));
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
251
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
252 /* set line attributes */
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
253 XSetLineAttributes(display, *gc, line_width, line_style,
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
254 cap_style, join_style);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
255
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
256 /* set dashes */
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
257 XSetDashes(display, *gc, dash_offset, dash_list, list_length);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
258 }
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
259
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
260 load_font(font_info)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
261 XFontStruct **font_info;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
262 {
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
263 char *fontname = "9x15";
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
264
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
265 /* Load font and get font information structure. */
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
266 if ((*font_info = XLoadQueryFont(display,fontname)) == NULL)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
267 {
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
268 (void) fprintf( stderr, "%s: Cannot open 9x15 font\n",
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
269 progname);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
270 exit( -1 );
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
271 }
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
272 }
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
273
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
274 draw_text(win, gc, font_info, win_width, win_height)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
275 Window win;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
276 GC gc;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
277 XFontStruct *font_info;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
278 unsigned int win_width, win_height;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
279 {
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
280 char *string1 = "Hi! I'm a window, who are you?";
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
281 char *string2 = "To terminate program; Press any key";
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
282 char *string3 = "or button while in this window.";
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
283 char *string4 = "Screen Dimensions:";
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
284 int len1, len2, len3, len4;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
285 int width1, width2, width3;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
286 char cd_height[50], cd_width[50], cd_depth[50];
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
287 int font_height;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
288 int initial_y_offset, x_offset;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
289
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
290
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
291 /* need length for both XTextWidth and XDrawString */
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
292 len1 = strlen(string1);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
293 len2 = strlen(string2);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
294 len3 = strlen(string3);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
295
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
296 /* get string widths for centering */
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
297 width1 = XTextWidth(font_info, string1, len1);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
298 width2 = XTextWidth(font_info, string2, len2);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
299 width3 = XTextWidth(font_info, string3, len3);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
300
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
301 font_height = font_info->ascent + font_info->descent;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
302
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
303 /* output text, centered on each line */
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
304 XDrawString(display, win, gc, (win_width - width1)/2,
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
305 font_height,
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
306 string1, len1);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
307 XDrawString(display, win, gc, (win_width - width2)/2,
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
308 (int)(win_height - (2 * font_height)),
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
309 string2, len2);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
310 XDrawString(display, win, gc, (win_width - width3)/2,
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
311 (int)(win_height - font_height),
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
312 string3, len3);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
313
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
314 /* copy numbers into string variables */
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
315 (void) sprintf(cd_height, " Height - %d pixels",
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
316 DisplayHeight(display,screen_num));
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
317 (void) sprintf(cd_width, " Width - %d pixels",
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
318 DisplayWidth(display,screen_num));
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
319 (void) sprintf(cd_depth, " Depth - %d plane(s)",
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
320 DefaultDepth(display, screen_num));
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
321
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
322 /* reuse these for same purpose */
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
323 len4 = strlen(string4);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
324 len1 = strlen(cd_height);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
325 len2 = strlen(cd_width);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
326 len3 = strlen(cd_depth);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
327
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
328 /* To center strings vertically, we place the first string
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
329 * so that the top of it is two font_heights above the center
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
330 * of the window. Since the baseline of the string is what we
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
331 * need to locate for XDrawString, and the baseline is one
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
332 * font_info->ascent below the top of the character,
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
333 * the final offset of the origin up from the center of the
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
334 * window is one font_height + one descent. */
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
335
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
336 initial_y_offset = win_height/2 - font_height - font_info->descent;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
337 x_offset = (int) win_width/4;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
338 XDrawString(display, win, gc, x_offset, (int) initial_y_offset,
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
339 string4,len4);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
340
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
341 XDrawString(display, win, gc, x_offset, (int) initial_y_offset +
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
342 font_height,cd_height,len1);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
343 XDrawString(display, win, gc, x_offset, (int) initial_y_offset +
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
344 2 * font_height,cd_width,len2);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
345 XDrawString(display, win, gc, x_offset, (int) initial_y_offset +
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
346 3 * font_height,cd_depth,len3);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
347 }
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
348
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
349 draw_graphics(win, gc, window_width, window_height)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
350 Window win;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
351 GC gc;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
352 unsigned int window_width, window_height;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
353 {
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
354 int x, y;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
355 int width, height;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
356
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
357 height = window_height/2;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
358 width = 3 * window_width/4;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
359 x = window_width/2 - width/2; /* center */
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
360 y = window_height/2 - height/2;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
361 XDrawRectangle(display, win, gc, x, y, width, height);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
362 }
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
363
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
364 TooSmall(win, gc, font_info)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
365 Window win;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
366 GC gc;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
367 XFontStruct *font_info;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
368 {
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
369 char *string1 = "Too Small";
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
370 int y_offset, x_offset;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
371
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
372 y_offset = font_info->ascent + 2;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
373 x_offset = 2;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
374
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
375 /* output text, centered on each line */
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
376 XDrawString(display, win, gc, x_offset, y_offset, string1,
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
377 strlen(string1));
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
378 }