Update Serbian translation from master branch
[wmaker-crm.git] / WINGs / Examples / fontl.c
bloba440a22c4c49a80966b4249f03e84877fe061cb2
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>
26 #include <inttypes.h>
28 void wAbort()
30 exit(0);
33 void show(WMWidget * self, void *data)
35 char buf[60];
36 void *d;
37 WMLabel *l = (WMLabel *) data;
38 d = WMGetHangedData(self);
39 sprintf(buf, "%"PRIiPTR" - 0x%"PRIxPTR" - 0%"PRIoPTR, (intptr_t) d, (intptr_t) d, (intptr_t) d);
40 WMSetLabelText(l, buf);
43 void quit(WMWidget * self, void *data)
45 (void) self;
46 (void) data;
47 exit(0);
50 int main(int argc, char **argv)
52 Display *dpy;
53 WMWindow *win;
54 WMScreen *scr;
55 WMButton *lab, *l0 = NULL;
56 WMLabel *pos;
57 int x, y, c;
58 char buf[20];
60 WMInitializeApplication("FontView", &argc, argv);
62 dpy = XOpenDisplay("");
63 if (!dpy) {
64 wfatal("cant open display");
65 exit(0);
68 scr = WMCreateSimpleApplicationScreen(dpy);
70 win = WMCreateWindow(scr, "main");
71 WMResizeWidget(win, 20 * 33, 20 + 20 * 9);
72 WMSetWindowTitle(win, "Font Chars");
73 WMSetWindowCloseAction(win, quit, NULL);
74 pos = WMCreateLabel(win);
75 WMResizeWidget(pos, 20 * 33, 20);
76 WMMoveWidget(pos, 10, 5);
78 c = 0;
79 for (y = 0; y < 8; y++) {
80 for (x = 0; x < 32; x++, c++) {
81 lab = WMCreateCustomButton(win, WBBStateLightMask);
82 WMResizeWidget(lab, 20, 20);
83 WMMoveWidget(lab, 10 + x * 20, 30 + y * 20);
84 sprintf(buf, "%c", c);
85 WMSetButtonText(lab, buf);
86 WMSetButtonAction(lab, show, pos);
87 WMHangData(lab, (void *)(uintptr_t) c);
88 if (c > 0) {
89 WMGroupButtons(l0, lab);
90 } else {
91 l0 = lab;
95 WMRealizeWidget(win);
96 WMMapSubwidgets(win);
97 WMMapWidget(win);
98 WMScreenMainLoop(scr);
99 return 0;