annotate lwlib/xlwscrollbar.c @ 312:d1b52dcaa789 r21-0b54

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