annotate lwlib/xlwtabs.c @ 436:080151679be2 r21-2-26

Import from CVS: tag r21-2-26
author cvs
date Mon, 13 Aug 2007 11:31:24 +0200
parents 9d177e8d4150
children 8de8e3f6228a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 /* Tabs Widget for XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2 Copyright (C) 1999 Edward A. Falk
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4 This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6 XEmacs is free software; you can redistribute it and/or modify it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7 under the terms of the GNU General Public License as published by the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8 Free Software Foundation; either version 2, or (at your option) any
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9 later version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11 XEmacs is distributed in the hope that it will be useful, but WITHOUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 along with XEmacs; see the file COPYING. If not, write to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 Boston, MA 02111-1307, USA. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
21 /* Synched up with: Tabs.c 1.27 */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24 * Tabs.c - Index Tabs composite widget
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26 * Author: Edward A. Falk
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27 * falk@falconer.vip.best.com
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29 * Date: July 29, 1997
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32 * Overall layout of this widget is as follows:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34 * ________ ,---------. _________
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35 * | label || Label || Label | \ tabs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 * |________|| ||_________| /
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37 * |+----------------------------+| \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38 * || || |
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39 * || child widget window || > frame
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40 * |+----------------------------+| |
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41 * +------------------------------+ /
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43 * The height of the tabs includes the shadow width, top and bottom
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44 * margins, and the height of the text.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46 * The height of the frame includes the top and bottom shadow width and the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47 * size of the child widget window.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49 * The tabs overlap the frame and each other vertically by the shadow
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50 * width, so that when the topmost tab is drawn, it obliterates part of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51 * the frame.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
54 /*
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
55 * TODO: min child height = tab height
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58 #include <config.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59 #include <stdio.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61 #include <X11/Xlib.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 #include <X11/IntrinsicP.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63 #include <X11/StringDefs.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64 #include "../src/xmu.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 #include "xlwtabsP.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66 #include "xlwgcs.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68 #define MIN_WID 10
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 #define MIN_HGT 10
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70 #define INDENT 3 /* tabs indented from edge by this much */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71 #define SPACING 0 /* distance between tabs */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72 #define SHADWID 1 /* default shadow width */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 #define TABDELTA 2 /* top tab grows this many pixels */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74 #define TABLDELTA 2 /* top tab label offset this many pixels */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77 /****************************************************************
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79 * IndexTabs Resources
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81 ****************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 static char defaultTranslations[] = "\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84 <BtnUp>: select() \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 <FocusIn>: highlight() \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 <FocusOut>: unhighlight() \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87 <Key>Page_Up: page(up) \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 <Key>KP_Page_Up: page(up) \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 <Key>Prior: page(up) \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 <Key>KP_Prior: page(up) \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91 <Key>Page_Down: page(down) \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 <Key>KP_Page_Down: page(down) \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93 <Key>Next: page(down) \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 <Key>KP_Next: page(down) \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 <Key>Home: page(home) \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 <Key>KP_Home: page(home) \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97 <Key>End: page(end) \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 <Key>KP_End: page(end) \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 <Key>Up: highlight(up) \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 <Key>KP_Up: highlight(up) \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 <Key>Down: highlight(down) \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 <Key>KP_Down: highlight(down) \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 <Key> : page(select) \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 " ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106 static char accelTable[] = " #augment\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107 <Key>Page_Up: page(up) \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 <Key>KP_Page_Up: page(up) \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 <Key>Prior: page(up) \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 <Key>KP_Prior: page(up) \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 <Key>Page_Down: page(down) \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112 <Key>KP_Page_Down: page(down) \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113 <Key>Next: page(down) \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114 <Key>KP_Next: page(down) \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115 <Key>Home: page(home) \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116 <Key>KP_Home: page(home) \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117 <Key>End: page(end) \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118 <Key>KP_End: page(end) \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119 <Key>Up: highlight(up) \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120 <Key>KP_Up: highlight(up) \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 <Key>Down: highlight(down) \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122 <Key>KP_Down: highlight(down) \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123 <Key> : page(select) \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124 " ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125 static XtAccelerators defaultAccelerators ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 #define offset(field) XtOffsetOf(TabsRec, tabs.field)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128 static XtResource resources[] = {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130 {XtNselectInsensitive, XtCSelectInsensitive, XtRBoolean, sizeof(Boolean),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131 offset(selectInsensitive), XtRImmediate, (XtPointer) True},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132 {XtNfont, XtCFont, XtRFontStruct, sizeof(XFontStruct *),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133 offset(font), XtRString, (XtPointer) XtDefaultFont},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134 {XtNinternalWidth, XtCWidth, XtRDimension, sizeof(Dimension),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135 offset(internalWidth), XtRImmediate, (XtPointer)4 },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136 {XtNinternalHeight, XtCHeight, XtRDimension, sizeof(Dimension),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137 offset(internalHeight), XtRImmediate, (XtPointer)4 },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138 {XtNborderWidth, XtCBorderWidth, XtRDimension, sizeof(Dimension),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
139 XtOffsetOf(RectObjRec,rectangle.border_width), XtRImmediate, (XtPointer)0},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140 {XtNtopWidget, XtCTopWidget, XtRWidget, sizeof(Widget),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141 offset(topWidget), XtRImmediate, NULL},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142 {XtNcallback, XtCCallback, XtRCallback, sizeof(XtPointer),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143 offset(callbacks), XtRCallback, NULL},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
144 {XtNpopdownCallback, XtCCallback, XtRCallback, sizeof(XtPointer),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145 offset(popdownCallbacks), XtRCallback, NULL},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146 {XtNbeNiceToColormap, XtCBeNiceToColormap, XtRBoolean, sizeof(Boolean),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147 offset(be_nice_to_cmap), XtRImmediate, (XtPointer) True},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 {XtNtopShadowContrast, XtCTopShadowContrast, XtRInt, sizeof(int),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149 offset(top_shadow_contrast), XtRImmediate, (XtPointer) 20},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150 {XtNbottomShadowContrast, XtCBottomShadowContrast, XtRInt, sizeof(int),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151 offset(bot_shadow_contrast), XtRImmediate, (XtPointer) 40},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152 {XtNinsensitiveContrast, XtCInsensitiveContrast, XtRInt, sizeof(int),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153 offset(insensitive_contrast), XtRImmediate, (XtPointer) 33},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154 {XtNaccelerators, XtCAccelerators, XtRAcceleratorTable,sizeof(XtTranslations),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155 XtOffsetOf(TabsRec,core.accelerators), XtRString, accelTable},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 #undef offset
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 /* constraint resources */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163 #define offset(field) XtOffsetOf(TabsConstraintsRec, tabs.field)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164 static XtResource tabsConstraintResources[] = {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 {XtNtabLabel, XtCLabel, XtRString, sizeof(String),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166 offset(label), XtRString, NULL},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167 {XtNtabLeftBitmap, XtCLeftBitmap, XtRBitmap, sizeof(Pixmap),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168 offset(left_bitmap), XtRImmediate, None},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169 {XtNtabForeground, XtCForeground, XtRPixel, sizeof(Pixel),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170 offset(foreground), XtRString, (XtPointer) XtDefaultForeground},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171 {XtNresizable, XtCResizable, XtRBoolean, sizeof(Boolean),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172 offset(resizable), XtRImmediate, (XtPointer) True},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173 } ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174 #undef offset
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179 #if !NeedFunctionPrototypes
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 /* FORWARD REFERENCES: */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 /* member functions */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185 static void TabsClassInit();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186 static void TabsInit();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187 static void TabsResize();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188 static void TabsExpose();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 static void TabsDestroy();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190 static void TabsRealize();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191 static Boolean TabsSetValues();
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
192 static Boolean TabsAcceptFocus();
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193 static XtGeometryResult TabsQueryGeometry();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194 static XtGeometryResult TabsGeometryManager();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195 static void TabsChangeManaged();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196 static void TabsConstraintInitialize() ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197 static Boolean TabsConstraintSetValues() ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
199 /* action procs */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
200
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
201 static void TabsSelect() ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
202 static void TabsPage() ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 static void TabsHighlight() ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204 static void TabsUnhighlight() ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206 /* internal privates */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208 static void TabsAllocGCs() ; /* get rendering GCs */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 static void TabsFreeGCs() ; /* return rendering GCs */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210 static void DrawTabs() ; /* draw all tabs */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 static void DrawTab() ; /* draw one index tab */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212 static void DrawFrame() ; /* draw frame around contents */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213 static void DrawTrim() ; /* draw trim around a tab */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214 static void DrawBorder() ; /* draw border */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215 static void DrawHighlight() ; /* draw highlight */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
216 static void UndrawTab() ; /* undraw interior of a tab */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
217 static void TabWidth() ; /* recompute tab size */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
218 static void GetPreferredSizes() ; /* query all children for their sizes */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
219 static void MaxChild() ; /* find max preferred child size */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
220 static int PreferredSize() ; /* compute preferred size */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
221 static int PreferredSize2() ; /* compute preferred size */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
222 static int PreferredSize3() ; /* compute preferred size */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223 static void MakeSizeRequest() ; /* try to change size */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
224 static void getBitmapInfo() ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
225 static int TabLayout() ; /* lay out tabs */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
226 static void TabsShuffleRows() ; /* bring current tab to bottom row */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228 static void TabsAllocFgGC() ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229 static void TabsAllocGreyGC() ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
230
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
232
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233 static void TabsClassInit(void) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
234 static void TabsInit( Widget req, Widget new, ArgList, Cardinal *nargs) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
235 static void TabsConstraintInitialize(Widget, Widget, ArgList, Cardinal *) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236 static void TabsRealize(Widget, Mask *, XSetWindowAttributes *) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237 static void TabsDestroy( Widget w) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
238 static void TabsResize( Widget w) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
239 static void TabsExpose( Widget w, XEvent *event, Region region) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
240 static Boolean TabsSetValues(Widget, Widget, Widget, ArgList, Cardinal *) ;
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
241 static Boolean TabsAcceptFocus(Widget, Time *);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242 static Boolean TabsConstraintSetValues(Widget, Widget, Widget,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
243 ArgList, Cardinal *) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
244 static XtGeometryResult TabsQueryGeometry(Widget,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
245 XtWidgetGeometry *, XtWidgetGeometry *) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
246 static XtGeometryResult TabsGeometryManager(Widget,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
247 XtWidgetGeometry *, XtWidgetGeometry *) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
248 static void TabsChangeManaged( Widget w) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
249
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250 static void TabsSelect(Widget, XEvent *, String *, Cardinal *) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
251 static void TabsPage(Widget, XEvent *, String *, Cardinal *) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252 static void TabsHighlight(Widget, XEvent *, String *, Cardinal *) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253 static void TabsUnhighlight(Widget, XEvent *, String *, Cardinal *) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
254
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
255 static void DrawTabs( TabsWidget tw, Bool labels) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
256 static void DrawTab( TabsWidget tw, Widget child, Bool labels) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
257 static void DrawFrame( TabsWidget tw) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
258 static void DrawTrim( TabsWidget, int x, int y,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
259 int wid, int hgt, Bool bottom, Bool undraw) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260 static void DrawBorder( TabsWidget tw, Widget child, Bool undraw) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
261 static void DrawHighlight( TabsWidget tw, Widget child, Bool undraw) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
262 static void UndrawTab( TabsWidget tw, Widget child) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
263
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264 static void TabWidth( Widget w) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
265 static int TabLayout( TabsWidget, int wid, int hgt, Dimension *r_hgt,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
266 Bool query_only) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267 static void GetPreferredSizes(TabsWidget) ;
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
268 static void MaxChild(TabsWidget, Widget except, Dimension, Dimension) ;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269 static void TabsShuffleRows( TabsWidget tw) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270 static int PreferredSize( TabsWidget,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
271 Dimension *reply_width, Dimension *reply_height,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272 Dimension *reply_cw, Dimension *reply_ch) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273 static int PreferredSize2( TabsWidget, int cw, int ch,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
274 Dimension *rw, Dimension *rh) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
275 static int PreferredSize3( TabsWidget, int wid, int hgt,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276 Dimension *rw, Dimension *rh) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277 static void MakeSizeRequest(TabsWidget) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
279 static void TabsAllocGCs(TabsWidget) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
280 static void TabsFreeGCs(TabsWidget) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
281 static void getBitmapInfo( TabsWidget tw, TabsConstraints tab) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
282 static void TabsAllocFgGC( TabsWidget tw) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283 static void TabsAllocGreyGC( TabsWidget tw) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
287 #define AddRect(i,xx,yy,w,h) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288 do{rects[(i)].x=(xx); rects[i].y=(yy); \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289 rects[i].width=(w); rects[i].height=(h);}while(0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
290
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291 static XtActionsRec actionsList[] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
292 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
293 {"select", TabsSelect},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
294 {"page", TabsPage},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
295 {"highlight", TabsHighlight},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
296 {"unhighlight", TabsUnhighlight},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
297 } ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
299
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
300 /****************************************************************
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
301 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
302 * Full class record constant
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
303 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
304 ****************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
305
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306 #ifndef NEED_MOTIF
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
307 #define SuperClass (&constraintClassRec)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
308 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
309 #define SuperClass (&xmManagerClassRec)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
311
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
312 TabsClassRec tabsClassRec = {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
313 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
314 /* core_class fields */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
315 /* superclass */ (WidgetClass) SuperClass,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
316 /* class_name */ "Tabs",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
317 /* widget_size */ sizeof(TabsRec),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
318 /* class_initialize */ TabsClassInit,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319 /* class_part_init */ NULL, /* TODO? */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
320 /* class_inited */ FALSE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
321 /* initialize */ TabsInit,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
322 /* initialize_hook */ NULL,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
323 /* realize */ TabsRealize,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
324 /* actions */ actionsList,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
325 /* num_actions */ XtNumber(actionsList),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
326 /* resources */ resources,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
327 /* num_resources */ XtNumber(resources),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
328 /* xrm_class */ NULLQUARK,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
329 /* compress_motion */ TRUE,
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
330 #if XtSpecificationRelease < 6
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
331 /* compress_exposure */ XtExposeCompressMaximal,
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
332 #else
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
333 /* compress_exposure */ XtExposeCompressMaximal|XtExposeNoRegion,
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
334 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
335 /* compress_enterleave*/ TRUE,
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
336 /* visible_interest */ TRUE,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
337 /* destroy */ TabsDestroy,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
338 /* resize */ TabsResize,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
339 /* expose */ TabsExpose,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
340 /* set_values */ TabsSetValues,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
341 /* set_values_hook */ NULL,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
342 /* set_values_almost */ XtInheritSetValuesAlmost,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
343 /* get_values_hook */ NULL,
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
344 /* accept_focus */ TabsAcceptFocus,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
345 /* version */ XtVersion,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
346 /* callback_private */ NULL,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
347 /* tm_table */ defaultTranslations,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
348 /* query_geometry */ TabsQueryGeometry,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
349 /* display_accelerator*/ XtInheritDisplayAccelerator,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
350 /* extension */ NULL
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
351 },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
352 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
353 /* composite_class fields */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
354 /* geometry_manager */ TabsGeometryManager,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
355 /* change_managed */ TabsChangeManaged,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
356 /* insert_child */ XtInheritInsertChild, /* TODO? */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
357 /* delete_child */ XtInheritDeleteChild, /* TODO? */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
358 /* extension */ NULL
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
359 },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
360 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
361 /* constraint_class fields */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
362 /* subresources */ tabsConstraintResources,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
363 /* subresource_count */ XtNumber(tabsConstraintResources),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
364 /* constraint_size */ sizeof(TabsConstraintsRec),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
365 /* initialize */ TabsConstraintInitialize,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
366 /* destroy */ NULL,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
367 /* set_values */ TabsConstraintSetValues,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
368 /* extension */ NULL,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369 },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370 #ifdef NEED_MOTIF
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
371 /* Manager Class fields */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
372 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
373 /* translations */ NULL,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
374 /* syn_resources */ NULL,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
375 /* num_syn_resources */ 0,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
376 /* syn_constraint_resources */ NULL,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
377 /* num_syn_constraint_resources */ 0,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
378 /* parent_process */ XmInheritParentProcess,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
379 /* extension */ NULL
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
380 },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
381 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
382 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
383 /* Tabs class fields */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
384 /* extension */ NULL,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
385 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
386 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
387
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
388 WidgetClass tabsWidgetClass = (WidgetClass)&tabsClassRec;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
389
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
390
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
391
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
392 #ifdef DEBUG
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
393 #ifdef __STDC__
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
394 #define assert(e) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
395 if(!(e)) fprintf(stderr,"yak! %s at %s:%d\n",#e,__FILE__,__LINE__)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
396 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
397 #define assert(e) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
398 if(!(e)) fprintf(stderr,"yak! e at %s:%d\n",__FILE__,__LINE__)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
399 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
400 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
401 #define assert(e)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
402 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
403
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
404
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
405
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
406
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
407 /****************************************************************
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
408 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
409 * Member Procedures
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
410 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
411 ****************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
412
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
413 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
414 TabsClassInit(void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
415 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
416 defaultAccelerators = XtParseAcceleratorTable(accelTable) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
417 /* TODO: register converter for labels? */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
418 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
419
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
420
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
421
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
422 /* Init a newly created tabs widget. Compute height of tabs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
423 * and optionally compute size of widget. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
424
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
425 /* ARGSUSED */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
426
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
427 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
428 TabsInit(Widget request, Widget new, ArgList args, Cardinal *num_args)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
429 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
430 TabsWidget newTw = (TabsWidget)new;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
431
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
432 newTw->tabs.numRows = 0 ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
433 newTw->tabs.displayChildren = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
434
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
435 GetPreferredSizes(newTw) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
436
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
437 /* height is easy, it's the same for all tabs:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
438 * TODO: font height + height of tallest bitmap.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
439 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
440 newTw->tabs.tab_height = 2 * newTw->tabs.internalHeight + SHADWID ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
441
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
442 if( newTw->tabs.font != NULL )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
443 newTw->tabs.tab_height += newTw->tabs.font->max_bounds.ascent +
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
444 newTw->tabs.font->max_bounds.descent ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
445
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
446 /* GC allocation is deferred until XtRealize() */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
447
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
448 /* if size not explicitly set, set it to our preferred size now. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
449
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
450 if( request->core.width == 0 || request->core.height == 0 )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
451 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
452 Dimension w,h ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
453 PreferredSize(newTw, &w, &h, NULL,NULL) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
454 if( request->core.width == 0 ) new->core.width = w ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
455 if( request->core.height == 0 ) new->core.height = h ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
456 XtClass(new)->core_class.resize(new) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
457 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
458
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
459 /* defer GC allocation, etc., until Realize() time. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
460 newTw->tabs.foregroundGC =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
461 newTw->tabs.backgroundGC =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
462 newTw->tabs.greyGC =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
463 newTw->tabs.topGC =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
464 newTw->tabs.botGC = None ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
465
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
466 newTw->tabs.grey50 = None ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
467
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
468 newTw->tabs.needs_layout = False ;
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
469
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
470 newTw->tabs.hilight = NULL ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
471
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
472 #ifdef NEED_MOTIF
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
473 newTw->manager.navigation_type = XmTAB_GROUP ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
474 newTw->manager.traversal_on = True ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
475 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
476 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
477
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
478
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
479 /* Init the constraint part of a new tab child. Compute the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
480 * size of the tab.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
481 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
482 /* ARGSUSED */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
483 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
484 TabsConstraintInitialize(Widget request, Widget new,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
485 ArgList args, Cardinal *num_args)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
486 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
487 TabsConstraints tab = (TabsConstraints) new->core.constraints ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
488 tab->tabs.greyAlloc = False ; /* defer allocation of pixel */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
489
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
490 getBitmapInfo((TabsWidget)XtParent(new), tab) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
491 TabWidth(new) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
492 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
493
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
494
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
495
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
496 /* Called when tabs widget first realized. Create the window
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
497 * and allocate the GCs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
498 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
499
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
500 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
501 TabsRealize(Widget w, Mask *valueMask, XSetWindowAttributes *attributes)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
502 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
503 TabsWidget tw = (TabsWidget) w;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
504
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
505 attributes->bit_gravity = NorthWestGravity;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
506 *valueMask |= CWBitGravity;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
507
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
508 SuperClass->core_class.realize(w, valueMask, attributes);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
509
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
510 TabsAllocGCs(tw) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
511 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
512
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
513
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
514
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
515 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
516 TabsDestroy(Widget w)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
517 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
518 TabsFreeGCs((TabsWidget)w) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
519 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
520
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
521
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
522 /* Parent has resized us. This will require that the tabs be
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
523 * laid out again.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
524 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
525
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
526 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
527 TabsResize(Widget w)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
528 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
529 TabsWidget tw = (TabsWidget) w;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
530 int i ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
531 int num_children = tw->composite.num_children ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
532 Widget *childP ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
533 TabsConstraints tab ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
534 Dimension cw,ch,bw ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
535
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
536 /* Our size has now been dictated by the parent. Lay out the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
537 * tabs, lay out the frame, lay out the children. Remember
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
538 * that the tabs overlap each other and the frame by shadowWidth.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
539 * Also, the top tab is larger than the others, so if there's only
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
540 * one row, the widget must be made taller to accommodate this.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
541 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
542 * Once the tabs are laid out, if there is more than one
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
543 * row, we may need to shuffle the rows to bring the top tab
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
544 * to the bottom row.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
545 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
546
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
547 tw->tabs.needs_layout = False ;
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
548
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
549 if( num_children > 0 && tw->composite.children != NULL )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
550 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
551 /* Loop through the tabs and assign rows & x positions */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
552 (void) TabLayout(tw, tw->core.width, tw->core.height, NULL, False) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
553 num_children = tw->tabs.displayChildren;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
554
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
555 /* assign a top widget, bring it to bottom row. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
556 TabsShuffleRows(tw) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
557
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
558 /* now assign child positions & sizes. Positions are all the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
559 * same: just inside the frame. Sizes are also all the same.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
560 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
561
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
562 tw->tabs.child_width = cw = tw->core.width - 2 * SHADWID ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
563 tw->tabs.child_height = ch =
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
564 tw->core.height - tw->tabs.tab_total - 2 * SHADWID ;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
565
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
566
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
567 for(i=0, childP=tw->composite.children;
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
568 i < num_children;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
569 ++i, ++childP)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
570 if( XtIsManaged(*childP) )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
571 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
572 tab = (TabsConstraints) (*childP)->core.constraints ;
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
573 bw = (*childP)->core.border_width ;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
574 XtConfigureWidget(*childP, SHADWID,tw->tabs.tab_total+SHADWID,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
575 cw-bw*2,ch-bw*2, bw) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
576 }
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
577 if( XtIsRealized(w) ) {
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
578 XClearWindow(XtDisplay((Widget)tw), XtWindow((Widget)tw)) ;
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
579 /* should not be necessary to explicitly repaint after a
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
580 * resize, but XEmacs folks tell me it is.
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
581 */
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
582 XtClass(tw)->core_class.expose((Widget)tw,NULL,None) ;
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
583 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
584 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
585 } /* Resize */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
586
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
587
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
588
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
589 /* Redraw entire Tabs widget */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
590
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
591 /* ARGSUSED */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
592 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
593 TabsExpose(Widget w, XEvent *event, Region region)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
594 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
595 TabsWidget tw = (TabsWidget) w;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
596
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
597 if( tw->tabs.needs_layout )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
598 XtClass(w)->core_class.resize(w) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
599
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
600 DrawTabs(tw, True) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
601 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
602
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
603
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
604 /* Called when any Tabs widget resources are changed. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
605
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
606 /* ARGSUSED */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
607 static Boolean
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
608 TabsSetValues(Widget current, Widget request, Widget new,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
609 ArgList args, Cardinal *num_args)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
610 {
430
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
611 TabsWidget curtw = (TabsWidget) current ;
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
612 TabsWidget tw = (TabsWidget) new ;
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
613 Boolean needRedraw = False ;
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
614 Widget *childP ;
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
615 int i ;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
616
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
617
430
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
618 if( tw->tabs.font != curtw->tabs.font ||
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
619 tw->tabs.internalWidth != curtw->tabs.internalWidth ||
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
620 tw->tabs.internalHeight != curtw->tabs.internalHeight )
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
621 {
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
622 tw->tabs.tab_height = 2 * tw->tabs.internalHeight + SHADWID ;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
623
430
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
624 if( tw->tabs.font != NULL )
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
625 tw->tabs.tab_height += tw->tabs.font->max_bounds.ascent +
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
626 tw->tabs.font->max_bounds.descent ;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
627
430
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
628 /* Tab size has changed. Resize all tabs and request a new size */
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
629 for(i=0, childP=tw->composite.children;
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
630 i < tw->composite.num_children;
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
631 ++i, ++childP)
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
632 if( XtIsManaged(*childP) )
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
633 TabWidth(*childP) ;
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
634 PreferredSize(tw, &tw->core.width, &tw->core.height, NULL,NULL) ;
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
635 needRedraw = True ;
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
636 tw->tabs.needs_layout = True ;
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
637 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
638
430
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
639 /* TODO: if any color changes, need to recompute GCs and redraw */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
640
430
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
641 if( tw->core.background_pixel != curtw->core.background_pixel ||
432
3a7e78e1142d Import from CVS: tag r21-2-24
cvs
parents: 430
diff changeset
642 tw->core.background_pixmap != curtw->core.background_pixmap ||
3a7e78e1142d Import from CVS: tag r21-2-24
cvs
parents: 430
diff changeset
643 tw->tabs.font != curtw->tabs.font )
430
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
644 if( XtIsRealized(new) )
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
645 {
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
646 TabsFreeGCs(tw) ;
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
647 TabsAllocGCs(tw) ;
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
648 needRedraw = True ;
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
649 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
650
430
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
651 if( tw->core.sensitive != curtw->core.sensitive )
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
652 needRedraw = True ;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
653
430
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
654 /* If top widget changes, need to change stacking order, redraw tabs.
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
655 * Window system will handle the redraws.
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
656 */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
657
432
3a7e78e1142d Import from CVS: tag r21-2-24
cvs
parents: 430
diff changeset
658 if( tw->tabs.topWidget != curtw->tabs.topWidget )
3a7e78e1142d Import from CVS: tag r21-2-24
cvs
parents: 430
diff changeset
659 {
430
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
660 if( XtIsRealized(tw->tabs.topWidget) )
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
661 {
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
662 Widget w = tw->tabs.topWidget ;
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
663 TabsConstraints tab = (TabsConstraints) w->core.constraints ;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
664
430
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
665 XRaiseWindow(XtDisplay(w), XtWindow(w)) ;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
666 #ifdef NEED_MOTIF
430
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
667 XtVaSetValues(curtw->tabs.topWidget, XmNtraversalOn, False, 0) ;
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
668 XtVaSetValues(w, XmNtraversalOn, True, 0) ;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
669 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
670
430
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
671 if( tab->tabs.row != tw->tabs.numRows-1 )
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
672 TabsShuffleRows(tw) ;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
673
430
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
674 needRedraw = True ;
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
675 }
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
676 else
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
677 tw->tabs.needs_layout = True ;
432
3a7e78e1142d Import from CVS: tag r21-2-24
cvs
parents: 430
diff changeset
678 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
679
430
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
680 return needRedraw ;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
681 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
682
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
683
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
684 /* Called when any child constraint resources change. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
685
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
686 /* ARGSUSED */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
687 static Boolean
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
688 TabsConstraintSetValues(Widget current, Widget request, Widget new,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
689 ArgList args, Cardinal *num_args)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
690 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
691 TabsWidget tw = (TabsWidget) XtParent(new) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
692 TabsConstraints ctab = (TabsConstraints) current->core.constraints ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
693 TabsConstraints tab = (TabsConstraints) new->core.constraints ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
694
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
695
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
696 /* if label changes, need to re-layout the entire widget */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
697 /* if foreground changes, need to redraw tab label */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
698
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
699 /* TODO: only need resize of new bitmap has different dimensions
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
700 * from old bitmap.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
701 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
702
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
703 if( tab->tabs.label != ctab->tabs.label || /* Tab size has changed. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
704 tab->tabs.left_bitmap != ctab->tabs.left_bitmap )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
705 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
706 TabWidth(new) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
707 tw->tabs.needs_layout = True ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
708
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
709 if( tab->tabs.left_bitmap != ctab->tabs.left_bitmap )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
710 getBitmapInfo(tw, tab) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
711
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
712 /* If there are no subclass ConstraintSetValues procedures remaining
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
713 * to be invoked, and if the preferred size has changed, ask
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
714 * for a resize.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
715 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
716 if( XtClass((Widget)tw) == tabsWidgetClass )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
717 MakeSizeRequest(tw) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
718 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
719
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
720
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
721 /* The child widget itself never needs a redisplay, but the parent
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
722 * Tabs widget might.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
723 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
724
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
725 if( XtIsRealized(new) )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
726 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
727 if( tw->tabs.needs_layout ) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
728 XClearWindow(XtDisplay((Widget)tw), XtWindow((Widget)tw)) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
729 XtClass(tw)->core_class.expose((Widget)tw,NULL,None) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
730 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
731
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
732 else if( tab->tabs.foreground != ctab->tabs.foreground )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
733 DrawTab(tw, new, True) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
734 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
735
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
736 return False ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
737 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
738
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
739
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
740 static Boolean
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
741 TabsAcceptFocus(Widget w, Time *t)
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
742 {
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
743 if( !w->core.being_destroyed && XtIsRealized(w) &&
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
744 XtIsSensitive(w) && XtIsManaged(w) && w->core.visible )
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
745 {
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
746 Widget p ;
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
747 for(p = XtParent(w); !XtIsShell(p); p = XtParent(p)) ;
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
748 XtSetKeyboardFocus(p,w) ;
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
749 return True ;
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
750 }
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
751 else
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
752 return False ;
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
753 }
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
754
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
755
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
756
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
757 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
758 * Return preferred size. Happily accept anything >= our preferred size.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
759 * (TODO: is that the right thing to do? Should we always return "almost"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
760 * if offerred more than we need?)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
761 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
762
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
763 static XtGeometryResult
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
764 TabsQueryGeometry(Widget w,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
765 XtWidgetGeometry *intended, XtWidgetGeometry *preferred)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
766 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
767 register TabsWidget tw = (TabsWidget)w ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
768 XtGeometryMask mode = intended->request_mode ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
769
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
770 preferred->request_mode = CWWidth | CWHeight ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
771 PreferredSize(tw, &preferred->width, &preferred->height, NULL,NULL) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
772
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
773 if( (!(mode & CWWidth) || intended->width == w->core.width) &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
774 (!(mode & CWHeight) || intended->height == w->core.height) )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
775 return XtGeometryNo ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
776
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
777 if( (!(mode & CWWidth) || intended->width >= preferred->width) &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
778 (!(mode & CWHeight) || intended->height >= preferred->height) )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
779 return XtGeometryYes;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
780
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
781 return XtGeometryAlmost;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
782 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
783
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
784
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
785
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
786 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
787 * Geometry Manager; called when a child wants to be resized.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
788 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
789
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
790 static XtGeometryResult
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
791 TabsGeometryManager(Widget w, XtWidgetGeometry *req, XtWidgetGeometry *reply)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
792 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
793 TabsWidget tw = (TabsWidget) XtParent(w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
794 Dimension s = SHADWID ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
795 TabsConstraints tab = (TabsConstraints)w->core.constraints;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
796 XtGeometryResult result ;
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
797 Dimension rw, rh ;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
798
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
799 /* Position request always denied */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
800
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
801 if( ((req->request_mode & CWX) && req->x != w->core.x) ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
802 ((req->request_mode & CWY) && req->y != w->core.y) ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
803 !tab->tabs.resizable )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
804 return XtGeometryNo ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
805
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
806 /* Make all three fields in the request valid */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
807 if( !(req->request_mode & CWWidth) )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
808 req->width = w->core.width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
809 if( !(req->request_mode & CWHeight) )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
810 req->height = w->core.height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
811 if( !(req->request_mode & CWBorderWidth) )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
812 req->border_width = w->core.border_width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
813
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
814 if( req->width == w->core.width &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
815 req->height == w->core.height &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
816 req->border_width == w->core.border_width )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
817 return XtGeometryNo ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
818
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
819 rw = req->width + 2 * req->border_width ;
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
820 rh = req->height + 2 * req->border_width ;
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
821
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
822 /* find out how big the children want to be now */
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
823 MaxChild(tw, w, rw, rh) ;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
824
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
825
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
826 /* Size changes must see if the new size can be accommodated.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
827 * The Tabs widget keeps all of its children the same
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
828 * size. A request to shrink will be accepted only if the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
829 * new size is still big enough for all other children. A
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
830 * request to shrink that is not big enough for all children
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
831 * returns an "almost" response with the new proposed size
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
832 * or a "no" response if unable to shrink at all.
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
833 *
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
834 * A request to grow will be accepted only if the Tabs parent can
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
835 * grow to accommodate.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
836 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
837 * TODO:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
838 * We could get fancy here and re-arrange the tabs if it is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
839 * necessary to compromise with the parent, but we'll save that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
840 * for another day.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
841 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
842
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
843 if (req->request_mode & (CWWidth | CWHeight | CWBorderWidth))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
844 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
845 Dimension cw,ch ; /* children's preferred size */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
846 Dimension aw,ah ; /* available size we can give child */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
847 Dimension th ; /* space used by tabs */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
848 Dimension wid,hgt ; /* Tabs widget size */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
849
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
850 cw = tw->tabs.max_cw ;
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
851 ch = tw->tabs.max_ch ;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
852
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
853 /* find out what *my* resulting preferred size would be */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
854
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
855 PreferredSize2(tw, cw, ch, &wid, &hgt) ;
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
856
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
857 /* Would my size change? If so, ask to be resized. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
858
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
859 if( wid != tw->core.width || hgt != tw->core.height )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
860 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
861 Dimension oldWid = tw->core.width, oldHgt = tw->core.height ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
862 XtWidgetGeometry myrequest, myreply ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
863
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
864 myrequest.width = wid ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
865 myrequest.height = hgt ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
866 myrequest.request_mode = CWWidth | CWHeight ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
867
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
868 /* If child is only querying, or if we're going to have to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
869 * offer the child a compromise, then make this a query only.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
870 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
871
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
872 if( (req->request_mode & XtCWQueryOnly) || rw < cw || rh < ch )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
873 myrequest.request_mode |= XtCWQueryOnly ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
874
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
875 result = XtMakeGeometryRequest((Widget)tw, &myrequest, &myreply) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
876
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
877 /* !$@# Athena Box widget changes the core size even if QueryOnly
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
878 * is set. I'm convinced this is a bug. At any rate, to work
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
879 * around the bug, we need to restore the core size after every
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
880 * query geometry request. This is only partly effective,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
881 * as there may be other boxes further up the tree.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
882 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
883 if( myrequest.request_mode & XtCWQueryOnly ) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
884 tw->core.width = oldWid ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
885 tw->core.height = oldHgt ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
886 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
887
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
888 /* based on the parent's response, determine what the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
889 * resulting Tabs widget size would be.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
890 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
891
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
892 switch( result ) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
893 case XtGeometryYes:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
894 case XtGeometryDone:
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
895 tw->tabs.needs_layout = True ;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
896 break ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
897
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
898 case XtGeometryNo:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
899 wid = tw->core.width ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
900 hgt = tw->core.height ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
901 break ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
902
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
903 case XtGeometryAlmost:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
904 wid = myreply.width ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
905 hgt = myreply.height ;
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
906 tw->tabs.needs_layout = True ;
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
907 break ;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
908 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
909 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
910
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
911 /* Within the constraints imposed by the parent, what is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
912 * the max size we can give the child?
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
913 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
914 (void) TabLayout(tw, wid, hgt, &th, True) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
915 aw = wid - 2*s ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
916 ah = hgt - th - 2*s ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
917
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
918 /* OK, make our decision. If requested size is >= max sibling
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
919 * preferred size, AND requested size <= available size, then
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
920 * we accept. Otherwise, we offer a compromise.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
921 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
922
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
923 if( rw == aw && rh == ah )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
924 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
925 /* Acceptable. If this wasn't a query, change *all* children
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
926 * to this size.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
927 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
928 if( req->request_mode & XtCWQueryOnly )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
929 return XtGeometryYes ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
930 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
931 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
932 Widget *childP = tw->composite.children ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
933 int i,bw ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
934 w->core.border_width = req->border_width ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
935 for(i=tw->tabs.displayChildren; --i >= 0; ++childP)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
936 if( XtIsManaged(*childP) )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
937 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
938 bw = (*childP)->core.border_width ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
939 XtConfigureWidget(*childP, s,tw->tabs.tab_total+s,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
940 rw-2*bw, rh-2*bw, bw) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
941 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
942 #ifdef COMMENT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
943 /* TODO: under what conditions will we need to redraw? */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
944 XClearWindow(XtDisplay((Widget)tw), XtWindow((Widget)tw)) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
945 XtClass(tw)->core_class.expose((Widget)tw,NULL,NULL) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
946 #endif /* COMMENT */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
947 return XtGeometryDone ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
948 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
949 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
950
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
951 /* Cannot grant child's request. Describe what we *can* do
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
952 * and return counter-offer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
953 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
954 reply->width = aw - 2 * req->border_width ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
955 reply->height = ah - 2 * req->border_width ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
956 reply->border_width = req->border_width ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
957 reply->request_mode = CWWidth | CWHeight | CWBorderWidth ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
958 return XtGeometryAlmost ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
959 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
960
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
961 return XtGeometryYes ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
962 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
963
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
964
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
965
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
966
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
967 /* The number of children we manage has changed; recompute
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
968 * size from scratch.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
969 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
970
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
971 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
972 TabsChangeManaged(Widget w)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
973 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
974 TabsWidget tw = (TabsWidget)w ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
975 Widget *childP = tw->composite.children ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
976 int i ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
977
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
978 if( tw->tabs.topWidget != NULL &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
979 ( !XtIsManaged(tw->tabs.topWidget) ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
980 tw->tabs.topWidget->core.being_destroyed ) )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
981 tw->tabs.topWidget = NULL ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
982
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
983 GetPreferredSizes(tw) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
984 MakeSizeRequest(tw) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
985
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
986 XtClass(w)->core_class.resize(w) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
987 if( XtIsRealized(w) )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
988 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
989 Display *dpy = XtDisplay(w) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
990 XClearWindow(dpy, XtWindow(w)) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
991 XtClass(w)->core_class.expose(w,NULL,NULL) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
992
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
993 /* make sure the top widget stays on top. This requires
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
994 * making sure that all new children are realized first.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
995 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
996 if( tw->tabs.topWidget != NULL && XtIsRealized(tw->tabs.topWidget) )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
997 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
998 for(i=tw->tabs.displayChildren; --i >= 0; ++childP)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
999 if( !XtIsRealized(*childP) )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1000 XtRealizeWidget(*childP) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1001
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1002 XRaiseWindow(dpy, XtWindow(tw->tabs.topWidget)) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1003 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1004 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1005
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1006 #ifdef NEED_MOTIF
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1007 /* Only top widget may receive input */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1008
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1009 for(childP = tw->composite.children, i=tw->composite.num_children;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1010 --i >= 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1011 ++childP)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1012 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1013 XtVaSetValues(*childP, XmNtraversalOn, False, 0) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1014 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1015
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1016 if( tw->tabs.topWidget != NULL )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1017 XtVaSetValues(tw->tabs.topWidget, XmNtraversalOn, True, 0) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1018 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1019 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1020
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1021
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1022
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1023
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1024 /****************************************************************
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1025 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1026 * Action Procedures
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1027 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1028 ****************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1029
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1030
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1031 /* User clicks on a tab, figure out which one it was. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1032
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1033 /* ARGSUSED */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1034 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1035 TabsSelect(Widget w, XEvent *event, String *params, Cardinal *num_params)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1036 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1037 TabsWidget tw = (TabsWidget) w ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1038 Widget *childP ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1039 Position x,y ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1040 Dimension h = tw->tabs.tab_height ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1041 int i ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1042
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1043 #ifdef NEED_MOTIF
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1044 XmProcessTraversal (w, XmTRAVERSE_CURRENT) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1045 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1046
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1047 /* TODO: is there an Xmu function or something to do this instead? */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1048 switch( event->type ) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1049 case ButtonPress:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1050 case ButtonRelease:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1051 x = event->xbutton.x ; y = event->xbutton.y ; break ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1052 case KeyPress:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1053 case KeyRelease:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1054 x = event->xkey.x ; y = event->xkey.y ; break ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1055 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1056 return ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1057 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1058
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1059 /* TODO: determine which tab was clicked, if any. Set that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1060 * widget to be top of stacking order with XawTabsSetTop().
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1061 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1062 for(i=0, childP=tw->composite.children;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1063 i < tw->tabs.displayChildren;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1064 ++i, ++childP)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1065 if( XtIsManaged(*childP) )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1066 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1067 TabsConstraints tab = (TabsConstraints)(*childP)->core.constraints;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1068 if( x > tab->tabs.x && x < tab->tabs.x + tab->tabs.width &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1069 y > tab->tabs.y && y < tab->tabs.y + h )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1070 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1071 if( *childP != tw->tabs.topWidget &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1072 (XtIsSensitive(*childP) || tw->tabs.selectInsensitive) )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1073 XawTabsSetTop(*childP, True) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1074 break ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1075 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1076 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1077 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1078
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1079
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1080 /* User hits a key */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1081
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1082 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1083 TabsPage(Widget w, XEvent *event, String *params, Cardinal *num_params)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1084 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1085 TabsWidget tw = (TabsWidget) w ;
430
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
1086 Widget newtop = NULL;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1087 Widget *childP ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1088 int idx ;
436
080151679be2 Import from CVS: tag r21-2-26
cvs
parents: 434
diff changeset
1089 int nc = tw->tabs.displayChildren ;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1090
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1091 if( nc <= 0 )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1092 return ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1093
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1094 if( *num_params < 1 ) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1095 XtAppWarning(XtWidgetToApplicationContext(w),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1096 "Tabs: page() action called with no arguments") ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1097 return ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1098 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1099
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1100 if( tw->tabs.topWidget == NULL )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1101 tw->tabs.topWidget = tw->composite.children[0] ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1102
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1103 for(idx=0, childP=tw->composite.children; idx < nc; ++idx, ++childP )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1104 if( tw->tabs.topWidget == *childP )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1105 break ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1106
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1107 switch( params[0][0] ) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1108 case 'u': /* up */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1109 case 'U':
432
3a7e78e1142d Import from CVS: tag r21-2-24
cvs
parents: 430
diff changeset
1110 if( --idx < 0 )
3a7e78e1142d Import from CVS: tag r21-2-24
cvs
parents: 430
diff changeset
1111 idx = nc-1 ;
3a7e78e1142d Import from CVS: tag r21-2-24
cvs
parents: 430
diff changeset
1112 newtop = tw->composite.children[idx] ;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1113 break ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1114
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1115 case 'd': /* down */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1116 case 'D':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1117 if( ++idx >= nc )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1118 idx = 0 ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1119 newtop = tw->composite.children[idx] ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1120 break ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1121
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1122 case 'h':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1123 case 'H':
432
3a7e78e1142d Import from CVS: tag r21-2-24
cvs
parents: 430
diff changeset
1124 default:
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1125 newtop = tw->composite.children[0] ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1126 break ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1127
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1128 case 'e':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1129 case 'E':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1130 newtop = tw->composite.children[nc-1] ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1131 break ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1132
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1133 case 's': /* selected */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1134 case 'S':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1135 if( (newtop = tw->tabs.hilight) == NULL )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1136 return ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1137 break ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1138 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1139
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1140 XawTabsSetTop(newtop, True) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1141 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1142
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1143
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1144 /* User hits up/down key */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1145
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1146 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1147 TabsHighlight(Widget w, XEvent *event, String *params, Cardinal *num_params)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1148 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1149 TabsWidget tw = (TabsWidget) w ;
430
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
1150 Widget newhl = NULL;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1151 Widget *childP ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1152 int idx ;
436
080151679be2 Import from CVS: tag r21-2-26
cvs
parents: 434
diff changeset
1153 int nc = tw->tabs.displayChildren ;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1154
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1155 if( nc <= 0 )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1156 return ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1157
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1158 if( *num_params < 1 )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1159 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1160 if( tw->tabs.hilight != NULL )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1161 DrawHighlight(tw, tw->tabs.hilight, False) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1162 return ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1163 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1164
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1165 if( tw->tabs.hilight == NULL )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1166 newhl = tw->composite.children[0] ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1167
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1168 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1169 {
432
3a7e78e1142d Import from CVS: tag r21-2-24
cvs
parents: 430
diff changeset
1170 /* find index of currently highlit child */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1171 for(idx=0, childP=tw->composite.children; idx < nc; ++idx, ++childP )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1172 if( tw->tabs.hilight == *childP )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1173 break ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1174
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1175 switch( params[0][0] ) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1176 case 'u': /* up */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1177 case 'U':
432
3a7e78e1142d Import from CVS: tag r21-2-24
cvs
parents: 430
diff changeset
1178 if( --idx < 0 )
3a7e78e1142d Import from CVS: tag r21-2-24
cvs
parents: 430
diff changeset
1179 idx = nc-1 ;
3a7e78e1142d Import from CVS: tag r21-2-24
cvs
parents: 430
diff changeset
1180 newhl = tw->composite.children[idx] ;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1181 break ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1182
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1183 case 'd': /* down */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1184 case 'D':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1185 if( ++idx >= nc )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1186 idx = 0 ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1187 newhl = tw->composite.children[idx] ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1188 break ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1189
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1190 case 'h':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1191 case 'H':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1192 newhl = tw->composite.children[0] ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1193 break ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1194
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1195 case 'e':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1196 case 'E':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1197 newhl = tw->composite.children[nc-1] ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1198 break ;
432
3a7e78e1142d Import from CVS: tag r21-2-24
cvs
parents: 430
diff changeset
1199
3a7e78e1142d Import from CVS: tag r21-2-24
cvs
parents: 430
diff changeset
1200 default:
3a7e78e1142d Import from CVS: tag r21-2-24
cvs
parents: 430
diff changeset
1201 newhl = tw->tabs.hilight ;
3a7e78e1142d Import from CVS: tag r21-2-24
cvs
parents: 430
diff changeset
1202 break ;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1203 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1204 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1205
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1206 XawTabsSetHighlight(w, newhl) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1207 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1208
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1209
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1210
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1211 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1212 TabsUnhighlight(Widget w, XEvent *event, String *params, Cardinal *num_params)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1213 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1214 TabsWidget tw = (TabsWidget) w ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1215 int nc = tw->composite.num_children ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1216
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1217 if( nc <= 0 )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1218 return ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1219
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1220 if( tw->tabs.hilight != NULL )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1221 DrawHighlight(tw, tw->tabs.hilight, True) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1222 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1223
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1224
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1225
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1226
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1227
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1228 /****************************************************************
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1229 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1230 * Public Procedures
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1231 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1232 ****************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1233
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1234
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1235 /* Set the top tab, optionally call all callbacks. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1236 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1237 XawTabsSetTop(Widget w, Bool callCallbacks)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1238 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1239 TabsWidget tw = (TabsWidget)w->core.parent ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1240 TabsConstraints tab ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1241 Widget oldtop = tw->tabs.topWidget ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1242
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1243 if( !XtIsSubclass(w->core.parent, tabsWidgetClass) )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1244 {
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1245 char line[256] ;
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1246 sprintf(line, "XawTabsSetTop: widget \"%.64s\" is not the child of a tabs widget.", XtName(w)) ;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1247 XtAppWarning(XtWidgetToApplicationContext(w), line) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1248 return ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1249 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1250
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1251 if( callCallbacks )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1252 XtCallCallbackList(w, tw->tabs.popdownCallbacks,
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1253 (XtPointer)tw->tabs.topWidget) ;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1254
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1255 if( !XtIsRealized(w) ) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1256 tw->tabs.topWidget = w ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1257 tw->tabs.needs_layout = True ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1258 return ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1259 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1260
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1261 XRaiseWindow(XtDisplay(w), XtWindow(w)) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1262 #ifdef NEED_MOTIF
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1263 XtVaSetValues(oldtop, XmNtraversalOn, False, 0) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1264 XtVaSetValues(w, XmNtraversalOn, True, 0) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1265 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1266
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1267 tab = (TabsConstraints) w->core.constraints ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1268 if( tab->tabs.row == 0 )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1269 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1270 /* Easy case; undraw current top, undraw new top, assign new
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1271 * top, redraw all borders.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1272 * We *could* just erase and execute a full redraw, but I like to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1273 * reduce screen flicker.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1274 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1275 UndrawTab(tw, oldtop) ; /* undraw old */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1276 DrawBorder(tw, oldtop, True) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1277 UndrawTab(tw, w) ; /* undraw new */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1278 DrawBorder(tw, w, True) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1279 tw->tabs.topWidget = w ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1280 DrawTab(tw, oldtop, True) ; /* redraw old */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1281 DrawTab(tw, w, True) ; /* redraw new */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1282 DrawTabs(tw, False) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1283 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1284 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1285 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1286 tw->tabs.topWidget = w ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1287 TabsShuffleRows(tw) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1288 XClearWindow(XtDisplay((Widget)tw), XtWindow((Widget)tw)) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1289 XtClass(tw)->core_class.expose((Widget)tw,NULL,None) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1290 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1291
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1292 XawTabsSetHighlight((Widget)tw, w) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1293
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1294 if( callCallbacks )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1295 XtCallCallbackList(w, tw->tabs.callbacks, (XtPointer)w) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1296 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1297
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1298
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1299 /* Set the top tab, optionally call all callbacks. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1300 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1301 XawTabsSetHighlight(Widget t, Widget w)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1302 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1303 TabsWidget tw = (TabsWidget)t ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1304
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1305 if( !XtIsSubclass(t, tabsWidgetClass) )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1306 return ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1307
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1308 if( XtIsRealized(t) && w != tw->tabs.hilight )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1309 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1310 if( tw->tabs.hilight != NULL )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1311 DrawHighlight(tw, tw->tabs.hilight, True) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1312 if( w != NULL )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1313 DrawHighlight(tw, w, False) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1314 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1315
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1316 tw->tabs.hilight = w ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1317 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1318
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1319
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1320
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1321
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1322 /****************************************************************
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1323 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1324 * Private Procedures
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1325 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1326 ****************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1327
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1328
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1329 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1330 TabsAllocGCs(TabsWidget tw)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1331 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1332 TabsAllocFgGC(tw) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1333 TabsAllocGreyGC(tw) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1334 tw->tabs.backgroundGC = AllocBackgroundGC((Widget)tw, None) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1335 tw->tabs.topGC = AllocTopShadowGC((Widget)tw,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1336 tw->tabs.top_shadow_contrast, tw->tabs.be_nice_to_cmap) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1337 tw->tabs.botGC = AllocBotShadowGC((Widget)tw,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1338 tw->tabs.bot_shadow_contrast, tw->tabs.be_nice_to_cmap) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1339 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1340
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1341
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1342 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1343 TabsFreeGCs(TabsWidget tw)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1344 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1345 Widget w = (Widget) tw;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1346
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1347 XtReleaseGC(w, tw->tabs.foregroundGC) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1348 XtReleaseGC(w, tw->tabs.greyGC) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1349 XtReleaseGC(w, tw->tabs.backgroundGC) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1350 XtReleaseGC(w, tw->tabs.topGC) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1351 XtReleaseGC(w, tw->tabs.botGC) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1352 #ifdef HAVE_XMU
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1353 XmuReleaseStippledPixmap(XtScreen(w), tw->tabs.grey50) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1354 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1355 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1356
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1357
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1358
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1359
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1360
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1361 /* Redraw entire Tabs widget */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1362
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1363 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1364 DrawTabs(TabsWidget tw, Bool labels)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1365 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1366 Widget *childP ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1367 int i,j ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1368 Dimension s = SHADWID ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1369 Dimension th = tw->tabs.tab_height ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1370 Position y ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1371 TabsConstraints tab ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1372
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1373 if( !XtIsRealized((Widget)tw))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1374 return ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1375
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1376 /* draw tabs and frames by row except for the top tab, which
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1377 * is drawn last. (This is inefficiently written, but should not
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1378 * be too slow as long as there are not a lot of rows.)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1379 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1380
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1381 y = tw->tabs.numRows == 1 ? TABDELTA : 0 ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1382 for(i=0; i<tw->tabs.numRows; ++i, y += th)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1383 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1384 for( j=tw->tabs.displayChildren, childP=tw->composite.children;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1385 --j >= 0; ++childP )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1386 if( XtIsManaged(*childP) )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1387 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1388 tab = (TabsConstraints)(*childP)->core.constraints;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1389 if( tab->tabs.row == i && *childP != tw->tabs.topWidget )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1390 DrawTab(tw, *childP, labels) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1391 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1392 if( i != tw->tabs.numRows -1 )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1393 DrawTrim(tw, 0,y+th, tw->core.width, th+s, False,False) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1394 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1395
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1396 DrawFrame(tw) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1397
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1398 /* and now the top tab */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1399 if( tw->tabs.topWidget != NULL )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1400 DrawTab(tw, tw->tabs.topWidget, labels) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1401 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1402
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1403
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1404
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1405 /* Draw one tab. Corners are rounded very slightly. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1406
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1407 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1408 DrawTab(TabsWidget tw, Widget child, Bool labels)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1409 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1410 GC gc ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1411 int x,y ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1412
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1413 if( !XtIsRealized((Widget)tw))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1414 return ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1415
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1416 DrawBorder(tw, child, False) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1417
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1418 if( labels )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1419 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1420 TabsConstraints tab = (TabsConstraints)child->core.constraints;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1421 Display *dpy = XtDisplay((Widget)tw) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1422 Window win = XtWindow((Widget)tw) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1423 String lbl = tab->tabs.label != NULL ?
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1424 tab->tabs.label : XtName(child) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1425
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1426 if( XtIsSensitive(child) )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1427 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1428 gc = tw->tabs.foregroundGC ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1429 XSetForeground(dpy, gc, tab->tabs.foreground) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1430 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1431 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1432 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1433 /* grey pixel allocation deferred until now */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1434 if( !tab->tabs.greyAlloc )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1435 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1436 if( tw->tabs.be_nice_to_cmap || tw->core.depth == 1 )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1437 tab->tabs.grey = tab->tabs.foreground ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1438 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1439 tab->tabs.grey = AllocGreyPixel((Widget)tw,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1440 tab->tabs.foreground,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1441 tw->core.background_pixel,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1442 tw->tabs.insensitive_contrast ) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1443 tab->tabs.greyAlloc = True ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1444 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1445 gc = tw->tabs.greyGC ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1446 XSetForeground(dpy, gc, tab->tabs.grey) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1447 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1448
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1449 x = tab->tabs.x ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1450 y = tab->tabs.y ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1451 if( child == tw->tabs.topWidget )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1452 y -= TABLDELTA ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1453
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1454 if( tab->tabs.left_bitmap != None && tab->tabs.lbm_width > 0 )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1455 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1456 if( tab->tabs.lbm_depth == 1 )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1457 XCopyPlane(dpy, tab->tabs.left_bitmap, win,gc,
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1458 0,0, tab->tabs.lbm_width, tab->tabs.lbm_height,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1459 x+tab->tabs.lbm_x, y+tab->tabs.lbm_y, 1L) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1460 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1461 XCopyArea(dpy, tab->tabs.left_bitmap, win,gc,
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1462 0,0, tab->tabs.lbm_width, tab->tabs.lbm_height,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1463 x+tab->tabs.lbm_x, y+tab->tabs.lbm_y) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1464 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1465
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1466 if( lbl != NULL && tw->tabs.font != NULL )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1467 XDrawString(dpy,win,gc,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1468 x+tab->tabs.l_x, y+tab->tabs.l_y,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1469 lbl, (int)strlen(lbl)) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1470 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1471
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1472 if( child == tw->tabs.hilight )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1473 DrawHighlight(tw, child, False) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1474 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1475
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1476
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1477 /* draw frame all the way around the child windows. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1478
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1479 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1480 DrawFrame(TabsWidget tw)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1481 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1482 GC topgc = tw->tabs.topGC ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1483 GC botgc = tw->tabs.botGC ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1484 Dimension s = SHADWID ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1485 Dimension ch = tw->tabs.child_height ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1486 Draw3dBox((Widget)tw, 0,tw->tabs.tab_total,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1487 tw->core.width, ch+2*s, s, topgc, botgc) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1488 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1489
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1490
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1491 /* draw trim around a tab or underneath a row of tabs */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1492
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1493 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1494 DrawTrim(TabsWidget tw, /* widget */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1495 int x, /* upper-left corner */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1496 int y,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1497 int wid, /* total size */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1498 int hgt,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1499 Bool bottom, /* draw bottom? */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1500 Bool undraw) /* undraw all */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1501 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1502 Display *dpy = XtDisplay((Widget)tw) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1503 Window win = XtWindow((Widget)tw) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1504 GC bggc = tw->tabs.backgroundGC ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1505 GC topgc = undraw ? bggc : tw->tabs.topGC ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1506 GC botgc = undraw ? bggc : tw->tabs.botGC ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1507 if( bottom )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1508 XDrawLine(dpy,win,bggc, x,y+hgt-1, x+wid-1,y+hgt-1) ; /* bottom */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1509 XDrawLine(dpy,win,topgc, x,y+2, x,y+hgt-2) ; /* left */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1510 XDrawPoint(dpy,win,topgc, x+1,y+1) ; /* corner */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1511 XDrawLine(dpy,win,topgc, x+2,y, x+wid-3,y) ; /* top */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1512 XDrawLine(dpy,win,botgc, x+wid-2,y+1, x+wid-2,y+hgt-2) ; /* right */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1513 XDrawLine(dpy,win,botgc, x+wid-1,y+2, x+wid-1,y+hgt-2) ; /* right */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1514 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1515
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1516
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1517 /* Draw one tab border. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1518
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1519 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1520 DrawBorder(TabsWidget tw, Widget child, Bool undraw)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1521 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1522 TabsConstraints tab = (TabsConstraints)child->core.constraints;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1523 Position x = tab->tabs.x ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1524 Position y = tab->tabs.y ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1525 Dimension twid = tab->tabs.width ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1526 Dimension thgt = tw->tabs.tab_height ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1527
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1528 /* top tab requires a little special attention; it overlaps
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1529 * neighboring tabs slightly, so the background must be cleared
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1530 * in the region of the overlap to partially erase those neighbors.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1531 * TODO: is this worth doing with regions instead?
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1532 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1533 if( child == tw->tabs.topWidget )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1534 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1535 Display *dpy = XtDisplay((Widget)tw) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1536 Window win = XtWindow((Widget)tw) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1537 GC bggc = tw->tabs.backgroundGC ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1538 XRectangle rects[3] ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1539 x -= TABDELTA ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1540 y -= TABDELTA ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1541 twid += TABDELTA*2 ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1542 thgt += TABDELTA ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1543 AddRect(0, x,y+1,twid,TABDELTA) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1544 AddRect(1, x+1,y,TABDELTA,thgt) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1545 AddRect(2, x+twid-TABDELTA-1,y,TABDELTA,thgt) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1546 XFillRectangles(dpy,win,bggc, rects, 3) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1547 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1548
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1549 DrawTrim(tw, x,y,twid,thgt+1, child == tw->tabs.topWidget, undraw) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1550 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1551
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1552
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1553 /* Draw highlight around tab that has focus */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1554
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1555 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1556 DrawHighlight(TabsWidget tw, Widget child, Bool undraw)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1557 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1558 TabsConstraints tab = (TabsConstraints)child->core.constraints;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1559 Display *dpy = XtDisplay((Widget)tw) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1560 Window win = XtWindow((Widget)tw) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1561 GC gc ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1562 Position x = tab->tabs.x ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1563 Position y = tab->tabs.y ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1564 Dimension wid = tab->tabs.width ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1565 Dimension hgt = tw->tabs.tab_height ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1566 XPoint points[6] ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1567
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1568 /* top tab does not have a highlight */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1569
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1570 if( child == tw->tabs.topWidget )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1571 return ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1572
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1573 if( undraw )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1574 gc = tw->tabs.backgroundGC ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1575
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1576 else if( XtIsSensitive(child) )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1577 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1578 gc = tw->tabs.foregroundGC ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1579 XSetForeground(dpy, gc, tab->tabs.foreground) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1580 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1581 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1582 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1583 gc = tw->tabs.greyGC ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1584 XSetForeground(dpy, gc, tab->tabs.grey) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1585 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1586
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1587 points[0].x = x+1 ; points[0].y = y+hgt-1 ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1588 points[1].x = x+1 ; points[1].y = y+2 ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1589 points[2].x = x+2 ; points[2].y = y+1 ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1590 points[3].x = x+wid-4 ; points[3].y = y+1 ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1591 points[4].x = x+wid-3 ; points[4].y = y+2 ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1592 points[5].x = x+wid-3 ; points[5].y = y+hgt-1 ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1593
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1594 XDrawLines(dpy,win,gc, points,6, CoordModeOrigin) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1595 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1596
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1597
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1598 /* Undraw one tab interior */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1599
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1600 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1601 UndrawTab(TabsWidget tw, Widget child)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1602 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1603 TabsConstraints tab = (TabsConstraints)child->core.constraints;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1604 Position x = tab->tabs.x ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1605 Position y = tab->tabs.y ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1606 Dimension twid = tab->tabs.width ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1607 Dimension thgt = tw->tabs.tab_height ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1608 Display *dpy = XtDisplay((Widget)tw) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1609 Window win = XtWindow((Widget)tw) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1610 GC bggc = tw->tabs.backgroundGC ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1611
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1612 XFillRectangle(dpy,win,bggc, x,y, twid,thgt) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1613 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1614
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1615
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1616
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1617
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1618
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1619 /* GEOMETRY UTILITIES */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1620
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1621 /* Overview:
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1622 *
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1623 * MaxChild(): ask all children (except possibly one) their
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1624 * preferred sizes, set max_cw, max_ch accordingly.
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1625 *
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1626 * GetPreferredSizes(): ask all children their preferred sizes,
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1627 * set max_cw, max_ch accordingly.
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1628 *
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1629 * PreferredSize(): given max_cw, max_ch, return tabs widget
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1630 * preferred size. Iterate with other widths in order to get
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1631 * a reasonable aspect ratio.
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1632 *
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1633 * PreferredSize2(): Given child dimensions, return Tabs
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1634 * widget dimensions.
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1635 *
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1636 * PreferredSize3(): Same, except given child dimensions plus
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1637 * shadow.
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1638 */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1639
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1640
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1641 /* Compute the width of one child's tab. Positions will be computed
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1642 * elsewhere.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1643 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1644 * height: font height + vertical_space*2 + shadowWid*2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1645 * width: string width + horizontal_space*2 + shadowWid*2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1646 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1647 * All tabs are the same height, so that is computed elsewhere.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1648 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1649
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1650 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1651 TabWidth(Widget w)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1652 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1653 TabsConstraints tab = (TabsConstraints) w->core.constraints ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1654 TabsWidget tw = (TabsWidget)XtParent(w) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1655 String lbl = tab->tabs.label != NULL ?
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1656 tab->tabs.label : XtName(w) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1657 XFontStruct *font = tw->tabs.font ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1658 int iw = tw->tabs.internalWidth ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1659
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1660 tab->tabs.width = iw + SHADWID*2 ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1661 tab->tabs.l_x = tab->tabs.lbm_x = SHADWID + iw ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1662
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1663 if( tab->tabs.left_bitmap != None )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1664 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1665 tab->tabs.width += tab->tabs.lbm_width + iw ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1666 tab->tabs.l_x += tab->tabs.lbm_width + iw ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1667 tab->tabs.lbm_y = (tw->tabs.tab_height - tab->tabs.lbm_height)/2 ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1668 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1669
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1670 if( lbl != NULL && font != NULL )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1671 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1672 tab->tabs.width += XTextWidth( font, lbl, (int)strlen(lbl) ) + iw ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1673 tab->tabs.l_y = (tw->tabs.tab_height +
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1674 tw->tabs.font->max_bounds.ascent -
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1675 tw->tabs.font->max_bounds.descent)/2 ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1676 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1677 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1678
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1679
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1680
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1681 /* Lay out tabs to fit in given width. Compute x,y position and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1682 * row number for each tab. Return number of rows and total height
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1683 * required by all tabs. If there is only one row, add TABDELTA
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1684 * height to the total. Rows are assigned bottom to top.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1685 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1686 * Tabs are indented from the edges by INDENT.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1687 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1688 * TODO: if they require more than two rows and the total height:width
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1689 * ratio is more than 2:1, then try something else.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1690 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1691
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1692 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1693 TabLayout(TabsWidget tw, int wid, int hgt, Dimension *reply_height, Bool query_only)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1694 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1695 int i, row ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1696 int num_children = tw->composite.num_children ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1697 Widget *childP ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1698 Dimension w ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1699 Position x,y ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1700 TabsConstraints tab ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1701
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1702 if (!query_only)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1703 tw->tabs.displayChildren = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1704
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1705 /* Algorithm: loop through children, assign X positions. If a tab
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1706 * would extend beyond the right edge, start a new row. After all
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1707 * rows are assigned, make a second pass and assign Y positions.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1708 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1709
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1710 if( num_children > 0 )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1711 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1712 /* Loop through the tabs and see how much space they need. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1713
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1714 row = 0 ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1715 x = INDENT ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1716 y = 0 ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1717 wid -= INDENT ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1718 for(i=num_children, childP=tw->composite.children; --i >= 0; ++childP)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1719 if( XtIsManaged(*childP) )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1720 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1721 tab = (TabsConstraints) (*childP)->core.constraints ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1722 w = tab->tabs.width ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1723 if( x + w > wid ) { /* new row */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1724 if (y + tw->tabs.tab_height > hgt)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1725 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1726 ++row ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1727 x = INDENT ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1728 y += tw->tabs.tab_height ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1729 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1730 if( !query_only ) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1731 tab->tabs.x = x ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1732 tab->tabs.y = y ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1733 tab->tabs.row = row ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1734 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1735 x += w + SPACING ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1736 if (!query_only)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1737 tw->tabs.displayChildren++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1738 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1739 /* If there was only one row, increse the height by TABDELTA */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1740 if( ++row == 1 )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1741 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1742 y = TABDELTA ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1743 if( !query_only )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1744 for(i=num_children, childP=tw->composite.children;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1745 --i >= 0 ; ++childP)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1746 if( XtIsManaged(*childP) )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1747 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1748 tab = (TabsConstraints) (*childP)->core.constraints ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1749 tab->tabs.y = y ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1750 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1751 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1752 y += tw->tabs.tab_height ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1753 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1754 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1755 row = y = 0 ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1756
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1757 if( !query_only ) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1758 tw->tabs.tab_total = y ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1759 tw->tabs.numRows = row ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1760 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1761
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1762 if( reply_height != NULL )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1763 *reply_height = y ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1764
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1765 return row ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1766 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1767
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1768
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1769
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1770 /* Find max preferred child size. Returned sizes include child
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1771 * border widths.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1772 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1773
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1774 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1775 GetPreferredSizes(TabsWidget tw)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1776 {
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1777 MaxChild(tw, NULL, 0,0) ;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1778 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1779
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1780
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1781
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1782 /* Find max preferred child size. Returned sizes include child
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1783 * border widths. If except is non-null, don't ask that one.
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1784 */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1785
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1786 static void
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1787 MaxChild(TabsWidget tw, Widget except, Dimension cw, Dimension ch)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1788 {
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1789 int i ;
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1790 Widget *childP = tw->composite.children ;
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1791 XtWidgetGeometry preferred ;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1792
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1793 for(i=tw->composite.num_children; --i >=0; ++childP)
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1794 if( XtIsManaged(*childP) && *childP != except )
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1795 {
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1796 (void) XtQueryGeometry(*childP, NULL, &preferred) ;
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1797 cw = Max(cw, preferred.width + preferred.border_width * 2 ) ;
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1798 ch = Max(ch, preferred.height + preferred.border_width * 2 ) ;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1799 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1800
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1801 tw->tabs.max_cw = cw ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1802 tw->tabs.max_ch = ch ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1803 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1804
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1805
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1806
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1807 /* rotate row numbers to bring current widget to bottom row,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1808 * compute y positions for all tabs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1809 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1810
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1811 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1812 TabsShuffleRows(TabsWidget tw)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1813 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1814 TabsConstraints tab ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1815 int move ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1816 int nrows ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1817 Widget *childP ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1818 Dimension th = tw->tabs.tab_height ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1819 Position bottom ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1820 int i ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1821
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1822 /* There must be a top widget. If not, assign one. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1823 if( tw->tabs.topWidget == NULL && tw->composite.children != NULL )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1824 for(i=tw->composite.num_children, childP=tw->composite.children;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1825 --i >= 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1826 ++childP)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1827 if( XtIsManaged(*childP) ) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1828 tw->tabs.topWidget = *childP ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1829 break ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1830 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1831
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1832 if( tw->tabs.topWidget != NULL )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1833 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1834 nrows = tw->tabs.numRows ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1835 assert( nrows > 0 ) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1836
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1837 if( nrows > 1 )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1838 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1839 tab = (TabsConstraints) tw->tabs.topWidget->core.constraints ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1840 assert( tab != NULL ) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1841
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1842 /* how far to move top row */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1843 move = nrows - tab->tabs.row ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1844 bottom = tw->tabs.tab_total - th ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1845
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1846 for(i=tw->tabs.displayChildren, childP=tw->composite.children;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1847 --i >= 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1848 ++childP)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1849 if( XtIsManaged(*childP) )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1850 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1851 tab = (TabsConstraints) (*childP)->core.constraints ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1852 tab->tabs.row = (tab->tabs.row + move) % nrows ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1853 tab->tabs.y = bottom - tab->tabs.row * th ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1854 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1855 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1856 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1857 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1858
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1859
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1860 /* Find preferred size. Ask children, find size of largest,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1861 * add room for tabs & return. This can get a little involved,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1862 * as we don't want to have too many rows of tabs; we may widen
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1863 * the widget to reduce # of rows.
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1864 *
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1865 * This function requires that max_cw, max_ch already be set.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1866 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1867
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1868 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1869 PreferredSize(
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1870 TabsWidget tw,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1871 Dimension *reply_width, /* total widget size */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1872 Dimension *reply_height,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1873 Dimension *reply_cw, /* child widget size */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1874 Dimension *reply_ch)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1875 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1876 Dimension cw,ch ; /* child width, height */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1877 Dimension wid,hgt ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1878 Dimension rwid,rhgt ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1879 int nrow ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1880
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1881 wid = cw = tw->tabs.max_cw ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1882 hgt = ch = tw->tabs.max_ch ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1883
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1884 nrow = PreferredSize2(tw, wid,hgt, &rwid, &rhgt) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1885
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1886 /* Check for absurd results (more than 2 rows, high aspect
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1887 * ratio). Try wider size if needed.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1888 * TODO: make sure this terminates.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1889 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1890
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1891 if( nrow > 2 && rhgt > rwid )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1892 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1893 Dimension w0, w1 ;
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1894 int maxloop = 20 ;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1895
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1896 /* step 1: start doubling size until it's too big */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1897 do {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1898 w0 = wid ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1899 wid = Max(wid*2, wid+20) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1900 nrow = PreferredSize2(tw, wid,hgt, &rwid,&rhgt) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1901 } while( nrow > 2 && rhgt > rwid ) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1902 w1 = wid ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1903
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1904 /* step 2: use Newton's method to find ideal size. Stop within
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1905 * 8 pixels.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1906 */
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1907 while( --maxloop > 0 && w1 > w0 + 8 )
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1908 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1909 wid = (w0+w1)/2 ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1910 nrow = PreferredSize2(tw, wid,hgt, &rwid,&rhgt) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1911 if( nrow > 2 && rhgt > rwid )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1912 w0 = wid ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1913 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1914 w1 = wid ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1915 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1916 wid = w1 ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1917 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1918
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1919 *reply_width = rwid ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1920 *reply_height = rhgt ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1921 if( reply_cw != NULL ) *reply_cw = cw ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1922 if( reply_ch != NULL ) *reply_ch = ch ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1923 return nrow ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1924 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1925
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1926
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1927 /* Find preferred size, given size of children. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1928
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1929 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1930 PreferredSize2(
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1931 TabsWidget tw,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1932 int cw, /* child width, height */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1933 int ch,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1934 Dimension *reply_width, /* total widget size */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1935 Dimension *reply_height)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1936 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1937 Dimension s = SHADWID ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1938
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1939 /* make room for shadow frame */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1940 cw += s*2 ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1941 ch += s*2 ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1942
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1943 return PreferredSize3(tw, cw, ch, reply_width, reply_height) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1944 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1945
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1946
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1947 /* Find preferred size, given size of children+shadow. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1948
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1949 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1950 PreferredSize3(
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1951 TabsWidget tw,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1952 int wid, /* child width, height */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1953 int hgt,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1954 Dimension *reply_width, /* total widget size */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1955 Dimension *reply_height)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1956 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1957 Dimension th ; /* space used by tabs */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1958 int nrows ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1959
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1960 if( tw->composite.num_children > 0 )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1961 nrows = TabLayout(tw, wid, hgt, &th, True) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1962 else {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1963 th = 0 ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1964 nrows = 0 ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1965 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1966
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1967 *reply_width = Max(wid, MIN_WID) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1968 *reply_height = Max(th+hgt, MIN_HGT) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1969
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1970 return nrows ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1971 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1972
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1973
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1974 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1975 MakeSizeRequest(TabsWidget tw)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1976 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1977 Widget w = (Widget)tw ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1978 XtWidgetGeometry request, reply ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1979 XtGeometryResult result ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1980 Dimension cw,ch ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1981
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1982 request.request_mode = CWWidth | CWHeight ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1983 PreferredSize(tw, &request.width, &request.height, &cw, &ch) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1984
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1985 if( request.width == tw->core.width &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1986 request.height == tw->core.height )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1987 return ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1988
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1989 result = XtMakeGeometryRequest(w, &request, &reply) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1990
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1991 if( result == XtGeometryAlmost )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1992 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1993 /* Bugger. Didn't get what we want, but were offered a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1994 * compromise. If the width was too small, recompute
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1995 * based on the too-small width and try again.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1996 * If the height was too small, make a wild-ass guess
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1997 * at a wider width and try again.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1998 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1999
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2000 if( reply.width < request.width && reply.height >= request.height )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2001 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2002 Dimension s = SHADWID ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2003 ch += s*2 ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2004 PreferredSize3(tw, reply.width,ch, &request.width, &request.height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2005 result = XtMakeGeometryRequest(w, &request, &reply) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2006 if( result == XtGeometryAlmost )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2007 (void) XtMakeGeometryRequest(w, &reply, NULL) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2008 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2009
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2010 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2011 (void) XtMakeGeometryRequest(w, &reply, NULL) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2012 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2013 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2014
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2015
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2016 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2017 getBitmapInfo(TabsWidget tw, TabsConstraints tab)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2018 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2019 Window root ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2020 int x,y ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2021 unsigned int bw ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2022
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2023 if( tab->tabs.left_bitmap == None ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2024 !XGetGeometry(XtDisplay(tw), tab->tabs.left_bitmap, &root, &x, &y,
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
2025 &tab->tabs.lbm_width, &tab->tabs.lbm_height,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2026 &bw, &tab->tabs.lbm_depth) )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2027 tab->tabs.lbm_width = tab->tabs.lbm_height = 0 ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2028 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2029
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2030
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2031
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2032
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2033 /* Code copied & modified from Gcs.c. This version has dynamic
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2034 * foreground.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2035 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2036
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2037 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2038 TabsAllocFgGC(TabsWidget tw)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2039 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2040 Widget w = (Widget) tw;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2041 XGCValues values ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2042
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2043 values.background = tw->core.background_pixel ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2044 values.font = tw->tabs.font->fid ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2045 values.line_style = LineOnOffDash ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2046 values.line_style = LineSolid ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2047
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2048 tw->tabs.foregroundGC =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2049 XtAllocateGC(w, w->core.depth,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2050 GCBackground|GCFont|GCLineStyle, &values,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2051 GCForeground,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2052 GCSubwindowMode|GCGraphicsExposures|GCDashOffset|
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2053 GCDashList|GCArcMode) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2054 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2055
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2056 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2057 TabsAllocGreyGC(TabsWidget tw)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2058 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2059 Widget w = (Widget) tw;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2060 XGCValues values ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2061
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2062 values.background = tw->core.background_pixel ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2063 values.font = tw->tabs.font->fid ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2064 #ifdef HAVE_XMU
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2065 if( tw->tabs.be_nice_to_cmap || w->core.depth == 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2066 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2067 values.fill_style = FillStippled ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2068 tw->tabs.grey50 =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2069 values.stipple = XmuCreateStippledPixmap(XtScreen(w), 1L, 0L, 1) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2070
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2071 tw->tabs.greyGC =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2072 XtAllocateGC(w, w->core.depth,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2073 GCBackground|GCFont|GCStipple|GCFillStyle, &values,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2074 GCForeground,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2075 GCSubwindowMode|GCGraphicsExposures|GCDashOffset|
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2076 GCDashList|GCArcMode) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2077 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2078 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2079 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2080 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2081 tw->tabs.greyGC =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2082 XtAllocateGC(w, w->core.depth,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2083 GCFont, &values,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2084 GCForeground,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2085 GCBackground|GCSubwindowMode|GCGraphicsExposures|GCDashOffset|
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2086 GCDashList|GCArcMode) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2087 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2088 }