annotate lwlib/xlwscrollbar.c @ 318:afd57c14dfc8 r21-0b57

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