annotate lwlib/xlwtabs.c @ 3401:81d2bb0cb5de

[xemacs-hg @ 2006-05-15 21:52:16 by viteno] Update xemacs_extra_name.
author viteno
date Mon, 15 May 2006 21:52:16 +0000
parents 6aa26bef0527
children 382b11fa8866
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
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4 This file is part of XEmacs.
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
5
428
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.
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
10
428
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.
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
15
428
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. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
20
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22 * Tabs.c - Index Tabs composite widget
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 * Author: Edward A. Falk
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25 * falk@falconer.vip.best.com
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27 * Date: July 29, 1997
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 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30 * Overall layout of this widget is as follows:
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 * ________ ,---------. _________
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33 * | label || Label || Label | \ tabs
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 * |+----------------------------+| \
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 * || child widget window || > frame
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 * +------------------------------+ /
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 * The height of the tabs includes the shadow width, top and bottom
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42 * margins, and the height of the text.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44 * 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
45 * size of the child widget window.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47 * The tabs overlap the frame and each other vertically by the shadow
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48 * 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
49 * the frame.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
52 /* Synched up with: Tabs.c 1.27.
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
53
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
54 This file contains essential XEmacs-related fixes to the original
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
55 version of the Tabs widget. Be VERY careful about syncing if you ever
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
56 update to a more recent version. In general this is probably now a
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
57 bad idea.
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
58
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
59 #### We need to check that various windows (the whole widget, or a single
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
60 tab) are of "reasonable" size, ie, we need to try for more sanity in the
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
61 geometry management routines.
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
62 */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
63
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
64 /*
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
65 * TODO: min child height = tab height
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66 */
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 #include <config.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 #include <stdio.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71 #include <X11/Xlib.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72 #include <X11/IntrinsicP.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 #include <X11/StringDefs.h>
448
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
74
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
75 /* #### This may be risky, lwlib-internal.h redefines abort() */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
76 #include "lwlib-fonts.h"
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
77 #include "lwlib-colors.h"
448
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
78 #include "lwlib-internal.h"
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79 #include "../src/xmu.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80 #include "xlwtabsP.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81 #include "xlwgcs.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
83 #define XFT_USE_HEIGHT_NOT_ASCENT_DESCENT 0
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
84
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
85 /* #### These should probably be resources. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 #define MIN_WID 10
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87 #define MIN_HGT 10
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 #define INDENT 3 /* tabs indented from edge by this much */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 #define SPACING 0 /* distance between tabs */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 #define SHADWID 1 /* default shadow width */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91 #define TABDELTA 2 /* top tab grows this many pixels */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 #define TABLDELTA 2 /* top tab label offset this many pixels */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 /****************************************************************
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97 * IndexTabs Resources
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 ****************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 static char defaultTranslations[] = "\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 <BtnUp>: select() \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 <FocusIn>: highlight() \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 <FocusOut>: unhighlight() \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 <Key>Page_Up: page(up) \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106 <Key>KP_Page_Up: page(up) \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107 <Key>Prior: page(up) \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 <Key>KP_Prior: page(up) \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 <Key>Page_Down: page(down) \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 <Key>KP_Page_Down: page(down) \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 <Key>Next: page(down) \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112 <Key>KP_Next: page(down) \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113 <Key>Home: page(home) \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114 <Key>KP_Home: page(home) \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115 <Key>End: page(end) \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116 <Key>KP_End: page(end) \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117 <Key>Up: highlight(up) \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118 <Key>KP_Up: highlight(up) \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119 <Key>Down: highlight(down) \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120 <Key>KP_Down: highlight(down) \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 <Key> : page(select) \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122 " ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124 static char accelTable[] = " #augment\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125 <Key>Page_Up: page(up) \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126 <Key>KP_Page_Up: page(up) \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 <Key>Prior: page(up) \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128 <Key>KP_Prior: page(up) \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 <Key>Page_Down: page(down) \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130 <Key>KP_Page_Down: page(down) \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131 <Key>Next: page(down) \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132 <Key>KP_Next: page(down) \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133 <Key>Home: page(home) \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134 <Key>KP_Home: page(home) \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135 <Key>End: page(end) \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136 <Key>KP_End: page(end) \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137 <Key>Up: highlight(up) \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138 <Key>KP_Up: highlight(up) \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
139 <Key>Down: highlight(down) \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140 <Key>KP_Down: highlight(down) \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141 <Key> : page(select) \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142 " ;
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
143 static XtAccelerators defaultAccelerators ; /* #### Never used */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
144
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145 #define offset(field) XtOffsetOf(TabsRec, tabs.field)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146 static XtResource resources[] = {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 {XtNselectInsensitive, XtCSelectInsensitive, XtRBoolean, sizeof(Boolean),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149 offset(selectInsensitive), XtRImmediate, (XtPointer) True},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150 {XtNfont, XtCFont, XtRFontStruct, sizeof(XFontStruct *),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151 offset(font), XtRString, (XtPointer) XtDefaultFont},
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
152 #ifdef USE_XFT_TABS
3397
6aa26bef0527 [xemacs-hg @ 2006-05-12 19:25:28 by stephent]
stephent
parents: 3374
diff changeset
153 /* #### Maybe use "-*-helvetica-bold-r-*-*-*-120-*-*-*-*-iso8859-1" here?
6aa26bef0527 [xemacs-hg @ 2006-05-12 19:25:28 by stephent]
stephent
parents: 3374
diff changeset
154 or XtDefaultFont? */
6aa26bef0527 [xemacs-hg @ 2006-05-12 19:25:28 by stephent]
stephent
parents: 3374
diff changeset
155 {XtNfcFontName, XtCFcFontName, XtRString, sizeof(String),
6aa26bef0527 [xemacs-hg @ 2006-05-12 19:25:28 by stephent]
stephent
parents: 3374
diff changeset
156 offset(fcFontName), XtRString, (XtPointer) "AirCut-16" },
6aa26bef0527 [xemacs-hg @ 2006-05-12 19:25:28 by stephent]
stephent
parents: 3374
diff changeset
157 /* #### This needs to be fixed to give a proper type and converter for
6aa26bef0527 [xemacs-hg @ 2006-05-12 19:25:28 by stephent]
stephent
parents: 3374
diff changeset
158 XftFonts. See also xlwmenu.c. */
6aa26bef0527 [xemacs-hg @ 2006-05-12 19:25:28 by stephent]
stephent
parents: 3374
diff changeset
159 {XtNxftFont, XtCXftFont, XtRPointer, sizeof(XtPointer),
6aa26bef0527 [xemacs-hg @ 2006-05-12 19:25:28 by stephent]
stephent
parents: 3374
diff changeset
160 offset(renderFont), XtRPointer, (XtPointer) NULL },
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
161 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 {XtNinternalWidth, XtCWidth, XtRDimension, sizeof(Dimension),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163 offset(internalWidth), XtRImmediate, (XtPointer)4 },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164 {XtNinternalHeight, XtCHeight, XtRDimension, sizeof(Dimension),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 offset(internalHeight), XtRImmediate, (XtPointer)4 },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166 {XtNborderWidth, XtCBorderWidth, XtRDimension, sizeof(Dimension),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167 XtOffsetOf(RectObjRec,rectangle.border_width), XtRImmediate, (XtPointer)0},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168 {XtNtopWidget, XtCTopWidget, XtRWidget, sizeof(Widget),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169 offset(topWidget), XtRImmediate, NULL},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170 {XtNcallback, XtCCallback, XtRCallback, sizeof(XtPointer),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171 offset(callbacks), XtRCallback, NULL},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172 {XtNpopdownCallback, XtCCallback, XtRCallback, sizeof(XtPointer),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173 offset(popdownCallbacks), XtRCallback, NULL},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174 {XtNbeNiceToColormap, XtCBeNiceToColormap, XtRBoolean, sizeof(Boolean),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 offset(be_nice_to_cmap), XtRImmediate, (XtPointer) True},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176 {XtNtopShadowContrast, XtCTopShadowContrast, XtRInt, sizeof(int),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177 offset(top_shadow_contrast), XtRImmediate, (XtPointer) 20},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178 {XtNbottomShadowContrast, XtCBottomShadowContrast, XtRInt, sizeof(int),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179 offset(bot_shadow_contrast), XtRImmediate, (XtPointer) 40},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 {XtNinsensitiveContrast, XtCInsensitiveContrast, XtRInt, sizeof(int),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 offset(insensitive_contrast), XtRImmediate, (XtPointer) 33},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182 {XtNaccelerators, XtCAccelerators, XtRAcceleratorTable,sizeof(XtTranslations),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 XtOffsetOf(TabsRec,core.accelerators), XtRString, accelTable},
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 #undef offset
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 /* constraint resources */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191 #define offset(field) XtOffsetOf(TabsConstraintsRec, tabs.field)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192 static XtResource tabsConstraintResources[] = {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193 {XtNtabLabel, XtCLabel, XtRString, sizeof(String),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194 offset(label), XtRString, NULL},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195 {XtNtabLeftBitmap, XtCLeftBitmap, XtRBitmap, sizeof(Pixmap),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196 offset(left_bitmap), XtRImmediate, None},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197 {XtNtabForeground, XtCForeground, XtRPixel, sizeof(Pixel),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198 offset(foreground), XtRString, (XtPointer) XtDefaultForeground},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
199 {XtNresizable, XtCResizable, XtRBoolean, sizeof(Boolean),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
200 offset(resizable), XtRImmediate, (XtPointer) True},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
201 } ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
202 #undef offset
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207 #if !NeedFunctionPrototypes
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 /* FORWARD REFERENCES: */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 /* member functions */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213 static void TabsClassInit();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214 static void TabsInit();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215 static void TabsResize();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
216 static void TabsExpose();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
217 static void TabsDestroy();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
218 static void TabsRealize();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
219 static Boolean TabsSetValues();
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
220 static Boolean TabsAcceptFocus();
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
221 static XtGeometryResult TabsQueryGeometry();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
222 static XtGeometryResult TabsGeometryManager();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223 static void TabsChangeManaged();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
224 static void TabsConstraintInitialize() ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
225 static Boolean TabsConstraintSetValues() ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
226
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227 /* action procs */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229 static void TabsSelect() ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
230 static void TabsPage() ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231 static void TabsHighlight() ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
232 static void TabsUnhighlight() ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
234 /* internal privates */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
235
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236 static void TabsAllocGCs() ; /* get rendering GCs */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237 static void TabsFreeGCs() ; /* return rendering GCs */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
238 static void DrawTabs() ; /* draw all tabs */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
239 static void DrawTab() ; /* draw one index tab */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
240 static void DrawFrame() ; /* draw frame around contents */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
241 static void DrawTrim() ; /* draw trim around a tab */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242 static void DrawBorder() ; /* draw border */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
243 static void DrawHighlight() ; /* draw highlight */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
244 static void UndrawTab() ; /* undraw interior of a tab */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
245 static void TabWidth() ; /* recompute tab size */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
246 static void GetPreferredSizes() ; /* query all children for their sizes */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
247 static void MaxChild() ; /* find max preferred child size */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
248 static int PreferredSize() ; /* compute preferred size */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
249 static int PreferredSize2() ; /* compute preferred size */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250 static int PreferredSize3() ; /* compute preferred size */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
251 static void MakeSizeRequest() ; /* try to change size */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252 static void getBitmapInfo() ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253 static int TabLayout() ; /* lay out tabs */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
254 static void TabsShuffleRows() ; /* bring current tab to bottom row */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
255
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
256 static void TabsAllocFgGC() ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
257 static void TabsAllocGreyGC() ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
258
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
259 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
261 static void TabsClassInit(void) ;
3025
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 2286
diff changeset
262 static void TabsInit( Widget req, Widget new_, ArgList, Cardinal *nargs) ;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
263 static void TabsConstraintInitialize(Widget, Widget, ArgList, Cardinal *) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264 static void TabsRealize(Widget, Mask *, XSetWindowAttributes *) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
265 static void TabsDestroy( Widget w) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
266 static void TabsResize( Widget w) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267 static void TabsExpose( Widget w, XEvent *event, Region region) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268 static Boolean TabsSetValues(Widget, Widget, Widget, ArgList, Cardinal *) ;
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
269 static Boolean TabsAcceptFocus(Widget, Time *);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270 static Boolean TabsConstraintSetValues(Widget, Widget, Widget,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
271 ArgList, Cardinal *) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272 static XtGeometryResult TabsQueryGeometry(Widget,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273 XtWidgetGeometry *, XtWidgetGeometry *) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
274 static XtGeometryResult TabsGeometryManager(Widget,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
275 XtWidgetGeometry *, XtWidgetGeometry *) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276 static void TabsChangeManaged( Widget w) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278 static void TabsSelect(Widget, XEvent *, String *, Cardinal *) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
279 static void TabsPage(Widget, XEvent *, String *, Cardinal *) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
280 static void TabsHighlight(Widget, XEvent *, String *, Cardinal *) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
281 static void TabsUnhighlight(Widget, XEvent *, String *, Cardinal *) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
282
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283 static void DrawTabs( TabsWidget tw, Bool labels) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284 static void DrawTab( TabsWidget tw, Widget child, Bool labels) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285 static void DrawFrame( TabsWidget tw) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286 static void DrawTrim( TabsWidget, int x, int y,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
287 int wid, int hgt, Bool bottom, Bool undraw) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288 static void DrawBorder( TabsWidget tw, Widget child, Bool undraw) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289 static void DrawHighlight( TabsWidget tw, Widget child, Bool undraw) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
290 static void UndrawTab( TabsWidget tw, Widget child) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
292 static void TabWidth( Widget w) ;
448
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
293 static int TabLayout( TabsWidget, Dimension wid, Dimension hgt, Dimension *r_hgt,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
294 Bool query_only) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
295 static void GetPreferredSizes(TabsWidget) ;
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
296 static void MaxChild(TabsWidget, Widget except, Dimension, Dimension) ;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
297 static void TabsShuffleRows( TabsWidget tw) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298 static int PreferredSize( TabsWidget,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
299 Dimension *reply_width, Dimension *reply_height,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
300 Dimension *reply_cw, Dimension *reply_ch) ;
448
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
301 static int PreferredSize2( TabsWidget, Dimension cw, Dimension ch,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
302 Dimension *rw, Dimension *rh) ;
448
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
303 static int PreferredSize3( TabsWidget, Dimension wid, Dimension hgt,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
304 Dimension *rw, Dimension *rh) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
305 static void MakeSizeRequest(TabsWidget) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
307 static void TabsAllocGCs(TabsWidget) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
308 static void TabsFreeGCs(TabsWidget) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
309 static void getBitmapInfo( TabsWidget tw, TabsConstraints tab) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310 static void TabsAllocFgGC( TabsWidget tw) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
311 static void TabsAllocGreyGC( TabsWidget tw) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
312
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
313 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
314
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
315 #define AddRect(i,xx,yy,w,h) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
316 do{rects[(i)].x=(xx); rects[i].y=(yy); \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
317 rects[i].width=(w); rects[i].height=(h);}while(0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
318
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319 static XtActionsRec actionsList[] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
320 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
321 {"select", TabsSelect},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
322 {"page", TabsPage},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
323 {"highlight", TabsHighlight},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
324 {"unhighlight", TabsUnhighlight},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
325 } ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
326
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
327
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
328 /****************************************************************
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
329 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
330 * Full class record constant
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
331 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
332 ****************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
333
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
334 #ifndef NEED_MOTIF
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
335 #define SuperClass (&constraintClassRec)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
336 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
337 #define SuperClass (&xmManagerClassRec)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
338 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
339
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
340 TabsClassRec tabsClassRec = {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
341 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
342 /* core_class fields */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
343 /* superclass */ (WidgetClass) SuperClass,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
344 /* class_name */ "Tabs",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
345 /* widget_size */ sizeof(TabsRec),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
346 /* class_initialize */ TabsClassInit,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
347 /* class_part_init */ NULL, /* TODO? */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
348 /* class_inited */ FALSE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
349 /* initialize */ TabsInit,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
350 /* initialize_hook */ NULL,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
351 /* realize */ TabsRealize,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
352 /* actions */ actionsList,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
353 /* num_actions */ XtNumber(actionsList),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
354 /* resources */ resources,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
355 /* num_resources */ XtNumber(resources),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
356 /* xrm_class */ NULLQUARK,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
357 /* compress_motion */ TRUE,
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
358 #if XtSpecificationRelease < 6
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
359 /* compress_exposure */ XtExposeCompressMaximal,
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
360 #else
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
361 /* compress_exposure */ XtExposeCompressMaximal|XtExposeNoRegion,
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
362 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
363 /* compress_enterleave*/ TRUE,
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
364 /* visible_interest */ TRUE,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
365 /* destroy */ TabsDestroy,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
366 /* resize */ TabsResize,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
367 /* expose */ TabsExpose,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
368 /* set_values */ TabsSetValues,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369 /* set_values_hook */ NULL,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370 /* set_values_almost */ XtInheritSetValuesAlmost,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
371 /* get_values_hook */ NULL,
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
372 /* accept_focus */ TabsAcceptFocus,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
373 /* version */ XtVersion,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
374 /* callback_private */ NULL,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
375 /* tm_table */ defaultTranslations,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
376 /* query_geometry */ TabsQueryGeometry,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
377 /* display_accelerator*/ XtInheritDisplayAccelerator,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
378 /* extension */ NULL
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
379 },
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 /* composite_class fields */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
382 /* geometry_manager */ TabsGeometryManager,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
383 /* change_managed */ TabsChangeManaged,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
384 /* insert_child */ XtInheritInsertChild, /* TODO? */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
385 /* delete_child */ XtInheritDeleteChild, /* TODO? */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
386 /* extension */ NULL
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 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
389 /* constraint_class fields */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
390 /* subresources */ tabsConstraintResources,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
391 /* subresource_count */ XtNumber(tabsConstraintResources),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
392 /* constraint_size */ sizeof(TabsConstraintsRec),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
393 /* initialize */ TabsConstraintInitialize,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
394 /* destroy */ NULL,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
395 /* set_values */ TabsConstraintSetValues,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
396 /* extension */ NULL,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
397 },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
398 #ifdef NEED_MOTIF
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
399 /* Manager Class fields */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
400 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
401 /* translations */ NULL,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
402 /* syn_resources */ NULL,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
403 /* num_syn_resources */ 0,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
404 /* syn_constraint_resources */ NULL,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
405 /* num_syn_constraint_resources */ 0,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
406 /* parent_process */ XmInheritParentProcess,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
407 /* extension */ NULL
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 #endif
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 /* Tabs class fields */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
412 /* extension */ NULL,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
413 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
414 };
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 WidgetClass tabsWidgetClass = (WidgetClass)&tabsClassRec;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
417
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
418 #define TabsNumChildren(tw) (((TabsWidget)tw)->composite.num_children)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
419 #define TabVisible(tab) \
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
420 (XtIsManaged(tab) && \
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
421 ((TabsConstraints)((tab)->core.constraints))->tabs.visible)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
422
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
423
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
424
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
425 static int debug_tabs = 0; /* increase for more verbosity */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
426
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
427 #ifdef USE_XFT_TABS
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
428 /* #### duplicated from xlwmenu.c -- CLEAN THIS SHIT UP!
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
429 Undeclared so define at top. */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
430 #define MINL(x,y) ((((unsigned long) (x)) < ((unsigned long) (y))) \
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
431 ? ((unsigned long) (x)) : ((unsigned long) (y)))
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
432
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
433 static int
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
434 x_xft_text_width (Display *dpy, XftFont *xft_font, FcChar8 *run, int len)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
435 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
436 static XGlyphInfo glyphinfo; /* #### static? */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
437
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
438 XftTextExtents8 (dpy,
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
439 xft_font,
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
440 run, len, &glyphinfo);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
441 return glyphinfo.xOff;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
442 }
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
443 #endif
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
444
428
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 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
447 * Member Procedures
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
448 *
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
451 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
452 TabsClassInit(void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
453 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
454 defaultAccelerators = XtParseAcceleratorTable(accelTable) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
455 /* TODO: register converter for labels? */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
456 }
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
460 /* Init a newly created tabs widget. Compute height of tabs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
461 * and optionally compute size of widget. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
462
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
463 /* ARGSUSED */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
464
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
465 static void
3025
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 2286
diff changeset
466 TabsInit(Widget request, Widget new_, ArgList UNUSED (args),
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 647
diff changeset
467 Cardinal *UNUSED (num_args))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
468 {
3025
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 2286
diff changeset
469 TabsWidget newTw = (TabsWidget)new_;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
470
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
471 newTw->tabs.numRows = 0 ;
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
472 newTw->tabs.realRows = 0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
473
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
474 GetPreferredSizes(newTw) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
475
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
476 /* height is easy, it's the same for all tabs:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
477 * TODO: font height + height of tallest bitmap.
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 newTw->tabs.tab_height = 2 * newTw->tabs.internalHeight + SHADWID ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
480
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
481 #ifdef USE_XFT_TABS
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
482 /* must get font here
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
483 to do this right, we should add a new Xt Resource type +
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
484 conversion function
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
485 */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
486 newTw->tabs.renderFont =
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
487 xft_open_font_by_name (XtDisplay ((Widget) newTw),
3397
6aa26bef0527 [xemacs-hg @ 2006-05-12 19:25:28 by stephent]
stephent
parents: 3374
diff changeset
488 newTw->tabs.fcFontName);
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
489 if (newTw->tabs.renderFont != NULL)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
490 #if XFT_USE_HEIGHT_NOT_ASCENT_DESCENT
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
491 newTw->tabs.tab_height += newTw->tabs.renderFont->height;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
492 #else
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
493 newTw->tabs.tab_height += newTw->tabs.renderFont->ascent +
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
494 newTw->tabs.renderFont->descent;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
495 #endif /* XFT_USE_HEIGHT_NOT_ASCENT_DESCENT */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
496 #else /* ! USE_XFT_TABS */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
497 if (newTw->tabs.font != NULL)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
498 newTw->tabs.tab_height += newTw->tabs.font->max_bounds.ascent +
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
499 newTw->tabs.font->max_bounds.descent;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
500 #endif /* ! USE_XFT_TABS */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
501
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
502 /* if size not explicitly set, set it to our preferred size now. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
503
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
504 if( request->core.width == 0 || request->core.height == 0 )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
505 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
506 Dimension w,h ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
507 PreferredSize(newTw, &w, &h, NULL,NULL) ;
3025
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 2286
diff changeset
508 if( request->core.width == 0 ) new_->core.width = w ;
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 2286
diff changeset
509 if( request->core.height == 0 ) new_->core.height = h ;
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 2286
diff changeset
510 XtClass(new_)->core_class.resize(new_) ;
428
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 /* defer GC allocation, etc., until Realize() time. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
514 newTw->tabs.foregroundGC =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
515 newTw->tabs.backgroundGC =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
516 newTw->tabs.greyGC =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
517 newTw->tabs.topGC =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
518 newTw->tabs.botGC = None ;
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 newTw->tabs.grey50 = None ;
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 newTw->tabs.needs_layout = False ;
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
523
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
524 newTw->tabs.hilight = NULL ;
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 #ifdef NEED_MOTIF
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
527 newTw->manager.navigation_type = XmTAB_GROUP ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
528 newTw->manager.traversal_on = True ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
529 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
530 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
531
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
532
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
533 /* Init the constraint part of a new tab child. Compute the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
534 * size of the tab.
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 /* ARGSUSED */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
537 static void
3025
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 2286
diff changeset
538 TabsConstraintInitialize(Widget UNUSED (request), Widget new_,
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 647
diff changeset
539 ArgList UNUSED (args), Cardinal *UNUSED (num_args))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
540 {
3025
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 2286
diff changeset
541 TabsConstraints tab = (TabsConstraints) new_->core.constraints ;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
542 tab->tabs.greyAlloc = False ; /* defer allocation of pixel */
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
543 tab->tabs.visible = False ;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
544
3025
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 2286
diff changeset
545 getBitmapInfo((TabsWidget)XtParent(new_), tab) ;
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 2286
diff changeset
546 TabWidth(new_) ;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
547 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
548
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
549
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 /* Called when tabs widget first realized. Create the window
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
552 * and allocate the GCs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
553 */
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 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
556 TabsRealize(Widget w, Mask *valueMask, XSetWindowAttributes *attributes)
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 TabsWidget tw = (TabsWidget) w;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
559
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
560 attributes->bit_gravity = NorthWestGravity;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
561 *valueMask |= CWBitGravity;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
562
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
563 SuperClass->core_class.realize(w, valueMask, attributes);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
564
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
565 TabsAllocGCs(tw) ;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
568
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
569
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
570 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
571 TabsDestroy(Widget w)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
572 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
573 TabsFreeGCs((TabsWidget)w) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
574 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
575
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
576
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
577 /* Parent has resized us. This will require that the tabs be
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
578 * laid out again.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
579 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
580
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
581 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
582 TabsResize(Widget w)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
583 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
584 TabsWidget tw = (TabsWidget) w;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
585 int i ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
586 int num_children = tw->composite.num_children ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
587 Widget *childP ;
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 647
diff changeset
588 /* TabsConstraints tab ; */ /* #### unused */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
589 Dimension cw,ch,bw ;
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 /* Our size has now been dictated by the parent. Lay out the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
592 * tabs, lay out the frame, lay out the children. Remember
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
593 * that the tabs overlap each other and the frame by shadowWidth.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
594 * 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
595 * one row, the widget must be made taller to accommodate this.
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 * Once the tabs are laid out, if there is more than one
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
598 * 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
599 * to the bottom row.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
600 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
601
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
602 tw->tabs.needs_layout = False ;
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
603
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
604 if( num_children > 0 && tw->composite.children != NULL )
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 /* Loop through the tabs and assign rows & x positions */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
607 (void) TabLayout(tw, tw->core.width, tw->core.height, NULL, False) ;
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
608 num_children = TabsNumChildren (tw);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
609
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
610 /* assign a top widget, bring it to bottom row. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
611 TabsShuffleRows(tw) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
612
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
613 /* now assign child positions & sizes. Positions are all the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
614 * same: just inside the frame. Sizes are also all the same.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
615 */
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 tw->tabs.child_width = cw = tw->core.width - 2 * SHADWID ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
618 tw->tabs.child_height = ch =
448
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
619 tw->core.height < (tw->tabs.tab_total + 2 * SHADWID) ? 0 :
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
620 tw->core.height - tw->tabs.tab_total - 2 * SHADWID ;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
621
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
622 for(i=0, childP=tw->composite.children;
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
623 i < num_children;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
624 ++i, ++childP)
448
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
625 if( XtIsManaged(*childP) )
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
626 {
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 647
diff changeset
627 /* tab = (TabsConstraints) (*childP)->core.constraints ; */
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
628 bw = (*childP)->core.border_width ;
448
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
629 /* Don't do anything if we can't see any of the child. */
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
630 if (ch >= bw*2 && ch > 0 && cw >= bw*2 && cw > 0)
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
631 XtConfigureWidget(*childP, SHADWID,tw->tabs.tab_total+SHADWID,
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
632 cw-bw*2,ch-bw*2, bw) ;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
633 }
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
634 if( XtIsRealized(w) ) {
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
635 XClearWindow(XtDisplay((Widget)tw), XtWindow((Widget)tw)) ;
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
636 /* should not be necessary to explicitly repaint after a
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
637 * resize, but XEmacs folks tell me it is.
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
638 */
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
639 XtClass(tw)->core_class.expose((Widget)tw,NULL,None) ;
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
640 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
641 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
642 } /* Resize */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
643
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
644
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
645
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
646 /* Redraw entire Tabs widget */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
647
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
648 /* ARGSUSED */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
649 static void
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 647
diff changeset
650 TabsExpose(Widget w, XEvent *UNUSED (event), Region UNUSED (region))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
651 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
652 TabsWidget tw = (TabsWidget) w;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
653
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
654 if( tw->tabs.needs_layout )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
655 XtClass(w)->core_class.resize(w) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
656
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
657 DrawTabs(tw, True) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
658 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
659
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
660
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
661 /* Called when any Tabs widget resources are changed. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
662
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
663 /* ARGSUSED */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
664 static Boolean
3025
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 2286
diff changeset
665 TabsSetValues(Widget current, Widget UNUSED (request), Widget new_,
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 647
diff changeset
666 ArgList UNUSED (args), Cardinal *UNUSED (num_args))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
667 {
430
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
668 TabsWidget curtw = (TabsWidget) current ;
3025
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 2286
diff changeset
669 TabsWidget tw = (TabsWidget) new_ ;
430
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
670 Boolean needRedraw = False ;
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
671 Widget *childP ;
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
672 int i ;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
673
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
674 if(
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
675 #ifdef USE_XFT_TABS
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
676 tw->tabs.renderFont != curtw->tabs.renderFont ||
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
677 #else
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
678 tw->tabs.font != curtw->tabs.font ||
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
679 #endif
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
680 tw->tabs.internalWidth != curtw->tabs.internalWidth ||
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
681 tw->tabs.internalHeight != curtw->tabs.internalHeight)
430
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
682 {
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
683 tw->tabs.tab_height = 2 * tw->tabs.internalHeight + SHADWID;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
684
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
685 #ifdef USE_XFT_TABS
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
686 if (tw->tabs.renderFont != NULL)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
687 #if XFT_USE_HEIGHT_NOT_ASCENT_DESCENT
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
688 tw->tabs.tab_height += tw->tabs.renderFont->height;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
689 #else
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
690 tw->tabs.tab_height += tw->tabs.renderFont->ascent +
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
691 tw->tabs.renderFont->descent;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
692 #endif /* XFT_USE_HEIGHT_NOT_ASCENT_DESCENT */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
693 #else /* ! USE_XFT_TABS */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
694 if (tw->tabs.font != NULL)
430
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
695 tw->tabs.tab_height += tw->tabs.font->max_bounds.ascent +
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
696 tw->tabs.font->max_bounds.descent;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
697 #endif /* ! USE_XFT_TABS */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
698
430
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
699 /* 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
700 for(i=0, childP=tw->composite.children;
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 448
diff changeset
701 i < (int) tw->composite.num_children;
430
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
702 ++i, ++childP)
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
703 if( XtIsManaged(*childP) )
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
704 TabWidth(*childP) ;
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
705 PreferredSize(tw, &tw->core.width, &tw->core.height, NULL,NULL) ;
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
706 needRedraw = True ;
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
707 tw->tabs.needs_layout = True ;
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
708 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
709
430
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
710 /* TODO: if any color changes, need to recompute GCs and redraw */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
711
430
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
712 if( tw->core.background_pixel != curtw->core.background_pixel ||
432
3a7e78e1142d Import from CVS: tag r21-2-24
cvs
parents: 430
diff changeset
713 tw->core.background_pixmap != curtw->core.background_pixmap ||
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
714 #ifdef USE_XFT_TABS
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
715 tw->tabs.renderFont != curtw->tabs.renderFont
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
716 #else
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
717 tw->tabs.font != curtw->tabs.font
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
718 #endif
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
719 )
3025
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 2286
diff changeset
720 if( XtIsRealized(new_) )
430
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
721 {
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
722 TabsFreeGCs(tw) ;
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
723 TabsAllocGCs(tw) ;
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
724 needRedraw = True ;
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
725 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
726
430
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
727 if( tw->core.sensitive != curtw->core.sensitive )
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
728 needRedraw = True ;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
729
430
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
730 /* If top widget changes, need to change stacking order, redraw tabs.
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
731 * Window system will handle the redraws.
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
732 */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
733
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
734 if( tw->tabs.topWidget != curtw->tabs.topWidget )
432
3a7e78e1142d Import from CVS: tag r21-2-24
cvs
parents: 430
diff changeset
735 {
430
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
736 if( XtIsRealized(tw->tabs.topWidget) )
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
737 {
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
738 Widget w = tw->tabs.topWidget ;
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
739 TabsConstraints tab = (TabsConstraints) w->core.constraints ;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
740
430
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
741 XRaiseWindow(XtDisplay(w), XtWindow(w)) ;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
742 #ifdef NEED_MOTIF
430
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
743 XtVaSetValues(curtw->tabs.topWidget, XmNtraversalOn, False, 0) ;
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
744 XtVaSetValues(w, XmNtraversalOn, True, 0) ;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
745 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
746
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 448
diff changeset
747 if( tab->tabs.row != (int) tw->tabs.numRows-1 )
430
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
748 TabsShuffleRows(tw) ;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
749
430
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
750 needRedraw = True ;
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
751 }
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
752 else
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
753 tw->tabs.needs_layout = True ;
432
3a7e78e1142d Import from CVS: tag r21-2-24
cvs
parents: 430
diff changeset
754 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
755
430
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
756 return needRedraw ;
428
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
759
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
760 /* Called when any child constraint resources change. */
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 /* ARGSUSED */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
763 static Boolean
3025
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 2286
diff changeset
764 TabsConstraintSetValues(Widget current, Widget UNUSED (request), Widget new_,
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 647
diff changeset
765 ArgList UNUSED (args), Cardinal *UNUSED (num_args))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
766 {
3025
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 2286
diff changeset
767 TabsWidget tw = (TabsWidget) XtParent(new_) ;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
768 TabsConstraints ctab = (TabsConstraints) current->core.constraints ;
3025
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 2286
diff changeset
769 TabsConstraints tab = (TabsConstraints) new_->core.constraints ;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
770
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
771
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
772 /* if label changes, need to re-layout the entire widget */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
773 /* if foreground changes, need to redraw tab label */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
774
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
775 /* TODO: only need resize of new bitmap has different dimensions
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
776 * from old bitmap.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
777 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
778
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
779 if( tab->tabs.label != ctab->tabs.label || /* Tab size has changed. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
780 tab->tabs.left_bitmap != ctab->tabs.left_bitmap )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
781 {
3025
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 2286
diff changeset
782 TabWidth(new_) ;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
783 tw->tabs.needs_layout = True ;
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 if( tab->tabs.left_bitmap != ctab->tabs.left_bitmap )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
786 getBitmapInfo(tw, tab) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
787
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
788 /* If there are no subclass ConstraintSetValues procedures remaining
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
789 * to be invoked, and if the preferred size has changed, ask
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
790 * for a resize.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
791 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
792 if( XtClass((Widget)tw) == tabsWidgetClass )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
793 MakeSizeRequest(tw) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
794 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
795
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
796
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
797 /* The child widget itself never needs a redisplay, but the parent
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
798 * Tabs widget might.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
799 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
800
3025
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 2286
diff changeset
801 if( XtIsRealized(new_) )
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
802 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
803 if( tw->tabs.needs_layout ) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
804 XClearWindow(XtDisplay((Widget)tw), XtWindow((Widget)tw)) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
805 XtClass(tw)->core_class.expose((Widget)tw,NULL,None) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
806 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
807
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
808 else if( tab->tabs.foreground != ctab->tabs.foreground )
3025
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 2286
diff changeset
809 DrawTab(tw, new_, True) ;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
810 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
811
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
812 return False ;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
815
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
816 static Boolean
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 647
diff changeset
817 TabsAcceptFocus(Widget w, Time *UNUSED (t))
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
818 {
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
819 if( !w->core.being_destroyed && XtIsRealized(w) &&
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
820 XtIsSensitive(w) && XtIsManaged(w) && w->core.visible )
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 Widget p ;
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
823 for(p = XtParent(w); !XtIsShell(p); p = XtParent(p)) ;
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
824 XtSetKeyboardFocus(p,w) ;
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
825 return True ;
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
826 }
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
827 else
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
828 return False ;
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
829 }
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
830
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
831
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
832
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
833 /*
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
834 * Return status, with preferred size in PREFERRED.
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
835 *
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
836 * According to the X Toolkit Intrinsics manual
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
837 * XtGeometryYes = accept INTENDED without change
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
838 * XtGeometryNo = request to stay _exactly_ the same
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
839 * XtGeometryAlmost = suggest PREFERRED as a compromise
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
840 * and the PREFERRED argument must be filled in completely (ie, any fields
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
841 * whose bits are set in the request_mode mask must correspond to the
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
842 * preferred geometry, which must be consistent with the return value).
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
843 *
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
844 * Assuming horizontal orientation, in XEmacs, we should always accept if
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
845 * the width is more than we need. There's no problem if there are only a
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
846 * couple of tabs packed to the left. OTOH there's probably something wrong
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
847 * if we're offered a height more than 1.5x or 2x the preferred height.
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
848 * (#### Do tab controls do vertical?)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
849 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
850
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
851 /* compute the height above which we complain */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
852 #define TAB_HEIGHT_TOLERANCE(x) (2*x)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
853
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
854 static XtGeometryResult
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
855 TabsQueryGeometry (Widget w,
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
856 XtWidgetGeometry *intended,
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
857 XtWidgetGeometry *preferred) /* RETURN */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
858 {
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
859 TabsWidget tw = (TabsWidget) w;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
860 XtGeometryMask mode = intended->request_mode;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
861
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
862 preferred->request_mode = CWWidth | CWHeight;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
863 PreferredSize (tw, &preferred->width, &preferred->height, NULL, NULL);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
864
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
865 /* If width is big enough, accept it. */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
866 if ((mode & CWWidth) && intended->width >= preferred->width)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
867 preferred->width = intended->width;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
868
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
869 /* If height is within range, accept it.
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
870 #### If too tall, we could offer a compromise at TAB_HEIGHT_TOLERANCE.
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
871 Should we? */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
872 if ((mode & CWHeight) && intended->height >= preferred->height
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
873 && intended->height <= TAB_HEIGHT_TOLERANCE (preferred->height))
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
874 preferred->height = intended->height;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
875
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
876 /* Compute return value. */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
877 if (preferred->width == ((mode & CWWidth) ? intended->width
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
878 : w->core.width)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
879 && preferred->height == ((mode & CWHeight) ? intended->height
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
880 : w->core.height))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
881 return XtGeometryYes;
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
882 else if (preferred->width == w->core.width
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
883 && preferred->height == w->core.height)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
884 return XtGeometryNo;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
885 else
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
886 return XtGeometryAlmost;
428
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
889
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 /*
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
892 * Geometry Manager; called when TAB (a child) wants to be resized.
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
893 *
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
894 * According to the X Toolkit Intrinsics manual
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
895 * XtGeometryDone = accept REQUEST and do it (#### check this)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
896 * XtGeometryYes = accept REQUEST without change
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
897 * XtGeometryNo = refuse REQUEST (ie, stay _exactly_ the same)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
898 * XtGeometryAlmost = suggest REPLY as a compromise
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
899 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
900
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
901 static XtGeometryResult
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
902 TabsGeometryManager (Widget tab,
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
903 XtWidgetGeometry *request,
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
904 XtWidgetGeometry *reply) /* RETURN */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
905 {
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
906 TabsWidget control = (TabsWidget) XtParent(tab);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
907 Dimension s = SHADWID;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
908 TabsConstraints constraint = (TabsConstraints) tab->core.constraints;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
909 XtGeometryResult result, best_offer = XtGeometryYes;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
910 Dimension rw, rh;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
911
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
912 static int debug_count = 0;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
913 static int debug_mask = 1;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
914
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
915 /* Position request cannot be satisfied, so if tabs are not resizable,
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
916 no nontrivial request can be satisfied: return XGeometryNo. */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
917 if (!constraint->tabs.resizable)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
918 return XtGeometryNo;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
919
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
920 fprintf (stderr, "Urk! label is resizable!\n");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
921
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
922 /* Assume we will refuse these; toggle iff we accept them.
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
923 Reply won't specify any fields not in the request. */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
924 reply->request_mode = request->request_mode;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
925 reply->x = tab->core.x;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
926 reply->y = tab->core.y;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
927
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
928 /* If a position request would result in a change, best offer is
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
929 XtGeometryAlmost. Otherwise toggle reply->request_mode. */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
930 if ((request->request_mode & CWX) && request->x != tab->core.x)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
931 best_offer = XtGeometryAlmost;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
932 else
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
933 reply->request_mode &= ~CWX;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
934 if ((request->request_mode & CWY) && request->y != tab->core.y)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
935 best_offer = XtGeometryAlmost;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
936 else
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
937 reply->request_mode &= ~CWY;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
938
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
939 /* Make all three fields in the reply valid */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
940 reply->width = (request->request_mode & CWWidth)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
941 ? request->width : tab->core.width;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
942 reply->height = (request->request_mode & CWHeight)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
943 ? request->height : tab->core.height;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
944 reply->border_width = (request->request_mode & CWBorderWidth)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
945 ? request->border_width : tab->core.border_width;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
946
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
947 /* check if we can already offer a compromise */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
948 if (best_offer == XtGeometryAlmost &&
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
949 reply->width == tab->core.width &&
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
950 reply->height == tab->core.height &&
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
951 reply->border_width == tab->core.border_width)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
952 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
953 reply->request_mode &= ~(CWWidth | CWHeight | CWBorderWidth);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
954 return best_offer;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
955 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
956
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
957 #ifndef DONT_DEBUG_REQUESTS
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
958 #define DBG_REQUEST_PRINT(name,field,size) \
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
959 do { \
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
960 if (reply->field > size) \
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
961 { \
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
962 if (++debug_count == debug_mask) \
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
963 { \
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
964 debug_mask <<= 1; \
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
965 fprintf (stderr, "ridiculous %s request #%d: %d > %d\n", \
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
966 name, debug_count, reply->field, size); \
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
967 } \
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
968 reply->field = tab->core.field; \
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
969 } \
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
970 } while (0)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
971
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
972 DBG_REQUEST_PRINT ("width",width,1024);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
973 DBG_REQUEST_PRINT ("height",height,768);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
974 DBG_REQUEST_PRINT ("border_width",border_width,30);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
975 #undef DBG_REQUEST_PRINT
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
976 #endif
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
977
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
978 rw = reply->width + 2 * reply->border_width;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
979 rh = reply->height + 2 * reply->border_width;
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
980
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
981 /* find out how big the children want to be now */
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
982 MaxChild (control, tab, rw, rh);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
983
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
984
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
985 /* Size changes must see if the new size can be accommodated.
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
986 * The Tabs widget keeps all of its children the same height, but
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
987 * widths may vary.
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
988 * A request to shrink will be accepted only if the
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
989 * new size is still big enough for all other children. A
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
990 * 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
991 * returns an "almost" response with the new proposed size
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
992 * or a "no" response if unable to shrink at all.
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
993 *
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
994 * A request to grow will be accepted only if the Tabs control can
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
995 * grow to accommodate.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
996 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
997 * TODO:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
998 * 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
999 * necessary to compromise with the parent, but we'll save that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1000 * for another day.
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
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1003 if (request->request_mode & (CWWidth | CWHeight | CWBorderWidth))
428
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 Dimension cw,ch ; /* children's preferred size */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1006 Dimension aw,ah ; /* available size we can give child */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1007 Dimension th ; /* space used by tabs */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1008 Dimension wid,hgt ; /* Tabs widget size */
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1009 int check_nrows;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1010
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1011 cw = control->tabs.max_cw ;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1012 ch = control->tabs.max_ch ;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1013
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1014 /* find out what *my* resulting preferred size would be */
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1015 /* #### this whole API is wrong; what should happen is
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1016 1. app should hint as to #rows and/or aspect ratio
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1017 2. tab control should attempt to layout in current space
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1018 3. if not all tabs fit, should request resize to achieve
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1019 layout hints
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1020 Probably can and should cache preferred size in widget, with
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1021 cache cleared when labels or core size changes. */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1022 PreferredSize2(control, cw, ch, &wid, &hgt) ;
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1023
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1024 /* Would my size change? If so, ask to be resized. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1025
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1026 if (wid != control->core.width || hgt != control->core.height)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1027 {
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1028 Dimension oldWid = control->core.width,
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1029 oldHgt = control->core.height;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1030 XtWidgetGeometry myrequest, myreply ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1031
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1032 myrequest.width = wid ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1033 myrequest.height = hgt ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1034 myrequest.request_mode = CWWidth | CWHeight ;
448
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
1035
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
1036 assert (wid > 0 && hgt > 0);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1037 /* 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
1038 * offer the child a compromise, then make this a query only.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1039 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1040
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1041 if ((request->request_mode & XtCWQueryOnly) || rw < cw || rh < ch)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1042 myrequest.request_mode |= XtCWQueryOnly;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1043
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1044 result = XtMakeGeometryRequest ((Widget) control,
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1045 &myrequest, &myreply);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1046
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1047 /* !$@# Athena Box widget changes the core size even if QueryOnly
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1048 * 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
1049 * around the bug, we need to restore the core size after every
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1050 * query geometry request. This is only partly effective,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1051 * as there may be other boxes further up the tree.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1052 */
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1053 if (myrequest.request_mode & XtCWQueryOnly) {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1054 control->core.width = oldWid;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1055 control->core.height = oldHgt;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1056 }
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 /* based on the parent's response, determine what the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1059 * resulting Tabs widget size would be.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1060 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1061
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1062 switch (result) {
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1063 case XtGeometryYes:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1064 case XtGeometryDone:
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1065 control->tabs.needs_layout = True;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1066 break;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1067
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1068 case XtGeometryNo:
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1069 wid = control->core.width;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1070 hgt = control->core.height;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1071 break;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1072
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1073 case XtGeometryAlmost:
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1074 wid = myreply.width;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1075 hgt = myreply.height;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1076 control->tabs.needs_layout = True;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1077 break;
428
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1081 /* Within the constraints imposed by the parent, what is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1082 * the max size we can give the child?
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1083 */
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1084 check_nrows = TabLayout (control, wid, hgt, &th, True);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1085 aw = wid - 2*s;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1086 if (check_nrows == 1)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1087 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1088 ah = hgt - th - 2*s;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1089 }
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1090 else
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1091 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1092 /* this rarely gets triggered, but when it does it seems to
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1093 get triggered forever after */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1094 int n = control->composite.num_children;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1095 ah = control->tabs.tab_height;
3397
6aa26bef0527 [xemacs-hg @ 2006-05-12 19:25:28 by stephent]
stephent
parents: 3374
diff changeset
1096 if (debug_tabs > 1)
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1097 fprintf (stderr, "Kludging around %d != 1 rows,"
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1098 " #children = %d, total height %d, using %d.\n",
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1099 check_nrows, n, th, ah);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1100 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1101
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1102 /* OK, make our decision. If requested size is >= max sibling
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1103 * preferred size, AND requested size <= available size, then
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1104 * we accept. Otherwise, we offer a compromise.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1105 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1106
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1107 if (rw == aw && rh == ah)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1108 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1109 /* Acceptable. If this wasn't a query, change *all* children
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1110 * to this size.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1111 */
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1112 if (request->request_mode & XtCWQueryOnly)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1113 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1114 control->tabs.needs_layout = False;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1115 return XtGeometryYes ;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1116 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1117 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1118 {
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1119 Widget *childP = control->composite.children;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1120 int i, bw;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1121 tab->core.border_width = request->border_width;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1122 for (i = TabsNumChildren (control); --i >= 0; ++childP)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1123 if (TabVisible (*childP))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1124 {
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1125 bw = (*childP)->core.border_width;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1126 XtConfigureWidget (*childP, s, control->tabs.tab_total+s,
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1127 rw-2*bw, rh-2*bw, bw);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1128 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1129 #ifdef COMMENT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1130 /* TODO: under what conditions will we need to redraw? */
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1131 XClearWindow (XtDisplay ((Widget) control),
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1132 XtWindow ((Widget) control));
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1133 XtClass (control)->core_class.expose ((Widget)control,
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1134 NULL, NULL);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1135 #endif /* COMMENT */
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1136 return XtGeometryDone;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1137 }
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 /* Cannot grant child's request. Describe what we *can* do
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1141 * and return counter-offer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1142 */
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1143 control->tabs.needs_layout = False;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1144 reply->width = aw - 2 * request->border_width ;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1145 reply->height = ah - 2 * request->border_width ;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1146 reply->request_mode &=
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1147 ~((reply->border_width == tab->core.border_width
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1148 ? CWBorderWidth : 0)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1149 |(reply->width == tab->core.width ? CWWidth : 0)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1150 |(reply->height == tab->core.height ? CWHeight : 0));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1151 return XtGeometryAlmost ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1152 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1153
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1154 return XtGeometryYes ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1155 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1156
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
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 /* The number of children we manage has changed; recompute
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1161 * size from scratch.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1162 */
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 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1165 TabsChangeManaged(Widget w)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1166 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1167 TabsWidget tw = (TabsWidget)w ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1168 Widget *childP = tw->composite.children ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1169 int i ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1170
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1171 if( tw->tabs.topWidget != NULL &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1172 ( !XtIsManaged(tw->tabs.topWidget) ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1173 tw->tabs.topWidget->core.being_destroyed ) )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1174 tw->tabs.topWidget = NULL ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1175
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 436
diff changeset
1176 /* Check whether the highlight tab is still valid. */
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 436
diff changeset
1177 if( tw->tabs.hilight != NULL &&
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 436
diff changeset
1178 ( !XtIsManaged(tw->tabs.hilight) ||
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 436
diff changeset
1179 tw->tabs.hilight->core.being_destroyed ) )
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 436
diff changeset
1180 tw->tabs.hilight = NULL ;
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 436
diff changeset
1181
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1182 GetPreferredSizes(tw) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1183 MakeSizeRequest(tw) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1184
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1185 XtClass(w)->core_class.resize(w) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1186 if( XtIsRealized(w) )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1187 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1188 Display *dpy = XtDisplay(w) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1189 XClearWindow(dpy, XtWindow(w)) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1190 XtClass(w)->core_class.expose(w,NULL,NULL) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1191
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1192 /* make sure the top widget stays on top. This requires
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1193 * making sure that all new children are realized first.
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 if( tw->tabs.topWidget != NULL && XtIsRealized(tw->tabs.topWidget) )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1196 {
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1197 for(i=TabsNumChildren (tw); --i >= 0; ++childP)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1198 if( !XtIsRealized(*childP) )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1199 XtRealizeWidget(*childP) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1200
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1201 XRaiseWindow(dpy, XtWindow(tw->tabs.topWidget)) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1202 }
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 #ifdef NEED_MOTIF
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1206 /* Only top widget may receive input */
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 for(childP = tw->composite.children, i=tw->composite.num_children;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1209 --i >= 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1210 ++childP)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1211 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1212 XtVaSetValues(*childP, XmNtraversalOn, False, 0) ;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1215 if( tw->tabs.topWidget != NULL )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1216 XtVaSetValues(tw->tabs.topWidget, XmNtraversalOn, True, 0) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1217 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1218 }
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1221
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 * Action Procedures
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 /* User clicks on a tab, figure out which one it was. */
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 /* ARGSUSED */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1233 static void
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 647
diff changeset
1234 TabsSelect(Widget w, XEvent *event, String *UNUSED (params),
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 647
diff changeset
1235 Cardinal *UNUSED (num_params))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1236 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1237 TabsWidget tw = (TabsWidget) w ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1238 Widget *childP ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1239 Position x,y ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1240 Dimension h = tw->tabs.tab_height ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1241 int i ;
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 #ifdef NEED_MOTIF
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1244 XmProcessTraversal (w, XmTRAVERSE_CURRENT) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1245 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1246
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1247 /* TODO: is there an Xmu function or something to do this instead? */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1248 switch( event->type ) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1249 case ButtonPress:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1250 case ButtonRelease:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1251 x = event->xbutton.x ; y = event->xbutton.y ; break ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1252 case KeyPress:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1253 case KeyRelease:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1254 x = event->xkey.x ; y = event->xkey.y ; break ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1255 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1256 return ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1257 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1258
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1259 /* TODO: determine which tab was clicked, if any. Set that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1260 * widget to be top of stacking order with XawTabsSetTop().
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1261 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1262 for(i=0, childP=tw->composite.children;
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 448
diff changeset
1263 i < (int) TabsNumChildren (tw);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1264 ++i, ++childP)
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1265 if( TabVisible(*childP) )
428
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 TabsConstraints tab = (TabsConstraints)(*childP)->core.constraints;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1268 if( x > tab->tabs.x && x < tab->tabs.x + tab->tabs.width &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1269 y > tab->tabs.y && y < tab->tabs.y + h )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1270 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1271 if( *childP != tw->tabs.topWidget &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1272 (XtIsSensitive(*childP) || tw->tabs.selectInsensitive) )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1273 XawTabsSetTop(*childP, True) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1274 break ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1275 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1276 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1277 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1278
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1279
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1280 /* User hits a key */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1281
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1282 static void
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 647
diff changeset
1283 TabsPage(Widget w, XEvent *UNUSED (event), String *params,
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 647
diff changeset
1284 Cardinal *num_params)
428
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 TabsWidget tw = (TabsWidget) w ;
430
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
1287 Widget newtop = NULL;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1288 Widget *childP ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1289 int idx ;
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1290 int nc = TabsNumChildren (tw) ;
428
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 if( nc <= 0 )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1293 return ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1294
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1295 if( *num_params < 1 ) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1296 XtAppWarning(XtWidgetToApplicationContext(w),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1297 "Tabs: page() action called with no arguments") ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1298 return ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1299 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1300
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1301 if( tw->tabs.topWidget == NULL )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1302 tw->tabs.topWidget = tw->composite.children[0] ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1303
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1304 for(idx=0, childP=tw->composite.children; idx < nc; ++idx, ++childP )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1305 if( tw->tabs.topWidget == *childP )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1306 break ;
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 switch( params[0][0] ) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1309 case 'u': /* up */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1310 case 'U':
432
3a7e78e1142d Import from CVS: tag r21-2-24
cvs
parents: 430
diff changeset
1311 if( --idx < 0 )
3a7e78e1142d Import from CVS: tag r21-2-24
cvs
parents: 430
diff changeset
1312 idx = nc-1 ;
3a7e78e1142d Import from CVS: tag r21-2-24
cvs
parents: 430
diff changeset
1313 newtop = tw->composite.children[idx] ;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1314 break ;
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 case 'd': /* down */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1317 case 'D':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1318 if( ++idx >= nc )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1319 idx = 0 ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1320 newtop = tw->composite.children[idx] ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1321 break ;
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 case 'h':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1324 case 'H':
432
3a7e78e1142d Import from CVS: tag r21-2-24
cvs
parents: 430
diff changeset
1325 default:
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1326 newtop = tw->composite.children[0] ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1327 break ;
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 case 'e':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1330 case 'E':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1331 newtop = tw->composite.children[nc-1] ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1332 break ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1333
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1334 case 's': /* selected */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1335 case 'S':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1336 if( (newtop = tw->tabs.hilight) == NULL )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1337 return ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1338 break ;
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 XawTabsSetTop(newtop, True) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1342 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1343
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 /* User hits up/down key */
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 static void
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 647
diff changeset
1348 TabsHighlight(Widget w, XEvent *UNUSED (event), String *params,
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 647
diff changeset
1349 Cardinal *num_params)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1350 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1351 TabsWidget tw = (TabsWidget) w ;
430
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
1352 Widget newhl = NULL;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1353 Widget *childP ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1354 int idx ;
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1355 int nc = TabsNumChildren (tw) ;
428
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 if( nc <= 0 )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1358 return ;
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 if( *num_params < 1 )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1361 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1362 if( tw->tabs.hilight != NULL )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1363 DrawHighlight(tw, tw->tabs.hilight, False) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1364 return ;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1367 if( tw->tabs.hilight == NULL )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1368 newhl = tw->composite.children[0] ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1369
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1370 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1371 {
432
3a7e78e1142d Import from CVS: tag r21-2-24
cvs
parents: 430
diff changeset
1372 /* find index of currently highlit child */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1373 for(idx=0, childP=tw->composite.children; idx < nc; ++idx, ++childP )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1374 if( tw->tabs.hilight == *childP )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1375 break ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1376
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1377 switch( params[0][0] ) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1378 case 'u': /* up */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1379 case 'U':
432
3a7e78e1142d Import from CVS: tag r21-2-24
cvs
parents: 430
diff changeset
1380 if( --idx < 0 )
3a7e78e1142d Import from CVS: tag r21-2-24
cvs
parents: 430
diff changeset
1381 idx = nc-1 ;
3a7e78e1142d Import from CVS: tag r21-2-24
cvs
parents: 430
diff changeset
1382 newhl = tw->composite.children[idx] ;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1383 break ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1384
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1385 case 'd': /* down */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1386 case 'D':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1387 if( ++idx >= nc )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1388 idx = 0 ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1389 newhl = tw->composite.children[idx] ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1390 break ;
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 case 'h':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1393 case 'H':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1394 newhl = tw->composite.children[0] ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1395 break ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1396
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1397 case 'e':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1398 case 'E':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1399 newhl = tw->composite.children[nc-1] ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1400 break ;
432
3a7e78e1142d Import from CVS: tag r21-2-24
cvs
parents: 430
diff changeset
1401
3a7e78e1142d Import from CVS: tag r21-2-24
cvs
parents: 430
diff changeset
1402 default:
3a7e78e1142d Import from CVS: tag r21-2-24
cvs
parents: 430
diff changeset
1403 newhl = tw->tabs.hilight ;
3a7e78e1142d Import from CVS: tag r21-2-24
cvs
parents: 430
diff changeset
1404 break ;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1405 }
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1408 XawTabsSetHighlight(w, newhl) ;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1411
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 static void
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 647
diff changeset
1414 TabsUnhighlight(Widget w, XEvent *UNUSED (event), String *UNUSED (params),
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 647
diff changeset
1415 Cardinal *UNUSED (num_params))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1416 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1417 TabsWidget tw = (TabsWidget) w ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1418 int nc = tw->composite.num_children ;
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 if( nc <= 0 )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1421 return ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1422
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1423 if( tw->tabs.hilight != NULL )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1424 DrawHighlight(tw, tw->tabs.hilight, True) ;
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
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1429
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 /****************************************************************
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 * Public Procedures
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1434 *
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1437
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1438 /* Set the top tab, optionally call all callbacks. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1439 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1440 XawTabsSetTop(Widget w, Bool callCallbacks)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1441 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1442 TabsWidget tw = (TabsWidget)w->core.parent ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1443 TabsConstraints tab ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1444 Widget oldtop = tw->tabs.topWidget ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1445
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1446 if( !XtIsSubclass(w->core.parent, tabsWidgetClass) )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1447 {
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1448 char line[256] ;
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1449 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
1450 XtAppWarning(XtWidgetToApplicationContext(w), line) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1451 return ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1452 }
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( callCallbacks )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1455 XtCallCallbackList(w, tw->tabs.popdownCallbacks,
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1456 (XtPointer)tw->tabs.topWidget) ;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1457
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1458 if( !XtIsRealized(w) ) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1459 tw->tabs.topWidget = w ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1460 tw->tabs.needs_layout = True ;
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 436
diff changeset
1461 tw->tabs.hilight = NULL; /* The highlight tab might disappear. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1462 return ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1463 }
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 XRaiseWindow(XtDisplay(w), XtWindow(w)) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1466 #ifdef NEED_MOTIF
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1467 XtVaSetValues(oldtop, XmNtraversalOn, False, 0) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1468 XtVaSetValues(w, XmNtraversalOn, True, 0) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1469 #endif
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 tab = (TabsConstraints) w->core.constraints ;
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 436
diff changeset
1472
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 436
diff changeset
1473 /* Unhighlight before we start messing with the stacking order. */
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 436
diff changeset
1474 if( tw->tabs.hilight != NULL )
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 436
diff changeset
1475 {
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 436
diff changeset
1476 DrawHighlight(tw, tw->tabs.hilight, True) ;
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 436
diff changeset
1477 tw->tabs.hilight = NULL;
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 436
diff changeset
1478 }
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 436
diff changeset
1479
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1480 if( tab->tabs.row == 0 )
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 /* Easy case; undraw current top, undraw new top, assign new
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1483 * top, redraw all borders.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1484 * 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
1485 * reduce screen flicker.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1486 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1487 UndrawTab(tw, oldtop) ; /* undraw old */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1488 DrawBorder(tw, oldtop, True) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1489 UndrawTab(tw, w) ; /* undraw new */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1490 DrawBorder(tw, w, True) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1491 tw->tabs.topWidget = w ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1492 DrawTab(tw, oldtop, True) ; /* redraw old */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1493 DrawTab(tw, w, True) ; /* redraw new */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1494 DrawTabs(tw, False) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1495 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1496 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1497 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1498 tw->tabs.topWidget = w ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1499 TabsShuffleRows(tw) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1500 XClearWindow(XtDisplay((Widget)tw), XtWindow((Widget)tw)) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1501 XtClass(tw)->core_class.expose((Widget)tw,NULL,None) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1502 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1503
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1504 XawTabsSetHighlight((Widget)tw, w) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1505
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1506 if( callCallbacks )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1507 XtCallCallbackList(w, tw->tabs.callbacks, (XtPointer)w) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1508 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1509
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1510
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1511 /* Set the top tab, optionally call all callbacks. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1512 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1513 XawTabsSetHighlight(Widget t, Widget w)
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 TabsWidget tw = (TabsWidget)t ;
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 if( !XtIsSubclass(t, tabsWidgetClass) )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1518 return ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1519
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1520 if( XtIsRealized(t) && w != tw->tabs.hilight )
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 if( w != NULL )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1523 DrawHighlight(tw, w, False) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1524 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1525
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1526 tw->tabs.hilight = w ;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1529
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1530
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1531
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 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1534 * Private Procedures
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1535 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1536 ****************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1537
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1538
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1539 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1540 TabsAllocGCs(TabsWidget tw)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1541 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1542 TabsAllocFgGC(tw) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1543 TabsAllocGreyGC(tw) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1544 tw->tabs.backgroundGC = AllocBackgroundGC((Widget)tw, None) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1545 tw->tabs.topGC = AllocTopShadowGC((Widget)tw,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1546 tw->tabs.top_shadow_contrast, tw->tabs.be_nice_to_cmap) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1547 tw->tabs.botGC = AllocBotShadowGC((Widget)tw,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1548 tw->tabs.bot_shadow_contrast, tw->tabs.be_nice_to_cmap) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1549 }
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 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1553 TabsFreeGCs(TabsWidget tw)
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 Widget w = (Widget) tw;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1556
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1557 XtReleaseGC(w, tw->tabs.foregroundGC) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1558 XtReleaseGC(w, tw->tabs.greyGC) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1559 XtReleaseGC(w, tw->tabs.backgroundGC) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1560 XtReleaseGC(w, tw->tabs.topGC) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1561 XtReleaseGC(w, tw->tabs.botGC) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1562 #ifdef HAVE_XMU
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1563 XmuReleaseStippledPixmap(XtScreen(w), tw->tabs.grey50) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1564 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1565 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1566
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
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1571 /* Redraw entire Tabs widget */
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 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1574 DrawTabs(TabsWidget tw, Bool labels)
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 Widget *childP ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1577 int i,j ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1578 Dimension s = SHADWID ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1579 Dimension th = tw->tabs.tab_height ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1580 Position y ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1581 TabsConstraints tab ;
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 if( !XtIsRealized((Widget)tw))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1584 return ;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1585
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1586 /* draw tabs and frames by row except for the top tab, which
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1587 * is drawn last. (This is inefficiently written, but should not
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1588 * 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
1589 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1590
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1591 y = tw->tabs.numRows == 1 ? TABDELTA : 0 ;
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 448
diff changeset
1592 for(i=0; i < (int) tw->tabs.numRows; ++i, y += th)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1593 {
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1594 for( j=TabsNumChildren (tw), childP=tw->composite.children;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1595 --j >= 0; ++childP )
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1596 if( TabVisible(*childP) )
428
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 tab = (TabsConstraints)(*childP)->core.constraints;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1599 if( tab->tabs.row == i && *childP != tw->tabs.topWidget )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1600 DrawTab(tw, *childP, labels) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1601 }
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 448
diff changeset
1602 if( i != (int) tw->tabs.numRows -1 )
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1603 DrawTrim(tw, 0,y+th, tw->core.width, th+s, False,False) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1604 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1605
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1606 DrawFrame(tw) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1607
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1608 /* and now the top tab */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1609 if( tw->tabs.topWidget != NULL )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1610 DrawTab(tw, tw->tabs.topWidget, labels) ;
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
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 /* Draw one tab. Corners are rounded very slightly. */
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 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1618 DrawTab(TabsWidget tw, Widget child, Bool labels)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1619 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1620 GC gc ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1621 int x,y ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1622
3397
6aa26bef0527 [xemacs-hg @ 2006-05-12 19:25:28 by stephent]
stephent
parents: 3374
diff changeset
1623 if (debug_tabs > 2) fprintf (stderr, "DrawTab called.\n");
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1624
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1625 if( !XtIsRealized((Widget)tw))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1626 return ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1627
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1628 DrawBorder(tw, child, False) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1629
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1630 if( labels )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1631 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1632 TabsConstraints tab = (TabsConstraints)child->core.constraints;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1633 Display *dpy = XtDisplay((Widget)tw) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1634 Window win = XtWindow((Widget)tw) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1635 String lbl = tab->tabs.label != NULL ?
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1636 tab->tabs.label : XtName(child) ;
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1637 #ifdef USE_XFT_TABS
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1638 XftColor color;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1639 XftColor colorBG;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1640 Colormap cmap = tw->core.colormap;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1641 Visual *visual;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1642 int ignored;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1643
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1644 visual_info_from_widget ((Widget) tw, &visual, &ignored);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1645 colorBG = xft_convert_color (dpy, cmap, visual,
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1646 tw->core.background_pixel, 0);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1647 #endif
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1648
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1649 if (debug_tabs > 2)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1650 fprintf (stderr, "(Re)drawing labels.\n");
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1651
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1652 if (XtIsSensitive(child))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1653 {
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1654 gc = tw->tabs.foregroundGC;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1655 #ifdef USE_XFT_TABS
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1656 color = xft_convert_color (dpy, cmap, visual,
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1657 tab->tabs.foreground, 0);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1658 #else
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1659 XSetForeground(dpy, gc, tab->tabs.foreground);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1660 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1661 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1662 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1663 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1664 /* grey pixel allocation deferred until now */
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1665 if (!tab->tabs.greyAlloc)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1666 {
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1667 if (tw->tabs.be_nice_to_cmap || tw->core.depth == 1)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1668 tab->tabs.grey = tab->tabs.foreground;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1669 else
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1670 tab->tabs.grey = AllocGreyPixel ((Widget) tw,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1671 tab->tabs.foreground,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1672 tw->core.background_pixel,
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1673 tw->tabs.insensitive_contrast);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1674 tab->tabs.greyAlloc = True;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1675 }
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1676 gc = tw->tabs.greyGC;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1677 #ifdef USE_XFT_TABS
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1678 color = xft_convert_color (dpy, cmap, visual, tab->tabs.grey, 0);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1679 #else
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1680 XSetForeground(dpy, gc, tab->tabs.grey);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1681 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1682 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1683
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1684 x = tab->tabs.x;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1685 y = tab->tabs.y;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1686 if (child == tw->tabs.topWidget)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1687 y -= TABLDELTA;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1688
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1689 if (tab->tabs.left_bitmap != None && tab->tabs.lbm_width > 0)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1690 {
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1691 if (tab->tabs.lbm_depth == 1)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1692 XCopyPlane(dpy, tab->tabs.left_bitmap, win,gc,
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1693 0,0, tab->tabs.lbm_width, tab->tabs.lbm_height,
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1694 x+tab->tabs.lbm_x, y+tab->tabs.lbm_y, 1L);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1695 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1696 XCopyArea(dpy, tab->tabs.left_bitmap, win,gc,
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1697 0,0, tab->tabs.lbm_width, tab->tabs.lbm_height,
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1698 x+tab->tabs.lbm_x, y+tab->tabs.lbm_y);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1699 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1700
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1701 if (lbl != NULL &&
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1702 #ifdef USE_XFT_TABS
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1703 tw->tabs.renderFont != NULL
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1704 #else
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1705 tw->tabs.font != NULL
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1706 #endif
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1707 )
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1708 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1709 #ifdef USE_XFT_TABS
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1710 XftDraw *xftDraw = XftDrawCreate (dpy, win, visual, cmap);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1711 XftFont *renderFont = tw->tabs.renderFont;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1712 XGlyphInfo glyphinfo;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1713 XftColor colorDBG;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1714 XftColorAllocName (dpy, visual, cmap, "wheat", &colorDBG);
3374
174eb4da74fb [xemacs-hg @ 2006-05-02 15:30:31 by james]
james
parents: 3094
diff changeset
1715 XftTextExtents8 (dpy, renderFont, (FcChar8 *) lbl,
174eb4da74fb [xemacs-hg @ 2006-05-02 15:30:31 by james]
james
parents: 3094
diff changeset
1716 (int) strlen (lbl), &glyphinfo);
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1717 /* #### unnecessary? for the moment, give visual extent */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1718 /* draw background rect */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1719 if (debug_tabs > 2)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1720 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1721 fprintf (stderr, "background color: pixel=%08lx, r=%04x,"
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1722 " g=%04x, b=%04x, alpha=%04x.\n",
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1723 colorDBG.pixel, colorDBG.color.red,
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1724 colorDBG.color.green, colorDBG.color.blue,
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1725 colorDBG.color.alpha);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1726 fprintf (stderr, "label geometry: x=%d, y=%d, xOff=%d,"
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1727 " yOff=%d, width=%d, height=%d\n",
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1728 glyphinfo.x, glyphinfo.y, glyphinfo.xOff,
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1729 glyphinfo.yOff, glyphinfo.width, glyphinfo.height);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1730 }
3397
6aa26bef0527 [xemacs-hg @ 2006-05-12 19:25:28 by stephent]
stephent
parents: 3374
diff changeset
1731 if (debug_tabs > 2)
6aa26bef0527 [xemacs-hg @ 2006-05-12 19:25:28 by stephent]
stephent
parents: 3374
diff changeset
1732 XftDrawRect (xftDraw, &colorDBG,
6aa26bef0527 [xemacs-hg @ 2006-05-12 19:25:28 by stephent]
stephent
parents: 3374
diff changeset
1733 /* left, top, width, height */
6aa26bef0527 [xemacs-hg @ 2006-05-12 19:25:28 by stephent]
stephent
parents: 3374
diff changeset
1734 x+tab->tabs.l_x-glyphinfo.x,
6aa26bef0527 [xemacs-hg @ 2006-05-12 19:25:28 by stephent]
stephent
parents: 3374
diff changeset
1735 y+tab->tabs.l_y-glyphinfo.y,
6aa26bef0527 [xemacs-hg @ 2006-05-12 19:25:28 by stephent]
stephent
parents: 3374
diff changeset
1736 glyphinfo.width, glyphinfo.height);
6aa26bef0527 [xemacs-hg @ 2006-05-12 19:25:28 by stephent]
stephent
parents: 3374
diff changeset
1737
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1738 /* draw text */
3397
6aa26bef0527 [xemacs-hg @ 2006-05-12 19:25:28 by stephent]
stephent
parents: 3374
diff changeset
1739 if (debug_tabs > 1)
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1740 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1741 fprintf (stderr, "label: %s.\n", lbl);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1742 fprintf (stderr, "foreground color: pixel=%08lx, r=%04x,"
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1743 " g=%04x, b=%04x, alpha=%04x.\n",
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1744 color.pixel, color.color.red, color.color.green,
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1745 color.color.blue, color.color.alpha);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1746 fprintf (stderr, "extent: x=%d, y=%d, xOffset=%d,"
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1747 " yOffset=%d, height=%d, width=%d.\n",
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1748 glyphinfo.x, glyphinfo.y, glyphinfo.xOff,
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1749 glyphinfo.yOff, glyphinfo.height, glyphinfo.width);
3397
6aa26bef0527 [xemacs-hg @ 2006-05-12 19:25:28 by stephent]
stephent
parents: 3374
diff changeset
1750 }
6aa26bef0527 [xemacs-hg @ 2006-05-12 19:25:28 by stephent]
stephent
parents: 3374
diff changeset
1751 if (debug_tabs > 0)
6aa26bef0527 [xemacs-hg @ 2006-05-12 19:25:28 by stephent]
stephent
parents: 3374
diff changeset
1752 {
6aa26bef0527 [xemacs-hg @ 2006-05-12 19:25:28 by stephent]
stephent
parents: 3374
diff changeset
1753 FcValue name;
6aa26bef0527 [xemacs-hg @ 2006-05-12 19:25:28 by stephent]
stephent
parents: 3374
diff changeset
1754 FcValue size;
6aa26bef0527 [xemacs-hg @ 2006-05-12 19:25:28 by stephent]
stephent
parents: 3374
diff changeset
1755 FcPatternGet (renderFont->pattern, FC_FAMILY, 0, &name);
6aa26bef0527 [xemacs-hg @ 2006-05-12 19:25:28 by stephent]
stephent
parents: 3374
diff changeset
1756 FcPatternGet (renderFont->pattern, FC_SIZE, 0, &size);
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1757 fprintf (stderr, "font: name=%s-%.1f,"
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1758 " height=%d, ascent=%d, descent=%d.\n",
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1759 name.u.s, size.u.d, renderFont->height,
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1760 renderFont->ascent, renderFont->descent);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1761 }
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1762 XftDrawString8 (xftDraw, &color, renderFont,
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1763 x+tab->tabs.l_x, y+tab->tabs.l_y,
3374
174eb4da74fb [xemacs-hg @ 2006-05-02 15:30:31 by james]
james
parents: 3094
diff changeset
1764 (FcChar8 *) lbl, (int) strlen (lbl));
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1765 XftDrawDestroy (xftDraw);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1766 #else
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1767 XDrawString(dpy,win,gc,
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1768 x+tab->tabs.l_x, y+tab->tabs.l_y,
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1769 lbl, (int)strlen(lbl));
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1770 #endif
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1771 }
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
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1774 if (child == tw->tabs.hilight)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1775 DrawHighlight(tw, child, False);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1776 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1777
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 /* draw frame all the way around the child windows. */
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 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1782 DrawFrame(TabsWidget tw)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1783 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1784 GC topgc = tw->tabs.topGC ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1785 GC botgc = tw->tabs.botGC ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1786 Dimension s = SHADWID ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1787 Dimension ch = tw->tabs.child_height ;
448
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
1788 if (ch > 0)
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
1789 Draw3dBox((Widget)tw, 0,tw->tabs.tab_total,
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
1790 tw->core.width, ch+2*s, s, topgc, botgc) ;
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
1791 else
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
1792 {
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
1793 Widget w = tw->tabs.topWidget ;
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
1794 if (w != NULL)
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
1795 {
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
1796 TabsConstraints tab = (TabsConstraints) w->core.constraints ;
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
1797 Draw3dBox((Widget)tw, 0,tw->core.height - 2*s,
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
1798 tab->tabs.x, 2*s, s, topgc, botgc);
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
1799 Draw3dBox((Widget)tw, tab->tabs.x + tab->tabs.width,
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
1800 tw->core.height - 2*s,
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
1801 tw->core.width - tab->tabs.x - tab->tabs.width, 2*s, s,
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
1802 topgc, botgc);
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
1803 }
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
1804 else
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
1805 Draw3dBox((Widget)tw, 0,tw->core.height - 2*s,
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
1806 tw->core.width, 2*s, s, topgc, botgc) ;
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
1807 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1808 }
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 /* draw trim around a tab or underneath a row of tabs */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1812
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1813 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1814 DrawTrim(TabsWidget tw, /* widget */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1815 int x, /* upper-left corner */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1816 int y,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1817 int wid, /* total size */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1818 int hgt,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1819 Bool bottom, /* draw bottom? */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1820 Bool undraw) /* undraw all */
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 Display *dpy = XtDisplay((Widget)tw) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1823 Window win = XtWindow((Widget)tw) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1824 GC bggc = tw->tabs.backgroundGC ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1825 GC topgc = undraw ? bggc : tw->tabs.topGC ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1826 GC botgc = undraw ? bggc : tw->tabs.botGC ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1827 if( bottom )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1828 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
1829 XDrawLine(dpy,win,topgc, x,y+2, x,y+hgt-2) ; /* left */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1830 XDrawPoint(dpy,win,topgc, x+1,y+1) ; /* corner */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1831 XDrawLine(dpy,win,topgc, x+2,y, x+wid-3,y) ; /* top */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1832 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
1833 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
1834 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1835
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 /* Draw one tab border. */
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 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1840 DrawBorder(TabsWidget tw, Widget child, Bool undraw)
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 TabsConstraints tab = (TabsConstraints)child->core.constraints;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1843 Position x = tab->tabs.x ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1844 Position y = tab->tabs.y ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1845 Dimension twid = tab->tabs.width ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1846 Dimension thgt = tw->tabs.tab_height ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1847
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1848 /* top tab requires a little special attention; it overlaps
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1849 * neighboring tabs slightly, so the background must be cleared
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1850 * in the region of the overlap to partially erase those neighbors.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1851 * TODO: is this worth doing with regions instead?
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1852 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1853 if( child == tw->tabs.topWidget )
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 Display *dpy = XtDisplay((Widget)tw) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1856 Window win = XtWindow((Widget)tw) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1857 GC bggc = tw->tabs.backgroundGC ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1858 XRectangle rects[3] ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1859 x -= TABDELTA ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1860 y -= TABDELTA ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1861 twid += TABDELTA*2 ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1862 thgt += TABDELTA ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1863 AddRect(0, x,y+1,twid,TABDELTA) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1864 AddRect(1, x+1,y,TABDELTA,thgt) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1865 AddRect(2, x+twid-TABDELTA-1,y,TABDELTA,thgt) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1866 XFillRectangles(dpy,win,bggc, rects, 3) ;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1869 DrawTrim(tw, x,y,twid,thgt+1, child == tw->tabs.topWidget, undraw) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1870 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1871
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1872
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1873 /* Draw highlight around tab that has focus */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1874
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1875 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1876 DrawHighlight(TabsWidget tw, Widget child, Bool undraw)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1877 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1878 TabsConstraints tab = (TabsConstraints)child->core.constraints;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1879 Display *dpy = XtDisplay((Widget)tw) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1880 Window win = XtWindow((Widget)tw) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1881 GC gc ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1882 Position x = tab->tabs.x ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1883 Position y = tab->tabs.y ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1884 Dimension wid = tab->tabs.width ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1885 Dimension hgt = tw->tabs.tab_height ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1886 XPoint points[6] ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1887
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1888 /* top tab does not have a highlight */
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 if( child == tw->tabs.topWidget )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1891 return ;
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 if( undraw )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1894 gc = tw->tabs.backgroundGC ;
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 else if( XtIsSensitive(child) )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1897 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1898 gc = tw->tabs.foregroundGC ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1899 XSetForeground(dpy, gc, tab->tabs.foreground) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1900 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1901 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1902 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1903 gc = tw->tabs.greyGC ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1904 XSetForeground(dpy, gc, tab->tabs.grey) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1905 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1906
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1907 points[0].x = x+1 ; points[0].y = y+hgt-1 ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1908 points[1].x = x+1 ; points[1].y = y+2 ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1909 points[2].x = x+2 ; points[2].y = y+1 ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1910 points[3].x = x+wid-4 ; points[3].y = y+1 ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1911 points[4].x = x+wid-3 ; points[4].y = y+2 ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1912 points[5].x = x+wid-3 ; points[5].y = y+hgt-1 ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1913
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1914 XDrawLines(dpy,win,gc, points,6, CoordModeOrigin) ;
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
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 /* Undraw one tab interior */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1919
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1920 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1921 UndrawTab(TabsWidget tw, Widget child)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1922 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1923 TabsConstraints tab = (TabsConstraints)child->core.constraints;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1924 Position x = tab->tabs.x ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1925 Position y = tab->tabs.y ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1926 Dimension twid = tab->tabs.width ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1927 Dimension thgt = tw->tabs.tab_height ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1928 Display *dpy = XtDisplay((Widget)tw) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1929 Window win = XtWindow((Widget)tw) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1930 GC bggc = tw->tabs.backgroundGC ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1931
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1932 XFillRectangle(dpy,win,bggc, x,y, twid,thgt) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1933 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1934
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1935
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
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 /* GEOMETRY UTILITIES */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1940
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1941 /* Overview:
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1942 *
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1943 * MaxChild(): ask all children (except possibly one) their
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1944 * preferred sizes, set max_cw, max_ch accordingly.
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1945 *
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1946 * GetPreferredSizes(): ask all children their preferred sizes,
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1947 * set max_cw, max_ch accordingly.
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1948 *
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1949 * PreferredSize(): given max_cw, max_ch, return tabs widget
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1950 * preferred size. Iterate with other widths in order to get
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1951 * a reasonable aspect ratio.
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1952 *
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1953 * PreferredSize2(): Given child dimensions, return Tabs
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1954 * widget dimensions.
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1955 *
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1956 * PreferredSize3(): Same, except given child dimensions plus
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1957 * shadow.
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1958 */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1959
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1960
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
1961 /* 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
1962 * elsewhere.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1963 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1964 * height: font height + vertical_space*2 + shadowWid*2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1965 * width: string width + horizontal_space*2 + shadowWid*2
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 * All tabs are the same height, so that is computed elsewhere.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1968 */
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 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1971 TabWidth(Widget w)
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 TabsConstraints tab = (TabsConstraints) w->core.constraints ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1974 TabsWidget tw = (TabsWidget)XtParent(w) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1975 String lbl = tab->tabs.label != NULL ?
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1976 tab->tabs.label : XtName(w);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1977 #ifdef USE_XFT_TABS
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1978 XftFont *font = tw->tabs.renderFont;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1979 #else
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1980 XFontStruct *font = tw->tabs.font;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1981 #endif
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1982 int iw = tw->tabs.internalWidth;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1983
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1984 tab->tabs.width = iw + SHADWID*2 ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1985 tab->tabs.l_x = tab->tabs.lbm_x = SHADWID + iw ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1986
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1987 if( tab->tabs.left_bitmap != None )
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 tab->tabs.width += tab->tabs.lbm_width + iw ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1990 tab->tabs.l_x += tab->tabs.lbm_width + iw ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1991 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
1992 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1993
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1994 if( lbl != NULL && font != NULL )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1995 {
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1996 #ifdef USE_XFT_TABS
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
1997 tab->tabs.width += x_xft_text_width (XtDisplay(tw), font,
3374
174eb4da74fb [xemacs-hg @ 2006-05-02 15:30:31 by james]
james
parents: 3094
diff changeset
1998 (FcChar8 *) lbl,
174eb4da74fb [xemacs-hg @ 2006-05-02 15:30:31 by james]
james
parents: 3094
diff changeset
1999 (int)strlen(lbl)) + iw;
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2000 tab->tabs.l_y = (tw->tabs.tab_height
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2001 + tw->tabs.renderFont->ascent
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2002 /* #### how can this subtraction be correct? */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2003 - tw->tabs.renderFont->descent)/2;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2004 if (debug_tabs > 2)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2005 fprintf (stderr, "tab: height=%d, width=%d, baseline=%d.\n",
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2006 tw->tabs.tab_height, tab->tabs.width, tab->tabs.l_y);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2007 if (debug_tabs > 1)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2008 fprintf (stderr, "font: height=%d, ascent=%d, descent=%d.\n",
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2009 tw->tabs.renderFont->height,
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2010 tw->tabs.renderFont->ascent,
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2011 tw->tabs.renderFont->descent);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2012 #else
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2013 tab->tabs.width += XTextWidth (font, lbl, (int)strlen(lbl)) + iw;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2014 tab->tabs.l_y = (tw->tabs.tab_height +
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
2015 tw->tabs.font->max_bounds.ascent -
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2016 tw->tabs.font->max_bounds.descent)/2;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2017 #endif
428
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 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2020
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2021
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 /* 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
2024 * row number for each tab. Return number of rows and total height
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2025 * required by all tabs. If there is only one row, add TABDELTA
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2026 * height to the total. Rows are assigned bottom to top.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2027 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2028 * Tabs are indented from the edges by INDENT.
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 * 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
2031 * ratio is more than 2:1, then try something else.
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2032 * Gaak! This is actually already done in PreferredSize()!
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2033 *
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2034 * TODO SOONER: for reasons unclear, some applications (specifically
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2035 * XEmacs) give a nominal geometry (in the core record) which doesn't
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2036 * make much sense (eg, may be smaller than some of the tab children).
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2037 * This results in bizarre values for DISPLAY_ROWS and REPLY_HEIGHT.
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2038 * Specify a way to say "tell me what you really want" (eg, with WID
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2039 * and/or HGT == 0 or == Dimension_MAX), and use it where appropriate.
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2040 * LATE-BREAKING LOSE: This happens in PreferredSize(), not XEmacs!
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2041 *
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2042 * TODO EVEN SOONER: some applications lay out the tab control by
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2043 * repeatedly querying until a fixed width and height has been filled
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2044 * by the tabs (XEmacs). There should be an API to cache this?
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2045 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2046
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2047 static int
448
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
2048 TabLayout(TabsWidget tw,
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2049 Dimension wid, /* if 0, use core.width as guess */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2050 Dimension hgt, /* if 0, use core.height as guess */
448
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
2051 Dimension *reply_height, Bool query_only)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2052 {
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
2053 int i, row, done = 0, display_rows = 0 ;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2054 int num_children = tw->composite.num_children ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2055 Widget *childP ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2056 Dimension w ;
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2057 Position x,y ; /* #### gaak, these are dimensions! */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2058 TabsConstraints tab ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2059
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2060 /* Algorithm: loop through children, assign X positions. If a tab
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2061 * would extend beyond the right edge, start a new row. After all
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2062 * rows are assigned, make a second pass and assign Y positions.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2063 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2064
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2065 if( num_children > 0 )
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 /* Loop through the tabs and see how much space they need. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2068
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2069 row = 0 ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2070 x = INDENT ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2071 y = 0 ;
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2072 /* If wid or hgt is 0, we want to guess our own dimensions.
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2073 Currently the guessing functions are broken....
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2074 #### When PreferredSize*() get fixed, fix this too. */
3397
6aa26bef0527 [xemacs-hg @ 2006-05-12 19:25:28 by stephent]
stephent
parents: 3374
diff changeset
2075 if (debug_tabs > 1)
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2076 fprintf (stderr, "arg=%d,", wid);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2077 wid = (wid ? wid : tw->core.width) - INDENT ;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2078 hgt = hgt ? hgt : tw->core.height;
3397
6aa26bef0527 [xemacs-hg @ 2006-05-12 19:25:28 by stephent]
stephent
parents: 3374
diff changeset
2079 if (debug_tabs > 1)
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2080 fprintf (stderr, "wid=%d: x,w,y=", wid);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2081 for(i=num_children, childP=tw->composite.children; --i >= 0; ++childP)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2082 if( XtIsManaged(*childP) )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2083 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2084 tab = (TabsConstraints) (*childP)->core.constraints ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2085 w = tab->tabs.width ;
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
2086
3397
6aa26bef0527 [xemacs-hg @ 2006-05-12 19:25:28 by stephent]
stephent
parents: 3374
diff changeset
2087 if (debug_tabs > 1)
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2088 fprintf (stderr, "%d,%d,%d;", x, w, y);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2089 if( x + w > wid ) { /* new row */
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2090 /* #### algorithm is not robust to wid < child's width */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2091 ++row;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2092 x = INDENT ;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2093 y += tw->tabs.tab_height ;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2094 if (y > hgt && !done)
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
2095 {
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
2096 display_rows = row;
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
2097 done = 1;
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
2098 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2099 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2100 if( !query_only ) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2101 tab->tabs.x = x ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2102 tab->tabs.y = y ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2103 tab->tabs.row = row ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2104 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2105 x += w + SPACING ;
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
2106 if (!query_only && !done)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
2107 tab->tabs.visible = 1;
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
2108
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2109 }
3397
6aa26bef0527 [xemacs-hg @ 2006-05-12 19:25:28 by stephent]
stephent
parents: 3374
diff changeset
2110 if (debug_tabs > 1)
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2111 fprintf (stderr, "\n");
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2112 /* If there was only one row, increase the height by TABDELTA */
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
2113 if( ++display_rows == 1 )
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2114 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2115 y = TABDELTA ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2116 if( !query_only )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2117 for(i=num_children, childP=tw->composite.children;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2118 --i >= 0 ; ++childP)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2119 if( XtIsManaged(*childP) )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2120 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2121 tab = (TabsConstraints) (*childP)->core.constraints ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2122 tab->tabs.y = y ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2123 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2124 }
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2125 row++;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2126 y += tw->tabs.tab_height ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2127 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2128 else
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
2129 display_rows = row = y = 0 ;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2130
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2131 if( !query_only ) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2132 tw->tabs.tab_total = y ;
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
2133 tw->tabs.numRows = display_rows ;
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
2134 tw->tabs.realRows = row;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2135 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2136
3397
6aa26bef0527 [xemacs-hg @ 2006-05-12 19:25:28 by stephent]
stephent
parents: 3374
diff changeset
2137 if (debug_tabs > 1 && (row > 1 || display_rows > 1))
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2138 fprintf (stderr, "tab: %d display rows, #children = %d,"
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2139 " total height %d, total rows %d%s.\n",
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2140 display_rows, num_children, y, row,
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2141 query_only ? " (query)" : "");
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2142
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2143 if( reply_height != NULL )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2144 *reply_height = y ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2145
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
2146 return display_rows ;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2147 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2148
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2149
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2150
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2151 /* Find max preferred child size. Returned sizes include child
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
2152 * border widths.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2153 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2154
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2155 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2156 GetPreferredSizes(TabsWidget tw)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2157 {
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
2158 MaxChild(tw, NULL, 0,0) ;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2159 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2160
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2161
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2162
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2163 /* Find max preferred child size and store in control widget.
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2164 * If except is non-null, don't ask that one.
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
2165 */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2166
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2167 static void
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
2168 MaxChild(TabsWidget tw, Widget except, Dimension cw, Dimension ch)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2169 {
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
2170 int i ;
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
2171 Widget *childP = tw->composite.children ;
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
2172 XtWidgetGeometry preferred ;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2173
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2174 for(i=tw->composite.num_children; --i >=0; ++childP)
448
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
2175 if( TabVisible (*childP) /*XtIsManaged(*childP)*/ && *childP != except )
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2176 {
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
2177 (void) XtQueryGeometry(*childP, NULL, &preferred) ;
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
2178 cw = Max(cw, preferred.width + preferred.border_width * 2 ) ;
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
2179 ch = Max(ch, preferred.height + preferred.border_width * 2 ) ;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2180 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2181
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2182 tw->tabs.max_cw = cw ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2183 tw->tabs.max_ch = ch ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2184 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2185
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2186
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2187
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2188 /* rotate row numbers to bring current widget to bottom row,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2189 * compute y positions for all tabs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2190 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2191
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2192 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2193 TabsShuffleRows(TabsWidget tw)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2194 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2195 TabsConstraints tab ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2196 int move ;
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
2197 int real_rows, display_rows ;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2198 Widget *childP ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2199 Dimension th = tw->tabs.tab_height ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2200 Position bottom ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2201 int i ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2202
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2203 /* There must be a top widget. If not, assign one. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2204 if( tw->tabs.topWidget == NULL && tw->composite.children != NULL )
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
2205 for(i=TabsNumChildren (tw), childP=tw->composite.children;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2206 --i >= 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2207 ++childP)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2208 if( XtIsManaged(*childP) ) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2209 tw->tabs.topWidget = *childP ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2210 break ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2211 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2212
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2213 if( tw->tabs.topWidget != NULL )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2214 {
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
2215 display_rows = tw->tabs.numRows ;
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
2216 real_rows = tw->tabs.realRows ;
448
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
2217 assert( display_rows <= real_rows ) ;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2218
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
2219 if( real_rows > 1 )
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2220 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2221 tab = (TabsConstraints) tw->tabs.topWidget->core.constraints ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2222 assert( tab != NULL ) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2223
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
2224 /* How far to move top row. The selected tab must be on
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
2225 the bottom row of the *visible* rows. */
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
2226 move = (real_rows + 1 - display_rows) - tab->tabs.row ;
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
2227 if (move < 0)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
2228 move = real_rows - move;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2229 bottom = tw->tabs.tab_total - th ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2230
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
2231 for(i=tw->composite.num_children, childP=tw->composite.children;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2232 --i >= 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2233 ++childP)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2234 if( XtIsManaged(*childP) )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2235 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2236 tab = (TabsConstraints) (*childP)->core.constraints ;
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
2237 tab->tabs.row = (tab->tabs.row + move) % real_rows ;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2238 tab->tabs.y = bottom - tab->tabs.row * th ;
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
2239 tab->tabs.visible = (tab->tabs.row < display_rows);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2240 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2241 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2242 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2243 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2244
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2245
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
2246 /* Find preferred size. Ask children, find size of largest,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2247 * add room for tabs & return. This can get a little involved,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2248 * 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
2249 * the widget to reduce # of rows.
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
2250 *
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
2251 * This function requires that max_cw, max_ch already be set.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2252 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2253 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2254 PreferredSize(
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2255 TabsWidget tw,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2256 Dimension *reply_width, /* total widget size */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2257 Dimension *reply_height,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2258 Dimension *reply_cw, /* child widget size */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2259 Dimension *reply_ch)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2260 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2261 Dimension cw,ch ; /* child width, height */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2262 Dimension wid,hgt ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2263 Dimension rwid,rhgt ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2264 int nrow ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2265
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2266 wid = cw = tw->tabs.max_cw ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2267 hgt = ch = tw->tabs.max_ch ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2268
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2269 nrow = PreferredSize2(tw, wid,hgt, &rwid, &rhgt) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2270
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2271 /* Check for absurd results (more than 2 rows, high aspect
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2272 * ratio). Try wider size if needed.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2273 * TODO: make sure this terminates.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2274 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2275
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2276 if( nrow > 2 && rhgt > rwid )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2277 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2278 Dimension w0, w1 ;
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
2279 int maxloop = 20 ;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2280
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2281 /* step 1: start doubling size until it's too big */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2282 do {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2283 w0 = wid ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2284 wid = Max(wid*2, wid+20) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2285 nrow = PreferredSize2(tw, wid,hgt, &rwid,&rhgt) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2286 } while( nrow > 2 && rhgt > rwid ) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2287 w1 = wid ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2288
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2289 /* step 2: use Newton's method to find ideal size. Stop within
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2290 * 8 pixels.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2291 */
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
2292 while( --maxloop > 0 && w1 > w0 + 8 )
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2293 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2294 wid = (w0+w1)/2 ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2295 nrow = PreferredSize2(tw, wid,hgt, &rwid,&rhgt) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2296 if( nrow > 2 && rhgt > rwid )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2297 w0 = wid ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2298 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2299 w1 = wid ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2300 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2301 wid = w1 ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2302 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2303
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2304 *reply_width = rwid ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2305 *reply_height = rhgt ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2306 if( reply_cw != NULL ) *reply_cw = cw ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2307 if( reply_ch != NULL ) *reply_ch = ch ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2308 return nrow ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2309 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2310
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2311
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2312 /* Find preferred size, given size of children. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2313
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2314 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2315 PreferredSize2(
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2316 TabsWidget tw,
448
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
2317 Dimension cw, /* child width, height */
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
2318 Dimension ch,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2319 Dimension *reply_width, /* total widget size */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2320 Dimension *reply_height)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2321 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2322 Dimension s = SHADWID ;
448
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
2323 int ret;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2324
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2325 /* make room for shadow frame */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2326 cw += s*2 ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2327 ch += s*2 ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2328
448
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
2329 ret = PreferredSize3(tw, cw, ch, reply_width, reply_height) ;
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
2330
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
2331 assert (*reply_width > 0 && *reply_height > 0);
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
2332 return ret;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2333 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2334
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2335
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2336 /* Find preferred size, given size of children+shadow. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2337
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2338 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2339 PreferredSize3(
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2340 TabsWidget tw,
448
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
2341 Dimension wid, /* child width, height */
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
2342 Dimension hgt,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2343 Dimension *reply_width, /* total widget size */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2344 Dimension *reply_height)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2345 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2346 Dimension th ; /* space used by tabs */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2347 int nrows ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2348
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2349 if( tw->composite.num_children > 0 )
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2350 /* used to be wid, hgt not 0, 0 but that's obviously wrong
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2351 since TabLayout wants dimensions of control parent but
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2352 wid, hgt are dimensions of some child */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2353 nrows = TabLayout(tw, 0, 0, &th, True) ;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2354 else {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2355 th = 0 ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2356 nrows = 0 ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2357 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2358
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2359 *reply_width = Max(wid, MIN_WID) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2360 *reply_height = Max(th+hgt, MIN_HGT) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2361
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2362 return nrows ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2363 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2364
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2365
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2366 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2367 MakeSizeRequest(TabsWidget tw)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2368 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2369 Widget w = (Widget)tw ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2370 XtWidgetGeometry request, reply ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2371 XtGeometryResult result ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2372 Dimension cw,ch ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2373
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2374 request.request_mode = CWWidth | CWHeight ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2375 PreferredSize(tw, &request.width, &request.height, &cw, &ch) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2376
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2377 if( request.width == tw->core.width &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2378 request.height == tw->core.height )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2379 return ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2380
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2381 result = XtMakeGeometryRequest(w, &request, &reply) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2382
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2383 if( result == XtGeometryAlmost )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2384 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2385 /* Bugger. Didn't get what we want, but were offered a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2386 * compromise. If the width was too small, recompute
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2387 * based on the too-small width and try again.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2388 * If the height was too small, make a wild-ass guess
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2389 * at a wider width and try again.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2390 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2391
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2392 if( reply.width < request.width && reply.height >= request.height )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2393 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2394 Dimension s = SHADWID ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2395 ch += s*2 ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2396 PreferredSize3(tw, reply.width,ch, &request.width, &request.height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2397 result = XtMakeGeometryRequest(w, &request, &reply) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2398 if( result == XtGeometryAlmost )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2399 (void) XtMakeGeometryRequest(w, &reply, NULL) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2400 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2401
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2402 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2403 (void) XtMakeGeometryRequest(w, &reply, NULL) ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2404 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2405 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2406
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2407
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2408 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2409 getBitmapInfo(TabsWidget tw, TabsConstraints tab)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2410 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2411 Window root ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2412 int x,y ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2413 unsigned int bw ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2414
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2415 if( tab->tabs.left_bitmap == None ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2416 !XGetGeometry(XtDisplay(tw), tab->tabs.left_bitmap, &root, &x, &y,
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 432
diff changeset
2417 &tab->tabs.lbm_width, &tab->tabs.lbm_height,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2418 &bw, &tab->tabs.lbm_depth) )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2419 tab->tabs.lbm_width = tab->tabs.lbm_height = 0 ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2420 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2421
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2422
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2423
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2424
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2425 /* Code copied & modified from Gcs.c. This version has dynamic
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2426 * foreground.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2427 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2429 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2430 TabsAllocFgGC(TabsWidget tw)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2431 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2432 Widget w = (Widget) tw;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2433 XGCValues values ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2434
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2435 values.background = tw->core.background_pixel;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2436 values.font =
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2437 #ifdef USE_XFT_TABS
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2438 None;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2439 #else
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2440 tw->tabs.font->fid;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2441 #endif
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2442 values.line_style = LineOnOffDash;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2443 values.line_style = LineSolid;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2444
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2445 tw->tabs.foregroundGC =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2446 XtAllocateGC(w, w->core.depth,
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2447 #ifndef USE_XFT_TABS
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2448 GCFont|
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2449 #endif
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2450 GCBackground|GCLineStyle,
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2451 &values,
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2452 GCForeground,
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2453 #ifdef USE_XFT_TABS
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2454 GCFont|
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2455 #endif
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2456 GCSubwindowMode|GCGraphicsExposures|GCDashOffset|
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2457 GCDashList|GCArcMode);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2458 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2459
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2460 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2461 TabsAllocGreyGC(TabsWidget tw)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2462 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2463 Widget w = (Widget) tw;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2464 XGCValues values ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2465
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2466 values.background = tw->core.background_pixel;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2467 values.font =
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2468 #ifdef USE_XFT_TABS
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2469 None;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2470 #else
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2471 tw->tabs.font->fid;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2472 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2473 #ifdef HAVE_XMU
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2474 if (tw->tabs.be_nice_to_cmap || w->core.depth == 1)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2475 {
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2476 values.fill_style = FillStippled;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2477 tw->tabs.grey50 =
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2478 values.stipple = XmuCreateStippledPixmap(XtScreen(w), 1L, 0L, 1);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2479
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2480 tw->tabs.greyGC =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2481 XtAllocateGC(w, w->core.depth,
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2482 #ifndef USE_XFT_TABS
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2483 GCFont|
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2484 #endif
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2485 GCBackground|GCStipple|GCFillStyle, &values,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2486 GCForeground,
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2487 #ifdef USE_XFT_TABS
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2488 GCFont|
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2489 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2490 GCSubwindowMode|GCGraphicsExposures|GCDashOffset|
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2491 GCDashList|GCArcMode);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2492 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2493 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2494 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2495 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2496 tw->tabs.greyGC =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2497 XtAllocateGC(w, w->core.depth,
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2498 #ifdef USE_XFT_TABS
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2499 0L,
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2500 #else
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2501 GCFont,
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2502 #endif
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2503 &values,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2504 GCForeground,
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2505 #ifdef USE_XFT_TABS
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2506 GCFont|
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2507 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2508 GCBackground|GCSubwindowMode|GCGraphicsExposures|GCDashOffset|
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3025
diff changeset
2509 GCDashList|GCArcMode);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2510 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2511 }