~profzoom/ubuntu/quantal/wmaker/bug-1079925

« back to all changes in this revision

Viewing changes to WINGs/Examples/fontl.c

  • Committer: Bazaar Package Importer
  • Author(s): Marcelo E. Magallon
  • Date: 2004-11-10 14:05:30 UTC
  • Revision ID: james.westby@ubuntu.com-20041110140530-qpd66b5lm38x7apk
Tags: upstream-0.91.0
ImportĀ upstreamĀ versionĀ 0.91.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * WINGs demo: font lister
 
3
 *
 
4
 *  Copyright (c) 1998-2003 Alfredo K. Kojima
 
5
 *
 
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.
 
10
 *
 
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.
 
15
 *
 
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.
 
20
 */
 
21
 
 
22
 
 
23
 
 
24
 
 
25
#include <stdlib.h>
 
26
#include <stdio.h>
 
27
#include <WINGs/WINGs.h>
 
28
#include <WINGs/WUtil.h>
 
29
 
 
30
void
 
31
wAbort()
 
32
{
 
33
    exit(0);
 
34
}
 
35
 
 
36
void show(WMWidget *self, void *data)
 
37
{
 
38
    char buf[60];
 
39
    void *d;
 
40
    WMLabel *l = (WMLabel*)data;
 
41
    d = WMGetHangedData(self);
 
42
    sprintf(buf, "%i -  0x%x - 0%o", (int)d, (int)d, (int)d);
 
43
    WMSetLabelText(l, buf);
 
44
}
 
45
 
 
46
void quit(WMWidget *self, void *data)
 
47
{
 
48
    exit(0);
 
49
}
 
50
 
 
51
 
 
52
int
 
53
main(int argc, char **argv)
 
54
{
 
55
    Display *dpy;
 
56
    WMWindow *win;
 
57
    WMScreen *scr;
 
58
    WMButton *lab, *l0=NULL;
 
59
    WMLabel *pos;
 
60
    int x, y, c;
 
61
    char buf[20];
 
62
 
 
63
    WMInitializeApplication("FontView", &argc, argv);
 
64
 
 
65
    dpy = XOpenDisplay("");
 
66
    if (!dpy) {
 
67
        wfatal("cant open display");
 
68
        exit(0);
 
69
    }
 
70
 
 
71
    scr = WMCreateSimpleApplicationScreen(dpy);
 
72
 
 
73
    win = WMCreateWindow(scr, "main");
 
74
    WMResizeWidget(win, 20*33, 20+20*9);
 
75
    WMSetWindowTitle(win, "Font Chars");
 
76
    WMSetWindowCloseAction(win, quit, NULL);
 
77
    pos = WMCreateLabel(win);
 
78
    WMResizeWidget(pos, 20*33, 20);
 
79
    WMMoveWidget(pos, 10, 5);
 
80
 
 
81
    c = 0;
 
82
    for (y=0; y<8; y++) {
 
83
        for (x=0; x<32; x++, c++) {
 
84
            lab = WMCreateCustomButton(win, WBBStateLightMask);
 
85
            WMResizeWidget(lab, 20, 20);
 
86
            WMMoveWidget(lab, 10+x*20, 30+y*20);
 
87
            sprintf(buf, "%c", c);
 
88
            WMSetButtonText(lab, buf);
 
89
            WMSetButtonAction(lab, show, pos);
 
90
            WMHangData(lab, (void*)c);
 
91
            if (c>0) {
 
92
                WMGroupButtons(l0, lab);
 
93
            } else {
 
94
                l0 = lab;
 
95
            }
 
96
        }
 
97
    }
 
98
    WMRealizeWidget(win);
 
99
    WMMapSubwidgets(win);
 
100
    WMMapWidget(win);
 
101
    WMScreenMainLoop(scr);
 
102
    return 0;
 
103
}
 
104