annotate lwlib/xlwscrollbar.c @ 177:6075d714658b r20-3b15

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