-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathview.c
276 lines (241 loc) · 5.57 KB
/
view.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
/*
* window.c
* Window and popup menu callbacks for mgv.
*
* Copyright (C) 1996 Eric A. Howe
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* Authors: Matthew D. Francey
* Eric A. Howe ([email protected])
*/
#include <wlib/rcs.h>
MU_ID("$Mu: mgv/view.c 1.13 2001/03/11 18:47:30 $")
#include <Xm/ToggleB.h>
#include <wlib/wlib.h>
#include <wlib/typesanity.h>
#include <wlib/sanity.h>
#include <mine/mgv.h>
#include <mine/app.h>
#include <mine/strings.h>
#include <mine/view.h>
#include <mine/zoom.h>
#include <mine/log.h>
/*
* window->hide log, popup->hide log
*/
void
mgv_view_log(Widget w, XtPointer closure, XtPointer call)
{
USEUP(w); USEUP(closure); USEUP(call);
mgv_log_show(!((XmTBS *)call)->set);
}
static void
layout(MGV *m)
{
Arg sw[6], pg[4], tb[2];
Cardinal sw_n, pg_n, tb_n;
Widget top;
sw_n = pg_n = tb_n = 0;
top = NULL;
if(m->bits & MgvPAGELIST) {
XtSetArg(sw[sw_n], XmNrightAttachment, XmATTACH_FORM);
++sw_n;
}
else {
XtManageChild(XtParent(m->pagelist));
XtSetArg(sw[sw_n], XmNrightAttachment, XmATTACH_WIDGET);
++sw_n;
XtSetArg(sw[sw_n], XmNrightWidget, XtParent(m->pagelist));
++sw_n;
}
if(m->bits & MgvSTATUSLINE) {
XtSetArg(sw[sw_n], XmNbottomAttachment, XmATTACH_FORM);
++sw_n;
XtSetArg(pg[pg_n], XmNbottomAttachment, XmATTACH_FORM);
++pg_n;
}
else {
XtManageChild(m->statusline);
XtSetArg(sw[sw_n], XmNbottomAttachment, XmATTACH_WIDGET);
++sw_n;
XtSetArg(sw[sw_n], XmNbottomWidget, m->statusline);
++sw_n;
XtSetArg(pg[pg_n], XmNbottomAttachment, XmATTACH_WIDGET);
++pg_n;
XtSetArg(pg[pg_n], XmNbottomWidget, m->statusline);
++pg_n;
}
if(m->bits & MgvTOOLBAR) {
top = NULL;
}
else {
XtManageChild(m->toolbar);
top = m->toolbar;
}
if(m->bits & MgvMENUBAR) {
if(!(m->bits & MgvMENUDOWN)) {
XtWidgetGeometry req;
/*
* Down on your knees rebel dog!
*/
memset((void *)&req, '\0', sizeof(req));
req.request_mode = CWStackMode;
req.stack_mode = Below;
XtMakeGeometryRequest(m->menubar, &req, NULL);
m->bits |= MgvMENUDOWN;
}
if(top != NULL) {
XtSetArg(tb[tb_n], XmNtopAttachment, XmATTACH_FORM);
++tb_n;
}
}
else {
XtManageChild(m->menubar);
if(top == NULL) {
top = m->menubar;
}
else {
XtSetArg(tb[tb_n], XmNtopAttachment, XmATTACH_WIDGET);
++tb_n;
XtSetArg(tb[tb_n], XmNtopWidget, m->menubar);
++tb_n;
}
}
if(top != NULL) {
XtSetArg(sw[sw_n], XmNtopAttachment, XmATTACH_WIDGET);
++sw_n;
XtSetArg(sw[sw_n], XmNtopWidget, top);
++sw_n;
XtSetArg(pg[pg_n], XmNtopAttachment, XmATTACH_WIDGET);
++pg_n;
XtSetArg(pg[pg_n], XmNtopWidget, top);
++pg_n;
}
else {
XtSetArg(sw[sw_n], XmNtopAttachment, XmATTACH_FORM);
++sw_n;
XtSetArg(pg[pg_n], XmNtopAttachment, XmATTACH_FORM);
++pg_n;
}
wlSetValues(m->sw, sw, sw_n);
wlSetValues(XtParent(m->pagelist), pg, pg_n);
wlSetValues(m->toolbar, tb, tb_n);
if(m->bits & MgvPAGELIST)
XtUnmanageChild(XtParent(m->pagelist));
if(m->bits & MgvSTATUSLINE)
XtUnmanageChild(m->statusline);
if(m->bits & MgvTOOLBAR)
XtUnmanageChild(m->toolbar);
m->autosizer(m);
}
/*
* hide/unhide the page list
*/
void
mgv_view_page(Widget w, XtPointer closure, XtPointer call)
{
XmTBS *cbs = (XmTBS *)call;
MGV *m = (MGV *)closure;
MGVR *r = mgv_app_res(m->main);
wl_assert(MgvOK(m));
if(cbs->set) {
r->hide_pglist = True;
m->bits |= MgvPAGELIST;
}
else {
if(!m->labels && !m->pgnums) {
w = wl_find1(m->main, "*menuBar*page_pd*showPgNums");
XmToggleButtonSetState(w, True, True);
}
r->hide_pglist = False;
m->bits &= ~MgvPAGELIST;
}
layout(m);
}
/*
* hide/unhide the status line
*/
void
mgv_view_status(Widget w, XtPointer closure, XtPointer call)
{
XmTBS *cbs = (XmTBS *)call;
MGV *m = (MGV *)closure;
MGVR *r = mgv_app_res(m->main);
USEUP(w);
wl_assert(MgvOK(m));
if(cbs->set) {
r->hide_status = True;
m->bits |= MgvSTATUSLINE;
}
else {
r->hide_status = False;
m->bits &= ~MgvSTATUSLINE;
}
layout(m);
}
/*
* Hide/unhide the menu bar, we don't manage/unmanage because we
* don't want to lose the accelerators.
*/
void
mgv_view_menu(Widget w, XtPointer closure, XtPointer call)
{
XmTBS *cbs = (XmTBS *)call;
MGV *m = (MGV *)closure;
MGVR *r = mgv_app_res(m->main);
USEUP(w);
wl_assert(MgvOK(m));
if(cbs->set) {
r->hide_menu = True;
m->bits |= MgvMENUBAR;
}
else {
r->hide_menu = False;
m->bits &= ~MgvMENUBAR;
}
layout(m);
}
/*
* Hide/unhide the tool bar.
*/
void
mgv_view_toolbar(Widget w, XtPointer closure, XtPointer call)
{
XmTBS *cbs = (XmTBS *)call;
MGV *m = (MGV *)closure;
MGVR *r = mgv_app_res(m->main);
USEUP(w);
if(cbs->set) {
r->hide_toolbar = True;
m->bits |= MgvTOOLBAR;
}
else {
r->hide_toolbar = False;
m->bits &= ~MgvTOOLBAR;
}
layout(m);
}
/*
* window->close zooms, popup->close zooms
*/
void
mgv_view_zoom(Widget w, XtPointer closure, XtPointer call)
{
MGV *m = (MGV *)closure;
USEUP(w); USEUP(call);
wl_assert(MgvOK(m));
mgv_zoom_killall(m);
}