annotate lwlib/xlwscrollbar.c @ 80:1ce6082ce73f r20-0b90

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