annotate src/gui_at_sb.c @ 1835:8389197c91f3 v7.2.133

updated for version 7.2-133
author vimboss
date Wed, 11 Mar 2009 11:47:18 +0000
parents f10fe14748e2
children fc89a4f98a8b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1 /* vi:set ts=8 sts=4 sw=4: */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3 * MODIFIED ATHENA SCROLLBAR (USING ARROWHEADS AT ENDS OF TRAVEL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4 * Modifications Copyright 1992 by Mitch Trachtenberg
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5 * Rights, permissions, and disclaimer of warranty are as in the DEC and MIT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6 * notice below.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 * $XConsortium: Scrollbar.c,v 1.72 94/04/17 20:12:40 kaleb Exp $
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 * Modified for Vim by Bill Foster and Bram Moolenaar
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 Copyright (c) 1987, 1988, 1994 X Consortium
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 Permission is hereby granted, free of charge, to any person obtaining a copy
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 of this software and associated documentation files (the "Software"), to deal
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 in the Software without restriction, including without limitation the rights
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 copies of the Software, and to permit persons to whom the Software is
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 furnished to do so, subject to the following conditions:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 The above copyright notice and this permission notice shall be included in all
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 copies or substantial portions of the Software.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE X
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 Except as contained in this notice, the name of the X Consortium shall not be
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 used in advertising or otherwise to promote the sale, use or other dealings in
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 this Software without prior written authorization from the X Consortium.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 All Rights Reserved
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 Permission to use, copy, modify, and distribute this software and its
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 documentation for any purpose and without fee is hereby granted, provided that
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 the above copyright notice appear in all copies and that both that copyright
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 notice and this permission notice appear in supporting documentation, and that
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 the name of Digital not be used in advertising or publicity pertaining to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 distribution of the software without specific, written prior permission.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL DIGITAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55 CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 /* ScrollBar.c */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 /* created by weissman, Mon Jul 7 13:20:03 1986 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 /* converted by swick, Thu Aug 27 1987 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 #include <X11/IntrinsicP.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 #include <X11/StringDefs.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 #include <X11/Xaw/XawInit.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67 #include "vim.h"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 #include "gui_at_sb.h"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 #include <X11/Xmu/Drawing.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 /* Private definitions. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74 static char defaultTranslations[] =
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75 "<Btn1Down>: NotifyScroll()\n\
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 <Btn2Down>: MoveThumb() NotifyThumb()\n\
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77 <Btn3Down>: NotifyScroll()\n\
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 <Btn4Down>: ScrollOneLineUp()\n\
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 Shift<Btn4Down>: ScrollPageUp()\n\
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 <Btn5Down>: ScrollOneLineDown()\n\
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 Shift<Btn5Down>: ScrollPageDown()\n\
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 <Btn1Motion>: HandleThumb()\n\
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 <Btn3Motion>: HandleThumb()\n\
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84 <Btn2Motion>: MoveThumb() NotifyThumb()\n\
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85 <BtnUp>: EndScroll()";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87 static float floatZero = 0.0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89 #define Offset(field) XtOffsetOf(ScrollbarRec, field)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91 static XtResource resources[] =
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93 {XtNlength, XtCLength, XtRDimension, sizeof(Dimension),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
94 Offset(scrollbar.length), XtRImmediate, (XtPointer) 1},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
95 {XtNthickness, XtCThickness, XtRDimension, sizeof(Dimension),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
96 Offset(scrollbar.thickness), XtRImmediate, (XtPointer) 14},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
97 {XtNorientation, XtCOrientation, XtROrientation, sizeof(XtOrientation),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98 Offset(scrollbar.orientation), XtRImmediate, (XtPointer) XtorientVertical},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
99 {XtNscrollProc, XtCCallback, XtRCallback, sizeof(XtPointer),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
100 Offset(scrollbar.scrollProc), XtRCallback, NULL},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
101 {XtNthumbProc, XtCCallback, XtRCallback, sizeof(XtPointer),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
102 Offset(scrollbar.thumbProc), XtRCallback, NULL},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103 {XtNjumpProc, XtCCallback, XtRCallback, sizeof(XtPointer),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104 Offset(scrollbar.jumpProc), XtRCallback, NULL},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105 {XtNthumb, XtCThumb, XtRBitmap, sizeof(Pixmap),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106 Offset(scrollbar.thumb), XtRImmediate, (XtPointer) XtUnspecifiedPixmap},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107 {XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108 Offset(scrollbar.foreground), XtRString, XtDefaultForeground},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
109 {XtNshown, XtCShown, XtRFloat, sizeof(float),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
110 Offset(scrollbar.shown), XtRFloat, (XtPointer)&floatZero},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
111 {XtNtopOfThumb, XtCTopOfThumb, XtRFloat, sizeof(float),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
112 Offset(scrollbar.top), XtRFloat, (XtPointer)&floatZero},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
113 {XtNmaxOfThumb, XtCMaxOfThumb, XtRFloat, sizeof(float),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
114 Offset(scrollbar.max), XtRFloat, (XtPointer)&floatZero},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
115 {XtNminimumThumb, XtCMinimumThumb, XtRDimension, sizeof(Dimension),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
116 Offset(scrollbar.min_thumb), XtRImmediate, (XtPointer) 7},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117 {XtNshadowWidth, XtCShadowWidth, XtRDimension, sizeof(Dimension),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
118 Offset(scrollbar.shadow_width), XtRImmediate, (XtPointer) 1},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
119 {XtNtopShadowPixel, XtCTopShadowPixel, XtRPixel, sizeof(Pixel),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
120 Offset(scrollbar.top_shadow_pixel), XtRString, XtDefaultBackground},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
121 {XtNbottomShadowPixel, XtCBottomShadowPixel, XtRPixel, sizeof(Pixel),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
122 Offset(scrollbar.bot_shadow_pixel), XtRString, XtDefaultForeground},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
123 {XtNlimitThumb, XtCLimitThumb, XtRBool, sizeof(Bool),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
124 Offset(scrollbar.limit_thumb), XtRImmediate, (XtPointer)0}
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
125 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
126 #undef Offset
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
127
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
128 static void ClassInitialize __ARGS((void));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
129 static void Initialize __ARGS((Widget, Widget, ArgList, Cardinal *));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
130 static void Destroy __ARGS((Widget));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
131 static void Realize __ARGS((Widget, Mask *, XSetWindowAttributes *));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
132 static void Resize __ARGS((Widget));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
133 static void Redisplay __ARGS((Widget, XEvent *, Region));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
134 static Boolean SetValues __ARGS((Widget, Widget, Widget, ArgList, Cardinal *));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
135
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
136 static void HandleThumb __ARGS((Widget, XEvent *, String *, Cardinal *));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
137 static void MoveThumb __ARGS((Widget, XEvent *, String *, Cardinal *));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
138 static void NotifyThumb __ARGS((Widget, XEvent *, String *, Cardinal *));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
139 static void NotifyScroll __ARGS((Widget, XEvent *, String *, Cardinal *));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
140 static void EndScroll __ARGS((Widget, XEvent *, String *, Cardinal *));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
141 static void ScrollOneLineUp __ARGS((Widget, XEvent *, String *, Cardinal *));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
142 static void ScrollOneLineDown __ARGS((Widget, XEvent *, String *, Cardinal *));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
143 static void ScrollPageUp __ARGS((Widget, XEvent *, String *, Cardinal *));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
144 static void ScrollPageDown __ARGS((Widget, XEvent *, String *, Cardinal *));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
145 static void ScrollSome __ARGS((Widget w, XEvent *event, int call_data));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
146 static void _Xaw3dDrawShadows __ARGS((Widget, XEvent *, Region, int));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
147 static void AllocTopShadowGC __ARGS((Widget));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
148 static void AllocBotShadowGC __ARGS((Widget));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
149
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
150 static XtActionsRec actions[] =
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
151 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
152 {"HandleThumb", HandleThumb},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
153 {"MoveThumb", MoveThumb},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
154 {"NotifyThumb", NotifyThumb},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
155 {"NotifyScroll", NotifyScroll},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
156 {"EndScroll", EndScroll},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
157 {"ScrollOneLineUp", ScrollOneLineUp},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
158 {"ScrollOneLineDown", ScrollOneLineDown},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
159 {"ScrollPageUp", ScrollPageUp},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
160 {"ScrollPageDown", ScrollPageDown}
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
161 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
162
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
163
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
164 ScrollbarClassRec vim_scrollbarClassRec =
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
165 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
166 { /* core fields */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
167 /* superclass */ (WidgetClass) &simpleClassRec,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
168 /* class_name */ "Scrollbar",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
169 /* size */ sizeof(ScrollbarRec),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
170 /* class_initialize */ ClassInitialize,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
171 /* class_part_init */ NULL,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
172 /* class_inited */ FALSE,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
173 /* initialize */ Initialize,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
174 /* initialize_hook */ NULL,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
175 /* realize */ Realize,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
176 /* actions */ actions,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
177 /* num_actions */ XtNumber(actions),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
178 /* resources */ resources,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
179 /* num_resources */ XtNumber(resources),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
180 /* xrm_class */ NULLQUARK,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
181 /* compress_motion */ TRUE,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
182 /* compress_exposure*/ TRUE,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
183 /* compress_enterleave*/ TRUE,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
184 /* visible_interest */ FALSE,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
185 /* destroy */ Destroy,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
186 /* resize */ Resize,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
187 /* expose */ Redisplay,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
188 /* set_values */ SetValues,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
189 /* set_values_hook */ NULL,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
190 /* set_values_almost */ XtInheritSetValuesAlmost,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
191 /* get_values_hook */ NULL,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
192 /* accept_focus */ NULL,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
193 /* version */ XtVersion,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
194 /* callback_private */ NULL,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
195 /* tm_table */ defaultTranslations,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
196 /* query_geometry */ XtInheritQueryGeometry,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
197 /* display_accelerator*/ XtInheritDisplayAccelerator,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
198 /* extension */ NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
199 },
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
200 { /* simple fields */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
201 /* change_sensitive */ XtInheritChangeSensitive
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
202 },
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
203 { /* scrollbar fields */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
204 /* ignore */ 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
205 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
206 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
207
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
208 WidgetClass vim_scrollbarWidgetClass = (WidgetClass)&vim_scrollbarClassRec;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
209
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
210 #define NoButton -1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
211 #define PICKLENGTH(widget, x, y) \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
212 ((widget->scrollbar.orientation == XtorientHorizontal) ? (x) : (y))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
213 #define AT_MIN(x,y) ((x) < (y) ? (x) : (y))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
214 #define AT_MAX(x,y) ((x) > (y) ? (x) : (y))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
215
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
216 #define LINE_DELAY 300
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
217 #define PAGE_DELAY 300
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
218 #define LINE_REPEAT 50
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
219 #define PAGE_REPEAT 250
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
220
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
221 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
222 ClassInitialize()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
223 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
224 XawInitializeWidgetSet();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
225 XtAddConverter( XtRString, XtROrientation, XmuCvtStringToOrientation,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
226 (XtConvertArgList)NULL, (Cardinal)0 );
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
227 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
228
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
229 #define MARGIN(sbw) (sbw)->scrollbar.thickness + (sbw)->scrollbar.shadow_width
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
230
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
231 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
232 FillArea(sbw, top, bottom, fill, draw_shadow)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
233 ScrollbarWidget sbw;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
234 Position top, bottom;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
235 int fill;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
236 int draw_shadow;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
237 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
238 int tlen = bottom - top; /* length of thumb in pixels */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
239 int sw, margin, floor;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
240 int lx, ly, lw, lh;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
241
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
242 if (bottom <= 0 || bottom <= top)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
243 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
244 if ((sw = sbw->scrollbar.shadow_width) < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
245 sw = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
246 margin = MARGIN (sbw);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
247 floor = sbw->scrollbar.length - margin + 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
248
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
249 if (sbw->scrollbar.orientation == XtorientHorizontal)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
250 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
251 lx = ((top < margin) ? margin : top);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
252 ly = sw;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
253 lw = (((top + tlen) > floor) ? floor - top : tlen);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
254 lh = sbw->core.height - 2 * sw;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
255 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
256 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
257 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
258 lx = sw;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
259 ly = ((top < margin) ? margin : top);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
260 lw = sbw->core.width - 2 * sw;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
261 lh = (((top + tlen) > floor) ? floor - top : tlen);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
262 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
263 if (lh <= 0 || lw <= 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
264 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
265
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
266 if (draw_shadow)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
267 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
268 if (!(sbw->scrollbar.orientation == XtorientHorizontal))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
269 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
270 /* Top border */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
271 XDrawLine (XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
272 sbw->scrollbar.top_shadow_GC,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
273 lx, ly, lx + lw - 1, ly);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
274
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
275 /* Bottom border */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
276 XDrawLine (XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
277 sbw->scrollbar.bot_shadow_GC,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
278 lx, ly + lh - 1, lx + lw - 1, ly + lh - 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
279 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
280 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
281 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
282 /* Left border */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
283 XDrawLine (XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
284 sbw->scrollbar.top_shadow_GC,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
285 lx, ly, lx, ly + lh - 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
286
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
287 /* Right border */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
288 XDrawLine (XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
289 sbw->scrollbar.bot_shadow_GC,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
290 lx + lw - 1, ly, lx + lw - 1, ly + lh - 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
291 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
292 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
293 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
294
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
295 if (fill)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
296 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
297 XFillRectangle(XtDisplay((Widget) sbw), XtWindow((Widget) sbw),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
298 sbw->scrollbar.gc,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
299 lx, ly, (unsigned int) lw, (unsigned int) lh);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
300
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
301 if (!(sbw->scrollbar.orientation == XtorientHorizontal))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
302 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
303 /* Left border */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
304 XDrawLine(XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
305 sbw->scrollbar.top_shadow_GC,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
306 lx, ly, lx, ly + lh - 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
307
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
308 /* Right border */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
309 XDrawLine(XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
310 sbw->scrollbar.bot_shadow_GC,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
311 lx + lw - 1, ly, lx + lw - 1, ly + lh - 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
312 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
313 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
314 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
315 /* Top border */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
316 XDrawLine(XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
317 sbw->scrollbar.top_shadow_GC,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
318 lx, ly, lx + lw - 1, ly);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
319
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
320 /* Bottom border */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
321 XDrawLine(XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
322 sbw->scrollbar.bot_shadow_GC,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
323 lx, ly + lh - 1, lx + lw - 1, ly + lh - 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
324 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
325 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
326 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
327 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
328 XClearArea(XtDisplay((Widget) sbw), XtWindow((Widget) sbw),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
329 lx, ly, (unsigned int) lw, (unsigned int) lh, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
330 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
331 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
332
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
333 /* Paint the thumb in the area specified by sbw->top and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
334 sbw->shown. The old area is erased. The painting and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
335 erasing is done cleverly so that no flickering will occur.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
336 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
337
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
338 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
339 PaintThumb(sbw)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
340 ScrollbarWidget sbw;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
341 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
342 Position oldtop, oldbot, newtop, newbot;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
343 Dimension margin, tzl;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
344
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
345 margin = MARGIN (sbw);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
346 tzl = sbw->scrollbar.length - 2 * margin;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
347 newtop = margin + (int)(tzl * sbw->scrollbar.top);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
348 newbot = newtop + (int)(tzl * sbw->scrollbar.shown) + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
349 if (newbot < newtop + (int)sbw->scrollbar.min_thumb)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
350 newbot = newtop + sbw->scrollbar.min_thumb;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
351
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
352 oldtop = sbw->scrollbar.topLoc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
353 oldbot = oldtop + sbw->scrollbar.shownLength;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
354 sbw->scrollbar.topLoc = newtop;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
355 sbw->scrollbar.shownLength = newbot - newtop;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
356 if (XtIsRealized ((Widget) sbw))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
357 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
358 if (newtop < oldtop)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
359 FillArea(sbw, newtop, AT_MIN(newbot, oldtop+1),1,0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
360 if (newtop > oldtop)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
361 FillArea(sbw, oldtop, AT_MIN(newtop, oldbot ),0,0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
362 if (newbot < oldbot)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
363 FillArea(sbw, AT_MAX(newbot, oldtop), oldbot, 0,0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
364 if (newbot > oldbot)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
365 FillArea(sbw, AT_MAX(newtop, oldbot-1), newbot, 1,0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
366
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
367 /* Only draw the missing shadows */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
368 FillArea(sbw, newtop, newbot, 0, 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
369 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
370 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
371
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
372 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
373 PaintArrows(sbw)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
374 ScrollbarWidget sbw;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
375 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
376 XPoint point[6];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
377 Dimension thickness = sbw->scrollbar.thickness - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
378 Dimension size;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
379 Dimension off;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
380
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
381 if (XtIsRealized((Widget) sbw))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
382 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
383 if ((int)thickness * 2 > (int)sbw->scrollbar.length)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
384 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
385 size = sbw->scrollbar.length / 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
386 off = (int)(thickness - size) / 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
387 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
388 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
389 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
390 size = thickness;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
391 off = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
392 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
393 point[0].x = off + sbw->scrollbar.shadow_width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
394 point[0].y = size;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
395 point[1].x = thickness - off - sbw->scrollbar.shadow_width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
396 point[1].y = size;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
397 point[2].x = thickness / 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
398 point[2].y = sbw->scrollbar.shadow_width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
399
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
400 point[3].x = off + sbw->scrollbar.shadow_width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
401 point[3].y = sbw->scrollbar.length - size;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
402 point[4].x = thickness - off - sbw->scrollbar.shadow_width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
403 point[4].y = sbw->scrollbar.length - size;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
404 point[5].x = thickness / 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
405 point[5].y = sbw->scrollbar.length - sbw->scrollbar.shadow_width - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
406
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
407 /* horizontal arrows require that x and y coordinates be swapped */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
408 if (sbw->scrollbar.orientation == XtorientHorizontal)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
409 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
410 int n;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
411 int swap;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
412 for (n = 0; n < 6; n++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
413 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
414 swap = point[n].x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
415 point[n].x = point[n].y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
416 point[n].y = swap;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
417 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
418 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
419 /* draw the up/left arrow */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
420 XFillPolygon (XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
421 sbw->scrollbar.gc,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
422 point, 3,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
423 Convex, CoordModeOrigin);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
424 XDrawLines (XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
425 sbw->scrollbar.bot_shadow_GC,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
426 point, 3,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
427 CoordModeOrigin);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
428 XDrawLine (XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
429 sbw->scrollbar.top_shadow_GC,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
430 point[0].x, point[0].y,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
431 point[2].x, point[2].y);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
432 /* draw the down/right arrow */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
433 XFillPolygon (XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
434 sbw->scrollbar.gc,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
435 point+3, 3,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
436 Convex, CoordModeOrigin);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
437 XDrawLine (XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
438 sbw->scrollbar.top_shadow_GC,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
439 point[3].x, point[3].y,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
440 point[4].x, point[4].y);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
441 XDrawLine (XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
442 sbw->scrollbar.top_shadow_GC,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
443 point[3].x, point[3].y,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
444 point[5].x, point[5].y);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
445 XDrawLine (XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
446 sbw->scrollbar.bot_shadow_GC,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
447 point[4].x, point[4].y,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
448 point[5].x, point[5].y);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
449 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
450 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
451
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
452 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
453 Destroy(w)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
454 Widget w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
455 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
456 ScrollbarWidget sbw = (ScrollbarWidget) w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
457 if (sbw->scrollbar.timer_id != (XtIntervalId) 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
458 XtRemoveTimeOut (sbw->scrollbar.timer_id);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
459 XtReleaseGC(w, sbw->scrollbar.gc);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
460 XtReleaseGC(w, sbw->scrollbar.top_shadow_GC);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
461 XtReleaseGC(w, sbw->scrollbar.bot_shadow_GC);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
462 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
463
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
464 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
465 CreateGC(w)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
466 Widget w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
467 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
468 ScrollbarWidget sbw = (ScrollbarWidget) w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
469 XGCValues gcValues;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
470 XtGCMask mask;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
471 unsigned int depth = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
472
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
473 if (sbw->scrollbar.thumb == XtUnspecifiedPixmap)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
474 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
475 sbw->scrollbar.thumb = XmuCreateStippledPixmap (XtScreen(w),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
476 (Pixel) 1, (Pixel) 0, depth);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
477 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
478 else if (sbw->scrollbar.thumb != None)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
479 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
480 Window root;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
481 int x, y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
482 unsigned int width, height, bw;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
483
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
484 if (XGetGeometry (XtDisplay(w), sbw->scrollbar.thumb, &root, &x, &y,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
485 &width, &height, &bw, &depth) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
486 EMSG(_("Scrollbar Widget: Could not get geometry of thumb pixmap."));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
487 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
488
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
489 gcValues.foreground = sbw->scrollbar.foreground;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
490 gcValues.background = sbw->core.background_pixel;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
491 mask = GCForeground | GCBackground;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
492
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
493 if (sbw->scrollbar.thumb != None)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
494 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
495 gcValues.fill_style = FillSolid;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
496 mask |= GCFillStyle;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
497 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
498 /* the creation should be non-caching, because */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
499 /* we now set and clear clip masks on the gc returned */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
500 sbw->scrollbar.gc = XtGetGC (w, mask, &gcValues);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
501 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
502
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
503 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
504 SetDimensions(sbw)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
505 ScrollbarWidget sbw;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
506 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
507 if (sbw->scrollbar.orientation == XtorientVertical)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
508 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
509 sbw->scrollbar.length = sbw->core.height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
510 sbw->scrollbar.thickness = sbw->core.width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
511 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
512 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
513 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
514 sbw->scrollbar.length = sbw->core.width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
515 sbw->scrollbar.thickness = sbw->core.height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
516 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
517 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
518
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
519 /* ARGSUSED */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
520 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
521 Initialize(request, new, args, num_args)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
522 Widget request; /* what the client asked for */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
523 Widget new; /* what we're going to give him */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
524 ArgList args;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
525 Cardinal *num_args;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
526 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
527 ScrollbarWidget sbw = (ScrollbarWidget) new;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
528
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
529 CreateGC(new);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
530 AllocTopShadowGC(new);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
531 AllocBotShadowGC(new);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
532
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
533 if (sbw->core.width == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
534 sbw->core.width = (sbw->scrollbar.orientation == XtorientVertical)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
535 ? sbw->scrollbar.thickness : sbw->scrollbar.length;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
536
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
537 if (sbw->core.height == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
538 sbw->core.height = (sbw->scrollbar.orientation == XtorientHorizontal)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
539 ? sbw->scrollbar.thickness : sbw->scrollbar.length;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
540
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
541 SetDimensions(sbw);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
542 sbw->scrollbar.scroll_mode = SMODE_NONE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
543 sbw->scrollbar.timer_id = (XtIntervalId)0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
544 sbw->scrollbar.topLoc = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
545 sbw->scrollbar.shownLength = sbw->scrollbar.min_thumb;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
546 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
547
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
548 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
549 Realize(w, valueMask, attributes)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
550 Widget w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
551 Mask *valueMask;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
552 XSetWindowAttributes *attributes;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
553 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
554 /* The Simple widget actually stuffs the value in the valuemask. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
555 (*vim_scrollbarWidgetClass->core_class.superclass->core_class.realize)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
556 (w, valueMask, attributes);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
557 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
558
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
559 /* ARGSUSED */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
560 static Boolean
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
561 SetValues(current, request, desired, args, num_args)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
562 Widget current, /* what I am */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
563 request, /* what he wants me to be */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
564 desired; /* what I will become */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
565 ArgList args;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
566 Cardinal *num_args;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
567 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
568 ScrollbarWidget sbw = (ScrollbarWidget) current;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
569 ScrollbarWidget dsbw = (ScrollbarWidget) desired;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
570 Boolean redraw = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
571
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
572 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
573 * If these values are outside the acceptable range ignore them...
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
574 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
575 if (dsbw->scrollbar.top < 0.0 || dsbw->scrollbar.top > 1.0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
576 dsbw->scrollbar.top = sbw->scrollbar.top;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
577
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
578 if (dsbw->scrollbar.shown < 0.0 || dsbw->scrollbar.shown > 1.0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
579 dsbw->scrollbar.shown = sbw->scrollbar.shown;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
580
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
581 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
582 * Change colors and stuff...
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
583 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
584 if (XtIsRealized(desired))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
585 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
586 if (sbw->scrollbar.foreground != dsbw->scrollbar.foreground ||
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
587 sbw->core.background_pixel != dsbw->core.background_pixel ||
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
588 sbw->scrollbar.thumb != dsbw->scrollbar.thumb)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
589 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
590 XtReleaseGC(desired, sbw->scrollbar.gc);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
591 CreateGC (desired);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
592 redraw = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
593 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
594 if (sbw->scrollbar.top != dsbw->scrollbar.top ||
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
595 sbw->scrollbar.shown != dsbw->scrollbar.shown)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
596 redraw = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
597 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
598 return redraw;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
599 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
600
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
601 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
602 Resize(w)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
603 Widget w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
604 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
605 /* ForgetGravity has taken care of background, but thumb may
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
606 * have to move as a result of the new size. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
607 SetDimensions ((ScrollbarWidget) w);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
608 Redisplay(w, (XEvent*) NULL, (Region)NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
609 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
610
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
611
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
612 /* ARGSUSED */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
613 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
614 Redisplay(w, event, region)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
615 Widget w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
616 XEvent *event;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
617 Region region;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
618 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
619 ScrollbarWidget sbw = (ScrollbarWidget) w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
620 int x, y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
621 unsigned int width, height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
622
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
623 _Xaw3dDrawShadows(w, event, region, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
624
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
625 if (sbw->scrollbar.orientation == XtorientHorizontal)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
626 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
627 x = sbw->scrollbar.topLoc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
628 y = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
629 width = sbw->scrollbar.shownLength;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
630 height = sbw->core.height - 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
631 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
632 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
633 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
634 x = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
635 y = sbw->scrollbar.topLoc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
636 width = sbw->core.width - 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
637 height = sbw->scrollbar.shownLength;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
638 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
639 if (region == NULL ||
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
640 XRectInRegion (region, x, y, width, height) != RectangleOut)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
641 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
642 /* Forces entire thumb to be painted. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
643 sbw->scrollbar.topLoc = -(sbw->scrollbar.length + 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
644 PaintThumb (sbw);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
645 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
646 /* we'd like to be region aware here!!!! */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
647 PaintArrows(sbw);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
648 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
649
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
650
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
651 static Boolean
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
652 CompareEvents(oldEvent, newEvent)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
653 XEvent *oldEvent, *newEvent;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
654 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
655 #define Check(field) if (newEvent->field != oldEvent->field) return False;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
656
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
657 Check(xany.display);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
658 Check(xany.type);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
659 Check(xany.window);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
660
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
661 switch (newEvent->type)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
662 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
663 case MotionNotify:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
664 Check(xmotion.state);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
665 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
666 case ButtonPress:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
667 case ButtonRelease:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
668 Check(xbutton.state);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
669 Check(xbutton.button);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
670 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
671 case KeyPress:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
672 case KeyRelease:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
673 Check(xkey.state);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
674 Check(xkey.keycode);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
675 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
676 case EnterNotify:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
677 case LeaveNotify:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
678 Check(xcrossing.mode);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
679 Check(xcrossing.detail);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
680 Check(xcrossing.state);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
681 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
682 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
683 #undef Check
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
684
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
685 return True;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
686 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
687
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
688 struct EventData
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
689 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
690 XEvent *oldEvent;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
691 int count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
692 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
693
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
694 static Bool
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
695 PeekNotifyEvent(dpy, event, args)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
696 Display *dpy;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
697 XEvent *event;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
698 char *args;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
699 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
700 struct EventData *eventData = (struct EventData*)args;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
701
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
702 return ((++eventData->count == QLength(dpy)) /* since PeekIf blocks */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
703 || CompareEvents(event, eventData->oldEvent));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
704 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
705
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
706
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
707 static Boolean
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
708 LookAhead(w, event)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
709 Widget w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
710 XEvent *event;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
711 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
712 XEvent newEvent;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
713 struct EventData eventData;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
714
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
715 if (QLength (XtDisplay (w)) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
716 return False;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
717
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
718 eventData.count = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
719 eventData.oldEvent = event;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
720
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
721 XPeekIfEvent (XtDisplay (w), &newEvent, PeekNotifyEvent, (char*)&eventData);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
722
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
723 return CompareEvents (event, &newEvent);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
724 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
725
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
726
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
727 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
728 ExtractPosition(event, x, y, state)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
729 XEvent *event;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
730 Position *x, *y; /* RETURN */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
731 unsigned int *state; /* RETURN */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
732 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
733 switch (event->type)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
734 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
735 case MotionNotify:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
736 *x = event->xmotion.x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
737 *y = event->xmotion.y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
738 if (state != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
739 *state = event->xmotion.state;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
740 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
741 case ButtonPress:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
742 case ButtonRelease:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
743 *x = event->xbutton.x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
744 *y = event->xbutton.y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
745 if (state != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
746 *state = event->xbutton.state;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
747 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
748 case KeyPress:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
749 case KeyRelease:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
750 *x = event->xkey.x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
751 *y = event->xkey.y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
752 if (state != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
753 *state = event->xkey.state;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
754 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
755 case EnterNotify:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
756 case LeaveNotify:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
757 *x = event->xcrossing.x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
758 *y = event->xcrossing.y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
759 if (state != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
760 *state = event->xcrossing.state;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
761 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
762 default:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
763 *x = 0; *y = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
764 if (state != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
765 *state = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
766 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
767 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
768
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
769 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
770 HandleThumb(w, event, params, num_params)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
771 Widget w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
772 XEvent *event;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
773 String *params;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
774 Cardinal *num_params;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
775 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
776 Position x, y, loc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
777 ScrollbarWidget sbw = (ScrollbarWidget) w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
778
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
779 ExtractPosition(event, &x, &y, (unsigned int *)NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
780 loc = PICKLENGTH(sbw, x, y);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
781 /* if the motion event puts the pointer in thumb, call Move and Notify */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
782 /* also call Move and Notify if we're already in continuous scroll mode */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
783 if (sbw->scrollbar.scroll_mode == SMODE_CONT ||
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
784 (loc >= sbw->scrollbar.topLoc &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
785 loc <= sbw->scrollbar.topLoc + (int)sbw->scrollbar.shownLength))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
786 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
787 XtCallActionProc(w, "MoveThumb", event, params, *num_params);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
788 XtCallActionProc(w, "NotifyThumb", event, params, *num_params);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
789 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
790 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
791
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
792 /* ARGSUSED */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
793 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
794 RepeatNotify(client_data, idp)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
795 XtPointer client_data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
796 XtIntervalId *idp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
797 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
798 ScrollbarWidget sbw = (ScrollbarWidget) client_data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
799 int call_data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
800 char mode = sbw->scrollbar.scroll_mode;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
801 unsigned long rep;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
802
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
803 if (mode == SMODE_NONE || mode == SMODE_CONT)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
804 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
805 sbw->scrollbar.timer_id = (XtIntervalId)0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
806 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
807 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
808
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
809 if (mode == SMODE_LINE_DOWN || mode == SMODE_LINE_UP)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
810 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
811 call_data = ONE_LINE_DATA;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
812 rep = LINE_REPEAT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
813 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
814 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
815 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
816 call_data = ONE_PAGE_DATA;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
817 rep = PAGE_REPEAT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
818 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
819
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
820 if (mode == SMODE_PAGE_UP || mode == SMODE_LINE_UP)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
821 call_data = -call_data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
822
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
823 XtCallCallbacks((Widget)sbw, XtNscrollProc, (XtPointer)call_data);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
824
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
825 sbw->scrollbar.timer_id =
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
826 XtAppAddTimeOut(XtWidgetToApplicationContext((Widget)sbw),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
827 rep,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
828 RepeatNotify,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
829 client_data);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
830 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
831
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
832 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
833 * Same as above, but for floating numbers.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
834 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
835 static float
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
836 FloatInRange(num, small, big)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
837 float num, small, big;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
838 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
839 return (num < small) ? small : ((num > big) ? big : num);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
840 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
841
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
842 /* ARGSUSED */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
843 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
844 ScrollOneLineUp(w, event, params, num_params)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
845 Widget w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
846 XEvent *event;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
847 String *params;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
848 Cardinal *num_params;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
849 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
850 ScrollSome(w, event, -ONE_LINE_DATA);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
851 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
852
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
853 /* ARGSUSED */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
854 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
855 ScrollOneLineDown(w, event, params, num_params)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
856 Widget w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
857 XEvent *event;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
858 String *params;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
859 Cardinal *num_params;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
860 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
861 ScrollSome(w, event, ONE_LINE_DATA);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
862 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
863
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
864 /* ARGSUSED */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
865 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
866 ScrollPageDown(w, event, params, num_params)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
867 Widget w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
868 XEvent *event;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
869 String *params;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
870 Cardinal *num_params;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
871 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
872 ScrollSome(w, event, ONE_PAGE_DATA);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
873 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
874
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
875 /* ARGSUSED */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
876 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
877 ScrollPageUp(w, event, params, num_params)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
878 Widget w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
879 XEvent *event;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
880 String *params;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
881 Cardinal *num_params;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
882 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
883 ScrollSome(w, event, -ONE_PAGE_DATA);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
884 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
885
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
886 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
887 ScrollSome(w, event, call_data)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
888 Widget w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
889 XEvent *event;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
890 int call_data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
891 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
892 ScrollbarWidget sbw = (ScrollbarWidget) w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
893
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
894 if (sbw->scrollbar.scroll_mode == SMODE_CONT) /* if scroll continuous */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
895 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
896
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
897 if (LookAhead(w, event))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
898 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
899
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
900 sbw->scrollbar.scroll_mode = SMODE_LINE_UP;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
901 XtCallCallbacks(w, XtNscrollProc, (XtPointer)call_data);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
902 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
903
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
904 /* ARGSUSED */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
905 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
906 NotifyScroll(w, event, params, num_params)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
907 Widget w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
908 XEvent *event;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
909 String *params;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
910 Cardinal *num_params;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
911 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
912 ScrollbarWidget sbw = (ScrollbarWidget) w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
913 Position x, y, loc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
914 Dimension arrow_size;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
915 unsigned long delay = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
916 int call_data = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
917 unsigned int state;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
918
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
919 if (sbw->scrollbar.scroll_mode == SMODE_CONT) /* if scroll continuous */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
920 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
921
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
922 if (LookAhead (w, event))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
923 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
924
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
925 ExtractPosition(event, &x, &y, &state);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
926 loc = PICKLENGTH(sbw, x, y);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
927
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
928 if ((int)sbw->scrollbar.thickness * 2 > (int)sbw->scrollbar.length)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
929 arrow_size = sbw->scrollbar.length / 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
930 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
931 arrow_size = sbw->scrollbar.thickness;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
932
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
933 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
934 * handle CTRL modifier
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
935 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
936 if (state & ControlMask)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
937 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
938 if (loc > sbw->scrollbar.topLoc + (Position)sbw->scrollbar.shownLength)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
939 call_data = END_PAGE_DATA;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
940 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
941 call_data = -END_PAGE_DATA;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
942 sbw->scrollbar.scroll_mode = SMODE_NONE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
943 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
944 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
945 * handle first arrow zone
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
946 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
947 else if (loc < (Position)arrow_size)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
948 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
949 call_data = -ONE_LINE_DATA;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
950 sbw->scrollbar.scroll_mode = SMODE_LINE_UP;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
951 delay = LINE_DELAY;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
952 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
953
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
954 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
955 * handle last arrow zone
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
956 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
957 else if (loc > (Position)(sbw->scrollbar.length - arrow_size))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
958 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
959 call_data = ONE_LINE_DATA;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
960 sbw->scrollbar.scroll_mode = SMODE_LINE_DOWN;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
961 delay = LINE_DELAY;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
962 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
963
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
964 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
965 * handle zone "above" the thumb
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
966 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
967 else if (loc < sbw->scrollbar.topLoc)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
968 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
969 call_data = -ONE_PAGE_DATA;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
970 sbw->scrollbar.scroll_mode = SMODE_PAGE_UP;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
971 delay = PAGE_DELAY;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
972 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
973
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
974 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
975 * handle zone "below" the thumb
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
976 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
977 else if (loc > sbw->scrollbar.topLoc + (Position)sbw->scrollbar.shownLength)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
978 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
979 call_data = ONE_PAGE_DATA;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
980 sbw->scrollbar.scroll_mode = SMODE_PAGE_DOWN;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
981 delay = PAGE_DELAY;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
982 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
983
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
984 if (call_data)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
985 XtCallCallbacks(w, XtNscrollProc, (XtPointer)call_data);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
986
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
987 /* establish autoscroll */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
988 if (delay)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
989 sbw->scrollbar.timer_id =
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
990 XtAppAddTimeOut(XtWidgetToApplicationContext(w),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
991 delay, RepeatNotify, (XtPointer)w);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
992 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
993
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
994 /* ARGSUSED */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
995 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
996 EndScroll(w, event, params, num_params)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
997 Widget w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
998 XEvent *event; /* unused */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
999 String *params; /* unused */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1000 Cardinal *num_params; /* unused */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1001 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1002 ScrollbarWidget sbw = (ScrollbarWidget) w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1003
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1004 sbw->scrollbar.scroll_mode = SMODE_NONE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1005 /* no need to remove any autoscroll timeout; it will no-op */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1006 /* because the scroll_mode is SMODE_NONE */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1007 /* but be sure to remove timeout in destroy proc */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1008 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1009
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1010 static float
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1011 FractionLoc(sbw, x, y)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1012 ScrollbarWidget sbw;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1013 int x, y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1014 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1015 int margin;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1016 float height, width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1017
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1018 margin = MARGIN(sbw);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1019 x -= margin;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1020 y -= margin;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1021 height = (float)sbw->core.height - 2 * margin;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1022 width = (float)sbw->core.width - 2 * margin;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1023 return PICKLENGTH(sbw, x / width, y / height);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1024 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1025
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1026 /* ARGSUSED */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1027 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1028 MoveThumb(w, event, params, num_params)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1029 Widget w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1030 XEvent *event;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1031 String *params; /* unused */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1032 Cardinal *num_params; /* unused */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1033 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1034 ScrollbarWidget sbw = (ScrollbarWidget)w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1035 Position x, y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1036 float top;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1037 char old_mode = sbw->scrollbar.scroll_mode;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1038
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1039 sbw->scrollbar.scroll_mode = SMODE_CONT; /* indicate continuous scroll */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1040
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1041 if (LookAhead(w, event))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1042 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1043
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1044 if (!event->xmotion.same_screen)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1045 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1046
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1047 ExtractPosition(event, &x, &y, (unsigned int *)NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1048
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1049 top = FractionLoc(sbw, x, y);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1050
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1051 if (old_mode != SMODE_CONT) /* start dragging: set offset */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1052 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1053 if (event->xbutton.button == Button2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1054 sbw->scrollbar.scroll_off = sbw->scrollbar.shown / 2.;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1055 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1056 sbw->scrollbar.scroll_off = top - sbw->scrollbar.top;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1057 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1058
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1059 top -= sbw->scrollbar.scroll_off;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1060 if (sbw->scrollbar.limit_thumb)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1061 top = FloatInRange(top, 0.0,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1062 sbw->scrollbar.max - sbw->scrollbar.shown + 0.000001);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1063 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1064 top = FloatInRange(top, 0.0, sbw->scrollbar.max);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1065
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1066 sbw->scrollbar.top = top;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1067 PaintThumb(sbw);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1068 XFlush(XtDisplay(w)); /* re-draw it before Notifying */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1069 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1070
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1071
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1072 /* ARGSUSED */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1073 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1074 NotifyThumb(w, event, params, num_params)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1075 Widget w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1076 XEvent *event;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1077 String *params; /* unused */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1078 Cardinal *num_params; /* unused */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1079 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1080 ScrollbarWidget sbw = (ScrollbarWidget)w;
1757
f10fe14748e2 updated for version 7.2-055
vimboss
parents: 7
diff changeset
1081 /* Use a union to avoid a warning for the weird conversion from float to
f10fe14748e2 updated for version 7.2-055
vimboss
parents: 7
diff changeset
1082 * XtPointer. Comes from Xaw/Scrollbar.c. */
f10fe14748e2 updated for version 7.2-055
vimboss
parents: 7
diff changeset
1083 union {
f10fe14748e2 updated for version 7.2-055
vimboss
parents: 7
diff changeset
1084 XtPointer xtp;
f10fe14748e2 updated for version 7.2-055
vimboss
parents: 7
diff changeset
1085 float xtf;
f10fe14748e2 updated for version 7.2-055
vimboss
parents: 7
diff changeset
1086 } xtpf;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1087
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1088 if (LookAhead(w, event))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1089 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1090
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1091 /* thumbProc is not pretty, but is necessary for backwards
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1092 compatibility on those architectures for which it work{s,ed};
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1093 the intent is to pass a (truncated) float by value. */
1757
f10fe14748e2 updated for version 7.2-055
vimboss
parents: 7
diff changeset
1094 xtpf.xtf = sbw->scrollbar.top;
f10fe14748e2 updated for version 7.2-055
vimboss
parents: 7
diff changeset
1095 XtCallCallbacks(w, XtNthumbProc, xtpf.xtp);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1096 XtCallCallbacks(w, XtNjumpProc, (XtPointer)&sbw->scrollbar.top);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1097 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1098
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1099 /* ARGSUSED */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1100 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1101 AllocTopShadowGC(w)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1102 Widget w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1103 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1104 ScrollbarWidget sbw = (ScrollbarWidget) w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1105 XtGCMask valuemask;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1106 XGCValues myXGCV;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1107
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1108 valuemask = GCForeground;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1109 myXGCV.foreground = sbw->scrollbar.top_shadow_pixel;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1110 sbw->scrollbar.top_shadow_GC = XtGetGC(w, valuemask, &myXGCV);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1111 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1112
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1113 /* ARGSUSED */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1114 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1115 AllocBotShadowGC(w)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1116 Widget w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1117 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1118 ScrollbarWidget sbw = (ScrollbarWidget) w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1119 XtGCMask valuemask;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1120 XGCValues myXGCV;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1121
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1122 valuemask = GCForeground;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1123 myXGCV.foreground = sbw->scrollbar.bot_shadow_pixel;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1124 sbw->scrollbar.bot_shadow_GC = XtGetGC(w, valuemask, &myXGCV);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1125 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1126
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1127 /* ARGSUSED */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1128 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1129 _Xaw3dDrawShadows(gw, event, region, out)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1130 Widget gw;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1131 XEvent *event;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1132 Region region;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1133 int out;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1134 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1135 XPoint pt[6];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1136 ScrollbarWidget sbw = (ScrollbarWidget) gw;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1137 Dimension s = sbw->scrollbar.shadow_width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1138 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1139 * draw the shadows using the core part width and height,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1140 * and the scrollbar part shadow_width.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1141 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1142 * no point to do anything if the shadow_width is 0 or the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1143 * widget has not been realized.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1144 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1145 if (s > 0 && XtIsRealized(gw))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1146 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1147 Dimension h = sbw->core.height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1148 Dimension w = sbw->core.width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1149 Dimension wms = w - s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1150 Dimension hms = h - s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1151 Display *dpy = XtDisplay (gw);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1152 Window win = XtWindow (gw);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1153 GC top, bot;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1154
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1155 if (out)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1156 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1157 top = sbw->scrollbar.top_shadow_GC;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1158 bot = sbw->scrollbar.bot_shadow_GC;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1159 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1160 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1161 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1162 top = sbw->scrollbar.bot_shadow_GC;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1163 bot = sbw->scrollbar.top_shadow_GC;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1164 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1165
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1166 /* top-left shadow */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1167 if ((region == NULL) ||
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1168 (XRectInRegion (region, 0, 0, w, s) != RectangleOut) ||
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1169 (XRectInRegion (region, 0, 0, s, h) != RectangleOut))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1170 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1171 pt[0].x = 0; pt[0].y = h;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1172 pt[1].x = pt[1].y = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1173 pt[2].x = w; pt[2].y = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1174 pt[3].x = wms; pt[3].y = s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1175 pt[4].x = pt[4].y = s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1176 pt[5].x = s; pt[5].y = hms;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1177 XFillPolygon (dpy, win, top, pt, 6, Complex, CoordModeOrigin);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1178 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1179
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1180 /* bottom-right shadow */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1181 if ((region == NULL) ||
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1182 (XRectInRegion (region, 0, hms, w, s) != RectangleOut) ||
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1183 (XRectInRegion (region, wms, 0, s, h) != RectangleOut))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1184 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1185 pt[0].x = 0; pt[0].y = h;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1186 pt[1].x = w; pt[1].y = h;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1187 pt[2].x = w; pt[2].y = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1188 pt[3].x = wms; pt[3].y = s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1189 pt[4].x = wms; pt[4].y = hms;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1190 pt[5].x = s; pt[5].y = hms;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1191 XFillPolygon (dpy, win, bot, pt, 6, Complex, CoordModeOrigin);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1192 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1193 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1194 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1195
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1196
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1197 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1198 * Set the scroll bar to the given location.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1199 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1200 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1201 vim_XawScrollbarSetThumb(w, top, shown, max)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1202 Widget w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1203 double top, shown, max;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1204 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1205 ScrollbarWidget sbw = (ScrollbarWidget) w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1206
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1207 if (sbw->scrollbar.scroll_mode == SMODE_CONT) /* if still thumbing */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1208 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1209
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1210 sbw->scrollbar.max = (max > 1.0) ? 1.0 :
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1211 (max >= 0.0) ? max : sbw->scrollbar.max;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1212
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1213 sbw->scrollbar.top = (top > sbw->scrollbar.max) ? sbw->scrollbar.max :
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1214 (top >= 0.0) ? top : sbw->scrollbar.top;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1215
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1216 sbw->scrollbar.shown = (shown > 1.0) ? 1.0 :
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1217 (shown >= 0.0) ? shown : sbw->scrollbar.shown;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1218
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1219 PaintThumb(sbw);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1220 }