annotate lwlib/xlwtabs.c @ 4769:5460287a3327

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