Revert "Prevent border drifting."
[wmaker-crm.git] / WINGs / Examples / fontl.c
blob6e08a90b0026a61bc0fdad865d49ba8a890fb304
1 /*
2 * WINGs demo: font lister
4 * Copyright (c) 1998-2003 Alfredo K. Kojima
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 #include <stdlib.h>
22 #include <stdio.h>
23 #include <stdint.h>
24 #include <WINGs/WINGs.h>
25 #include <WINGs/WUtil.h>
27 void wAbort()
29 exit(0);
32 void show(WMWidget * self, void *data)
34 char buf[60];
35 void *d;
36 WMLabel *l = (WMLabel *) data;
37 d = WMGetHangedData(self);
38 sprintf(buf, "%i - 0x%x - 0%o", (int)d, (int)d, (int)d);
39 WMSetLabelText(l, buf);
42 void quit(WMWidget * self, void *data)
44 exit(0);
47 int main(int argc, char **argv)
49 Display *dpy;
50 WMWindow *win;
51 WMScreen *scr;
52 WMButton *lab, *l0 = NULL;
53 WMLabel *pos;
54 int x, y, c;
55 char buf[20];
57 WMInitializeApplication("FontView", &argc, argv);
59 dpy = XOpenDisplay("");
60 if (!dpy) {
61 wfatal("cant open display");
62 exit(0);
65 scr = WMCreateSimpleApplicationScreen(dpy);
67 win = WMCreateWindow(scr, "main");
68 WMResizeWidget(win, 20 * 33, 20 + 20 * 9);
69 WMSetWindowTitle(win, "Font Chars");
70 WMSetWindowCloseAction(win, quit, NULL);
71 pos = WMCreateLabel(win);
72 WMResizeWidget(pos, 20 * 33, 20);
73 WMMoveWidget(pos, 10, 5);
75 c = 0;
76 for (y = 0; y < 8; y++) {
77 for (x = 0; x < 32; x++, c++) {
78 lab = WMCreateCustomButton(win, WBBStateLightMask);
79 WMResizeWidget(lab, 20, 20);
80 WMMoveWidget(lab, 10 + x * 20, 30 + y * 20);
81 sprintf(buf, "%c", c);
82 WMSetButtonText(lab, buf);
83 WMSetButtonAction(lab, show, pos);
84 WMHangData(lab, (void *)(uintptr_t) c);
85 if (c > 0) {
86 WMGroupButtons(l0, lab);
87 } else {
88 l0 = lab;
92 WMRealizeWidget(win);
93 WMMapSubwidgets(win);
94 WMMapWidget(win);
95 WMScreenMainLoop(scr);
96 return 0;