annotate lwlib/xlwscrollbar.c @ 5593:4218b56833b3

Give the label name when warning or erroring, bytecomp.el 2011-11-02 Aidan Kehoe <kehoea@parhasard.net> * bytecomp.el (byte-compile-lambda): Accept a new NAME argument here, have byte-compile-current-form reflect that if it's specified. * bytecomp.el (byte-compile-initial-macro-environment): Specify the label name when byte-compiling it, so warning and errors are more helpful.
author Aidan Kehoe <kehoea@parhasard.net>
date Wed, 02 Nov 2011 17:50:39 +0000
parents ade4c7e2c6cb
children
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 /* Implements a lightweight scrollbar widget.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2 Copyright (C) 1992, 1993, 1994 Lucid, Inc.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3 Copyright (C) 1997 Sun Microsystems, Inc.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5 This file is part of the Lucid Widget Library.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6
5422
ade4c7e2c6cb Migrate lwlib/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 4528
diff changeset
7 The Lucid Widget Library is free software: you can redistribute it
ade4c7e2c6cb Migrate lwlib/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 4528
diff changeset
8 and/or modify it under the terms of the GNU General Public License as
ade4c7e2c6cb Migrate lwlib/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 4528
diff changeset
9 published by the Free Software Foundation, either version 3 of the
ade4c7e2c6cb Migrate lwlib/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 4528
diff changeset
10 License, or (at your option) any later version.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11
5422
ade4c7e2c6cb Migrate lwlib/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 4528
diff changeset
12 The Lucid Widget Library is distributed in the hope that it will be
ade4c7e2c6cb Migrate lwlib/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 4528
diff changeset
13 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
ade4c7e2c6cb Migrate lwlib/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 4528
diff changeset
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
ade4c7e2c6cb Migrate lwlib/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 4528
diff changeset
15 General Public License for more details.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
5422
ade4c7e2c6cb Migrate lwlib/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 4528
diff changeset
18 along with the Lucid Widget Library. If not, see
ade4c7e2c6cb Migrate lwlib/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 4528
diff changeset
19 <http://www.gnu.org/licenses/>. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21 /* Created by Douglas Keller <dkeller@vnet.ibm.com> */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22 /* Lots of hacking by Martin Buchholz */
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25 * Athena-style scrollbar button bindings added on Sun Dec 24 22:03:57 1995
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26 * by Jonathan Stigelman <Stig@hackvan.com>... Ho ho ho!
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27 *
1389
6355bae896e3 [xemacs-hg @ 2003-03-27 12:57:36 by stephent]
stephent
parents: 766
diff changeset
28 * To use them, put this resource in your .Xresources
428
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 * Emacs*XlwScrollBar.translations: #override \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31 * <Btn1Down>: PageDownOrRight() \n\
766
7b8fc81f9587 [xemacs-hg @ 2002-03-05 13:39:26 by stephent]
stephent
parents: 442
diff changeset
32 * <Btn3Down>: PageUpOrLeft() \n\
7b8fc81f9587 [xemacs-hg @ 2002-03-05 13:39:26 by stephent]
stephent
parents: 442
diff changeset
33 * <Btn3Up>: Release()
428
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38 * Resources Supported:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39 * XmNforeground
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40 * XmNbackground
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41 * XmNtopShadowColor
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42 * XmNtopShadowPixmap
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43 * XmNbottomShadowColor
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44 * XmNbottomShadowPixmap
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45 * XmNtroughColor
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46 * XmNshadowThickness
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47 * XmNshowArrows
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48 * XmNorientation
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49 * XmNborderWidth
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 * XmNminimum
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52 * XmNmaximum
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53 * XmNvalue
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 * XmNincrement
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55 * XmNpageIncrement
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 * XmNvalueChangedCallback
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58 * XmNincrementCallback
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59 * XmNdecrementCallback
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60 * XmNpageIncrementCallback
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61 * XmNpageDecrementCallback
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 * XmNtoTopCallback
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63 * XmNtoBottomCallback
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64 * XmNdragCallback
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66 * XmNsliderStyle - values can be: "plain" or "dimple"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67 * XmNarrowPosition - values can be: "opposite" or "same"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 */
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 <config.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72 #include <stdio.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 #include <stdlib.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74 #include <limits.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76 #include <X11/IntrinsicP.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77 #include <X11/StringDefs.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 #include <X11/bitmaps/gray>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
80 #include "lwlib-colors.h"
4528
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
81 #include "xt-wrappers.h"
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
82
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 #include "xlwscrollbarP.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84 #include "xlwscrollbar.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 #ifdef USE_DEBUG_MALLOC
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87 #include <dmalloc.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 #define DBUG(x)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 #define MINL(x,y) ((((unsigned long) (x)) < ((unsigned long) (y))) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93 ? ((unsigned long) (x)) : ((unsigned long) (y)))
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 #define VERT(w) ((w)->sb.orientation == XmVERTICAL)
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 #define SS_MIN 8
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 typedef enum
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 BUTTON_NONE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 BUTTON_SLIDER,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 BUTTON_UP_ARROW,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 BUTTON_DOWN_ARROW,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 BUTTON_TROUGH_ABOVE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106 BUTTON_TROUGH_BELOW
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107 } button_where;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 typedef enum
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 SLIDER_PLAIN,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112 SLIDER_DIMPLE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113 } SliderStyle;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115 /*-------------------------- Resources ----------------------------------*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117 static XtResource resources[] = {
4528
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
118 #define offset(field) XtOffset(XlwScrollBarWidget, field)
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
119 #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
120 Xt_RESOURCE (name, _class, intrepr, type, offset(sb.member), extrepr, value)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121
4528
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
122 res (XmNforeground, XmCForeground, XtRPixel, Pixel,
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
123 foreground, XtRImmediate, XtDefaultForeground),
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
124 res (XmNtopShadowColor, XmCTopShadowColor, XtRPixel,
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
125 Pixel, topShadowColor, 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
126 res (XmNbottomShadowColor, XmCBottomShadowColor, XtRPixel,
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
127 Pixel, bottomShadowColor, XtRImmediate, ~0),
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128
4528
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
129 res (XmNtopShadowPixmap, XmCTopShadowPixmap, XtRPixmap,
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
130 Pixmap, topShadowPixmap, 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
131 res (XmNbottomShadowPixmap, XmCBottomShadowPixmap,
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
132 XtRPixmap, Pixmap, bottomShadowPixmap, XtRImmediate, None),
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133
4528
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
134 res (XmNtroughColor, XmCTroughColor, XtRPixel, Pixel, troughColor,
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
135 XtRImmediate, ~0),
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136
4528
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
137 res (XmNshadowThickness, XmCShadowThickness, 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
138 shadowThickness, XtRImmediate, 2),
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
139
4528
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
140 Xt_RESOURCE (XmNborderWidth, XmCBorderWidth, 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
141 offset(core.border_width), XtRImmediate, 0),
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142
4528
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
143 res (XmNshowArrows, XmCShowArrows, XtRBoolean, Boolean, showArrows,
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
144 XtRImmediate, True),
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145
4528
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
146 res (XmNinitialDelay, XmCInitialDelay, XtRInt, int, initialDelay,
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
147 XtRImmediate, 250),
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
148 res (XmNrepeatDelay, XmCRepeatDelay, XtRInt, int, repeatDelay,
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
149 XtRImmediate, 50),
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
150
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
151 res (XmNorientation, XmCOrientation, XtROrientation,
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
152 unsigned char, orientation, XtRImmediate, XmVERTICAL),
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153
4528
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
154 res (XmNminimum, XmCMinimum, XtRInt, int, minimum, 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
155 res (XmNmaximum, XmCMaximum, XtRInt, int, maximum, XtRImmediate, 100),
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
156 res (XmNvalue, XmCValue, XtRInt, int, value, 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
157 res (XmNsliderSize, XmCSliderSize, XtRInt, int, sliderSize, XtRImmediate, 10),
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
158 res (XmNincrement, XmCIncrement, XtRInt, int, increment, XtRImmediate, 1),
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
159 res (XmNpageIncrement, XmCPageIncrement, 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
160 pageIncrement, XtRImmediate, 10),
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161
4528
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
162 res (XmNvalueChangedCallback, XmCValueChangedCallback,
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
163 XtRCallback, XtPointer, valueChangedCBL, 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
164 res (XmNincrementCallback, XmCIncrementCallback,
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
165 XtRCallback, XtPointer, incrementCBL, 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
166 res (XmNdecrementCallback, XmCDecrementCallback,
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
167 XtRCallback, XtPointer, decrementCBL, 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
168 res (XmNpageIncrementCallback, XmCPageIncrementCallback,
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
169 XtRCallback, XtPointer, pageIncrementCBL, 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
170 res (XmNpageDecrementCallback, XmCPageDecrementCallback,
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
171 XtRCallback, XtPointer, pageDecrementCBL, 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
172 res (XmNtoTopCallback, XmCToTopCallback, XtRCallback,
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
173 XtPointer, toTopCBL, 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 (XmNtoBottomCallback, XmCToBottomCallback, XtRCallback,
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
175 XtPointer, toBottomCBL, 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 (XmNdragCallback, XmCDragCallback, XtRCallback,
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
177 XtPointer, dragCBL, XtRCallback, NULL),
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179 /* "knob" is obsolete; use "slider" instead. */
4528
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 (XmNsliderStyle, XmCSliderStyle, XtRString, char *,
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
181 sliderStyle, 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
182 res (XmNknobStyle, XmCKnobStyle, XtRString, char *,
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
183 knobStyle, XtRImmediate, NULL),
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184
4528
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
185 res (XmNarrowPosition, XmCArrowPosition, XtRString, char *,
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
186 arrowPosition, 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
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
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 };
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 /*-------------------------- Prototypes ---------------------------------*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193 /* Actions */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194 typedef void Action(Widget w, XEvent *event, String *parms, Cardinal *num_parms);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195 static Action Select, PageUpOrLeft, PageDownOrRight, Drag, Release, Jump, Abort;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197 /* Methods */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198 static void Initialize(Widget treq, Widget tnew, ArgList args, Cardinal *num_args);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
199 static Boolean SetValues(Widget current, Widget request, Widget nw, ArgList args, Cardinal *num_args);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
200 static void Destroy(Widget widget);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
201 static void Redisplay(Widget widget, XEvent *event, Region region);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
202 static void Resize(Widget widget);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 static void Realize(Widget widget, XtValueMask *valuemask, XSetWindowAttributes *attr);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205 /* Private */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207 /*-------------------------- Actions Table ------------------------------*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208 static XtActionsRec actions[] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 {
4528
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
210 { (String) "Select", Select},
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
211 { (String) "PageDownOrRight", PageDownOrRight},
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
212 { (String) "PageUpOrLeft", PageUpOrLeft},
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
213 { (String) "Drag", Drag},
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
214 { (String) "Release", Release},
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
215 { (String) "Jump", Jump},
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
216 { (String) "Abort", Abort},
428
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
219 /*--------------------- Default Translation Table -----------------------*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
220 static char default_translations[] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
221 "<Btn1Down>: Select()\n"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
222 "<Btn1Motion>: Drag()\n"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223 "<Btn1Up>: Release()\n"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
224 "<Btn2Down>: Jump()\n"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
225 "<Btn2Motion>: Drag()\n"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
226 "<Btn2Up>: Release()\n"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227 "<Key>Delete: Abort()"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228 ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
230 /*------------------- Class record initialization -----------------------*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231 XlwScrollBarClassRec xlwScrollBarClassRec = {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
232 /* core_class fields */
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 /* superclass */ (WidgetClass) &coreClassRec,
4528
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
235 /* class_name */ (String) "XlwScrollBar",
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236 /* widget_size */ sizeof(XlwScrollBarRec),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237 /* class_initialize */ NULL,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
238 /* class_part_init */ NULL,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
239 /* class_inited */ False,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
240 /* initialize */ Initialize,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
241 /* initialize_hook */ NULL,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242 /* realize */ Realize,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
243 /* actions */ actions,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
244 /* num_actions */ XtNumber(actions),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
245 /* resources */ resources,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
246 /* num_resources */ XtNumber(resources),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
247 /* xrm_class */ NULLQUARK,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
248 /* compress_motion */ True,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
249 /* compress_exposure */ XtExposeCompressMultiple,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250 /* compress_enterleave */ True,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
251 /* visible_interest */ False,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252 /* destroy */ Destroy,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253 /* resize */ Resize,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
254 /* expose */ Redisplay,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
255 /* set_values */ SetValues,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
256 /* set_values_hook */ NULL,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
257 /* set_values_almost */ XtInheritSetValuesAlmost,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
258 /* get_values_hook */ NULL,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
259 /* accept_focus */ NULL,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260 /* version */ XtVersionDontCheck,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
261 /* callback_private */ NULL,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
262 /* tm_table */ default_translations,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
263 /* query_geometry */ NULL,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264 },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
265 /* scrollbar_class fields */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
266 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267 /* dummy_field */ 0,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268 },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
271 WidgetClass xlwScrollBarWidgetClass = (WidgetClass) &xlwScrollBarClassRec;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273 /*-------------------------- Debug Functions ----------------------------*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
274
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
275 #ifdef SHOW_CLEAR
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277 myXClearArea(Display *dpy, Drawable d, int x, int y, int w, int h,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278 Boolean exp, XlwScrollBarWidget widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
279 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
280 XFillRectangle (dpy, d, widget->sb.topShadowGC, x, y, w, h);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
281 XSync (dpy, False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
282 sleep (2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283 XClearArea (dpy, d, x, y, w, h, exp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286 #define XClearArea(dpy,win,x,y,width,height,exp) myXClearArea(dpy,win,x,y,width,height,exp,w)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
287 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289 #ifdef CHECK_VALUES
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
290 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291 check(XlwScrollBarWidget w)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
292 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
293 int height = widget_h (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
294 if (w->sb.showArrows)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
295 height -= (2 * arrow_h (w));
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 if ((w->sb.above + w->sb.ss + w->sb.below > height) ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298 (w->sb.value < w->sb.minimum) ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
299 (w->sb.value > w->sb.maximum - w->sb.sliderSize))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
300 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
301 printf("above=%d ss=%d below=%d height=%d\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
302 w->sb.above, w->sb.ss, w->sb.below, height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
303 printf("value=%d min=%d max=%d ss=%d max-ss=%d\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
304 w->sb.value, w->sb.minimum, w->sb.maximum,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
305 w->sb.sliderSize, w->sb.maximum - w->sb.sliderSize);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306 abort();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
307 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
308 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
309
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310 # define CHECK(w) check(w)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
311 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
312 # define CHECK(w)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
313 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
314
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
315 /*-------------------------- Static functions ---------------------------*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
316
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
317 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
318 call_callbacks (XlwScrollBarWidget w, int reason,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319 int value, int pixel, XEvent *event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
320 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
321 XlwScrollBarCallbackStruct cbs;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
322 Boolean called_anything;
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 cbs.reason = reason;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
325 cbs.event = event;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
326 cbs.value = value;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
327 cbs.pixel = pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
328
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
329 called_anything = False;
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 switch (reason)
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 case XmCR_VALUE_CHANGED:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
334 XtCallCallbackList ((Widget) w, w->sb.valueChangedCBL, &cbs);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
335 called_anything = True;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
336 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
337 case XmCR_INCREMENT:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
338 if (w->sb.incrementCBL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
339 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
340 XtCallCallbackList ((Widget) w, w->sb.incrementCBL, &cbs);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
341 called_anything = True;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
342 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
343 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
344 case XmCR_DECREMENT:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
345 if (w->sb.decrementCBL)
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 XtCallCallbackList ((Widget) w, w->sb.decrementCBL, &cbs);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
348 called_anything = True;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
349 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
350 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
351 case XmCR_PAGE_INCREMENT:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
352 if (w->sb.incrementCBL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
353 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
354 XtCallCallbackList ((Widget) w, w->sb.pageIncrementCBL, &cbs);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
355 called_anything = True;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
356 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
357 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
358 case XmCR_PAGE_DECREMENT:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
359 if (w->sb.decrementCBL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
360 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
361 XtCallCallbackList ((Widget) w, w->sb.pageDecrementCBL, &cbs);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
362 called_anything = True;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
363 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
364 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
365 case XmCR_TO_TOP:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
366 if (w->sb.toTopCBL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
367 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
368 XtCallCallbackList ((Widget) w, w->sb.toTopCBL, &cbs);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369 called_anything = True;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
371 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
372 case XmCR_TO_BOTTOM:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
373 if (w->sb.toBottomCBL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
374 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
375 XtCallCallbackList ((Widget) w, w->sb.toBottomCBL, &cbs);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
376 called_anything = True;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
377 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
378 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
379 case XmCR_DRAG:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
380 if (w->sb.dragCBL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
381 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
382 XtCallCallbackList ((Widget) w, w->sb.dragCBL, &cbs);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
383 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
384 called_anything = True; /* Special Case */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
385 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
386 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
387
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
388 if (!called_anything)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
389 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
390 cbs.reason = XmCR_VALUE_CHANGED;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
391 XtCallCallbackList ((Widget) w, w->sb.valueChangedCBL, &cbs);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
395 /* Widget sizes minus the shadow and highlight area */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
396
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
397 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
398 widget_x (XlwScrollBarWidget w)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
399 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
400 return w->sb.shadowThickness;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
401 }
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 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
404 widget_y (XlwScrollBarWidget w)
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 return w->sb.shadowThickness;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
407 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
408
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
409 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
410 widget_w (XlwScrollBarWidget w)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
411 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
412 int x = w->sb.shadowThickness;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
413 int width = (VERT (w) ? w->core.width : w->core.height) - (2 * x);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
414 return width > 1 ? width : 1;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
417 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
418 widget_h (XlwScrollBarWidget w)
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 int y = w->sb.shadowThickness;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
421 int height = (VERT (w) ? w->core.height : w->core.width) - (2 * y);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
422
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
423 return height > 1 ? height : 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
424 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
425
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
426 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
427 arrow_h (XlwScrollBarWidget w)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
428 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
429 int width = widget_w (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
430 int minimum_size = ((widget_h (w) - SS_MIN) / 2) - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
431 return minimum_size < width ? minimum_size : width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
432 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
433
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
434 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
435 event_x (XlwScrollBarWidget w, XEvent *event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
436 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
437 return VERT (w) ? event->xbutton.x : event->xbutton.y;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
438 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
439
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
440 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
441 event_y (XlwScrollBarWidget w, XEvent *event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
442 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
443 return VERT (w) ? event->xbutton.y : event->xbutton.x;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
444 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
445
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
446 /* Safe addition and subtraction */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
447 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
448 increment_value (XlwScrollBarWidget w, int diff)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
449 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
450 w->sb.value = w->sb.maximum - diff < w->sb.value ?
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
451 w->sb.maximum :
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
452 w->sb.value + diff;
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 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
456 decrement_value (XlwScrollBarWidget w, int diff)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
457 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
458 w->sb.value = w->sb.minimum + diff > w->sb.value ?
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
459 w->sb.minimum :
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
460 w->sb.value - diff;
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 static SliderStyle
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
464 slider_style (XlwScrollBarWidget w)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
465 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
466 return (w->sb.sliderStyle ? w->sb.sliderStyle[0] == 'd' :
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
467 w->sb.knobStyle ? w->sb.knobStyle[0] == 'd' :
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
468 0) ?
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
469 SLIDER_DIMPLE :
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
470 SLIDER_PLAIN;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
471 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
472
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
473 static Boolean
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
474 arrow_same_end (XlwScrollBarWidget w)
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 return w->sb.arrowPosition && w->sb.arrowPosition[0] == 's' ? True : False;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
477 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
478
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
479 /*-------------------------- GC and Pixel allocation --------------------*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
480 #ifndef XmUNSPECIFIED_PIXMAP
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
481 #define XmUNSPECIFIED_PIXMAP 2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
482 #endif
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 static GC
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
485 get_gc (XlwScrollBarWidget w, Pixel fg, Pixel bg, Pixmap pm)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
486 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
487 XGCValues values;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
488 XtGCMask mask;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
489
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
490 if (pm == w->sb.grayPixmap)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
491 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
492 /* If we're using the gray pixmap, guarantee white on black ...
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
493 * otherwise, we could end up with something odd like grey on white
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
494 * when we're on a color display that ran out of color cells
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
495 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
496
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
497 fg = WhitePixelOfScreen (DefaultScreenOfDisplay (XtDisplay (w)));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
498 bg = BlackPixelOfScreen (DefaultScreenOfDisplay (XtDisplay (w)));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
499 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
500
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
501 values.foreground = fg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
502 values.background = bg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
503 values.fill_style = FillOpaqueStippled;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
504 values.stipple = pm;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
505 /* mask = GCForeground | GCBackground |
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
506 (pm == None ? 0 : GCStipple | GCFillStyle); gtb */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
507 if (pm != None && pm != 0 && pm != XmUNSPECIFIED_PIXMAP)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
508 values.stipple = pm;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
509 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
510 values.stipple = None;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
511 mask = GCForeground | GCBackground |
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
512 (values.stipple == None ? 0 : GCStipple | GCFillStyle);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
513
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
514 return XtGetGC((Widget) w, mask, &values);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
515 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
516
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
517 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
518 make_shadow_pixels (XlwScrollBarWidget w)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
519 {
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
520 Display *dpy = XtDisplay ((Widget) w);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
521 Colormap cmap = w->core.colormap;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
522 XColor topc, botc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
523 int top_frobbed, bottom_frobbed;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
524 Pixel bg, fg;
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
525 Visual *visual;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
526 int ignored;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
527
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
528 visual_info_from_widget ((Widget) w, &visual, &ignored);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
529 /* #### Apparently this is called before any shell has a visual?
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
530 or maybe the widget doesn't have a parent yet? */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
531 if (visual == CopyFromParent)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
532 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
533 Screen *screen = DefaultScreenOfDisplay (dpy);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
534 visual = DefaultVisualOfScreen (screen);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
535 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
536
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
537 top_frobbed = bottom_frobbed = 0;
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 bg = w->core.background_pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
540 fg = w->sb.foreground;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
541
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
542 if (w->sb.topShadowColor == (Pixel)~0) w->sb.topShadowColor = bg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
543 if (w->sb.bottomShadowColor == (Pixel)~0) w->sb.bottomShadowColor = fg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
544
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
545 if (w->sb.topShadowColor == bg || w->sb.topShadowColor == fg)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
546 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
547 topc.pixel = bg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
548 XQueryColor (dpy, cmap, &topc);
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
549 /* #### can we use a (generalized) xft_convert_color here? */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
550 /* don't overflow/wrap! */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
551 topc.red = MINL(65535, topc.red * 1.2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
552 topc.green = MINL(65535, topc.green * 1.2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
553 topc.blue = MINL(65535, topc.blue * 1.2);
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
554 if (x_allocate_nearest_color (dpy, cmap, visual, &topc))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
555 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
556 if (topc.pixel == bg)
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 XFreeColors (dpy, cmap, &topc.pixel, 1, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
559 topc.red = MINL(65535, topc.red + 0x8000);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
560 topc.green = MINL(65535, topc.green + 0x8000);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
561 topc.blue = MINL(65535, topc.blue + 0x8000);
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
562 if (x_allocate_nearest_color (dpy, cmap, visual, &topc))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
563 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
564 w->sb.topShadowColor = topc.pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
565 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
566 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
567 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
568 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
569 w->sb.topShadowColor = topc.pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
570 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
571
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
572 top_frobbed = 1;
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 if (w->sb.bottomShadowColor == fg || w->sb.bottomShadowColor == bg)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
577 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
578 botc.pixel = bg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
579 XQueryColor (dpy, cmap, &botc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
580 botc.red = (botc.red * 3) / 5;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
581 botc.green = (botc.green * 3) / 5;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
582 botc.blue = (botc.blue * 3) / 5;
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
583 if (x_allocate_nearest_color (dpy, cmap, visual, &botc))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
584 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
585 if (botc.pixel == bg)
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 XFreeColors (dpy, cmap, &botc.pixel, 1, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
588 botc.red = MINL(65535, botc.red + 0x4000);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
589 botc.green = MINL(65535, botc.green + 0x4000);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
590 botc.blue = MINL(65535, botc.blue + 0x4000);
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
591 if (x_allocate_nearest_color (dpy, cmap, visual, &botc))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
592 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
593 w->sb.bottomShadowColor = botc.pixel;
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 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
596 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
597 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
598 w->sb.bottomShadowColor = botc.pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
599 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
600 bottom_frobbed = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
601 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
602 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
603
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
604 if (top_frobbed && bottom_frobbed)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
605 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
606 int top_avg = ((topc.red / 3) + (topc.green / 3) + (topc.blue / 3));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
607 int bot_avg = ((botc.red / 3) + (botc.green / 3) + (botc.blue / 3));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
608 if (bot_avg > top_avg)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
609 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
610 Pixel tmp = w->sb.topShadowColor;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
611 w->sb.topShadowColor = w->sb.bottomShadowColor;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
612 w->sb.bottomShadowColor = tmp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
613 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
614 else if (topc.pixel == botc.pixel)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
615 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
616 if (botc.pixel == bg)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
617 w->sb.topShadowColor = bg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
618 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
619 w->sb.bottomShadowColor = fg;
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 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
622
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
623 if (w->sb.topShadowColor == w->core.background_pixel ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
624 w->sb.bottomShadowColor == w->core.background_pixel)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
625 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
626 /* Assume we're in mono. This code should be okay even if we're
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
627 * really in color but just short on color cells -- We want the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
628 * following behavior, which has been empirically determined to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
629 * work well for all fg/bg combinations in mono: If the trough
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
630 * and slider are BOTH black, then use a white top shadow and a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
631 * grey bottom shadow, otherwise use a grey top shadow and a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
632 * black bottom shadow.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
633 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
634
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
635 Pixel white = WhitePixelOfScreen (DefaultScreenOfDisplay (XtDisplay (w)));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
636 Pixel black = BlackPixelOfScreen (DefaultScreenOfDisplay (XtDisplay (w)));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
637
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
638 /* Note: core.background_pixel is the color of the slider ... */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
639
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
640 if (w->core.background_pixel == black &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
641 w->sb.troughColor == black)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
642 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
643 w->sb.topShadowColor = white;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
644 w->sb.bottomShadowPixmap = w->sb.grayPixmap;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
645 } else {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
646 w->sb.topShadowPixmap = w->sb.grayPixmap;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
647 w->sb.bottomShadowColor = black;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
648 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
649 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
650 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
651
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
652 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
653 make_trough_pixel (XlwScrollBarWidget w)
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 Display *dpy = XtDisplay((Widget) w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
656 Colormap cmap = w->core.colormap;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
657 XColor troughC;
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
658 Visual *visual;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
659 int ignored;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
660
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
661 visual_info_from_widget ((Widget) w, &visual, &ignored);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
662 /* #### Apparently this is called before any shell has a visual?
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
663 or maybe the widget doesn't have a parent yet? */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
664 if (visual == CopyFromParent)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
665 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
666 Screen *screen = DefaultScreenOfDisplay (dpy);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
667 visual = DefaultVisualOfScreen (screen);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
668 }
428
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 if (w->sb.troughColor == (Pixel)~0) w->sb.troughColor = w->core.background_pixel;
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 if (w->sb.troughColor == w->core.background_pixel)
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 troughC.pixel = w->core.background_pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
675 XQueryColor (dpy, cmap, &troughC);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
676 troughC.red = (troughC.red * 4) / 5;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
677 troughC.green = (troughC.green * 4) / 5;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
678 troughC.blue = (troughC.blue * 4) / 5;
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
679 if (x_allocate_nearest_color (dpy, cmap, visual, &troughC))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
680 w->sb.troughColor = troughC.pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
681 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
682 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
683
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
684 /*-------------------------- Draw 3D Border -----------------------------*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
685 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
686 draw_shadows (Display *dpy, Drawable d, GC shine_gc, GC shadow_gc,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
687 int x, int y, int width, int height, int shadowT)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
688 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
689 XSegment shine[10], shadow[10];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
690 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
691
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
692 if (shadowT > (width / 2)) shadowT = (width / 2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
693 if (shadowT > (height / 2)) shadowT = (height / 2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
694 if (shadowT <= 0) return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
695
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
696 for (i = 0; i < shadowT; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
697 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
698 /* Top segments */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
699 shine[i].x1 = x;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
700 shine[i].y2 = shine[i].y1 = y + i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
701 shine[i].x2 = x + width - i - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
702 /* Left segments */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
703 shine[i + shadowT].x2 = shine[i + shadowT].x1 = x + i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
704 shine[i + shadowT].y1 = y + shadowT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
705 shine[i + shadowT].y2 = y + height - i - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
706
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
707 /* Bottom segments */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
708 shadow[i].x1 = x + i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
709 shadow[i].y2 = shadow[i].y1 = y + height - i - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
710 shadow[i].x2 = x + width - 1 ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
711 /* Right segments */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
712 shadow[i + shadowT].x2 = shadow[i + shadowT].x1 = x + width - i - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
713 shadow[i + shadowT].y1 = y + i + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
714 shadow[i + shadowT].y2 = y + height - 1 ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
715 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
716
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
717 XDrawSegments (dpy, d, shine_gc, shine, shadowT * 2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
718 XDrawSegments (dpy, d, shadow_gc, shadow, shadowT * 2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
719 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
720
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
721 /*------------------ Draw 3D Arrows: left, up, down, right --------------*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
722 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
723 make_vert_seg (XSegment *seg, int x1, int y1, int x2, int y2, int shadowT)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
724 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
725 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
726
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
727 for (i=0; i<shadowT; i++, seg++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
728 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
729 seg->x1 = x1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
730 seg->y1 = y1++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
731 seg->x2 = x2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
732 seg->y2 = y2++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
733 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
734 return shadowT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
735 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
736
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
737 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
738 make_hor_seg (XSegment *seg, int x1, int y1, int x2, int y2, int shadowT)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
739 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
740 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
741
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
742 for (i=0; i<shadowT; i++, seg++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
743 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
744 seg->x1 = x1++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
745 seg->y1 = y1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
746 seg->x2 = x2++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
747 seg->y2 = y2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
748 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
749 return shadowT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
750 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
751
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
752 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
753 draw_arrow_up (Display *dpy, Drawable win, GC bgGC, GC shineGC, GC shadowGC,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
754 int x, int y, int width, int height, int shadowT)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
755 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
756 XSegment shine[10], shadow[10];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
757 XPoint triangle[3];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
758 int mid;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
759
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
760 mid = width / 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
761
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
762 if (shadowT > (width / 2)) shadowT = (width / 2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
763 if (shadowT > (height / 2)) shadowT = (height / 2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
764 if (shadowT < 0) shadowT = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
765
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
766 /* / */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
767 make_vert_seg (shine,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
768 x, y + height - shadowT - 1,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
769 x + mid, y, shadowT);
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 make_vert_seg (shadow,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
772 x, y + height - shadowT - 1,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
773 x + width - 1, y + height - shadowT - 1, shadowT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
774 make_vert_seg (shadow + shadowT,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
775 x + mid, y,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
776 x + width - 1, y + height - shadowT - 1, shadowT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
777
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
778 triangle[0].x = x;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
779 triangle[0].y = y + height - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
780 triangle[1].x = x + mid;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
781 triangle[1].y = y;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
782 triangle[2].x = x + width - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
783 triangle[2].y = y + height - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
784
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
785 XFillPolygon (dpy, win, bgGC, triangle, 3, Convex, ArcChord);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
786
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
787 XDrawSegments (dpy, win, shadowGC, shadow, shadowT * 2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
788 XDrawSegments (dpy, win, shineGC, shine, shadowT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
789 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
790
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
791 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
792 draw_arrow_left (Display *dpy, Drawable win, GC bgGC, GC shineGC, GC shadowGC,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
793 int x, int y, int width, int height, int shadowT)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
794 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
795 XSegment shine[10], shadow[10];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
796 XPoint triangle[3];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
797
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
798 int mid = width / 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
799
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
800 if (shadowT > (width / 2)) shadowT = (width / 2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
801 if (shadowT > (height / 2)) shadowT = (height / 2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
802 if (shadowT < 0) shadowT = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
803
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
804 /* / */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
805 make_hor_seg (shine,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
806 x, y + mid,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
807 x + width - shadowT - 1, y, shadowT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
808 /* \| */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
809 make_hor_seg (shadow,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
810 x, y + mid,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
811 x + width - shadowT - 1, y + height - 1, shadowT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
812 make_hor_seg (shadow + shadowT,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
813 x + width - shadowT - 1, y,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
814 x + width - shadowT - 1, y + height - 1, shadowT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
815
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
816 triangle[0].x = x + width - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
817 triangle[0].y = y + height - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
818 triangle[1].x = x;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
819 triangle[1].y = y + mid;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
820 triangle[2].x = x + width - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
821 triangle[2].y = y;
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 XFillPolygon (dpy, win, bgGC, triangle, 3, Convex, ArcChord);
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 XDrawSegments (dpy, win, shadowGC, shadow, shadowT * 2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
826 XDrawSegments (dpy, win, shineGC, shine, shadowT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
827 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
828
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
829 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
830 draw_arrow_down (Display *dpy, Drawable win, GC bgGC, GC shineGC, GC shadowGC,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
831 int x, int y, int width, int height, int shadowT)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
832 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
833 XSegment shine[10], shadow[10];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
834 XPoint triangle[3];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
835 int mid;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
836
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
837 mid = width / 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
838
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
839 if (shadowT > (width / 2)) shadowT = (width / 2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
840 if (shadowT > (height / 2)) shadowT = (height / 2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
841 if (shadowT < 0) shadowT = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
842
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
843 /* \- */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
844 make_vert_seg (shine,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
845 x, y,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
846 x + mid, y + height - shadowT - 1, shadowT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
847 make_vert_seg (shine + shadowT,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
848 x, y,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
849 x + width - 1, y, shadowT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
850 /* / */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
851 make_vert_seg (shadow,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
852 x + width - 1, y,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
853 x + mid, y + height - shadowT - 1, shadowT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
854
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
855 triangle[0].x = x;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
856 triangle[0].y = y;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
857 triangle[1].x = x + mid;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
858 triangle[1].y = y + height - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
859 triangle[2].x = x + width - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
860 triangle[2].y = y;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
861
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
862 XFillPolygon (dpy, win, bgGC, triangle, 3, Convex, ArcChord);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
863
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
864 XDrawSegments (dpy, win, shadowGC, shadow, shadowT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
865 XDrawSegments (dpy, win, shineGC, shine, shadowT * 2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
866 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
867
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
868 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
869 draw_arrow_right (Display *dpy, Drawable win, GC bgGC, GC shineGC, GC shadowGC,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
870 int x, int y, int width, int height, int shadowT)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
871 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
872 XSegment shine[10], shadow[10];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
873 XPoint triangle[3];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
874 int mid;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
875
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
876 mid = width / 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
877
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
878 if (shadowT > (width / 2)) shadowT = (width / 2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
879 if (shadowT > (height / 2)) shadowT = (height / 2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
880 if (shadowT < 0) shadowT = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
881
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
882 /* |\ */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
883 make_hor_seg (shine,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
884 x, y,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
885 x + width - shadowT - 1, y + mid, shadowT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
886 make_hor_seg (shine + shadowT,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
887 x, y,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
888 x, y + height - 1, shadowT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
889 /* / */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
890 make_hor_seg (shadow,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
891 x, y + height - 1,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
892 x + width - shadowT - 1, y + mid, shadowT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
893
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
894 triangle[0].x = x + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
895 triangle[0].y = y + height - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
896 triangle[1].x = x + width - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
897 triangle[1].y = y + mid;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
898 triangle[2].x = x + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
899 triangle[2].y = y;
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 XFillPolygon (dpy, win, bgGC, triangle, 3, Convex, ArcChord);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
902
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
903 XDrawSegments (dpy, win, shadowGC, shadow, shadowT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
904 XDrawSegments (dpy, win, shineGC, shine, shadowT * 2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
905 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
906
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
907 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
908 draw_dimple (Display *dpy, Drawable win, GC shine, GC shadow,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
909 int x, int y, int width, int height)
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 XDrawArc (dpy, win, shine, x, y, width, height, 46*64, 180*64);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
912 XDrawArc (dpy, win, shadow, x, y, width, height, 45*64, -179*64);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
913 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
914
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
915 /*------- Scrollbar values -> pixels, pixels -> scrollbar values --------*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
916
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
917 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
918 seg_pixel_sizes (XlwScrollBarWidget w, int *above_return,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
919 int *ss_return, int *below_return)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
920 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
921 float total, height, fuz;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
922 int value, above, ss, below;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
923
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
924 height = widget_h (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
925 if (w->sb.showArrows) height -= (2 * arrow_h (w));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
926
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
927 value = w->sb.value - w->sb.minimum;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
928
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
929 total = w->sb.maximum - w->sb.minimum;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
930 fuz = total / 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
931
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
932 ss = (int) ((height * w->sb.sliderSize + fuz) / total);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
933 above = (int) ((height * value + fuz) / total);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
934 below = (int) ((height) - (ss + above));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
935
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
936 /* Don't let slider get smaller than SS_MIN */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
937 if (ss < SS_MIN)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
938 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
939 /* add a percent amount for integer rounding */
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
940 float tmp = (((float) (SS_MIN - ss) * (float) value) / total) + 0.5;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
941
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
942 above -= (int) tmp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
943 ss = SS_MIN;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
944 below = (int) ((height) - (ss + above));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
945
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
946 if (above < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
947 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
948 above = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
949 below = (int) (height - ss);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
950 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
951 if (below < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
952 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
953 above = (int) (height - ss);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
954 below = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
955 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
956 if (ss > height)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
957 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
958 above = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
959 ss = (int) height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
960 below = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
961 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
962 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
963
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
964 *above_return = above;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
965 *ss_return = ss;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
966 *below_return = below;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
967
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
968 CHECK (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
969 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
970
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
971 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
972 verify_values (XlwScrollBarWidget w)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
973 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
974 int total = w->sb.maximum - w->sb.minimum;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
975
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
976 if (w->sb.sliderSize > total)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
977 w->sb.sliderSize = total;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
978
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
979 if (w->sb.pageIncrement > total)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
980 w->sb.pageIncrement = total;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
981
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
982 if (w->sb.increment > total)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
983 w->sb.increment = total;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
984
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
985 if (w->sb.value < w->sb.minimum)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
986 w->sb.value = w->sb.minimum;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
987
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
988 if (w->sb.value > w->sb.maximum)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
989 w->sb.value = w->sb.maximum;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
990
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
991 if (w->sb.sliderSize > w->sb.maximum - w->sb.value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
992 w->sb.sliderSize = w->sb.maximum - w->sb.value;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
993 }
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 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
996 value_from_pixel (XlwScrollBarWidget w, int above)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
997 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
998 float total, height, fuz;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
999 int value, ss;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1000
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1001 height = widget_h (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1002 if (w->sb.showArrows)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1003 height -= (2 * arrow_h (w));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1004
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1005 total = w->sb.maximum - w->sb.minimum;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1006 fuz = height / 2;
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 ss = (int) ((height * w->sb.sliderSize + (total / 2)) / total);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1009
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1010 if (ss < SS_MIN)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1011 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1012 /* add a percent amount for integer rounding */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1013 above += (int) ((((SS_MIN - ss) * above) + fuz) / height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1014 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1015
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1016 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1017 /* Prevent SIGFPE's that would occur if we don't truncate the value. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1018 float floatval = w->sb.minimum + ((float)(above * total + fuz) / height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1019 if (floatval >= (float) INT_MAX)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1020 value = INT_MAX;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1021 else if (floatval <= (float) INT_MIN)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1022 value = INT_MIN;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1023 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1024 value = (int) floatval;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1025 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1026
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1027 return value;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1028 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1029
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1030
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1031 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1032 redraw_dimple (XlwScrollBarWidget w, Display *dpy, Window win,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1033 int x, int y, int width, int height)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1034 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1035 if (SLIDER_DIMPLE == slider_style (w))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1036 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1037 int size;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1038 int slider_p = (w->sb.armed == ARM_SLIDER);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1039 GC shine = slider_p ? w->sb.bottomShadowGC : w->sb.topShadowGC;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1040 GC shadow = slider_p ? w->sb.topShadowGC : w->sb.bottomShadowGC;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1041 int shadowT = w->sb.shadowThickness;
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 x += shadowT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1044 y += shadowT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1045 width -= 2*shadowT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1046 height -= 2*shadowT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1047
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1048 size = (width < height ? width : height) * 3 / 4;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1049
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1050 if (size%2 != (width < height ? width : height)%2) size--;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1051
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1052 DBUG (fprintf (stderr, "%d %d\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1053 x + (width / 2) - (size / 2) - 2*shadowT,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1054 width - size - shadowT));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1055
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1056 draw_dimple (dpy, win, shine, shadow,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1057 x + (width / 2) - (size / 2),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1058 y + (height / 2) - (size / 2),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1059 size, size);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1060 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1061 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1062
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1063 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1064 draw_slider (XlwScrollBarWidget w, int above, int ss, int below)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1065 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1066 Display *dpy = XtDisplay ((Widget) w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1067 Window win = XtWindow ((Widget) w);
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 int x = widget_x (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1070 int y = widget_y (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1071 int width = widget_w (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1072 int height = widget_h (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1073 int shadowT = w->sb.shadowThickness;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1074 int vert_p = VERT (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1075
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1076 if (shadowT > (width / 2)) shadowT = (width / 2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1077 if (shadowT > (height / 2)) shadowT = (height / 2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1078 if (shadowT < 0) shadowT = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1079
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1080 if (w->sb.showArrows && !arrow_same_end (w))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1081 y += arrow_h (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1082
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1083 /* trough above slider */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1084 if (above > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1085 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1086 if (vert_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1087 XClearArea (dpy, win, x, y, width, above, False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1088 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1089 XClearArea (dpy, win, y, x, above, width, False);
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 /* slider */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1093 if (vert_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1094 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1095 draw_shadows (dpy, win, w->sb.topShadowGC, w->sb.bottomShadowGC,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1096 x, y + above, width, ss, shadowT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1097 XFillRectangle (dpy, win, w->sb.backgroundGC,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1098 x+shadowT, y + above + shadowT,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1099 width-2*shadowT, ss-2*shadowT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1100 redraw_dimple (w, dpy, win, x, y + above, width, ss);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1101 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1102 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1103 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1104 draw_shadows (dpy, win, w->sb.topShadowGC, w->sb.bottomShadowGC,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1105 y + above, x, ss, width, shadowT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1106 XFillRectangle (dpy, win, w->sb.backgroundGC,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1107 y + above + shadowT, x+shadowT,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1108 ss-2*shadowT, width-2*shadowT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1109 redraw_dimple (w, dpy, win, y + above, x, ss, width);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1110 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1111
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1112 /* trough below slider */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1113 if (below > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1114 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1115 if (vert_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1116 XClearArea (dpy, win, x, y + above + ss, width, below, False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1117 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1118 XClearArea (dpy, win, y + above + ss, x, below, width, False);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1121 CHECK (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1122 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1123
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1124 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1125 redraw_up_arrow (XlwScrollBarWidget w, Boolean armed, Boolean clear_behind)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1126 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1127 Display *dpy = XtDisplay ((Widget) w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1128 Window win = XtWindow ((Widget) w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1129
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1130 int x = widget_x (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1131 int y = widget_y (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1132 int width = widget_w (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1133 int height = widget_h (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1134 int shadowT = w->sb.shadowThickness;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1135 int arrow_height = arrow_h (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1136
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1137 GC bg = w->sb.backgroundGC;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1138 GC shine = armed ? w->sb.bottomShadowGC : w->sb.topShadowGC;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1139 GC shadow = armed ? w->sb.topShadowGC : w->sb.bottomShadowGC;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1140
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1141 if (VERT (w))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1142 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1143 if (arrow_same_end (w))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1144 y += height - 2 * arrow_height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1145 if (clear_behind)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1146 XClearArea (dpy, win, x, y, width, arrow_height + 1, False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1147 draw_arrow_up (dpy, win, bg, shine, shadow,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1148 x + (width - arrow_height)/2, y,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1149 arrow_height, arrow_height, shadowT);
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 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1152 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1153 if (arrow_same_end (w))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1154 y += height - 2 * arrow_height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1155 if (clear_behind)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1156 XClearArea (dpy, win, y, x, arrow_height + 1, height, False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1157 draw_arrow_left (dpy, win, bg, shine, shadow,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1158 y, x + (width - arrow_height)/2,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1159 arrow_height, arrow_height, shadowT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1160 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1161 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1162
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1163 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1164 redraw_down_arrow (XlwScrollBarWidget w, Boolean armed, Boolean clear_behind)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1165 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1166 Display *dpy = XtDisplay ((Widget) w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1167 Window win = XtWindow ((Widget) w);
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 int x = widget_x (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1170 int y = widget_y (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1171 int width = widget_w (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1172 int height = widget_h (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1173 int shadowT = w->sb.shadowThickness;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1174 int arrow_height = arrow_h (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1175
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1176 GC bg = w->sb.backgroundGC;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1177 GC shine = armed ? w->sb.bottomShadowGC : w->sb.topShadowGC;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1178 GC shadow = armed ? w->sb.topShadowGC : w->sb.bottomShadowGC;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1179
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1180 if (VERT (w))
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 (clear_behind)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1183 XClearArea (dpy, win, x, y + height - arrow_height, width,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1184 arrow_height + 1, False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1185 draw_arrow_down (dpy, win, bg, shine, shadow,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1186 x + (width - arrow_height)/2,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1187 y + height - arrow_height + 1,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1188 arrow_height, arrow_height, shadowT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1189 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1190 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1191 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1192 if (clear_behind)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1193 XClearArea (dpy, win, y + height - arrow_height, x,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1194 arrow_height + 1, height, False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1195 draw_arrow_right (dpy, win, bg, shine, shadow,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1196 y + height - arrow_height + 1,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1197 x + (width - arrow_height)/2,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1198 arrow_height, arrow_height, shadowT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1199 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1200 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1201
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1202 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1203 redraw_everything (XlwScrollBarWidget w, Region region, Boolean behind_arrows)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1204 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1205 Display *dpy = XtDisplay ((Widget) w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1206 Window win = XtWindow ((Widget) w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1207
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1208 if (w->sb.showArrows)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1209 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1210 if (region == NULL)
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 redraw_up_arrow (w, False, behind_arrows);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1213 redraw_down_arrow (w, False, behind_arrows);
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 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1216 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1217 int x = widget_x (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1218 int y = widget_y (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1219 int width = widget_w (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1220 int height = widget_h (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1221 int arrow_height = arrow_h (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1222 int ax = x, ay = y;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1223
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1224 if (arrow_same_end (w))
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 (VERT (w))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1227 ay = y + height - arrow_height - arrow_height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1228 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1229 ax = x + height - arrow_height - arrow_height;
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 if (XRectInRegion (region, ax, ay, width, width))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1232 redraw_up_arrow (w, False, behind_arrows);
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 if (VERT (w))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1235 ay = y + height - arrow_height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1236 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1237 ax = x + height - arrow_height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1238 if (XRectInRegion (region, ax, ay, width, width))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1239 redraw_down_arrow (w, False, behind_arrows);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1240 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1241 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1242
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1243 draw_shadows (dpy, win, w->sb.bottomShadowGC, w->sb.topShadowGC, 0, 0,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1244 w->core.width, w->core.height, w->sb.shadowThickness);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1245
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1246 draw_slider (w, w->sb.above, w->sb.ss, w->sb.below);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1249 /*-------------------------- Method Functions ---------------------------*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1250
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1251 static void
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1389
diff changeset
1252 Initialize (Widget treq, Widget tnew, ArgList UNUSED (args),
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1389
diff changeset
1253 Cardinal *UNUSED (num_args))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1254 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1255 XlwScrollBarWidget request = (XlwScrollBarWidget) treq;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1256 XlwScrollBarWidget w = (XlwScrollBarWidget) tnew;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1257 Display *dpy = XtDisplay ((Widget) w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1258 Window win = RootWindowOfScreen (DefaultScreenOfDisplay (dpy));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1259
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1260 if (request->core.width == 0) w->core.width += (VERT (w) ? 12 : 25);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1261 if (request->core.height == 0) w->core.height += (VERT (w) ? 25 : 12);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1262
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1263 verify_values (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1264
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1265 w->sb.lastY = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1266 w->sb.above = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1267 w->sb.ss = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1268 w->sb.below = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1269 w->sb.armed = ARM_NONE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1270 w->sb.forced_scroll = FORCED_SCROLL_NONE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1271
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1272 if (w->sb.shadowThickness > 5) w->sb.shadowThickness = 5;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1273
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1274 w->sb.grayPixmap =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1275 XCreatePixmapFromBitmapData (dpy, win, (char *) gray_bits, gray_width,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1276 gray_height, 1, 0, 1);
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 make_trough_pixel (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1279
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1280 make_shadow_pixels (w);
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 w->sb.backgroundGC =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1283 get_gc (w, w->core.background_pixel, w->core.background_pixel, None);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1284 w->sb.topShadowGC =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1285 get_gc (w, w->sb.topShadowColor, w->core.background_pixel,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1286 w->sb.topShadowPixmap);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1287 w->sb.bottomShadowGC =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1288 get_gc (w, w->sb.bottomShadowColor, w->core.background_pixel,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1289 w->sb.bottomShadowPixmap);
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 w->sb.fullRedrawNext = True;
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 w->sb.timerActive = False;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1294 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1295
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1296 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1297 Destroy (Widget widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1298 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1299 XlwScrollBarWidget w = (XlwScrollBarWidget) widget;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1300 Display *dpy = XtDisplay ((Widget) w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1301
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1302 XtReleaseGC (widget, w->sb.bottomShadowGC);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1303 XtReleaseGC (widget, w->sb.topShadowGC);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1304 XtReleaseGC (widget, w->sb.backgroundGC);
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 XFreePixmap (dpy, w->sb.grayPixmap);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1307
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1308 if (w->sb.timerActive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1309 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1310 XtRemoveTimeOut (w->sb.timerId);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1311 w->sb.timerActive = False; /* Should be a no-op, but you never know */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1312 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1313 }
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 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1316 Realize (Widget widget, XtValueMask *valuemask, XSetWindowAttributes *attr)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1317 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1318 XlwScrollBarWidget w = (XlwScrollBarWidget) widget;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1319 Display *dpy = XtDisplay ((Widget) w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1320 Window win;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1321 XSetWindowAttributes win_attr;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1322
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1323 (*coreClassRec.core_class.realize)(widget, valuemask, attr);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1324
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1325 win = XtWindow ((Widget) w);
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 seg_pixel_sizes (w, &w->sb.above, &w->sb.ss, &w->sb.below);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1328
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1329 XSetWindowBackground (dpy, win, w->sb.troughColor);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1330
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1331 /* Change bit gravity so widget is not cleared on resize */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1332 win_attr.bit_gravity = NorthWestGravity;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1333 XChangeWindowAttributes (dpy, win, CWBitGravity , &win_attr);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1334
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1335 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1336
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1337 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1338 Resize (Widget widget)
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 XlwScrollBarWidget w = (XlwScrollBarWidget) widget;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1341 Display *dpy = XtDisplay ((Widget) w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1342 Window win = XtWindow ((Widget) w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1343
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1344 if (XtIsRealized (widget))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1345 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1346 DBUG (fprintf (stderr, "Resize = %08lx\n", w));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1347
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1348 seg_pixel_sizes (w, &w->sb.above, &w->sb.ss, &w->sb.below);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1349
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1350 /* redraw_everything (w, NULL, True); */
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 w->sb.fullRedrawNext = True;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1353 /* Force expose event */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1354 XClearArea (dpy, win, widget_x (w), widget_y (w), 1, 1, True);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1355 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1356
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1357 if (w->sb.timerActive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1358 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1359 XtRemoveTimeOut (w->sb.timerId);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1360 w->sb.timerActive = False;
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 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1363
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1364 static void
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1389
diff changeset
1365 Redisplay (Widget widget, XEvent *UNUSED (event), Region region)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1366 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1367 XlwScrollBarWidget w = (XlwScrollBarWidget) widget;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1368
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1369 DBUG (fprintf (stderr, "Redisplay = %08lx\n", w));
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 (XtIsRealized (widget))
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 (w->sb.fullRedrawNext)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1374 redraw_everything (w, NULL, True);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1375 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1376 redraw_everything (w, region, False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1377 w->sb.fullRedrawNext = False;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1378 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1379 }
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 static Boolean
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1389
diff changeset
1382 SetValues (Widget current, Widget UNUSED (request), Widget neww,
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1389
diff changeset
1383 ArgList UNUSED (args), Cardinal *UNUSED (num_args))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1384 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1385 XlwScrollBarWidget cur = (XlwScrollBarWidget) current;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1386 XlwScrollBarWidget w = (XlwScrollBarWidget) neww;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1387 Boolean do_redisplay = False;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1388
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1389 if (cur->sb.troughColor != w->sb.troughColor)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1390 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1391 if (XtIsRealized ((Widget) w))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1392 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1393 XSetWindowBackground (XtDisplay((Widget) w), XtWindow ((Widget) w),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1394 w->sb.troughColor);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1395 do_redisplay = True;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1396 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1397 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1398
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1399 if (cur->core.background_pixel != w->core.background_pixel)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1400 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1401 XtReleaseGC ((Widget)cur, cur->sb.backgroundGC);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1402 w->sb.backgroundGC =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1403 get_gc (w, w->core.background_pixel, w->core.background_pixel, None);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1404 do_redisplay = True;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1405 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1406
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1407 if (cur->sb.topShadowColor != w->sb.topShadowColor ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1408 cur->sb.topShadowPixmap != w->sb.topShadowPixmap)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1409 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1410 XtReleaseGC ((Widget)cur, cur->sb.topShadowGC);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1411 w->sb.topShadowGC =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1412 get_gc (w, w->sb.topShadowColor, w->core.background_pixel,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1413 w->sb.topShadowPixmap);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1414 do_redisplay = True;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1415 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1416
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1417 if (cur->sb.bottomShadowColor != w->sb.bottomShadowColor ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1418 cur->sb.bottomShadowPixmap != w->sb.bottomShadowPixmap)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1419 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1420 XtReleaseGC ((Widget)cur, cur->sb.bottomShadowGC);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1421 w->sb.bottomShadowGC =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1422 get_gc (w, w->sb.bottomShadowColor, w->core.background_pixel,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1423 w->sb.bottomShadowPixmap);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1424 do_redisplay = True;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1425 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1426
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1427 if (cur->sb.orientation != w->sb.orientation)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1428 do_redisplay = True;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1429
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1430
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1431 if (cur->sb.minimum != w->sb.minimum ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1432 cur->sb.maximum != w->sb.maximum ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1433 cur->sb.sliderSize != w->sb.sliderSize ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1434 cur->sb.value != w->sb.value ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1435 cur->sb.pageIncrement != w->sb.pageIncrement ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1436 cur->sb.increment != w->sb.increment)
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 verify_values (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1439 if (XtIsRealized ((Widget) w))
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 seg_pixel_sizes (w, &w->sb.above, &w->sb.ss, &w->sb.below);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1442 draw_slider (w, w->sb.above, w->sb.ss, w->sb.below);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1443 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1444 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1445
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1446 if (w->sb.shadowThickness > 5) w->sb.shadowThickness = 5;
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 return do_redisplay;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1449 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1450
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1451 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1452 XlwScrollBarGetValues (Widget widget, int *value, int *sliderSize,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1453 int *increment, int *pageIncrement)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1454 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1455 XlwScrollBarWidget w = (XlwScrollBarWidget) widget;
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 (w && XtClass ((Widget) w) == xlwScrollBarWidgetClass)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1458 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1459 if (value) *value = w->sb.value;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1460 if (sliderSize) *sliderSize = w->sb.sliderSize;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1461 if (increment) *increment = w->sb.increment;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1462 if (pageIncrement) *pageIncrement = w->sb.pageIncrement;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1466 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1467 XlwScrollBarSetValues (Widget widget, int value, int sliderSize,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1468 int increment, int pageIncrement, Boolean notify)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1469 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1470 XlwScrollBarWidget w = (XlwScrollBarWidget) widget;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1471
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1472 if (w && XtClass ((Widget) w) == xlwScrollBarWidgetClass &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1473 (w->sb.value != value ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1474 w->sb.sliderSize != sliderSize ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1475 w->sb.increment != increment ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1476 w->sb.pageIncrement != pageIncrement))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1477 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1478 int last_value = w->sb.value;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1479
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1480 w->sb.value = value;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1481 w->sb.sliderSize = sliderSize;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1482 w->sb.increment = increment;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1483 w->sb.pageIncrement = pageIncrement;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1484
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1485 verify_values (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1486
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1487 if (XtIsRealized (widget))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1488 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1489 seg_pixel_sizes (w, &w->sb.above, &w->sb.ss, &w->sb.below);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1490 draw_slider (w, w->sb.above, w->sb.ss, w->sb.below);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1491
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1492 if (w->sb.value != last_value && notify)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1493 call_callbacks (w, XmCR_VALUE_CHANGED, w->sb.value, 0, NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1494 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1495 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1496 }
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 /*-------------------------- Action Functions ---------------------------*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1499
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1500 static void
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1389
diff changeset
1501 timer (XtPointer data, XtIntervalId *UNUSED (id))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1502 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1503 XlwScrollBarWidget w = (XlwScrollBarWidget) data;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1504 w->sb.timerActive = False;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1505
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1506 if (w->sb.armed != ARM_NONE)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1507 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1508 int last_value = w->sb.value;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1509 int reason;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1510
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1511 switch (w->sb.armed)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1512 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1513 case ARM_PAGEUP:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1514 decrement_value (w, w->sb.pageIncrement);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1515 reason = XmCR_PAGE_DECREMENT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1516 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1517 case ARM_PAGEDOWN:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1518 increment_value (w, w->sb.pageIncrement);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1519 reason = XmCR_PAGE_INCREMENT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1520 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1521 case ARM_UP:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1522 decrement_value (w, w->sb.increment);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1523 reason = XmCR_DECREMENT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1524 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1525 case ARM_DOWN:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1526 increment_value (w, w->sb.increment);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1527 reason = XmCR_INCREMENT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1528 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1529 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1530 reason = XmCR_NONE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1531 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1532
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1533 verify_values (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1534
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1535 if (last_value != w->sb.value)
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 seg_pixel_sizes (w, &w->sb.above, &w->sb.ss, &w->sb.below);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1538 draw_slider (w, w->sb.above, w->sb.ss, w->sb.below);
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 call_callbacks (w, reason, w->sb.value, 0, NULL);
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 w->sb.timerId =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1543 XtAppAddTimeOut (XtWidgetToApplicationContext ((Widget) w),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1544 (unsigned long) w->sb.repeatDelay,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1545 timer, (XtPointer) w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1546 w->sb.timerActive = True;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1547 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1548 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1549 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1550
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1551 static button_where
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1552 what_button (XlwScrollBarWidget w, int mouse_x, int mouse_y)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1553 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1554 int width = widget_w (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1555 int height = widget_h (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1556 int arrow_height = arrow_h (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1557
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1558 mouse_x -= widget_x (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1559 mouse_y -= widget_y (w);
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 if (mouse_x < 0 || mouse_x >= width ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1562 mouse_y < 0 || mouse_y >= height)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1563 return BUTTON_NONE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1564
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1565 if (w->sb.showArrows)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1566 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1567 if (mouse_y >= (height -= arrow_height))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1568 return BUTTON_DOWN_ARROW;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1569
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1570 if (arrow_same_end (w))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1571 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1572 if (mouse_y >= (height -= arrow_height))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1573 return BUTTON_UP_ARROW;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1574 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1575 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1576 if ( (mouse_y -= arrow_height) < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1577 return BUTTON_UP_ARROW;
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 if ( (mouse_y -= w->sb.above) < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1581 return BUTTON_TROUGH_ABOVE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1582
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1583 if ( (mouse_y -= w->sb.ss) < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1584 return BUTTON_SLIDER;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1585
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1586 return BUTTON_TROUGH_BELOW;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1587 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1588
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1589 static void
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1389
diff changeset
1590 Select (Widget widget, XEvent *event, String *UNUSED (parms),
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1389
diff changeset
1591 Cardinal *UNUSED (num_parms))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1592 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1593 XlwScrollBarWidget w = (XlwScrollBarWidget) widget;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1594 button_where sb_button;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1595
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1596 int mouse_x = event_x (w, event);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1597 int mouse_y = event_y (w, event);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1598
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1599 int last_value = w->sb.savedValue = w->sb.value;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1600 int reason = XmCR_NONE;
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 XtGrabKeyboard ((Widget) w, False, GrabModeAsync, GrabModeAsync,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1603 event->xbutton.time);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1604
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1605 sb_button = what_button (w, mouse_x, mouse_y);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1606
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1607 if (w->sb.forced_scroll != FORCED_SCROLL_NONE)
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 switch (sb_button)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1610 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1611 case BUTTON_TROUGH_ABOVE:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1612 case BUTTON_TROUGH_BELOW:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1613 case BUTTON_SLIDER:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1614 sb_button= BUTTON_NONE; /* cause next switch to fall through */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1615 if (w->sb.forced_scroll == FORCED_SCROLL_UPLEFT)
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 decrement_value (w, w->sb.pageIncrement);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1618 w->sb.armed = ARM_PAGEUP;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1619 reason = XmCR_PAGE_DECREMENT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1620 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1621 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1622 else if (w->sb.forced_scroll == FORCED_SCROLL_DOWNRIGHT)
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 increment_value (w, w->sb.pageIncrement);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1625 w->sb.armed = ARM_PAGEDOWN;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1626 reason = XmCR_PAGE_INCREMENT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1627 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1628 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1629 abort();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1630 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1631 ; /* Do nothing */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1632 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1633 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1634
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1635 switch (sb_button)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1636 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1637 case BUTTON_TROUGH_ABOVE:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1638 decrement_value (w, w->sb.pageIncrement);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1639 w->sb.armed = ARM_PAGEUP;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1640 reason = XmCR_PAGE_DECREMENT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1641 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1642 case BUTTON_TROUGH_BELOW:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1643 increment_value (w, w->sb.pageIncrement);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1644 w->sb.armed = ARM_PAGEDOWN;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1645 reason = XmCR_PAGE_INCREMENT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1646 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1647 case BUTTON_SLIDER:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1648 w->sb.lastY = mouse_y;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1649 w->sb.armed = ARM_SLIDER;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1650 draw_slider (w, w->sb.above, w->sb.ss, w->sb.below);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1651 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1652 case BUTTON_UP_ARROW:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1653 if (event->xbutton.state & ControlMask)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1654 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1655 w->sb.value = w->sb.minimum;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1656 reason = XmCR_TO_TOP;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1657 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1658 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1659 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1660 decrement_value (w, w->sb.increment);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1661 reason = XmCR_DECREMENT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1662 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1663 w->sb.armed = ARM_UP;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1664 redraw_up_arrow (w, True, False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1665 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1666 case BUTTON_DOWN_ARROW:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1667 if (event->xbutton.state & ControlMask)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1668 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1669 w->sb.value = w->sb.maximum;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1670 reason = XmCR_TO_BOTTOM;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1671 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1672 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1673 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1674 increment_value (w, w->sb.increment);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1675 reason = XmCR_INCREMENT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1676 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1677 w->sb.armed = ARM_DOWN;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1678 redraw_down_arrow (w, True, False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1679 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1680 case BUTTON_NONE:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1681 ; /* Do nothing */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1682 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1683
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1684 verify_values (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1685
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1686 if (last_value != w->sb.value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1687 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1688 seg_pixel_sizes (w, &w->sb.above, &w->sb.ss, &w->sb.below);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1689 draw_slider (w, w->sb.above, w->sb.ss, w->sb.below);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1690
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1691 call_callbacks (w, reason, w->sb.value, mouse_y, event);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1692
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1693 if (w->sb.timerActive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1694 XtRemoveTimeOut (w->sb.timerId);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1695
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1696 w->sb.timerId =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1697 XtAppAddTimeOut (XtWidgetToApplicationContext ((Widget) w),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1698 (unsigned long) w->sb.initialDelay,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1699 timer, (XtPointer) w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1700 w->sb.timerActive = True;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1701 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1702
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1703 CHECK (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1704 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1705
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1706 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1707 PageDownOrRight (Widget widget, XEvent *event, String *parms, Cardinal *num_parms)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1708 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1709 XlwScrollBarWidget w = (XlwScrollBarWidget) widget;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1710 w->sb.forced_scroll = FORCED_SCROLL_DOWNRIGHT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1711 Select (widget, event, parms, num_parms);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1712 w->sb.forced_scroll = FORCED_SCROLL_NONE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1713 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1714
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1715 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1716 PageUpOrLeft (Widget widget, XEvent *event, String *parms, Cardinal *num_parms)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1717 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1718 XlwScrollBarWidget w = (XlwScrollBarWidget) widget;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1719 w->sb.forced_scroll = FORCED_SCROLL_UPLEFT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1720 Select (widget, event, parms, num_parms);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1721 w->sb.forced_scroll = FORCED_SCROLL_NONE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1722 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1723
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1724 static void
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1389
diff changeset
1725 Drag (Widget widget, XEvent *event, String *UNUSED (parms),
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1389
diff changeset
1726 Cardinal *UNUSED (num_parms))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1727 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1728 XlwScrollBarWidget w = (XlwScrollBarWidget) widget;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1729
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1730 if (w->sb.armed == ARM_SLIDER)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1731 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1732 int mouse_y = event_y (w, event);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1733 int diff = mouse_y - w->sb.lastY;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1734
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1735 if (diff < -(w->sb.above)) /* up */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1736 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1737 mouse_y -= (diff + w->sb.above);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1738 diff = -(w->sb.above);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1739 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1740 else if (diff > w->sb.below) /* down */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1741 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1742 mouse_y -= (diff - w->sb.below);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1743 diff = w->sb.below;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1744 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1745
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1746 if (diff)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1747 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1748 w->sb.above += diff;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1749 w->sb.below -= diff;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1750
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1751 draw_slider (w, w->sb.above, w->sb.ss, w->sb.below);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1752
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1753 w->sb.lastY = mouse_y;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1754
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1755 w->sb.value = value_from_pixel (w, w->sb.above);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1756 verify_values (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1757 CHECK (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1758
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1759 call_callbacks (w, XmCR_DRAG, w->sb.value, event_y (w, event), event);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1760 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1761 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1762 CHECK (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1763 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1764
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1765 static void
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1389
diff changeset
1766 Release (Widget widget, XEvent *event, String *UNUSED (parms),
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1389
diff changeset
1767 Cardinal *UNUSED (num_parms))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1768 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1769 XlwScrollBarWidget w = (XlwScrollBarWidget) widget;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1770
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1771 switch (w->sb.armed)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1772 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1773 case ARM_SLIDER:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1774 call_callbacks (w, XmCR_VALUE_CHANGED, w->sb.value, event_y (w, event), event);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1775 w->sb.armed = ARM_NONE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1776 draw_slider (w, w->sb.above, w->sb.ss, w->sb.below);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1777 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1778 case ARM_UP:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1779 redraw_up_arrow (w, False, False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1780 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1781 case ARM_DOWN:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1782 redraw_down_arrow (w, False, False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1783 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1784 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1785 ; /* Do nothing */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1786 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1787
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1788 XtUngrabKeyboard ((Widget) w, event->xbutton.time);
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 w->sb.armed = ARM_NONE;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1793 static void
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1389
diff changeset
1794 Jump (Widget widget, XEvent *event, String *UNUSED (parms),
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1389
diff changeset
1795 Cardinal *UNUSED (num_parms))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1796 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1797 XlwScrollBarWidget w = (XlwScrollBarWidget) widget;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1798 int last_value;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1799
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1800 int mouse_x = event_x (w, event);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1801 int mouse_y = event_y (w, event);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1802
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1803 int scroll_region_y = widget_y (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1804 int scroll_region_h = widget_h (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1805
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1806 if (w->sb.showArrows)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1807 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1808 int arrow_height = arrow_h (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1809 scroll_region_h -= 2 * arrow_height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1810 if (!arrow_same_end (w))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1811 scroll_region_y += arrow_height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1812 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1813
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1814 XtGrabKeyboard ((Widget) w, False, GrabModeAsync, GrabModeAsync,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1815 event->xbutton.time);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1816
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1817 switch (what_button (w, mouse_x, mouse_y))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1818 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1819 case BUTTON_TROUGH_ABOVE:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1820 case BUTTON_TROUGH_BELOW:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1821 case BUTTON_SLIDER:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1822 w->sb.savedValue = w->sb.value;
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 last_value = w->sb.value;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1825
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1826 w->sb.above = mouse_y - (w->sb.ss / 2) - scroll_region_y;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1827 if (w->sb.above < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1828 w->sb.above = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1829 else if (w->sb.above + w->sb.ss > scroll_region_h)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1830 w->sb.above = scroll_region_h - w->sb.ss;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1831
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1832 w->sb.below = scroll_region_h - w->sb.ss - w->sb.above;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1833
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1834 w->sb.armed = ARM_SLIDER;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1835 draw_slider (w, w->sb.above, w->sb.ss, w->sb.below);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1836
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1837 w->sb.value = value_from_pixel (w, w->sb.above);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1838 verify_values (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1839 CHECK (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1840
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1841 w->sb.lastY = mouse_y;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1842
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1843 if (w->sb.value != last_value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1844 call_callbacks (w, XmCR_DRAG, w->sb.value, mouse_y, event);
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 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1847 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1848 ; /* Do nothing */
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 CHECK (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1851 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1852
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1853 static void
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1389
diff changeset
1854 Abort (Widget widget, XEvent *event, String *UNUSED (parms),
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1389
diff changeset
1855 Cardinal *UNUSED (num_parms))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1856 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1857 XlwScrollBarWidget w = (XlwScrollBarWidget) widget;
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 if (w->sb.armed != ARM_NONE)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1860 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1861 if (w->sb.value != w->sb.savedValue)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1862 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1863 w->sb.value = w->sb.savedValue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1864
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1865 seg_pixel_sizes (w, &w->sb.above, &w->sb.ss, &w->sb.below);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1866 draw_slider (w, w->sb.above, w->sb.ss, w->sb.below);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1867
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1868 call_callbacks (w, XmCR_VALUE_CHANGED, w->sb.value,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1869 event_y (w, event), event);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1870 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1871
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1872 switch (w->sb.armed)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1873 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1874 case ARM_UP: redraw_up_arrow (w, False, False); break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1875 case ARM_DOWN: redraw_down_arrow (w, False, False); break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1876 default: ; /* Do nothing */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1877 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1878
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1879 w->sb.armed = ARM_NONE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1880
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1881 XtUngrabKeyboard ((Widget) w, event->xbutton.time);
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 }