annotate src/gui_at_sb.c @ 7867:3b79ecd05a51

Added tag v7.4.1230 for changeset 30a9f5fc3508e60c66993b2977a59bedc94cd2ec
author Christian Brabandt <cb@256bit.org>
date Mon, 01 Feb 2016 21:45:06 +0100
parents 7898da204b98
children 4aead6a9b7a9
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
7809
4635a259ecc0 commit https://github.com/vim/vim/commit/569850724ef37061bfd4cb6423f04c8b8c690515
Christian Brabandt <cb@256bit.org>
parents: 2255
diff changeset
128 static void ClassInitialize(void);
4635a259ecc0 commit https://github.com/vim/vim/commit/569850724ef37061bfd4cb6423f04c8b8c690515
Christian Brabandt <cb@256bit.org>
parents: 2255
diff changeset
129 static void Initialize(Widget, Widget, ArgList, Cardinal *);
4635a259ecc0 commit https://github.com/vim/vim/commit/569850724ef37061bfd4cb6423f04c8b8c690515
Christian Brabandt <cb@256bit.org>
parents: 2255
diff changeset
130 static void Destroy(Widget);
4635a259ecc0 commit https://github.com/vim/vim/commit/569850724ef37061bfd4cb6423f04c8b8c690515
Christian Brabandt <cb@256bit.org>
parents: 2255
diff changeset
131 static void Realize(Widget, Mask *, XSetWindowAttributes *);
4635a259ecc0 commit https://github.com/vim/vim/commit/569850724ef37061bfd4cb6423f04c8b8c690515
Christian Brabandt <cb@256bit.org>
parents: 2255
diff changeset
132 static void Resize(Widget);
4635a259ecc0 commit https://github.com/vim/vim/commit/569850724ef37061bfd4cb6423f04c8b8c690515
Christian Brabandt <cb@256bit.org>
parents: 2255
diff changeset
133 static void Redisplay(Widget, XEvent *, Region);
4635a259ecc0 commit https://github.com/vim/vim/commit/569850724ef37061bfd4cb6423f04c8b8c690515
Christian Brabandt <cb@256bit.org>
parents: 2255
diff changeset
134 static Boolean SetValues(Widget, Widget, Widget, ArgList, Cardinal *);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
135
7809
4635a259ecc0 commit https://github.com/vim/vim/commit/569850724ef37061bfd4cb6423f04c8b8c690515
Christian Brabandt <cb@256bit.org>
parents: 2255
diff changeset
136 static void HandleThumb(Widget, XEvent *, String *, Cardinal *);
4635a259ecc0 commit https://github.com/vim/vim/commit/569850724ef37061bfd4cb6423f04c8b8c690515
Christian Brabandt <cb@256bit.org>
parents: 2255
diff changeset
137 static void MoveThumb(Widget, XEvent *, String *, Cardinal *);
4635a259ecc0 commit https://github.com/vim/vim/commit/569850724ef37061bfd4cb6423f04c8b8c690515
Christian Brabandt <cb@256bit.org>
parents: 2255
diff changeset
138 static void NotifyThumb(Widget, XEvent *, String *, Cardinal *);
4635a259ecc0 commit https://github.com/vim/vim/commit/569850724ef37061bfd4cb6423f04c8b8c690515
Christian Brabandt <cb@256bit.org>
parents: 2255
diff changeset
139 static void NotifyScroll(Widget, XEvent *, String *, Cardinal *);
4635a259ecc0 commit https://github.com/vim/vim/commit/569850724ef37061bfd4cb6423f04c8b8c690515
Christian Brabandt <cb@256bit.org>
parents: 2255
diff changeset
140 static void EndScroll(Widget, XEvent *, String *, Cardinal *);
4635a259ecc0 commit https://github.com/vim/vim/commit/569850724ef37061bfd4cb6423f04c8b8c690515
Christian Brabandt <cb@256bit.org>
parents: 2255
diff changeset
141 static void ScrollOneLineUp(Widget, XEvent *, String *, Cardinal *);
4635a259ecc0 commit https://github.com/vim/vim/commit/569850724ef37061bfd4cb6423f04c8b8c690515
Christian Brabandt <cb@256bit.org>
parents: 2255
diff changeset
142 static void ScrollOneLineDown(Widget, XEvent *, String *, Cardinal *);
4635a259ecc0 commit https://github.com/vim/vim/commit/569850724ef37061bfd4cb6423f04c8b8c690515
Christian Brabandt <cb@256bit.org>
parents: 2255
diff changeset
143 static void ScrollPageUp(Widget, XEvent *, String *, Cardinal *);
4635a259ecc0 commit https://github.com/vim/vim/commit/569850724ef37061bfd4cb6423f04c8b8c690515
Christian Brabandt <cb@256bit.org>
parents: 2255
diff changeset
144 static void ScrollPageDown(Widget, XEvent *, String *, Cardinal *);
4635a259ecc0 commit https://github.com/vim/vim/commit/569850724ef37061bfd4cb6423f04c8b8c690515
Christian Brabandt <cb@256bit.org>
parents: 2255
diff changeset
145 static void ScrollSome(Widget w, XEvent *event, int call_data);
4635a259ecc0 commit https://github.com/vim/vim/commit/569850724ef37061bfd4cb6423f04c8b8c690515
Christian Brabandt <cb@256bit.org>
parents: 2255
diff changeset
146 static void _Xaw3dDrawShadows(Widget, XEvent *, Region, int);
4635a259ecc0 commit https://github.com/vim/vim/commit/569850724ef37061bfd4cb6423f04c8b8c690515
Christian Brabandt <cb@256bit.org>
parents: 2255
diff changeset
147 static void AllocTopShadowGC(Widget);
4635a259ecc0 commit https://github.com/vim/vim/commit/569850724ef37061bfd4cb6423f04c8b8c690515
Christian Brabandt <cb@256bit.org>
parents: 2255
diff changeset
148 static void AllocBotShadowGC(Widget);
7
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 */
1887
fc89a4f98a8b updated for version 7.2-184
vimboss
parents: 1757
diff changeset
201 /* change_sensitive */ XtInheritChangeSensitive,
fc89a4f98a8b updated for version 7.2-184
vimboss
parents: 1757
diff changeset
202 #ifndef OLDXAW
fc89a4f98a8b updated for version 7.2-184
vimboss
parents: 1757
diff changeset
203 /* extension */ NULL
fc89a4f98a8b updated for version 7.2-184
vimboss
parents: 1757
diff changeset
204 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
205 },
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
206 { /* scrollbar fields */
1887
fc89a4f98a8b updated for version 7.2-184
vimboss
parents: 1757
diff changeset
207 /* empty */ 0
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
208 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
209 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
210
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
211 WidgetClass vim_scrollbarWidgetClass = (WidgetClass)&vim_scrollbarClassRec;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
212
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
213 #define NoButton -1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
214 #define PICKLENGTH(widget, x, y) \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
215 ((widget->scrollbar.orientation == XtorientHorizontal) ? (x) : (y))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
216 #define AT_MIN(x,y) ((x) < (y) ? (x) : (y))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
217 #define AT_MAX(x,y) ((x) > (y) ? (x) : (y))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
218
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
219 #define LINE_DELAY 300
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
220 #define PAGE_DELAY 300
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
221 #define LINE_REPEAT 50
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
222 #define PAGE_REPEAT 250
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
223
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
224 static void
7821
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
225 ClassInitialize(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
226 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
227 XawInitializeWidgetSet();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
228 XtAddConverter( XtRString, XtROrientation, XmuCvtStringToOrientation,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
229 (XtConvertArgList)NULL, (Cardinal)0 );
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
230 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
231
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
232 #define MARGIN(sbw) (sbw)->scrollbar.thickness + (sbw)->scrollbar.shadow_width
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
233
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
234 static void
7821
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
235 FillArea(
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
236 ScrollbarWidget sbw,
7825
7898da204b98 commit https://github.com/vim/vim/commit/02fdaeaa697fb5af4ba7fee6e209b3c2c825bb4f
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
237 Position top,
7898da204b98 commit https://github.com/vim/vim/commit/02fdaeaa697fb5af4ba7fee6e209b3c2c825bb4f
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
238 Position bottom,
7821
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
239 int fill,
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
240 int draw_shadow)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
241 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
242 int tlen = bottom - top; /* length of thumb in pixels */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
243 int sw, margin, floor;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
244 int lx, ly, lw, lh;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
245
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
246 if (bottom <= 0 || bottom <= top)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
247 return;
1887
fc89a4f98a8b updated for version 7.2-184
vimboss
parents: 1757
diff changeset
248 sw = sbw->scrollbar.shadow_width;
fc89a4f98a8b updated for version 7.2-184
vimboss
parents: 1757
diff changeset
249 if (sw < 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
250 sw = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
251 margin = MARGIN (sbw);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
252 floor = sbw->scrollbar.length - margin + 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
253
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
254 if (sbw->scrollbar.orientation == XtorientHorizontal)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
255 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
256 lx = ((top < margin) ? margin : top);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
257 ly = sw;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
258 lw = (((top + tlen) > floor) ? floor - top : tlen);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
259 lh = sbw->core.height - 2 * sw;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
260 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
261 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
262 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
263 lx = sw;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
264 ly = ((top < margin) ? margin : top);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
265 lw = sbw->core.width - 2 * sw;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
266 lh = (((top + tlen) > floor) ? floor - top : tlen);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
267 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
268 if (lh <= 0 || lw <= 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
269 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
270
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
271 if (draw_shadow)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
272 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
273 if (!(sbw->scrollbar.orientation == XtorientHorizontal))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
274 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
275 /* Top 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.top_shadow_GC,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
278 lx, ly, lx + lw - 1, ly);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
279
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
280 /* Bottom border */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
281 XDrawLine (XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
282 sbw->scrollbar.bot_shadow_GC,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
283 lx, ly + lh - 1, lx + lw - 1, ly + lh - 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
284 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
285 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
286 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
287 /* Left 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.top_shadow_GC,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
290 lx, ly, lx, 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 /* Right border */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
293 XDrawLine (XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
294 sbw->scrollbar.bot_shadow_GC,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
295 lx + lw - 1, ly, lx + lw - 1, ly + lh - 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
296 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
297 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
298 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
299
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
300 if (fill)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
301 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
302 XFillRectangle(XtDisplay((Widget) sbw), XtWindow((Widget) sbw),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
303 sbw->scrollbar.gc,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
304 lx, ly, (unsigned int) lw, (unsigned int) lh);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
305
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
306 if (!(sbw->scrollbar.orientation == XtorientHorizontal))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
307 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
308 /* Left 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.top_shadow_GC,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
311 lx, ly, lx, 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 /* Right border */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
314 XDrawLine(XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
315 sbw->scrollbar.bot_shadow_GC,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
316 lx + lw - 1, ly, lx + lw - 1, ly + lh - 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
317 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
318 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
319 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
320 /* Top 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.top_shadow_GC,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
323 lx, ly, lx + lw - 1, ly);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
324
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
325 /* Bottom border */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
326 XDrawLine(XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
327 sbw->scrollbar.bot_shadow_GC,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
328 lx, ly + lh - 1, lx + lw - 1, ly + lh - 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
329 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
330 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
331 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
332 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
333 XClearArea(XtDisplay((Widget) sbw), XtWindow((Widget) sbw),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
334 lx, ly, (unsigned int) lw, (unsigned int) lh, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
335 }
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 /* Paint the thumb in the area specified by sbw->top and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
339 sbw->shown. The old area is erased. The painting and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
340 erasing is done cleverly so that no flickering will occur.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
341 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
342
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
343 static void
7821
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
344 PaintThumb(ScrollbarWidget sbw)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
345 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
346 Position oldtop, oldbot, newtop, newbot;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
347 Dimension margin, tzl;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
348
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
349 margin = MARGIN (sbw);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
350 tzl = sbw->scrollbar.length - 2 * margin;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
351 newtop = margin + (int)(tzl * sbw->scrollbar.top);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
352 newbot = newtop + (int)(tzl * sbw->scrollbar.shown) + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
353 if (newbot < newtop + (int)sbw->scrollbar.min_thumb)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
354 newbot = newtop + sbw->scrollbar.min_thumb;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
355
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
356 oldtop = sbw->scrollbar.topLoc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
357 oldbot = oldtop + sbw->scrollbar.shownLength;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
358 sbw->scrollbar.topLoc = newtop;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
359 sbw->scrollbar.shownLength = newbot - newtop;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
360 if (XtIsRealized ((Widget) sbw))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
361 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
362 if (newtop < oldtop)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
363 FillArea(sbw, newtop, AT_MIN(newbot, oldtop+1),1,0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
364 if (newtop > oldtop)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
365 FillArea(sbw, oldtop, AT_MIN(newtop, oldbot ),0,0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
366 if (newbot < oldbot)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
367 FillArea(sbw, AT_MAX(newbot, oldtop), oldbot, 0,0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
368 if (newbot > oldbot)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
369 FillArea(sbw, AT_MAX(newtop, oldbot-1), newbot, 1,0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
370
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
371 /* Only draw the missing shadows */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
372 FillArea(sbw, newtop, newbot, 0, 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
373 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
374 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
375
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
376 static void
7821
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
377 PaintArrows(ScrollbarWidget sbw)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
378 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
379 XPoint point[6];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
380 Dimension thickness = sbw->scrollbar.thickness - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
381 Dimension size;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
382 Dimension off;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
383
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
384 if (XtIsRealized((Widget) sbw))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
385 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
386 if ((int)thickness * 2 > (int)sbw->scrollbar.length)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
387 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
388 size = sbw->scrollbar.length / 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
389 off = (int)(thickness - size) / 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
390 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
391 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
392 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
393 size = thickness;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
394 off = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
395 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
396 point[0].x = off + sbw->scrollbar.shadow_width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
397 point[0].y = size;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
398 point[1].x = thickness - off - sbw->scrollbar.shadow_width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
399 point[1].y = size;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
400 point[2].x = thickness / 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
401 point[2].y = sbw->scrollbar.shadow_width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
402
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
403 point[3].x = off + sbw->scrollbar.shadow_width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
404 point[3].y = sbw->scrollbar.length - size;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
405 point[4].x = thickness - off - sbw->scrollbar.shadow_width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
406 point[4].y = sbw->scrollbar.length - size;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
407 point[5].x = thickness / 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
408 point[5].y = sbw->scrollbar.length - sbw->scrollbar.shadow_width - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
409
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
410 /* horizontal arrows require that x and y coordinates be swapped */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
411 if (sbw->scrollbar.orientation == XtorientHorizontal)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
412 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
413 int n;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
414 int swap;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
415 for (n = 0; n < 6; n++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
416 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
417 swap = point[n].x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
418 point[n].x = point[n].y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
419 point[n].y = swap;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
420 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
421 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
422 /* draw the up/left arrow */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
423 XFillPolygon (XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
424 sbw->scrollbar.gc,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
425 point, 3,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
426 Convex, CoordModeOrigin);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
427 XDrawLines (XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
428 sbw->scrollbar.bot_shadow_GC,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
429 point, 3,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
430 CoordModeOrigin);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
431 XDrawLine (XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
432 sbw->scrollbar.top_shadow_GC,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
433 point[0].x, point[0].y,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
434 point[2].x, point[2].y);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
435 /* draw the down/right arrow */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
436 XFillPolygon (XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
437 sbw->scrollbar.gc,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
438 point+3, 3,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
439 Convex, CoordModeOrigin);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
440 XDrawLine (XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
441 sbw->scrollbar.top_shadow_GC,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
442 point[3].x, point[3].y,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
443 point[4].x, point[4].y);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
444 XDrawLine (XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
445 sbw->scrollbar.top_shadow_GC,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
446 point[3].x, point[3].y,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
447 point[5].x, point[5].y);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
448 XDrawLine (XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
449 sbw->scrollbar.bot_shadow_GC,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
450 point[4].x, point[4].y,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
451 point[5].x, point[5].y);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
452 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
453 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
454
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
455 static void
7821
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
456 Destroy(Widget w)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
457 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
458 ScrollbarWidget sbw = (ScrollbarWidget) w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
459 if (sbw->scrollbar.timer_id != (XtIntervalId) 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
460 XtRemoveTimeOut (sbw->scrollbar.timer_id);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
461 XtReleaseGC(w, sbw->scrollbar.gc);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
462 XtReleaseGC(w, sbw->scrollbar.top_shadow_GC);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
463 XtReleaseGC(w, sbw->scrollbar.bot_shadow_GC);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
464 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
465
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
466 static void
7821
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
467 CreateGC(Widget w)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
468 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
469 ScrollbarWidget sbw = (ScrollbarWidget) w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
470 XGCValues gcValues;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
471 XtGCMask mask;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
472 unsigned int depth = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
473
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
474 if (sbw->scrollbar.thumb == XtUnspecifiedPixmap)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
475 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
476 sbw->scrollbar.thumb = XmuCreateStippledPixmap (XtScreen(w),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
477 (Pixel) 1, (Pixel) 0, depth);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
478 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
479 else if (sbw->scrollbar.thumb != None)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
480 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
481 Window root;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
482 int x, y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
483 unsigned int width, height, bw;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
484
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
485 if (XGetGeometry (XtDisplay(w), sbw->scrollbar.thumb, &root, &x, &y,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
486 &width, &height, &bw, &depth) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
487 EMSG(_("Scrollbar Widget: Could not get geometry of thumb pixmap."));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
488 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
489
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
490 gcValues.foreground = sbw->scrollbar.foreground;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
491 gcValues.background = sbw->core.background_pixel;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
492 mask = GCForeground | GCBackground;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
493
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
494 if (sbw->scrollbar.thumb != None)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
495 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
496 gcValues.fill_style = FillSolid;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
497 mask |= GCFillStyle;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
498 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
499 /* the creation should be non-caching, because */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
500 /* we now set and clear clip masks on the gc returned */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
501 sbw->scrollbar.gc = XtGetGC (w, mask, &gcValues);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
502 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
503
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
504 static void
7821
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
505 SetDimensions(ScrollbarWidget sbw)
7
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 static void
7821
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
520 Initialize(
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
521 Widget request UNUSED, /* what the client asked for */
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
522 Widget new, /* what we're going to give him */
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
523 ArgList args UNUSED,
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
524 Cardinal *num_args UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
525 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
526 ScrollbarWidget sbw = (ScrollbarWidget) new;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
527
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
528 CreateGC(new);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
529 AllocTopShadowGC(new);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
530 AllocBotShadowGC(new);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
531
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
532 if (sbw->core.width == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
533 sbw->core.width = (sbw->scrollbar.orientation == XtorientVertical)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
534 ? sbw->scrollbar.thickness : sbw->scrollbar.length;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
535
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
536 if (sbw->core.height == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
537 sbw->core.height = (sbw->scrollbar.orientation == XtorientHorizontal)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
538 ? sbw->scrollbar.thickness : sbw->scrollbar.length;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
539
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
540 SetDimensions(sbw);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
541 sbw->scrollbar.scroll_mode = SMODE_NONE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
542 sbw->scrollbar.timer_id = (XtIntervalId)0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
543 sbw->scrollbar.topLoc = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
544 sbw->scrollbar.shownLength = sbw->scrollbar.min_thumb;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
545 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
546
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
547 static void
7821
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
548 Realize(
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
549 Widget w,
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
550 Mask *valueMask,
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
551 XSetWindowAttributes *attributes)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
552 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
553 /* The Simple widget actually stuffs the value in the valuemask. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
554 (*vim_scrollbarWidgetClass->core_class.superclass->core_class.realize)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
555 (w, valueMask, attributes);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
556 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
557
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
558 static Boolean
7821
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
559 SetValues(
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
560 Widget current, /* what I am */
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
561 Widget request UNUSED, /* what he wants me to be */
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
562 Widget desired, /* what I will become */
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
563 ArgList args UNUSED,
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
564 Cardinal *num_args UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
565 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
566 ScrollbarWidget sbw = (ScrollbarWidget) current;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
567 ScrollbarWidget dsbw = (ScrollbarWidget) desired;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
568 Boolean redraw = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
569
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
570 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
571 * If these values are outside the acceptable range ignore them...
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
572 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
573 if (dsbw->scrollbar.top < 0.0 || dsbw->scrollbar.top > 1.0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
574 dsbw->scrollbar.top = sbw->scrollbar.top;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
575
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
576 if (dsbw->scrollbar.shown < 0.0 || dsbw->scrollbar.shown > 1.0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
577 dsbw->scrollbar.shown = sbw->scrollbar.shown;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
578
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
579 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
580 * Change colors and stuff...
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
581 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
582 if (XtIsRealized(desired))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
583 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
584 if (sbw->scrollbar.foreground != dsbw->scrollbar.foreground ||
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
585 sbw->core.background_pixel != dsbw->core.background_pixel ||
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
586 sbw->scrollbar.thumb != dsbw->scrollbar.thumb)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
587 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
588 XtReleaseGC(desired, sbw->scrollbar.gc);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
589 CreateGC (desired);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
590 redraw = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
591 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
592 if (sbw->scrollbar.top != dsbw->scrollbar.top ||
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
593 sbw->scrollbar.shown != dsbw->scrollbar.shown)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
594 redraw = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
595 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
596 return redraw;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
597 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
598
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
599 static void
7821
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
600 Resize(Widget w)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
601 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
602 /* ForgetGravity has taken care of background, but thumb may
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
603 * have to move as a result of the new size. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
604 SetDimensions ((ScrollbarWidget) w);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
605 Redisplay(w, (XEvent*) NULL, (Region)NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
606 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
607
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
608
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
609 static void
7821
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
610 Redisplay(Widget w, XEvent *event, Region region)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
611 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
612 ScrollbarWidget sbw = (ScrollbarWidget) w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
613 int x, y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
614 unsigned int width, height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
615
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
616 _Xaw3dDrawShadows(w, event, region, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
617
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
618 if (sbw->scrollbar.orientation == XtorientHorizontal)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
619 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
620 x = sbw->scrollbar.topLoc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
621 y = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
622 width = sbw->scrollbar.shownLength;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
623 height = sbw->core.height - 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
624 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
625 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
626 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
627 x = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
628 y = sbw->scrollbar.topLoc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
629 width = sbw->core.width - 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
630 height = sbw->scrollbar.shownLength;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
631 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
632 if (region == NULL ||
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
633 XRectInRegion (region, x, y, width, height) != RectangleOut)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
634 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
635 /* Forces entire thumb to be painted. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
636 sbw->scrollbar.topLoc = -(sbw->scrollbar.length + 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
637 PaintThumb (sbw);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
638 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
639 /* we'd like to be region aware here!!!! */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
640 PaintArrows(sbw);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
641 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
642
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
643
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
644 static Boolean
7825
7898da204b98 commit https://github.com/vim/vim/commit/02fdaeaa697fb5af4ba7fee6e209b3c2c825bb4f
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
645 CompareEvents(XEvent *oldEvent, XEvent *newEvent)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
646 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
647 #define Check(field) if (newEvent->field != oldEvent->field) return False;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
648
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
649 Check(xany.display);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
650 Check(xany.type);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
651 Check(xany.window);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
652
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
653 switch (newEvent->type)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
654 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
655 case MotionNotify:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
656 Check(xmotion.state);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
657 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
658 case ButtonPress:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
659 case ButtonRelease:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
660 Check(xbutton.state);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
661 Check(xbutton.button);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
662 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
663 case KeyPress:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
664 case KeyRelease:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
665 Check(xkey.state);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
666 Check(xkey.keycode);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
667 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
668 case EnterNotify:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
669 case LeaveNotify:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
670 Check(xcrossing.mode);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
671 Check(xcrossing.detail);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
672 Check(xcrossing.state);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
673 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
674 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
675 #undef Check
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
676
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
677 return True;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
678 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
679
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
680 struct EventData
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
681 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
682 XEvent *oldEvent;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
683 int count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
684 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
685
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
686 static Bool
7821
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
687 PeekNotifyEvent(Display *dpy, XEvent *event, char *args)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
688 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
689 struct EventData *eventData = (struct EventData*)args;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
690
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
691 return ((++eventData->count == QLength(dpy)) /* since PeekIf blocks */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
692 || CompareEvents(event, eventData->oldEvent));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
693 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
694
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
695
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
696 static Boolean
7821
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
697 LookAhead(Widget w, XEvent *event)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
698 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
699 XEvent newEvent;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
700 struct EventData eventData;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
701
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
702 if (QLength (XtDisplay (w)) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
703 return False;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
704
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
705 eventData.count = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
706 eventData.oldEvent = event;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
707
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
708 XPeekIfEvent (XtDisplay (w), &newEvent, PeekNotifyEvent, (char*)&eventData);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
709
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
710 return CompareEvents (event, &newEvent);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
711 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
712
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
713
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
714 static void
7821
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
715 ExtractPosition(
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
716 XEvent *event,
7825
7898da204b98 commit https://github.com/vim/vim/commit/02fdaeaa697fb5af4ba7fee6e209b3c2c825bb4f
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
717 Position *x, /* RETURN */
7898da204b98 commit https://github.com/vim/vim/commit/02fdaeaa697fb5af4ba7fee6e209b3c2c825bb4f
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
718 Position *y, /* RETURN */
7821
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
719 unsigned int *state) /* RETURN */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
720 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
721 switch (event->type)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
722 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
723 case MotionNotify:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
724 *x = event->xmotion.x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
725 *y = event->xmotion.y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
726 if (state != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
727 *state = event->xmotion.state;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
728 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
729 case ButtonPress:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
730 case ButtonRelease:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
731 *x = event->xbutton.x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
732 *y = event->xbutton.y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
733 if (state != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
734 *state = event->xbutton.state;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
735 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
736 case KeyPress:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
737 case KeyRelease:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
738 *x = event->xkey.x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
739 *y = event->xkey.y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
740 if (state != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
741 *state = event->xkey.state;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
742 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
743 case EnterNotify:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
744 case LeaveNotify:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
745 *x = event->xcrossing.x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
746 *y = event->xcrossing.y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
747 if (state != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
748 *state = event->xcrossing.state;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
749 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
750 default:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
751 *x = 0; *y = 0;
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 = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
754 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
755 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
756
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
757 static void
7821
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
758 HandleThumb(
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
759 Widget w,
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
760 XEvent *event,
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
761 String *params,
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
762 Cardinal *num_params)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
763 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
764 Position x, y, loc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
765 ScrollbarWidget sbw = (ScrollbarWidget) w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
766
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
767 ExtractPosition(event, &x, &y, (unsigned int *)NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
768 loc = PICKLENGTH(sbw, x, y);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
769 /* if the motion event puts the pointer in thumb, call Move and Notify */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
770 /* also call Move and Notify if we're already in continuous scroll mode */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
771 if (sbw->scrollbar.scroll_mode == SMODE_CONT ||
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
772 (loc >= sbw->scrollbar.topLoc &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
773 loc <= sbw->scrollbar.topLoc + (int)sbw->scrollbar.shownLength))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
774 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
775 XtCallActionProc(w, "MoveThumb", event, params, *num_params);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
776 XtCallActionProc(w, "NotifyThumb", event, params, *num_params);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
777 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
778 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
779
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
780 static void
7821
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
781 RepeatNotify(XtPointer client_data, XtIntervalId *idp UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
782 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
783 ScrollbarWidget sbw = (ScrollbarWidget) client_data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
784 int call_data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
785 char mode = sbw->scrollbar.scroll_mode;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
786 unsigned long rep;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
787
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
788 if (mode == SMODE_NONE || mode == SMODE_CONT)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
789 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
790 sbw->scrollbar.timer_id = (XtIntervalId)0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
791 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
792 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
793
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
794 if (mode == SMODE_LINE_DOWN || mode == SMODE_LINE_UP)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
795 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
796 call_data = ONE_LINE_DATA;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
797 rep = LINE_REPEAT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
798 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
799 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
800 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
801 call_data = ONE_PAGE_DATA;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
802 rep = PAGE_REPEAT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
803 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
804
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
805 if (mode == SMODE_PAGE_UP || mode == SMODE_LINE_UP)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
806 call_data = -call_data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
807
2255
e5265e4d4725 Avoid compiler warnings.
Bram Moolenaar <bram@vim.org>
parents: 1887
diff changeset
808 XtCallCallbacks((Widget)sbw, XtNscrollProc, (XtPointer)(long_u)call_data);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
809
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
810 sbw->scrollbar.timer_id =
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
811 XtAppAddTimeOut(XtWidgetToApplicationContext((Widget)sbw),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
812 rep,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
813 RepeatNotify,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
814 client_data);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
815 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
816
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
817 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
818 * Same as above, but for floating numbers.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
819 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
820 static float
7825
7898da204b98 commit https://github.com/vim/vim/commit/02fdaeaa697fb5af4ba7fee6e209b3c2c825bb4f
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
821 FloatInRange(float num, float small, float big)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
822 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
823 return (num < small) ? small : ((num > big) ? big : num);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
824 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
825
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
826 static void
7821
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
827 ScrollOneLineUp(
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
828 Widget w,
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
829 XEvent *event,
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
830 String *params UNUSED,
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
831 Cardinal *num_params UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
832 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
833 ScrollSome(w, event, -ONE_LINE_DATA);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
834 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
835
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
836 static void
7821
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
837 ScrollOneLineDown(
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
838 Widget w,
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
839 XEvent *event,
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
840 String *params UNUSED,
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
841 Cardinal *num_params UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
842 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
843 ScrollSome(w, event, ONE_LINE_DATA);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
844 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
845
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
846 static void
7821
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
847 ScrollPageDown(
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
848 Widget w,
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
849 XEvent *event,
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
850 String *params UNUSED,
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
851 Cardinal *num_params UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
852 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
853 ScrollSome(w, event, ONE_PAGE_DATA);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
854 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
855
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
856 static void
7821
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
857 ScrollPageUp(
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
858 Widget w,
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
859 XEvent *event,
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
860 String *params UNUSED,
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
861 Cardinal *num_params UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
862 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
863 ScrollSome(w, event, -ONE_PAGE_DATA);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
864 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
865
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
866 static void
7821
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
867 ScrollSome(
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
868 Widget w,
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
869 XEvent *event,
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
870 int call_data)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
871 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
872 ScrollbarWidget sbw = (ScrollbarWidget) w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
873
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
874 if (sbw->scrollbar.scroll_mode == SMODE_CONT) /* if scroll continuous */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
875 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
876
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
877 if (LookAhead(w, event))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
878 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
879
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
880 sbw->scrollbar.scroll_mode = SMODE_LINE_UP;
2255
e5265e4d4725 Avoid compiler warnings.
Bram Moolenaar <bram@vim.org>
parents: 1887
diff changeset
881 XtCallCallbacks(w, XtNscrollProc, (XtPointer)(long_u)call_data);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
882 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
883
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
884 static void
7821
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
885 NotifyScroll(
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
886 Widget w,
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
887 XEvent *event,
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
888 String *params UNUSED,
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
889 Cardinal *num_params UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
890 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
891 ScrollbarWidget sbw = (ScrollbarWidget) w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
892 Position x, y, loc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
893 Dimension arrow_size;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
894 unsigned long delay = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
895 int call_data = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
896 unsigned int state;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
897
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
898 if (sbw->scrollbar.scroll_mode == SMODE_CONT) /* if scroll continuous */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
899 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
900
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
901 if (LookAhead (w, event))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
902 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
903
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
904 ExtractPosition(event, &x, &y, &state);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
905 loc = PICKLENGTH(sbw, x, y);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
906
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
907 if ((int)sbw->scrollbar.thickness * 2 > (int)sbw->scrollbar.length)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
908 arrow_size = sbw->scrollbar.length / 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
909 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
910 arrow_size = sbw->scrollbar.thickness;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
911
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
912 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
913 * handle CTRL modifier
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
914 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
915 if (state & ControlMask)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
916 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
917 if (loc > sbw->scrollbar.topLoc + (Position)sbw->scrollbar.shownLength)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
918 call_data = END_PAGE_DATA;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
919 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
920 call_data = -END_PAGE_DATA;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
921 sbw->scrollbar.scroll_mode = SMODE_NONE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
922 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
923 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
924 * handle first arrow zone
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
925 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
926 else if (loc < (Position)arrow_size)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
927 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
928 call_data = -ONE_LINE_DATA;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
929 sbw->scrollbar.scroll_mode = SMODE_LINE_UP;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
930 delay = LINE_DELAY;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
931 }
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 last arrow zone
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
935 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
936 else if (loc > (Position)(sbw->scrollbar.length - arrow_size))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
937 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
938 call_data = ONE_LINE_DATA;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
939 sbw->scrollbar.scroll_mode = SMODE_LINE_DOWN;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
940 delay = LINE_DELAY;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
941 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
942
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
943 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
944 * handle zone "above" the thumb
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
945 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
946 else if (loc < sbw->scrollbar.topLoc)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
947 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
948 call_data = -ONE_PAGE_DATA;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
949 sbw->scrollbar.scroll_mode = SMODE_PAGE_UP;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
950 delay = PAGE_DELAY;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
951 }
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 * handle zone "below" the thumb
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
955 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
956 else if (loc > sbw->scrollbar.topLoc + (Position)sbw->scrollbar.shownLength)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
957 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
958 call_data = ONE_PAGE_DATA;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
959 sbw->scrollbar.scroll_mode = SMODE_PAGE_DOWN;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
960 delay = PAGE_DELAY;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
961 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
962
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
963 if (call_data)
2255
e5265e4d4725 Avoid compiler warnings.
Bram Moolenaar <bram@vim.org>
parents: 1887
diff changeset
964 XtCallCallbacks(w, XtNscrollProc, (XtPointer)(long_u)call_data);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
965
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
966 /* establish autoscroll */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
967 if (delay)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
968 sbw->scrollbar.timer_id =
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
969 XtAppAddTimeOut(XtWidgetToApplicationContext(w),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
970 delay, RepeatNotify, (XtPointer)w);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
971 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
972
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
973 static void
7821
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
974 EndScroll(
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
975 Widget w,
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
976 XEvent *event UNUSED,
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
977 String *params UNUSED,
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
978 Cardinal *num_params UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
979 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
980 ScrollbarWidget sbw = (ScrollbarWidget) w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
981
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
982 sbw->scrollbar.scroll_mode = SMODE_NONE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
983 /* no need to remove any autoscroll timeout; it will no-op */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
984 /* because the scroll_mode is SMODE_NONE */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
985 /* but be sure to remove timeout in destroy proc */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
986 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
987
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
988 static float
7825
7898da204b98 commit https://github.com/vim/vim/commit/02fdaeaa697fb5af4ba7fee6e209b3c2c825bb4f
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
989 FractionLoc(ScrollbarWidget sbw, int x, int y)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
990 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
991 int margin;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
992 float height, width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
993
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
994 margin = MARGIN(sbw);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
995 x -= margin;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
996 y -= margin;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
997 height = (float)sbw->core.height - 2 * margin;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
998 width = (float)sbw->core.width - 2 * margin;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
999 return PICKLENGTH(sbw, x / width, y / height);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1000 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1001
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1002 static void
7821
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
1003 MoveThumb(
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
1004 Widget w,
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
1005 XEvent *event,
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
1006 String *params UNUSED,
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
1007 Cardinal *num_params UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1008 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1009 ScrollbarWidget sbw = (ScrollbarWidget)w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1010 Position x, y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1011 float top;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1012 char old_mode = sbw->scrollbar.scroll_mode;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1013
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1014 sbw->scrollbar.scroll_mode = SMODE_CONT; /* indicate continuous scroll */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1015
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1016 if (LookAhead(w, event))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1017 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1018
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1019 if (!event->xmotion.same_screen)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1020 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1021
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1022 ExtractPosition(event, &x, &y, (unsigned int *)NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1023
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1024 top = FractionLoc(sbw, x, y);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1025
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1026 if (old_mode != SMODE_CONT) /* start dragging: set offset */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1027 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1028 if (event->xbutton.button == Button2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1029 sbw->scrollbar.scroll_off = sbw->scrollbar.shown / 2.;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1030 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1031 sbw->scrollbar.scroll_off = top - sbw->scrollbar.top;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1032 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1033
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1034 top -= sbw->scrollbar.scroll_off;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1035 if (sbw->scrollbar.limit_thumb)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1036 top = FloatInRange(top, 0.0,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1037 sbw->scrollbar.max - sbw->scrollbar.shown + 0.000001);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1038 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1039 top = FloatInRange(top, 0.0, sbw->scrollbar.max);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1040
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1041 sbw->scrollbar.top = top;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1042 PaintThumb(sbw);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1043 XFlush(XtDisplay(w)); /* re-draw it before Notifying */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1044 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1045
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1046
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1047 static void
7821
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
1048 NotifyThumb(
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
1049 Widget w,
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
1050 XEvent *event,
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
1051 String *params UNUSED,
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
1052 Cardinal *num_params UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1053 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1054 ScrollbarWidget sbw = (ScrollbarWidget)w;
1757
f10fe14748e2 updated for version 7.2-055
vimboss
parents: 7
diff changeset
1055 /* 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
1056 * XtPointer. Comes from Xaw/Scrollbar.c. */
f10fe14748e2 updated for version 7.2-055
vimboss
parents: 7
diff changeset
1057 union {
f10fe14748e2 updated for version 7.2-055
vimboss
parents: 7
diff changeset
1058 XtPointer xtp;
f10fe14748e2 updated for version 7.2-055
vimboss
parents: 7
diff changeset
1059 float xtf;
f10fe14748e2 updated for version 7.2-055
vimboss
parents: 7
diff changeset
1060 } xtpf;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1061
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1062 if (LookAhead(w, event))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1063 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1064
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1065 /* thumbProc is not pretty, but is necessary for backwards
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1066 compatibility on those architectures for which it work{s,ed};
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1067 the intent is to pass a (truncated) float by value. */
1757
f10fe14748e2 updated for version 7.2-055
vimboss
parents: 7
diff changeset
1068 xtpf.xtf = sbw->scrollbar.top;
f10fe14748e2 updated for version 7.2-055
vimboss
parents: 7
diff changeset
1069 XtCallCallbacks(w, XtNthumbProc, xtpf.xtp);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1070 XtCallCallbacks(w, XtNjumpProc, (XtPointer)&sbw->scrollbar.top);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1071 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1072
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1073 static void
7821
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
1074 AllocTopShadowGC(Widget w)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1075 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1076 ScrollbarWidget sbw = (ScrollbarWidget) w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1077 XtGCMask valuemask;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1078 XGCValues myXGCV;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1079
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1080 valuemask = GCForeground;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1081 myXGCV.foreground = sbw->scrollbar.top_shadow_pixel;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1082 sbw->scrollbar.top_shadow_GC = XtGetGC(w, valuemask, &myXGCV);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1083 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1084
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1085 static void
7821
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
1086 AllocBotShadowGC(Widget w)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1087 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1088 ScrollbarWidget sbw = (ScrollbarWidget) w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1089 XtGCMask valuemask;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1090 XGCValues myXGCV;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1091
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1092 valuemask = GCForeground;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1093 myXGCV.foreground = sbw->scrollbar.bot_shadow_pixel;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1094 sbw->scrollbar.bot_shadow_GC = XtGetGC(w, valuemask, &myXGCV);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1095 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1096
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1097 static void
7821
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
1098 _Xaw3dDrawShadows(
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
1099 Widget gw,
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
1100 XEvent *event UNUSED,
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
1101 Region region,
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7809
diff changeset
1102 int out)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1103 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1104 XPoint pt[6];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1105 ScrollbarWidget sbw = (ScrollbarWidget) gw;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1106 Dimension s = sbw->scrollbar.shadow_width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1107 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1108 * draw the shadows using the core part width and height,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1109 * and the scrollbar part shadow_width.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1110 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1111 * no point to do anything if the shadow_width is 0 or the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1112 * widget has not been realized.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1113 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1114 if (s > 0 && XtIsRealized(gw))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1115 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1116 Dimension h = sbw->core.height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1117 Dimension w = sbw->core.width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1118 Dimension wms = w - s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1119 Dimension hms = h - s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1120 Display *dpy = XtDisplay (gw);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1121 Window win = XtWindow (gw);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1122 GC top, bot;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1123
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1124 if (out)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1125 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1126 top = sbw->scrollbar.top_shadow_GC;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1127 bot = sbw->scrollbar.bot_shadow_GC;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1128 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1129 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1130 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1131 top = sbw->scrollbar.bot_shadow_GC;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1132 bot = sbw->scrollbar.top_shadow_GC;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1133 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1134
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1135 /* top-left shadow */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1136 if ((region == NULL) ||
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1137 (XRectInRegion (region, 0, 0, w, s) != RectangleOut) ||
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1138 (XRectInRegion (region, 0, 0, s, h) != RectangleOut))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1139 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1140 pt[0].x = 0; pt[0].y = h;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1141 pt[1].x = pt[1].y = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1142 pt[2].x = w; pt[2].y = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1143 pt[3].x = wms; pt[3].y = s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1144 pt[4].x = pt[4].y = s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1145 pt[5].x = s; pt[5].y = hms;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1146 XFillPolygon (dpy, win, top, pt, 6, Complex, CoordModeOrigin);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1147 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1148
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1149 /* bottom-right shadow */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1150 if ((region == NULL) ||
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1151 (XRectInRegion (region, 0, hms, w, s) != RectangleOut) ||
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1152 (XRectInRegion (region, wms, 0, s, h) != RectangleOut))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1153 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1154 pt[0].x = 0; pt[0].y = h;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1155 pt[1].x = w; pt[1].y = h;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1156 pt[2].x = w; pt[2].y = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1157 pt[3].x = wms; pt[3].y = s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1158 pt[4].x = wms; pt[4].y = hms;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1159 pt[5].x = s; pt[5].y = hms;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1160 XFillPolygon (dpy, win, bot, pt, 6, Complex, CoordModeOrigin);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1161 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1162 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1163 }
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 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1167 * Set the scroll bar to the given location.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1168 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1169 void
7825
7898da204b98 commit https://github.com/vim/vim/commit/02fdaeaa697fb5af4ba7fee6e209b3c2c825bb4f
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1170 vim_XawScrollbarSetThumb(Widget w, double top, double shown, double max)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1171 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1172 ScrollbarWidget sbw = (ScrollbarWidget) w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1173
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1174 if (sbw->scrollbar.scroll_mode == SMODE_CONT) /* if still thumbing */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1175 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1176
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1177 sbw->scrollbar.max = (max > 1.0) ? 1.0 :
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1178 (max >= 0.0) ? max : sbw->scrollbar.max;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1179
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1180 sbw->scrollbar.top = (top > sbw->scrollbar.max) ? sbw->scrollbar.max :
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1181 (top >= 0.0) ? top : sbw->scrollbar.top;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1182
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1183 sbw->scrollbar.shown = (shown > 1.0) ? 1.0 :
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1184 (shown >= 0.0) ? shown : sbw->scrollbar.shown;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1185
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1186 PaintThumb(sbw);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1187 }