wmaker: Fix compiler warnings about pointer <--> integer conversion
[wmaker-crm.git] / WINGs / Examples / fontl.c
blobad9957aa039adfb5ff393d7272a4db81fb4af1ce
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
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
19 * USA.
25 #include <stdlib.h>
26 #include <stdio.h>
27 #include <stdint.h>
28 #include <WINGs/WINGs.h>
29 #include <WINGs/WUtil.h>
31 void
32 wAbort()
34 exit(0);
37 void show(WMWidget *self, void *data)
39 char buf[60];
40 void *d;
41 WMLabel *l = (WMLabel*)data;
42 d = WMGetHangedData(self);
43 sprintf(buf, "%i - 0x%x - 0%o", (int)(uintptr_t)d, (int)(uintptr_t)d,
44 (int)(uintptr_t)d);
45 WMSetLabelText(l, buf);
48 void quit(WMWidget *self, void *data)
50 exit(0);
54 int
55 main(int argc, char **argv)
57 Display *dpy;
58 WMWindow *win;
59 WMScreen *scr;
60 WMButton *lab, *l0=NULL;
61 WMLabel *pos;
62 int x, y, c;
63 char buf[20];
65 WMInitializeApplication("FontView", &argc, argv);
67 dpy = XOpenDisplay("");
68 if (!dpy) {
69 wfatal("cant open display");
70 exit(0);
73 scr = WMCreateSimpleApplicationScreen(dpy);
75 win = WMCreateWindow(scr, "main");
76 WMResizeWidget(win, 20*33, 20+20*9);
77 WMSetWindowTitle(win, "Font Chars");
78 WMSetWindowCloseAction(win, quit, NULL);
79 pos = WMCreateLabel(win);
80 WMResizeWidget(pos, 20*33, 20);
81 WMMoveWidget(pos, 10, 5);
83 c = 0;
84 for (y=0; y<8; y++) {
85 for (x=0; x<32; x++, c++) {
86 lab = WMCreateCustomButton(win, WBBStateLightMask);
87 WMResizeWidget(lab, 20, 20);
88 WMMoveWidget(lab, 10+x*20, 30+y*20);
89 sprintf(buf, "%c", c);
90 WMSetButtonText(lab, buf);
91 WMSetButtonAction(lab, show, pos);
92 WMHangData(lab, (void*)(uintptr_t)c);
93 if (c>0) {
94 WMGroupButtons(l0, lab);
95 } else {
96 l0 = lab;
100 WMRealizeWidget(win);
101 WMMapSubwidgets(win);
102 WMMapWidget(win);
103 WMScreenMainLoop(scr);
104 return 0;