~ubuntu-branches/ubuntu/lucid/graphviz/lucid-security

« back to all changes in this revision

Viewing changes to lefty/ws/mswin32/gview.c

  • Committer: Bazaar Package Importer
  • Author(s): Stephen M Moraco
  • Date: 2002-02-05 18:52:12 UTC
  • Revision ID: james.westby@ubuntu.com-20020205185212-8i04c70te00rc40y
Tags: upstream-1.7.16
ImportĀ upstreamĀ versionĀ 1.7.16

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#pragma prototyped
 
2
/* Lefteris Koutsofios - AT&T Bell Laboratories */
 
3
 
 
4
#include "common.h"
 
5
#include "g.h"
 
6
#include "gcommon.h"
 
7
#include "mem.h"
 
8
 
 
9
#define WVU widget->u.v
 
10
 
 
11
int GVcreatewidget (Gwidget_t *parent, Gwidget_t *widget,
 
12
        int attrn, Gwattr_t *attrp) {
 
13
    PIXpoint_t po;
 
14
    PIXsize_t ps;
 
15
    DWORD wflags;
 
16
    char *s;
 
17
    int ai;
 
18
 
 
19
    WVU->func = NULL;
 
20
    WVU->closing = FALSE;
 
21
    wflags = WS_OVERLAPPEDWINDOW;
 
22
    s = "LEFTY";
 
23
    po.x = po.y = CW_USEDEFAULT;
 
24
    ps.x = ps.y = MINVWSIZE;
 
25
    for (ai = 0; ai < attrn; ai++) {
 
26
        switch (attrp[ai].id) {
 
27
        case G_ATTRORIGIN:
 
28
            GETORIGIN (attrp[ai].u.p, po);
 
29
            break;
 
30
        case G_ATTRSIZE:
 
31
            GETSIZE (attrp[ai].u.s, ps, MINVWSIZE);
 
32
            break;
 
33
        case G_ATTRNAME:
 
34
            s = attrp[ai].u.t;
 
35
            break;
 
36
        case G_ATTRZORDER:
 
37
            Gerr (POS, G_ERRCANNOTSETATTR1, "zorder");
 
38
            return -1;
 
39
        case G_ATTRWINDOWID:
 
40
            Gerr (POS, G_ERRCANNOTSETATTR1, "windowid");
 
41
            return -1;
 
42
        case G_ATTREVENTCB:
 
43
            WVU->func = attrp[ai].u.func;
 
44
            break;
 
45
        case G_ATTRUSERDATA:
 
46
            widget->udata = attrp[ai].u.u;
 
47
            break;
 
48
        default:
 
49
            Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
 
50
            return -1;
 
51
        }
 
52
    }
 
53
    if (!(widget->w = CreateWindow ("LeftyClass", s, wflags, po.x, po.y,
 
54
            ps.x, ps.y, (HWND) 0, (HMENU) 0, hinstance, NULL))) {
 
55
        Gerr (POS, G_ERRCANNOTCREATEWIDGET);
 
56
        return -1;
 
57
    }
 
58
    ShowWindow (widget->w, SW_SHOW);
 
59
    UpdateWindow (widget->w);
 
60
    return 0;
 
61
}
 
62
 
 
63
int GVsetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
 
64
    PIXpoint_t po;
 
65
    PIXsize_t ps;
 
66
    DWORD wflags1, wflags2, wflags3, wflags4;
 
67
    int ai;
 
68
 
 
69
    wflags1 = SWP_NOMOVE | SWP_NOZORDER;
 
70
    wflags2 = SWP_NOSIZE | SWP_NOZORDER;
 
71
    wflags3 = SWP_NOSIZE | SWP_NOMOVE;
 
72
    wflags4 = SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE;
 
73
    for (ai = 0; ai < attrn; ai++) {
 
74
        switch (attrp[ai].id) {
 
75
        case G_ATTRORIGIN:
 
76
            GETORIGIN (attrp[ai].u.p, po);
 
77
            SetWindowPos (widget->w, (HWND) NULL, po.x, po.y, 0, 0, wflags2);
 
78
            break;
 
79
        case G_ATTRSIZE:
 
80
            GETSIZE (attrp[ai].u.s, ps, MINVWSIZE);
 
81
            SetWindowPos (widget->w, (HWND) NULL, 0, 0, ps.x, ps.y, wflags1);
 
82
            break;
 
83
        case G_ATTRNAME:
 
84
            SetWindowText (widget->w, attrp[ai].u.t);
 
85
            return -1;
 
86
        case G_ATTRZORDER:
 
87
            if (Strcmp (attrp[ai].u.t, "top") == 0)
 
88
                SetWindowPos (widget->w, (HWND) HWND_TOP, 0, 0, 0, 0, wflags3);
 
89
            else if (Strcmp (attrp[ai].u.t, "bottom") == 0)
 
90
                SetWindowPos (widget->w, (HWND) HWND_BOTTOM,
 
91
                        0, 0, 0, 0, wflags4);
 
92
            else {
 
93
                Gerr (POS, G_ERRBADATTRVALUE, attrp[ai].u.t);
 
94
                return -1;
 
95
            }
 
96
            break;
 
97
        case G_ATTRWINDOWID:
 
98
            Gerr (POS, G_ERRCANNOTSETATTR1, "windowid");
 
99
            return -1;
 
100
        case G_ATTREVENTCB:
 
101
            WVU->func = attrp[ai].u.func;
 
102
            break;
 
103
        case G_ATTRUSERDATA:
 
104
            widget->udata = attrp[ai].u.u;
 
105
            break;
 
106
        default:
 
107
            Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
 
108
            return -1;
 
109
        }
 
110
    }
 
111
    return 0;
 
112
}
 
113
 
 
114
int GVgetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
 
115
    RECT r;
 
116
    int ai;
 
117
 
 
118
    for (ai = 0; ai < attrn; ai++) {
 
119
        switch (attrp[ai].id) {
 
120
        case G_ATTRORIGIN:
 
121
            GetWindowRect (widget->w, &r);
 
122
            attrp[ai].u.p.x = r.left, attrp[ai].u.p.y = r.top;
 
123
            break;
 
124
        case G_ATTRSIZE:
 
125
            GetWindowRect (widget->w, &r);
 
126
            attrp[ai].u.s.x = r.right - r.left;
 
127
            attrp[ai].u.s.y = r.bottom - r.top;
 
128
            break;
 
129
        case G_ATTRNAME:
 
130
            Gerr (POS, G_ERRNOTIMPLEMENTED);
 
131
            return -1;
 
132
        case G_ATTRZORDER:
 
133
            Gerr (POS, G_ERRNOTIMPLEMENTED);
 
134
            return -1;
 
135
        case G_ATTRWINDOWID:
 
136
            sprintf (&Gbufp[0], "0x%lx", widget->w);
 
137
            attrp[ai].u.t = &Gbufp[0];
 
138
            break;
 
139
        case G_ATTREVENTCB:
 
140
            attrp[ai].u.func = WVU->func;
 
141
            break;
 
142
        case G_ATTRUSERDATA:
 
143
            attrp[ai].u.u = widget->udata;
 
144
            break;
 
145
        default:
 
146
            Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
 
147
            return -1;
 
148
        }
 
149
    }
 
150
    return 0;
 
151
}
 
152
 
 
153
int GVdestroywidget (Gwidget_t *widget) {
 
154
    WVU->closing = TRUE;
 
155
    DestroyWindow (widget->w);
 
156
    return 0;
 
157
}