annotate lwlib/xlwtabs.c @ 4697:0d6d0edf1253

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