annotate src/gui_at_sb.c @ 18713:baf890fa1621 v8.1.2348

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