annotate lwlib/xlwscrollbar.c @ 191:ecf6ba7b0a10 r20-3b22

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