annotate lwlib/xlwscrollbar.c @ 0:376386a54a3c r19-14

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