annotate lwlib/xlwscrollbar.c @ 442:abe6d1db359e r21-2-36

Import from CVS: tag r21-2-36
author cvs
date Mon, 13 Aug 2007 11:35:02 +0200
parents 9d177e8d4150
children 7b8fc81f9587
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7 The Lucid Widget Library is free software; you can redistribute it and/or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8 modify it under the terms of the GNU General Public License as published by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9 the Free Software Foundation; either version 2, or (at your option)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10 any later version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12 The Lucid Widget Library is distributed in the hope that it will be useful,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15 GNU General Public License for more details.
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18 along with XEmacs; see the file COPYING. If not, write to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20 Boston, MA 02111-1307, USA. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22 /* Created by Douglas Keller <dkeller@vnet.ibm.com> */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23 /* Lots of hacking by Martin Buchholz */
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26 * 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
27 * by Jonathan Stigelman <Stig@hackvan.com>... Ho ho ho!
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29 * To use them, put this resource in your .Xdefaults
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31 * Emacs*XlwScrollBar.translations: #override \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32 * <Btn1Down>: PageDownOrRight() \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33 * <Btn3Down>: PageUpOrLeft()
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80 #include "xlwscrollbarP.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81 #include "xlwscrollbar.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 #ifdef USE_DEBUG_MALLOC
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84 #include <dmalloc.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87 #define DBUG(x)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 #define MINL(x,y) ((((unsigned long) (x)) < ((unsigned long) (y))) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 ? ((unsigned long) (x)) : ((unsigned long) (y)))
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 VERT(w) ((w)->sb.orientation == XmVERTICAL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 #define SS_MIN 8
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 typedef enum
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 BUTTON_NONE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 BUTTON_SLIDER,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 BUTTON_UP_ARROW,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 BUTTON_DOWN_ARROW,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 BUTTON_TROUGH_ABOVE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 BUTTON_TROUGH_BELOW
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 } button_where;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106 typedef enum
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 SLIDER_PLAIN,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 SLIDER_DIMPLE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 } SliderStyle;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112 /*-------------------------- Resources ----------------------------------*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113 #define offset(field) XtOffset(XlwScrollBarWidget, field)
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 static XtResource resources[] = {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116 { XmNforeground, XmCForeground, XtRPixel, sizeof(Pixel),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117 offset(sb.foreground), XtRImmediate, (XtPointer) XtDefaultForeground },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119 { XmNtopShadowColor, XmCTopShadowColor, XtRPixel,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120 sizeof(Pixel), offset(sb.topShadowColor), XtRImmediate, (XtPointer) ~0 },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 { XmNbottomShadowColor, XmCBottomShadowColor, XtRPixel,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122 sizeof(Pixel), offset(sb.bottomShadowColor), XtRImmediate,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123 (XtPointer)~0 },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125 { XmNtopShadowPixmap, XmCTopShadowPixmap, XtRPixmap,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126 sizeof (Pixmap), offset(sb.topShadowPixmap), XtRImmediate,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 (XtPointer)None},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128 { XmNbottomShadowPixmap, XmCBottomShadowPixmap,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 XtRPixmap, sizeof (Pixmap), offset(sb.bottomShadowPixmap),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130 XtRImmediate, (XtPointer)None},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132 { XmNtroughColor, XmCTroughColor, XtRPixel, sizeof(Pixel),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133 offset(sb.troughColor), XtRImmediate, (XtPointer)~0 },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135 { XmNshadowThickness, XmCShadowThickness, XtRInt,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136 sizeof(int), offset(sb.shadowThickness), XtRImmediate, (XtPointer)2 },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138 { XmNborderWidth, XmCBorderWidth, XtRDimension,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
139 sizeof(Dimension), offset(core.border_width), XtRImmediate,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140 (XtPointer)0 },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142 { XmNshowArrows, XmCShowArrows, XtRBoolean,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143 sizeof(Boolean), offset(sb.showArrows), XtRImmediate, (XtPointer)True },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
144
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145 { XmNinitialDelay, XmCInitialDelay, XtRInt, sizeof(int),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146 offset(sb.initialDelay), XtRImmediate, (XtPointer) 250 },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147 { XmNrepeatDelay, XmCRepeatDelay, XtRInt, sizeof(int),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 offset(sb.repeatDelay), XtRImmediate, (XtPointer) 50 },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150 { XmNorientation, XmCOrientation, XtROrientation,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151 sizeof(unsigned char), offset(sb.orientation), XtRImmediate,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152 (XtPointer) XmVERTICAL },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154 { XmNminimum, XmCMinimum, XtRInt, sizeof(int),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155 offset(sb.minimum), XtRImmediate, (XtPointer) 0},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156 { XmNmaximum, XmCMaximum, XtRInt, sizeof(int),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 offset(sb.maximum), XtRImmediate, (XtPointer) 100},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158 { XmNvalue, XmCValue, XtRInt, sizeof(int),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159 offset(sb.value), XtRImmediate, (XtPointer) 0},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 { XmNsliderSize, XmCSliderSize, XtRInt, sizeof(int),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 offset(sb.sliderSize), XtRImmediate, (XtPointer) 10},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 { XmNincrement, XmCIncrement, XtRInt, sizeof(int),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163 offset(sb.increment), XtRImmediate, (XtPointer) 1},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164 { XmNpageIncrement, XmCPageIncrement, XtRInt, sizeof(int),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 offset(sb.pageIncrement), XtRImmediate, (XtPointer) 10},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167 { XmNvalueChangedCallback, XmCValueChangedCallback,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168 XtRCallback, sizeof(XtPointer), offset(sb.valueChangedCBL),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169 XtRCallback, NULL},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170 { XmNincrementCallback, XmCIncrementCallback,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171 XtRCallback, sizeof(XtPointer), offset(sb.incrementCBL),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172 XtRCallback, NULL},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173 { XmNdecrementCallback, XmCDecrementCallback,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174 XtRCallback, sizeof(XtPointer), offset(sb.decrementCBL),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 XtRCallback, NULL},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176 { XmNpageIncrementCallback, XmCPageIncrementCallback,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177 XtRCallback, sizeof(XtPointer), offset(sb.pageIncrementCBL),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178 XtRCallback, NULL},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179 { XmNpageDecrementCallback, XmCPageDecrementCallback,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 XtRCallback, sizeof(XtPointer), offset(sb.pageDecrementCBL),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 XtRCallback, NULL},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182 { XmNtoTopCallback, XmCToTopCallback, XtRCallback,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 sizeof(XtPointer), offset(sb.toTopCBL), XtRCallback, NULL},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184 { XmNtoBottomCallback, XmCToBottomCallback, XtRCallback,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185 sizeof(XtPointer), offset(sb.toBottomCBL), XtRCallback, NULL},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186 { XmNdragCallback, XmCDragCallback, XtRCallback,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187 sizeof(XtPointer), offset(sb.dragCBL), XtRCallback, NULL},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 /* "knob" is obsolete; use "slider" instead. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190 { XmNsliderStyle, XmCSliderStyle, XtRString, sizeof(char *),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191 offset(sb.sliderStyle), XtRImmediate, NULL},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192 { XmNknobStyle, XmCKnobStyle, XtRString, sizeof(char *),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193 offset(sb.knobStyle), XtRImmediate, NULL},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195 { XmNarrowPosition, XmCArrowPosition, XtRString, sizeof(char *),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196 offset(sb.arrowPosition), XtRImmediate, NULL},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
199 /*-------------------------- Prototypes ---------------------------------*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
200
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
201 /* Actions */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
202 typedef void Action(Widget w, XEvent *event, String *parms, Cardinal *num_parms);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 static Action Select, PageUpOrLeft, PageDownOrRight, Drag, Release, Jump, Abort;
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 /* Methods */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206 static void Initialize(Widget treq, Widget tnew, ArgList args, Cardinal *num_args);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207 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
208 static void Destroy(Widget widget);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 static void Redisplay(Widget widget, XEvent *event, Region region);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210 static void Resize(Widget widget);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 static void Realize(Widget widget, XtValueMask *valuemask, XSetWindowAttributes *attr);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213 /* Private */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215 /*-------------------------- Actions Table ------------------------------*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
216 static XtActionsRec actions[] =
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 {"Select", Select},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
219 {"PageDownOrRight", PageDownOrRight},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
220 {"PageUpOrLeft", PageUpOrLeft},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
221 {"Drag", Drag},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
222 {"Release", Release},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223 {"Jump", Jump},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
224 {"Abort", Abort},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
225 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
226
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227 /*--------------------- Default Translation Table -----------------------*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228 static char default_translations[] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229 "<Btn1Down>: Select()\n"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
230 "<Btn1Motion>: Drag()\n"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231 "<Btn1Up>: Release()\n"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
232 "<Btn2Down>: Jump()\n"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233 "<Btn2Motion>: Drag()\n"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
234 "<Btn2Up>: Release()\n"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
235 "<Key>Delete: Abort()"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236 ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
238 /*------------------- Class record initialization -----------------------*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
239 XlwScrollBarClassRec xlwScrollBarClassRec = {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
240 /* core_class fields */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
241 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242 /* superclass */ (WidgetClass) &coreClassRec,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
243 /* class_name */ "XlwScrollBar",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
244 /* widget_size */ sizeof(XlwScrollBarRec),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
245 /* class_initialize */ NULL,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
246 /* class_part_init */ NULL,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
247 /* class_inited */ False,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
248 /* initialize */ Initialize,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
249 /* initialize_hook */ NULL,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250 /* realize */ Realize,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
251 /* actions */ actions,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252 /* num_actions */ XtNumber(actions),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253 /* resources */ resources,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
254 /* num_resources */ XtNumber(resources),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
255 /* xrm_class */ NULLQUARK,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
256 /* compress_motion */ True,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
257 /* compress_exposure */ XtExposeCompressMultiple,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
258 /* compress_enterleave */ True,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
259 /* visible_interest */ False,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260 /* destroy */ Destroy,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
261 /* resize */ Resize,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
262 /* expose */ Redisplay,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
263 /* set_values */ SetValues,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264 /* set_values_hook */ NULL,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
265 /* set_values_almost */ XtInheritSetValuesAlmost,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
266 /* get_values_hook */ NULL,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267 /* accept_focus */ NULL,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268 /* version */ XtVersionDontCheck,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269 /* callback_private */ NULL,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270 /* tm_table */ default_translations,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
271 /* query_geometry */ NULL,
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 /* scrollbar_class fields */
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 /* dummy_field */ 0,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276 },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
279 WidgetClass xlwScrollBarWidgetClass = (WidgetClass) &xlwScrollBarClassRec;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
280
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
281 /*-------------------------- Debug Functions ----------------------------*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
282
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283 #ifdef SHOW_CLEAR
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285 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
286 Boolean exp, XlwScrollBarWidget widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
287 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288 XFillRectangle (dpy, d, widget->sb.topShadowGC, x, y, w, h);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289 XSync (dpy, False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
290 sleep (2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291 XClearArea (dpy, d, x, y, w, h, exp);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
294 #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
295 #endif
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 #ifdef CHECK_VALUES
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
299 check(XlwScrollBarWidget w)
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 int height = widget_h (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
302 if (w->sb.showArrows)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
303 height -= (2 * arrow_h (w));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
304
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
305 if ((w->sb.above + w->sb.ss + w->sb.below > height) ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306 (w->sb.value < w->sb.minimum) ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
307 (w->sb.value > w->sb.maximum - w->sb.sliderSize))
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 printf("above=%d ss=%d below=%d height=%d\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310 w->sb.above, w->sb.ss, w->sb.below, height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
311 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
312 w->sb.value, w->sb.minimum, w->sb.maximum,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
313 w->sb.sliderSize, w->sb.maximum - w->sb.sliderSize);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
314 abort();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
315 }
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
318 # define CHECK(w) check(w)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
320 # define CHECK(w)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
321 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
322
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
323 /*-------------------------- Static functions ---------------------------*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
324
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
325 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
326 call_callbacks (XlwScrollBarWidget w, int reason,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
327 int value, int pixel, XEvent *event)
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 XlwScrollBarCallbackStruct cbs;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
330 Boolean called_anything;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
331
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
332 cbs.reason = reason;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
333 cbs.event = event;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
334 cbs.value = value;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
335 cbs.pixel = pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
336
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
337 called_anything = False;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
338
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
339 switch (reason)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
340 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
341 case XmCR_VALUE_CHANGED:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
342 XtCallCallbackList ((Widget) w, w->sb.valueChangedCBL, &cbs);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
343 called_anything = True;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
344 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
345 case XmCR_INCREMENT:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
346 if (w->sb.incrementCBL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
347 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
348 XtCallCallbackList ((Widget) w, w->sb.incrementCBL, &cbs);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
349 called_anything = True;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
350 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
351 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
352 case XmCR_DECREMENT:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
353 if (w->sb.decrementCBL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
354 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
355 XtCallCallbackList ((Widget) w, w->sb.decrementCBL, &cbs);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
356 called_anything = True;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
357 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
358 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
359 case XmCR_PAGE_INCREMENT:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
360 if (w->sb.incrementCBL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
361 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
362 XtCallCallbackList ((Widget) w, w->sb.pageIncrementCBL, &cbs);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
363 called_anything = True;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
364 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
365 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
366 case XmCR_PAGE_DECREMENT:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
367 if (w->sb.decrementCBL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
368 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369 XtCallCallbackList ((Widget) w, w->sb.pageDecrementCBL, &cbs);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370 called_anything = True;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
371 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
372 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
373 case XmCR_TO_TOP:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
374 if (w->sb.toTopCBL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
375 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
376 XtCallCallbackList ((Widget) w, w->sb.toTopCBL, &cbs);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
377 called_anything = True;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
378 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
379 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
380 case XmCR_TO_BOTTOM:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
381 if (w->sb.toBottomCBL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
382 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
383 XtCallCallbackList ((Widget) w, w->sb.toBottomCBL, &cbs);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
384 called_anything = True;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
385 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
386 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
387 case XmCR_DRAG:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
388 if (w->sb.dragCBL)
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 XtCallCallbackList ((Widget) w, w->sb.dragCBL, &cbs);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
391 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
392 called_anything = True; /* Special Case */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
393 break;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
396 if (!called_anything)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
397 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
398 cbs.reason = XmCR_VALUE_CHANGED;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
399 XtCallCallbackList ((Widget) w, w->sb.valueChangedCBL, &cbs);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
400 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
401 }
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 /* Widget sizes minus the shadow and highlight area */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
404
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
405 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
406 widget_x (XlwScrollBarWidget w)
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 return w->sb.shadowThickness;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
409 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
410
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
411 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
412 widget_y (XlwScrollBarWidget w)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
413 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
414 return w->sb.shadowThickness;
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_w (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 x = w->sb.shadowThickness;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
421 int width = (VERT (w) ? w->core.width : w->core.height) - (2 * x);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
422 return width > 1 ? width : 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
423 }
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 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
426 widget_h (XlwScrollBarWidget w)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
427 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
428 int y = w->sb.shadowThickness;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
429 int height = (VERT (w) ? w->core.height : w->core.width) - (2 * y);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
430
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
431 return height > 1 ? height : 1;
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 arrow_h (XlwScrollBarWidget w)
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 int width = widget_w (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
438 int minimum_size = ((widget_h (w) - SS_MIN) / 2) - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
439 return minimum_size < width ? minimum_size : width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
440 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
441
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
442 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
443 event_x (XlwScrollBarWidget w, XEvent *event)
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 return VERT (w) ? event->xbutton.x : event->xbutton.y;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
446 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
447
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
448 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
449 event_y (XlwScrollBarWidget w, XEvent *event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
450 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
451 return VERT (w) ? event->xbutton.y : event->xbutton.x;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
452 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
453
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
454 /* Safe addition and subtraction */
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 increment_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.maximum - diff < w->sb.value ?
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
459 w->sb.maximum :
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 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
464 decrement_value (XlwScrollBarWidget w, int diff)
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 w->sb.value = w->sb.minimum + diff > w->sb.value ?
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
467 w->sb.minimum :
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
468 w->sb.value - diff;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
469 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
470
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
471 static SliderStyle
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
472 slider_style (XlwScrollBarWidget w)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
473 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
474 return (w->sb.sliderStyle ? w->sb.sliderStyle[0] == 'd' :
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
475 w->sb.knobStyle ? w->sb.knobStyle[0] == 'd' :
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
476 0) ?
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
477 SLIDER_DIMPLE :
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
478 SLIDER_PLAIN;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
479 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
480
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
481 static Boolean
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
482 arrow_same_end (XlwScrollBarWidget w)
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 return w->sb.arrowPosition && w->sb.arrowPosition[0] == 's' ? True : False;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
485 }
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 /*-------------------------- GC and Pixel allocation --------------------*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
488 #ifndef XmUNSPECIFIED_PIXMAP
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
489 #define XmUNSPECIFIED_PIXMAP 2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
490 #endif
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 static GC
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
493 get_gc (XlwScrollBarWidget w, Pixel fg, Pixel bg, Pixmap pm)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
494 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
495 XGCValues values;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
496 XtGCMask mask;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
497
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
498 if (pm == w->sb.grayPixmap)
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 /* If we're using the gray pixmap, guarantee white on black ...
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
501 * otherwise, we could end up with something odd like grey on white
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
502 * 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
503 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
504
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
505 fg = WhitePixelOfScreen (DefaultScreenOfDisplay (XtDisplay (w)));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
506 bg = BlackPixelOfScreen (DefaultScreenOfDisplay (XtDisplay (w)));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
507 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
508
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
509 values.foreground = fg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
510 values.background = bg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
511 values.fill_style = FillOpaqueStippled;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
512 values.stipple = pm;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
513 /* mask = GCForeground | GCBackground |
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
514 (pm == None ? 0 : GCStipple | GCFillStyle); gtb */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
515 if (pm != None && pm != 0 && pm != XmUNSPECIFIED_PIXMAP)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
516 values.stipple = pm;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
517 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
518 values.stipple = None;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
519 mask = GCForeground | GCBackground |
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
520 (values.stipple == None ? 0 : GCStipple | GCFillStyle);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
521
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
522 return XtGetGC((Widget) w, mask, &values);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
523 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
524
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
525 /* Replacement for XAllocColor() that tries to return the nearest
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
526 available color if the colormap is full. From FSF Emacs. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
527
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
528 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
529 allocate_nearest_color (Display *display, Colormap screen_colormap,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
530 XColor *color_def)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
531 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
532 int status = XAllocColor (display, screen_colormap, color_def);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
533 if (status)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
534 return status;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
535
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
536 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
537 /* If we got to this point, the colormap is full, so we're
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
538 going to try to get the next closest color.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
539 The algorithm used is a least-squares matching, which is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
540 what X uses for closest color matching with StaticColor visuals. */
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 int nearest, x;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
543 unsigned long nearest_delta = ULONG_MAX;
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 int no_cells = XDisplayCells (display, XDefaultScreen (display));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
546 /* Don't use alloca here because lwlib doesn't have the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
547 necessary configuration information that src does. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
548 XColor *cells = (XColor *) malloc (sizeof (XColor) * no_cells);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
549
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
550 for (x = 0; x < no_cells; x++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
551 cells[x].pixel = x;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
552
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
553 XQueryColors (display, screen_colormap, cells, no_cells);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
554
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
555 for (nearest = 0, x = 0; x < no_cells; x++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
556 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
557 long dred = (color_def->red >> 8) - (cells[x].red >> 8);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
558 long dgreen = (color_def->green >> 8) - (cells[x].green >> 8);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
559 long dblue = (color_def->blue >> 8) - (cells[x].blue >> 8);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
560 unsigned long delta = dred * dred + dgreen * dgreen + dblue * dblue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
561
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
562 if (delta < nearest_delta)
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 nearest = x;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
565 nearest_delta = delta;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
566 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
567 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
568 color_def->red = cells[nearest].red;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
569 color_def->green = cells[nearest].green;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
570 color_def->blue = cells[nearest].blue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
571 free (cells);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
572 return XAllocColor (display, screen_colormap, color_def);
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 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
577 make_shadow_pixels (XlwScrollBarWidget w)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
578 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
579 Display *dpy = XtDisplay((Widget) w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
580 Colormap cmap = w->core.colormap;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
581 XColor topc, botc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
582 int top_frobbed, bottom_frobbed;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
583 Pixel bg, fg;
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 top_frobbed = bottom_frobbed = 0;
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 bg = w->core.background_pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
588 fg = w->sb.foreground;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
589
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
590 if (w->sb.topShadowColor == (Pixel)~0) w->sb.topShadowColor = bg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
591 if (w->sb.bottomShadowColor == (Pixel)~0) w->sb.bottomShadowColor = fg;
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 if (w->sb.topShadowColor == bg || w->sb.topShadowColor == fg)
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 topc.pixel = bg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
596 XQueryColor (dpy, cmap, &topc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
597 /* don't overflow/wrap! */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
598 topc.red = MINL(65535, topc.red * 1.2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
599 topc.green = MINL(65535, topc.green * 1.2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
600 topc.blue = MINL(65535, topc.blue * 1.2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
601 if (allocate_nearest_color (dpy, cmap, &topc))
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 if (topc.pixel == bg)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
604 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
605 XFreeColors (dpy, cmap, &topc.pixel, 1, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
606 topc.red = MINL(65535, topc.red + 0x8000);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
607 topc.green = MINL(65535, topc.green + 0x8000);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
608 topc.blue = MINL(65535, topc.blue + 0x8000);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
609 if (allocate_nearest_color (dpy, cmap, &topc))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
610 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
611 w->sb.topShadowColor = topc.pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
612 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
613 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
614 else
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 w->sb.topShadowColor = topc.pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
617 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
618
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
619 top_frobbed = 1;
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.bottomShadowColor == fg || w->sb.bottomShadowColor == bg)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
624 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
625 botc.pixel = bg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
626 XQueryColor (dpy, cmap, &botc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
627 botc.red = (botc.red * 3) / 5;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
628 botc.green = (botc.green * 3) / 5;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
629 botc.blue = (botc.blue * 3) / 5;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
630 if (allocate_nearest_color (dpy, cmap, &botc))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
631 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
632 if (botc.pixel == bg)
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 XFreeColors (dpy, cmap, &botc.pixel, 1, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
635 botc.red = MINL(65535, botc.red + 0x4000);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
636 botc.green = MINL(65535, botc.green + 0x4000);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
637 botc.blue = MINL(65535, botc.blue + 0x4000);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
638 if (allocate_nearest_color (dpy, cmap, &botc))
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 w->sb.bottomShadowColor = botc.pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
641 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
642 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
643 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
644 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
645 w->sb.bottomShadowColor = botc.pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
646 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
647 bottom_frobbed = 1;
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 if (top_frobbed && bottom_frobbed)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
652 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
653 int top_avg = ((topc.red / 3) + (topc.green / 3) + (topc.blue / 3));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
654 int bot_avg = ((botc.red / 3) + (botc.green / 3) + (botc.blue / 3));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
655 if (bot_avg > top_avg)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
656 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
657 Pixel tmp = w->sb.topShadowColor;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
658 w->sb.topShadowColor = w->sb.bottomShadowColor;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
659 w->sb.bottomShadowColor = tmp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
660 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
661 else if (topc.pixel == botc.pixel)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
662 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
663 if (botc.pixel == bg)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
664 w->sb.topShadowColor = bg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
665 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
666 w->sb.bottomShadowColor = fg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
667 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
668 }
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.topShadowColor == w->core.background_pixel ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
671 w->sb.bottomShadowColor == w->core.background_pixel)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
672 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
673 /* 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
674 * really in color but just short on color cells -- We want the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
675 * following behavior, which has been empirically determined to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
676 * work well for all fg/bg combinations in mono: If the trough
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
677 * 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
678 * grey bottom shadow, otherwise use a grey top shadow and a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
679 * black bottom shadow.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
680 */
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 Pixel white = WhitePixelOfScreen (DefaultScreenOfDisplay (XtDisplay (w)));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
683 Pixel black = BlackPixelOfScreen (DefaultScreenOfDisplay (XtDisplay (w)));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
684
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
685 /* Note: core.background_pixel is the color of the slider ... */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
686
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
687 if (w->core.background_pixel == black &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
688 w->sb.troughColor == black)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
689 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
690 w->sb.topShadowColor = white;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
691 w->sb.bottomShadowPixmap = w->sb.grayPixmap;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
692 } else {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
693 w->sb.topShadowPixmap = w->sb.grayPixmap;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
694 w->sb.bottomShadowColor = black;
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 }
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
699 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
700 make_trough_pixel (XlwScrollBarWidget w)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
701 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
702 Display *dpy = XtDisplay((Widget) w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
703 Colormap cmap = w->core.colormap;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
704 XColor troughC;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
705
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
706 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
707
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
708 if (w->sb.troughColor == w->core.background_pixel)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
709 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
710 troughC.pixel = w->core.background_pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
711 XQueryColor (dpy, cmap, &troughC);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
712 troughC.red = (troughC.red * 4) / 5;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
713 troughC.green = (troughC.green * 4) / 5;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
714 troughC.blue = (troughC.blue * 4) / 5;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
715 if (allocate_nearest_color (dpy, cmap, &troughC))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
716 w->sb.troughColor = troughC.pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
717 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
718 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
719
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
720 /*-------------------------- Draw 3D Border -----------------------------*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
721 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
722 draw_shadows (Display *dpy, Drawable d, GC shine_gc, GC shadow_gc,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
723 int x, int y, int width, int height, 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 XSegment shine[10], shadow[10];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
726 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
727
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
728 if (shadowT > (width / 2)) shadowT = (width / 2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
729 if (shadowT > (height / 2)) shadowT = (height / 2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
730 if (shadowT <= 0) return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
731
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
732 for (i = 0; i < shadowT; i++)
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 /* Top segments */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
735 shine[i].x1 = x;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
736 shine[i].y2 = shine[i].y1 = y + i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
737 shine[i].x2 = x + width - i - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
738 /* Left segments */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
739 shine[i + shadowT].x2 = shine[i + shadowT].x1 = x + i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
740 shine[i + shadowT].y1 = y + shadowT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
741 shine[i + shadowT].y2 = y + height - i - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
742
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
743 /* Bottom segments */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
744 shadow[i].x1 = x + i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
745 shadow[i].y2 = shadow[i].y1 = y + height - i - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
746 shadow[i].x2 = x + width - 1 ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
747 /* Right segments */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
748 shadow[i + shadowT].x2 = shadow[i + shadowT].x1 = x + width - i - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
749 shadow[i + shadowT].y1 = y + i + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
750 shadow[i + shadowT].y2 = y + height - 1 ;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
753 XDrawSegments (dpy, d, shine_gc, shine, shadowT * 2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
754 XDrawSegments (dpy, d, shadow_gc, shadow, shadowT * 2);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
757 /*------------------ Draw 3D Arrows: left, up, down, right --------------*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
758 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
759 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
760 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
761 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
762
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
763 for (i=0; i<shadowT; i++, seg++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
764 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
765 seg->x1 = x1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
766 seg->y1 = y1++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
767 seg->x2 = x2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
768 seg->y2 = y2++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
769 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
770 return shadowT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
771 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
772
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
773 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
774 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
775 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
776 int i;
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 for (i=0; i<shadowT; i++, seg++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
779 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
780 seg->x1 = x1++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
781 seg->y1 = y1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
782 seg->x2 = x2++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
783 seg->y2 = y2;
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 return shadowT;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
788 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
789 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
790 int x, int y, int width, int height, int shadowT)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
791 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
792 XSegment shine[10], shadow[10];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
793 XPoint triangle[3];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
794 int mid;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
795
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
796 mid = width / 2;
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 if (shadowT > (width / 2)) shadowT = (width / 2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
799 if (shadowT > (height / 2)) shadowT = (height / 2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
800 if (shadowT < 0) shadowT = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
801
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
802 /* / */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
803 make_vert_seg (shine,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
804 x, y + height - shadowT - 1,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
805 x + mid, y, shadowT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
806 /* _\ */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
807 make_vert_seg (shadow,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
808 x, y + height - shadowT - 1,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
809 x + width - 1, y + height - shadowT - 1, shadowT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
810 make_vert_seg (shadow + shadowT,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
811 x + mid, y,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
812 x + width - 1, y + height - shadowT - 1, shadowT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
813
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
814 triangle[0].x = x;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
815 triangle[0].y = y + height - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
816 triangle[1].x = x + mid;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
817 triangle[1].y = y;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
818 triangle[2].x = x + width - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
819 triangle[2].y = y + height - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
820
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
821 XFillPolygon (dpy, win, bgGC, triangle, 3, Convex, ArcChord);
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 XDrawSegments (dpy, win, shadowGC, shadow, shadowT * 2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
824 XDrawSegments (dpy, win, shineGC, shine, shadowT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
825 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
826
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
827 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
828 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
829 int x, int y, int width, int height, int shadowT)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
830 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
831 XSegment shine[10], shadow[10];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
832 XPoint triangle[3];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
833
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
834 int mid = width / 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
835
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
836 if (shadowT > (width / 2)) shadowT = (width / 2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
837 if (shadowT > (height / 2)) shadowT = (height / 2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
838 if (shadowT < 0) shadowT = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
839
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
840 /* / */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
841 make_hor_seg (shine,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
842 x, y + mid,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
843 x + width - shadowT - 1, y, shadowT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
844 /* \| */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
845 make_hor_seg (shadow,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
846 x, y + mid,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
847 x + width - shadowT - 1, y + height - 1, shadowT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
848 make_hor_seg (shadow + shadowT,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
849 x + width - shadowT - 1, y,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
850 x + width - shadowT - 1, y + height - 1, shadowT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
851
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
852 triangle[0].x = x + width - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
853 triangle[0].y = y + height - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
854 triangle[1].x = x;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
855 triangle[1].y = y + mid;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
856 triangle[2].x = x + width - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
857 triangle[2].y = y;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
858
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
859 XFillPolygon (dpy, win, bgGC, triangle, 3, Convex, ArcChord);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
860
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
861 XDrawSegments (dpy, win, shadowGC, shadow, shadowT * 2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
862 XDrawSegments (dpy, win, shineGC, shine, shadowT);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
865 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
866 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
867 int x, int y, int width, int height, int shadowT)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
868 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
869 XSegment shine[10], shadow[10];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
870 XPoint triangle[3];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
871 int mid;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
872
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
873 mid = width / 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
874
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
875 if (shadowT > (width / 2)) shadowT = (width / 2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
876 if (shadowT > (height / 2)) shadowT = (height / 2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
877 if (shadowT < 0) shadowT = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
878
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
879 /* \- */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
880 make_vert_seg (shine,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
881 x, y,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
882 x + mid, y + height - shadowT - 1, shadowT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
883 make_vert_seg (shine + shadowT,
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 - 1, y, shadowT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
886 /* / */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
887 make_vert_seg (shadow,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
888 x + width - 1, y,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
889 x + mid, y + height - shadowT - 1, shadowT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
890
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
891 triangle[0].x = x;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
892 triangle[0].y = y;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
893 triangle[1].x = x + mid;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
894 triangle[1].y = y + height - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
895 triangle[2].x = x + width - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
896 triangle[2].y = y;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
897
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
898 XFillPolygon (dpy, win, bgGC, triangle, 3, Convex, ArcChord);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
899
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
900 XDrawSegments (dpy, win, shadowGC, shadow, shadowT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
901 XDrawSegments (dpy, win, shineGC, shine, shadowT * 2);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
904 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
905 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
906 int x, int y, int width, int height, int shadowT)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
907 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
908 XSegment shine[10], shadow[10];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
909 XPoint triangle[3];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
910 int mid;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
911
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
912 mid = width / 2;
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 if (shadowT > (width / 2)) shadowT = (width / 2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
915 if (shadowT > (height / 2)) shadowT = (height / 2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
916 if (shadowT < 0) shadowT = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
917
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
918 /* |\ */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
919 make_hor_seg (shine,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
920 x, y,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
921 x + width - shadowT - 1, y + mid, shadowT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
922 make_hor_seg (shine + shadowT,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
923 x, y,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
924 x, y + height - 1, shadowT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
925 /* / */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
926 make_hor_seg (shadow,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
927 x, y + height - 1,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
928 x + width - shadowT - 1, y + mid, shadowT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
929
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
930 triangle[0].x = x + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
931 triangle[0].y = y + height - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
932 triangle[1].x = x + width - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
933 triangle[1].y = y + mid;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
934 triangle[2].x = x + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
935 triangle[2].y = y;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
936
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
937 XFillPolygon (dpy, win, bgGC, triangle, 3, Convex, ArcChord);
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 XDrawSegments (dpy, win, shadowGC, shadow, shadowT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
940 XDrawSegments (dpy, win, shineGC, shine, shadowT * 2);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
943 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
944 draw_dimple (Display *dpy, Drawable win, GC shine, GC shadow,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
945 int x, int y, int width, int height)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
946 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
947 XDrawArc (dpy, win, shine, x, y, width, height, 46*64, 180*64);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
948 XDrawArc (dpy, win, shadow, x, y, width, height, 45*64, -179*64);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
949 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
950
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
951 /*------- Scrollbar values -> pixels, pixels -> scrollbar values --------*/
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 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
954 seg_pixel_sizes (XlwScrollBarWidget w, int *above_return,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
955 int *ss_return, int *below_return)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
956 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
957 float total, height, fuz;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
958 int value, above, ss, below;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
959
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
960 height = widget_h (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
961 if (w->sb.showArrows) height -= (2 * arrow_h (w));
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 value = w->sb.value - w->sb.minimum;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
964
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
965 total = w->sb.maximum - w->sb.minimum;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
966 fuz = total / 2;
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 ss = (int) ((height * w->sb.sliderSize + fuz) / total);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
969 above = (int) ((height * value + fuz) / total);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
970 below = (int) ((height) - (ss + above));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
971
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
972 /* Don't let slider get smaller than SS_MIN */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
973 if (ss < SS_MIN)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
974 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
975 /* add a percent amount for integer rounding */
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
976 float tmp = (((float) (SS_MIN - ss) * (float) value) / total) + 0.5;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
977
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
978 above -= (int) tmp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
979 ss = SS_MIN;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
980 below = (int) ((height) - (ss + above));
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 (above < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
983 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
984 above = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
985 below = (int) (height - ss);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
986 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
987 if (below < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
988 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
989 above = (int) (height - ss);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
990 below = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
991 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
992 if (ss > height)
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 above = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
995 ss = (int) height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
996 below = 0;
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 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
999
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1000 *above_return = above;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1001 *ss_return = ss;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1002 *below_return = below;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1003
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1004 CHECK (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1005 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1006
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1007 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1008 verify_values (XlwScrollBarWidget w)
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 int total = w->sb.maximum - w->sb.minimum;
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 if (w->sb.sliderSize > total)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1013 w->sb.sliderSize = total;
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 if (w->sb.pageIncrement > total)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1016 w->sb.pageIncrement = total;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1017
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1018 if (w->sb.increment > total)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1019 w->sb.increment = total;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1020
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1021 if (w->sb.value < w->sb.minimum)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1022 w->sb.value = w->sb.minimum;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1023
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1024 if (w->sb.value > w->sb.maximum)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1025 w->sb.value = w->sb.maximum;
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 if (w->sb.sliderSize > w->sb.maximum - w->sb.value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1028 w->sb.sliderSize = w->sb.maximum - w->sb.value;
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 int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1032 value_from_pixel (XlwScrollBarWidget w, int above)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1033 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1034 float total, height, fuz;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1035 int value, ss;
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 height = widget_h (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1038 if (w->sb.showArrows)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1039 height -= (2 * arrow_h (w));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1040
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1041 total = w->sb.maximum - w->sb.minimum;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1042 fuz = height / 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1043
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1044 ss = (int) ((height * w->sb.sliderSize + (total / 2)) / total);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1045
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1046 if (ss < SS_MIN)
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 /* add a percent amount for integer rounding */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1049 above += (int) ((((SS_MIN - ss) * above) + fuz) / height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1050 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1051
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1052 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1053 /* 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
1054 float floatval = w->sb.minimum + ((float)(above * total + fuz) / height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1055 if (floatval >= (float) INT_MAX)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1056 value = INT_MAX;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1057 else if (floatval <= (float) INT_MIN)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1058 value = INT_MIN;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1059 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1060 value = (int) floatval;
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 return value;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1064 }
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1067 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1068 redraw_dimple (XlwScrollBarWidget w, Display *dpy, Window win,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1069 int x, int y, int width, int height)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1070 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1071 if (SLIDER_DIMPLE == slider_style (w))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1072 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1073 int size;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1074 int slider_p = (w->sb.armed == ARM_SLIDER);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1075 GC shine = slider_p ? w->sb.bottomShadowGC : w->sb.topShadowGC;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1076 GC shadow = slider_p ? w->sb.topShadowGC : w->sb.bottomShadowGC;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1077 int shadowT = w->sb.shadowThickness;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1078
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1079 x += shadowT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1080 y += shadowT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1081 width -= 2*shadowT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1082 height -= 2*shadowT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1083
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1084 size = (width < height ? width : height) * 3 / 4;
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 (size%2 != (width < height ? width : height)%2) size--;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1087
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1088 DBUG (fprintf (stderr, "%d %d\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1089 x + (width / 2) - (size / 2) - 2*shadowT,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1090 width - size - shadowT));
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 draw_dimple (dpy, win, shine, shadow,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1093 x + (width / 2) - (size / 2),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1094 y + (height / 2) - (size / 2),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1095 size, size);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1096 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1097 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1098
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1099 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1100 draw_slider (XlwScrollBarWidget w, int above, int ss, int below)
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 Display *dpy = XtDisplay ((Widget) w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1103 Window win = XtWindow ((Widget) w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1104
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1105 int x = widget_x (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1106 int y = widget_y (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1107 int width = widget_w (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1108 int height = widget_h (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1109 int shadowT = w->sb.shadowThickness;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1110 int vert_p = VERT (w);
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 if (shadowT > (width / 2)) shadowT = (width / 2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1113 if (shadowT > (height / 2)) shadowT = (height / 2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1114 if (shadowT < 0) shadowT = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1115
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1116 if (w->sb.showArrows && !arrow_same_end (w))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1117 y += arrow_h (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1118
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1119 /* trough above slider */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1120 if (above > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1121 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1122 if (vert_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1123 XClearArea (dpy, win, x, y, width, above, False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1124 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1125 XClearArea (dpy, win, y, x, above, width, False);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1128 /* slider */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1129 if (vert_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1130 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1131 draw_shadows (dpy, win, w->sb.topShadowGC, w->sb.bottomShadowGC,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1132 x, y + above, width, ss, shadowT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1133 XFillRectangle (dpy, win, w->sb.backgroundGC,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1134 x+shadowT, y + above + shadowT,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1135 width-2*shadowT, ss-2*shadowT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1136 redraw_dimple (w, dpy, win, x, y + above, width, ss);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1137 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1138 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1139 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1140 draw_shadows (dpy, win, w->sb.topShadowGC, w->sb.bottomShadowGC,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1141 y + above, x, ss, width, shadowT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1142 XFillRectangle (dpy, win, w->sb.backgroundGC,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1143 y + above + shadowT, x+shadowT,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1144 ss-2*shadowT, width-2*shadowT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1145 redraw_dimple (w, dpy, win, y + above, x, ss, width);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1146 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1147
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1148 /* trough below slider */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1149 if (below > 0)
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 if (vert_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1152 XClearArea (dpy, win, x, y + above + ss, width, below, False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1153 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1154 XClearArea (dpy, win, y + above + ss, x, below, width, False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1155 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1156
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1157 CHECK (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1158 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1159
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1160 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1161 redraw_up_arrow (XlwScrollBarWidget w, Boolean armed, Boolean clear_behind)
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 Display *dpy = XtDisplay ((Widget) w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1164 Window win = XtWindow ((Widget) w);
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 int x = widget_x (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1167 int y = widget_y (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1168 int width = widget_w (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1169 int height = widget_h (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1170 int shadowT = w->sb.shadowThickness;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1171 int arrow_height = arrow_h (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1172
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1173 GC bg = w->sb.backgroundGC;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1174 GC shine = armed ? w->sb.bottomShadowGC : w->sb.topShadowGC;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1175 GC shadow = armed ? w->sb.topShadowGC : w->sb.bottomShadowGC;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1176
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1177 if (VERT (w))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1178 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1179 if (arrow_same_end (w))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1180 y += height - 2 * arrow_height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1181 if (clear_behind)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1182 XClearArea (dpy, win, x, y, width, arrow_height + 1, False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1183 draw_arrow_up (dpy, win, bg, shine, shadow,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1184 x + (width - arrow_height)/2, y,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1185 arrow_height, arrow_height, shadowT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1186 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1187 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1188 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1189 if (arrow_same_end (w))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1190 y += height - 2 * arrow_height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1191 if (clear_behind)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1192 XClearArea (dpy, win, y, x, arrow_height + 1, height, False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1193 draw_arrow_left (dpy, win, bg, shine, shadow,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1194 y, x + (width - arrow_height)/2,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1195 arrow_height, arrow_height, shadowT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1196 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1197 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1198
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1199 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1200 redraw_down_arrow (XlwScrollBarWidget w, Boolean armed, Boolean clear_behind)
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 Display *dpy = XtDisplay ((Widget) w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1203 Window win = XtWindow ((Widget) w);
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 int x = widget_x (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1206 int y = widget_y (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1207 int width = widget_w (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1208 int height = widget_h (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1209 int shadowT = w->sb.shadowThickness;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1210 int arrow_height = arrow_h (w);
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 GC bg = w->sb.backgroundGC;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1213 GC shine = armed ? w->sb.bottomShadowGC : w->sb.topShadowGC;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1214 GC shadow = armed ? w->sb.topShadowGC : w->sb.bottomShadowGC;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1215
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1216 if (VERT (w))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1217 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1218 if (clear_behind)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1219 XClearArea (dpy, win, x, y + height - arrow_height, width,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1220 arrow_height + 1, False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1221 draw_arrow_down (dpy, win, bg, shine, shadow,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1222 x + (width - arrow_height)/2,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1223 y + height - arrow_height + 1,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1224 arrow_height, arrow_height, shadowT);
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 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1227 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1228 if (clear_behind)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1229 XClearArea (dpy, win, y + height - arrow_height, x,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1230 arrow_height + 1, height, False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1231 draw_arrow_right (dpy, win, bg, shine, shadow,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1232 y + height - arrow_height + 1,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1233 x + (width - arrow_height)/2,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1234 arrow_height, arrow_height, shadowT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1235 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1236 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1237
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1238 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1239 redraw_everything (XlwScrollBarWidget w, Region region, Boolean 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 Display *dpy = XtDisplay ((Widget) w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1242 Window win = XtWindow ((Widget) w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1243
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1244 if (w->sb.showArrows)
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 if (region == NULL)
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 redraw_up_arrow (w, False, behind_arrows);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1249 redraw_down_arrow (w, False, behind_arrows);
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 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1252 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1253 int x = widget_x (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1254 int y = widget_y (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1255 int width = widget_w (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1256 int height = widget_h (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1257 int arrow_height = arrow_h (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1258 int ax = x, ay = y;
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 (arrow_same_end (w))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1261 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1262 if (VERT (w))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1263 ay = y + height - arrow_height - arrow_height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1264 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1265 ax = x + height - arrow_height - arrow_height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1266 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1267 if (XRectInRegion (region, ax, ay, width, width))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1268 redraw_up_arrow (w, False, behind_arrows);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1269
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1270 if (VERT (w))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1271 ay = y + height - arrow_height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1272 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1273 ax = x + height - arrow_height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1274 if (XRectInRegion (region, ax, ay, width, width))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1275 redraw_down_arrow (w, False, behind_arrows);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1276 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1277 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1278
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1279 draw_shadows (dpy, win, w->sb.bottomShadowGC, w->sb.topShadowGC, 0, 0,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1280 w->core.width, w->core.height, w->sb.shadowThickness);
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 draw_slider (w, w->sb.above, w->sb.ss, w->sb.below);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1283 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1284
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1285 /*-------------------------- Method Functions ---------------------------*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1286
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1287 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1288 Initialize (Widget treq, Widget tnew, ArgList args, Cardinal *num_args)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1289 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1290 XlwScrollBarWidget request = (XlwScrollBarWidget) treq;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1291 XlwScrollBarWidget w = (XlwScrollBarWidget) tnew;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1292 Display *dpy = XtDisplay ((Widget) w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1293 Window win = RootWindowOfScreen (DefaultScreenOfDisplay (dpy));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1294
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1295 if (request->core.width == 0) w->core.width += (VERT (w) ? 12 : 25);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1296 if (request->core.height == 0) w->core.height += (VERT (w) ? 25 : 12);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1297
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1298 verify_values (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1299
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1300 w->sb.lastY = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1301 w->sb.above = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1302 w->sb.ss = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1303 w->sb.below = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1304 w->sb.armed = ARM_NONE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1305 w->sb.forced_scroll = FORCED_SCROLL_NONE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1306
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1307 if (w->sb.shadowThickness > 5) w->sb.shadowThickness = 5;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1308
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1309 w->sb.grayPixmap =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1310 XCreatePixmapFromBitmapData (dpy, win, (char *) gray_bits, gray_width,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1311 gray_height, 1, 0, 1);
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 make_trough_pixel (w);
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 make_shadow_pixels (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1316
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1317 w->sb.backgroundGC =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1318 get_gc (w, w->core.background_pixel, w->core.background_pixel, None);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1319 w->sb.topShadowGC =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1320 get_gc (w, w->sb.topShadowColor, w->core.background_pixel,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1321 w->sb.topShadowPixmap);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1322 w->sb.bottomShadowGC =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1323 get_gc (w, w->sb.bottomShadowColor, w->core.background_pixel,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1324 w->sb.bottomShadowPixmap);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1325
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1326 w->sb.fullRedrawNext = True;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1327
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1328 w->sb.timerActive = False;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1329 }
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 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1332 Destroy (Widget widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1333 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1334 XlwScrollBarWidget w = (XlwScrollBarWidget) widget;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1335 Display *dpy = XtDisplay ((Widget) w);
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 XtReleaseGC (widget, w->sb.bottomShadowGC);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1338 XtReleaseGC (widget, w->sb.topShadowGC);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1339 XtReleaseGC (widget, w->sb.backgroundGC);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1340
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1341 XFreePixmap (dpy, w->sb.grayPixmap);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1342
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1343 if (w->sb.timerActive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1344 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1345 XtRemoveTimeOut (w->sb.timerId);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1346 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
1347 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1348 }
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 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1351 Realize (Widget widget, XtValueMask *valuemask, XSetWindowAttributes *attr)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1352 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1353 XlwScrollBarWidget w = (XlwScrollBarWidget) widget;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1354 Display *dpy = XtDisplay ((Widget) w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1355 Window win;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1356 XSetWindowAttributes win_attr;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1357
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1358 (*coreClassRec.core_class.realize)(widget, valuemask, attr);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1359
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1360 win = XtWindow ((Widget) w);
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 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
1363
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1364 XSetWindowBackground (dpy, win, w->sb.troughColor);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1365
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1366 /* Change bit gravity so widget is not cleared on resize */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1367 win_attr.bit_gravity = NorthWestGravity;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1368 XChangeWindowAttributes (dpy, win, CWBitGravity , &win_attr);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1369
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1370 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1371
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1372 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1373 Resize (Widget widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1374 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1375 XlwScrollBarWidget w = (XlwScrollBarWidget) widget;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1376 Display *dpy = XtDisplay ((Widget) w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1377 Window win = XtWindow ((Widget) w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1378
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1379 if (XtIsRealized (widget))
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 DBUG (fprintf (stderr, "Resize = %08lx\n", w));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1382
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1383 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
1384
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1385 /* redraw_everything (w, NULL, True); */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1386
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1387 w->sb.fullRedrawNext = True;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1388 /* Force expose event */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1389 XClearArea (dpy, win, widget_x (w), widget_y (w), 1, 1, True);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1392 if (w->sb.timerActive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1393 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1394 XtRemoveTimeOut (w->sb.timerId);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1395 w->sb.timerActive = False;
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 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1400 Redisplay (Widget widget, XEvent *event, Region region)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1401 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1402 XlwScrollBarWidget w = (XlwScrollBarWidget) widget;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1403
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1404 DBUG (fprintf (stderr, "Redisplay = %08lx\n", w));
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 if (XtIsRealized (widget))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1407 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1408 if (w->sb.fullRedrawNext)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1409 redraw_everything (w, NULL, True);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1410 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1411 redraw_everything (w, region, False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1412 w->sb.fullRedrawNext = False;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1413 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1414 }
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 static Boolean
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1417 SetValues (Widget current, Widget request, Widget neww,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1418 ArgList args, Cardinal *num_args)
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 XlwScrollBarWidget cur = (XlwScrollBarWidget) current;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1421 XlwScrollBarWidget w = (XlwScrollBarWidget) neww;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1422 Boolean do_redisplay = False;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1423
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1424 if (cur->sb.troughColor != w->sb.troughColor)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1425 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1426 if (XtIsRealized ((Widget) w))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1427 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1428 XSetWindowBackground (XtDisplay((Widget) w), XtWindow ((Widget) w),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1429 w->sb.troughColor);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1430 do_redisplay = True;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1431 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1432 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1433
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1434 if (cur->core.background_pixel != w->core.background_pixel)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1435 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1436 XtReleaseGC ((Widget)cur, cur->sb.backgroundGC);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1437 w->sb.backgroundGC =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1438 get_gc (w, w->core.background_pixel, w->core.background_pixel, None);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1439 do_redisplay = True;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1440 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1441
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1442 if (cur->sb.topShadowColor != w->sb.topShadowColor ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1443 cur->sb.topShadowPixmap != w->sb.topShadowPixmap)
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 XtReleaseGC ((Widget)cur, cur->sb.topShadowGC);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1446 w->sb.topShadowGC =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1447 get_gc (w, w->sb.topShadowColor, w->core.background_pixel,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1448 w->sb.topShadowPixmap);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1449 do_redisplay = True;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1452 if (cur->sb.bottomShadowColor != w->sb.bottomShadowColor ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1453 cur->sb.bottomShadowPixmap != w->sb.bottomShadowPixmap)
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 XtReleaseGC ((Widget)cur, cur->sb.bottomShadowGC);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1456 w->sb.bottomShadowGC =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1457 get_gc (w, w->sb.bottomShadowColor, w->core.background_pixel,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1458 w->sb.bottomShadowPixmap);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1459 do_redisplay = True;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1460 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1461
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1462 if (cur->sb.orientation != w->sb.orientation)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1463 do_redisplay = True;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1464
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1465
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1466 if (cur->sb.minimum != w->sb.minimum ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1467 cur->sb.maximum != w->sb.maximum ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1468 cur->sb.sliderSize != w->sb.sliderSize ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1469 cur->sb.value != w->sb.value ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1470 cur->sb.pageIncrement != w->sb.pageIncrement ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1471 cur->sb.increment != w->sb.increment)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1472 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1473 verify_values (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1474 if (XtIsRealized ((Widget) w))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1475 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1476 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
1477 draw_slider (w, w->sb.above, w->sb.ss, w->sb.below);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1478 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1479 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1480
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1481 if (w->sb.shadowThickness > 5) w->sb.shadowThickness = 5;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1482
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1483 return do_redisplay;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1486 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1487 XlwScrollBarGetValues (Widget widget, int *value, int *sliderSize,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1488 int *increment, int *pageIncrement)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1489 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1490 XlwScrollBarWidget w = (XlwScrollBarWidget) widget;
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 && XtClass ((Widget) w) == xlwScrollBarWidgetClass)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1493 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1494 if (value) *value = w->sb.value;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1495 if (sliderSize) *sliderSize = w->sb.sliderSize;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1496 if (increment) *increment = w->sb.increment;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1497 if (pageIncrement) *pageIncrement = w->sb.pageIncrement;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1498 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1499 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1500
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1501 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1502 XlwScrollBarSetValues (Widget widget, int value, int sliderSize,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1503 int increment, int pageIncrement, Boolean notify)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1504 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1505 XlwScrollBarWidget w = (XlwScrollBarWidget) widget;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1506
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1507 if (w && XtClass ((Widget) w) == xlwScrollBarWidgetClass &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1508 (w->sb.value != value ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1509 w->sb.sliderSize != sliderSize ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1510 w->sb.increment != increment ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1511 w->sb.pageIncrement != pageIncrement))
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 int last_value = w->sb.value;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1514
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1515 w->sb.value = value;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1516 w->sb.sliderSize = sliderSize;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1517 w->sb.increment = increment;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1518 w->sb.pageIncrement = pageIncrement;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1519
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1520 verify_values (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1521
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1522 if (XtIsRealized (widget))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1523 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1524 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
1525 draw_slider (w, w->sb.above, w->sb.ss, w->sb.below);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1526
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1527 if (w->sb.value != last_value && notify)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1528 call_callbacks (w, XmCR_VALUE_CHANGED, w->sb.value, 0, NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1529 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1530 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1531 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1532
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1533 /*-------------------------- Action Functions ---------------------------*/
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 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1536 timer (XtPointer data, XtIntervalId *id)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1537 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1538 XlwScrollBarWidget w = (XlwScrollBarWidget) data;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1539 w->sb.timerActive = False;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1540
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1541 if (w->sb.armed != ARM_NONE)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1542 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1543 int last_value = w->sb.value;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1544 int reason;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1545
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1546 switch (w->sb.armed)
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 case ARM_PAGEUP:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1549 decrement_value (w, w->sb.pageIncrement);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1550 reason = XmCR_PAGE_DECREMENT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1551 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1552 case ARM_PAGEDOWN:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1553 increment_value (w, w->sb.pageIncrement);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1554 reason = XmCR_PAGE_INCREMENT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1555 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1556 case ARM_UP:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1557 decrement_value (w, w->sb.increment);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1558 reason = XmCR_DECREMENT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1559 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1560 case ARM_DOWN:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1561 increment_value (w, w->sb.increment);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1562 reason = XmCR_INCREMENT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1563 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1564 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1565 reason = XmCR_NONE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1566 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1567
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1568 verify_values (w);
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 (last_value != w->sb.value)
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 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
1573 draw_slider (w, w->sb.above, w->sb.ss, w->sb.below);
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 call_callbacks (w, reason, w->sb.value, 0, NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1576
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1577 w->sb.timerId =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1578 XtAppAddTimeOut (XtWidgetToApplicationContext ((Widget) w),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1579 (unsigned long) w->sb.repeatDelay,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1580 timer, (XtPointer) w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1581 w->sb.timerActive = True;
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 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1584 }
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 static button_where
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1587 what_button (XlwScrollBarWidget w, int mouse_x, int mouse_y)
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 int width = widget_w (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1590 int height = widget_h (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1591 int arrow_height = arrow_h (w);
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 mouse_x -= widget_x (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1594 mouse_y -= widget_y (w);
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 if (mouse_x < 0 || mouse_x >= width ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1597 mouse_y < 0 || mouse_y >= height)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1598 return BUTTON_NONE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1599
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1600 if (w->sb.showArrows)
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 if (mouse_y >= (height -= arrow_height))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1603 return BUTTON_DOWN_ARROW;
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 if (arrow_same_end (w))
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 (mouse_y >= (height -= arrow_height))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1608 return BUTTON_UP_ARROW;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1609 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1610 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1611 if ( (mouse_y -= arrow_height) < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1612 return BUTTON_UP_ARROW;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1613 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1614
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1615 if ( (mouse_y -= w->sb.above) < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1616 return BUTTON_TROUGH_ABOVE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1617
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1618 if ( (mouse_y -= w->sb.ss) < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1619 return BUTTON_SLIDER;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1620
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1621 return BUTTON_TROUGH_BELOW;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1622 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1623
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1624 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1625 Select (Widget widget, XEvent *event, String *parms, Cardinal *num_parms)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1626 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1627 XlwScrollBarWidget w = (XlwScrollBarWidget) widget;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1628 button_where sb_button;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1629
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1630 int mouse_x = event_x (w, event);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1631 int mouse_y = event_y (w, event);
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 int last_value = w->sb.savedValue = w->sb.value;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1634 int reason = XmCR_NONE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1635
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1636 XtGrabKeyboard ((Widget) w, False, GrabModeAsync, GrabModeAsync,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1637 event->xbutton.time);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1638
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1639 sb_button = what_button (w, mouse_x, mouse_y);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1640
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1641 if (w->sb.forced_scroll != FORCED_SCROLL_NONE)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1642 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1643 switch (sb_button)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1644 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1645 case BUTTON_TROUGH_ABOVE:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1646 case BUTTON_TROUGH_BELOW:
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 sb_button= BUTTON_NONE; /* cause next switch to fall through */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1649 if (w->sb.forced_scroll == FORCED_SCROLL_UPLEFT)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1650 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1651 decrement_value (w, w->sb.pageIncrement);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1652 w->sb.armed = ARM_PAGEUP;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1653 reason = XmCR_PAGE_DECREMENT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1654 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1655 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1656 else if (w->sb.forced_scroll == FORCED_SCROLL_DOWNRIGHT)
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 increment_value (w, w->sb.pageIncrement);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1659 w->sb.armed = ARM_PAGEDOWN;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1660 reason = XmCR_PAGE_INCREMENT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1661 break;
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 abort();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1664 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1665 ; /* Do nothing */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1666 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1667 }
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 switch (sb_button)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1670 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1671 case BUTTON_TROUGH_ABOVE:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1672 decrement_value (w, w->sb.pageIncrement);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1673 w->sb.armed = ARM_PAGEUP;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1674 reason = XmCR_PAGE_DECREMENT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1675 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1676 case BUTTON_TROUGH_BELOW:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1677 increment_value (w, w->sb.pageIncrement);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1678 w->sb.armed = ARM_PAGEDOWN;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1679 reason = XmCR_PAGE_INCREMENT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1680 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1681 case BUTTON_SLIDER:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1682 w->sb.lastY = mouse_y;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1683 w->sb.armed = ARM_SLIDER;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1684 draw_slider (w, w->sb.above, w->sb.ss, w->sb.below);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1685 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1686 case BUTTON_UP_ARROW:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1687 if (event->xbutton.state & ControlMask)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1688 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1689 w->sb.value = w->sb.minimum;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1690 reason = XmCR_TO_TOP;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1691 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1692 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1693 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1694 decrement_value (w, w->sb.increment);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1695 reason = XmCR_DECREMENT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1696 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1697 w->sb.armed = ARM_UP;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1698 redraw_up_arrow (w, True, False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1699 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1700 case BUTTON_DOWN_ARROW:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1701 if (event->xbutton.state & ControlMask)
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 w->sb.value = w->sb.maximum;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1704 reason = XmCR_TO_BOTTOM;
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 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1707 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1708 increment_value (w, w->sb.increment);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1709 reason = XmCR_INCREMENT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1710 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1711 w->sb.armed = ARM_DOWN;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1712 redraw_down_arrow (w, True, False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1713 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1714 case BUTTON_NONE:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1715 ; /* Do nothing */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1716 }
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 verify_values (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1719
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1720 if (last_value != w->sb.value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1721 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1722 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
1723 draw_slider (w, w->sb.above, w->sb.ss, w->sb.below);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1724
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1725 call_callbacks (w, reason, w->sb.value, mouse_y, event);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1726
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1727 if (w->sb.timerActive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1728 XtRemoveTimeOut (w->sb.timerId);
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 w->sb.timerId =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1731 XtAppAddTimeOut (XtWidgetToApplicationContext ((Widget) w),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1732 (unsigned long) w->sb.initialDelay,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1733 timer, (XtPointer) w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1734 w->sb.timerActive = True;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1735 }
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 CHECK (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1738 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1739
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1740 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1741 PageDownOrRight (Widget widget, XEvent *event, String *parms, Cardinal *num_parms)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1742 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1743 XlwScrollBarWidget w = (XlwScrollBarWidget) widget;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1744 w->sb.forced_scroll = FORCED_SCROLL_DOWNRIGHT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1745 Select (widget, event, parms, num_parms);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1746 w->sb.forced_scroll = FORCED_SCROLL_NONE;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1749 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1750 PageUpOrLeft (Widget widget, XEvent *event, String *parms, Cardinal *num_parms)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1751 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1752 XlwScrollBarWidget w = (XlwScrollBarWidget) widget;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1753 w->sb.forced_scroll = FORCED_SCROLL_UPLEFT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1754 Select (widget, event, parms, num_parms);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1755 w->sb.forced_scroll = FORCED_SCROLL_NONE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1756 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1757
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1758 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1759 Drag (Widget widget, XEvent *event, String *parms, Cardinal *num_parms)
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 XlwScrollBarWidget w = (XlwScrollBarWidget) widget;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1762
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1763 if (w->sb.armed == ARM_SLIDER)
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 int mouse_y = event_y (w, event);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1766 int diff = mouse_y - w->sb.lastY;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1767
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1768 if (diff < -(w->sb.above)) /* up */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1769 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1770 mouse_y -= (diff + w->sb.above);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1771 diff = -(w->sb.above);
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 else if (diff > w->sb.below) /* down */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1774 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1775 mouse_y -= (diff - w->sb.below);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1776 diff = w->sb.below;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1777 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1778
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1779 if (diff)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1780 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1781 w->sb.above += diff;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1782 w->sb.below -= diff;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1783
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1784 draw_slider (w, w->sb.above, w->sb.ss, w->sb.below);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1785
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1786 w->sb.lastY = mouse_y;
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 w->sb.value = value_from_pixel (w, w->sb.above);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1789 verify_values (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1790 CHECK (w);
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 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
1793 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1794 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1795 CHECK (w);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1798 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1799 Release (Widget widget, XEvent *event, String *parms, Cardinal *num_parms)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1800 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1801 XlwScrollBarWidget w = (XlwScrollBarWidget) widget;
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 switch (w->sb.armed)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1804 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1805 case ARM_SLIDER:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1806 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
1807 w->sb.armed = ARM_NONE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1808 draw_slider (w, w->sb.above, w->sb.ss, w->sb.below);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1809 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1810 case ARM_UP:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1811 redraw_up_arrow (w, False, False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1812 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1813 case ARM_DOWN:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1814 redraw_down_arrow (w, False, False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1815 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1816 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1817 ; /* Do nothing */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1818 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1819
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1820 XtUngrabKeyboard ((Widget) w, event->xbutton.time);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1821
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1822 w->sb.armed = ARM_NONE;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1825 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1826 Jump (Widget widget, XEvent *event, String *parms, Cardinal *num_parms)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1827 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1828 XlwScrollBarWidget w = (XlwScrollBarWidget) widget;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1829 int last_value;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1830
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1831 int mouse_x = event_x (w, event);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1832 int mouse_y = event_y (w, event);
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 int scroll_region_y = widget_y (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1835 int scroll_region_h = widget_h (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1836
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1837 if (w->sb.showArrows)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1838 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1839 int arrow_height = arrow_h (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1840 scroll_region_h -= 2 * arrow_height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1841 if (!arrow_same_end (w))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1842 scroll_region_y += arrow_height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1843 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1844
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1845 XtGrabKeyboard ((Widget) w, False, GrabModeAsync, GrabModeAsync,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1846 event->xbutton.time);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1847
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1848 switch (what_button (w, mouse_x, mouse_y))
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 case BUTTON_TROUGH_ABOVE:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1851 case BUTTON_TROUGH_BELOW:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1852 case BUTTON_SLIDER:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1853 w->sb.savedValue = w->sb.value;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1854
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1855 last_value = w->sb.value;
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 w->sb.above = mouse_y - (w->sb.ss / 2) - scroll_region_y;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1858 if (w->sb.above < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1859 w->sb.above = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1860 else if (w->sb.above + w->sb.ss > scroll_region_h)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1861 w->sb.above = scroll_region_h - w->sb.ss;
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.below = scroll_region_h - w->sb.ss - w->sb.above;
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 w->sb.armed = ARM_SLIDER;
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 w->sb.value = value_from_pixel (w, w->sb.above);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1869 verify_values (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1870 CHECK (w);
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 w->sb.lastY = mouse_y;
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 if (w->sb.value != last_value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1875 call_callbacks (w, XmCR_DRAG, w->sb.value, mouse_y, event);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1876
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1877 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1878 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1879 ; /* Do nothing */
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 CHECK (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1882 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1883
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1884 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1885 Abort (Widget widget, XEvent *event, String *parms, Cardinal *num_parms)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1886 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1887 XlwScrollBarWidget w = (XlwScrollBarWidget) widget;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1888
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1889 if (w->sb.armed != ARM_NONE)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1890 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1891 if (w->sb.value != w->sb.savedValue)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1892 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1893 w->sb.value = w->sb.savedValue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1894
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1895 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
1896 draw_slider (w, w->sb.above, w->sb.ss, w->sb.below);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1897
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1898 call_callbacks (w, XmCR_VALUE_CHANGED, w->sb.value,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1899 event_y (w, event), event);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1900 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1901
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1902 switch (w->sb.armed)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1903 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1904 case ARM_UP: redraw_up_arrow (w, False, False); break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1905 case ARM_DOWN: redraw_down_arrow (w, False, False); break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1906 default: ; /* Do nothing */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1907 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1908
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1909 w->sb.armed = ARM_NONE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1910
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1911 XtUngrabKeyboard ((Widget) w, event->xbutton.time);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1912 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1913 }