Mercurial > projects > dwt-linux
annotate dwt/widgets/ScrollBar.d @ 364:2bcb17ebe0be default tip
fix: thx torhu
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 08 Nov 2009 20:57:46 +0100 |
parents | c0d810de7093 |
children |
rev | line source |
---|---|
72 | 1 /******************************************************************************* |
259 | 2 * Copyright (c) 2000, 2008 IBM Corporation and others. |
31 | 3 * All rights reserved. This program and the accompanying materials |
4 * are made available under the terms of the Eclipse Public License v1.0 | |
5 * which accompanies this distribution, and is available at | |
6 * http://www.eclipse.org/legal/epl-v10.html | |
7 * | |
8 * Contributors: | |
9 * IBM Corporation - initial API and implementation | |
72 | 10 * Port to the D programming language: |
11 * Frank Benoit <benoit@tionex.de> | |
31 | 12 *******************************************************************************/ |
13 module dwt.widgets.ScrollBar; | |
14 | |
15 import dwt.widgets.Control; | |
16 import dwt.widgets.Scrollable; | |
71 | 17 import dwt.DWT; |
45 | 18 import dwt.graphics.Point; |
19 import dwt.internal.gtk.OS; | |
20 import dwt.events.SelectionListener; | |
21 import dwt.events.SelectionEvent; | |
22 import dwt.widgets.Scrollable; | |
23 import dwt.widgets.Widget; | |
24 import dwt.widgets.Event; | |
25 import dwt.widgets.TypedListener; | |
31 | 26 |
45 | 27 import Math = tango.math.Math; |
31 | 28 |
29 /** | |
30 * Instances of this class are selectable user interface | |
31 * objects that represent a range of positive, numeric values. | |
32 * <p> | |
33 * At any given moment, a given scroll bar will have a | |
34 * single 'selection' that is considered to be its | |
35 * value, which is constrained to be within the range of | |
36 * values the scroll bar represents (that is, between its | |
37 * <em>minimum</em> and <em>maximum</em> values). | |
38 * </p><p> | |
39 * Typically, scroll bars will be made up of five areas: | |
40 * <ol> | |
41 * <li>an arrow button for decrementing the value</li> | |
42 * <li>a page decrement area for decrementing the value by a larger amount</li> | |
43 * <li>a <em>thumb</em> for modifying the value by mouse dragging</li> | |
44 * <li>a page increment area for incrementing the value by a larger amount</li> | |
45 * <li>an arrow button for incrementing the value</li> | |
46 * </ol> | |
47 * Based on their style, scroll bars are either <code>HORIZONTAL</code> | |
48 * (which have a left facing button for decrementing the value and a | |
49 * right facing button for incrementing it) or <code>VERTICAL</code> | |
50 * (which have an upward facing button for decrementing the value | |
51 * and a downward facing buttons for incrementing it). | |
52 * </p><p> | |
53 * On some platforms, the size of the scroll bar's thumb can be | |
54 * varied relative to the magnitude of the range of values it | |
55 * represents (that is, relative to the difference between its | |
56 * maximum and minimum values). Typically, this is used to | |
57 * indicate some proportional value such as the ratio of the | |
58 * visible area of a document to the total amount of space that | |
71 | 59 * it would take to display it. DWT supports setting the thumb |
31 | 60 * size even if the underlying platform does not, but in this |
61 * case the appearance of the scroll bar will not change. | |
62 * </p><p> | |
63 * Scroll bars are created by specifying either <code>H_SCROLL</code>, | |
64 * <code>V_SCROLL</code> or both when creating a <code>Scrollable</code>. | |
65 * They are accessed from the <code>Scrollable</code> using | |
66 * <code>getHorizontalBar</code> and <code>getVerticalBar</code>. | |
67 * </p><p> | |
68 * Note: Scroll bars are not Controls. On some platforms, scroll bars | |
69 * that appear as part of some standard controls such as a text or list | |
70 * have no operating system resources and are not children of the control. | |
71 * For this reason, scroll bars are treated specially. To create a control | |
72 * that looks like a scroll bar but has operating system resources, use | |
73 * <code>Slider</code>. | |
74 * </p> | |
75 * <dl> | |
76 * <dt><b>Styles:</b></dt> | |
77 * <dd>HORIZONTAL, VERTICAL</dd> | |
78 * <dt><b>Events:</b></dt> | |
79 * <dd>Selection</dd> | |
80 * </dl> | |
81 * <p> | |
82 * Note: Only one of the styles HORIZONTAL and VERTICAL may be specified. | |
83 * </p><p> | |
84 * IMPORTANT: This class is <em>not</em> intended to be subclassed. | |
85 * </p> | |
86 * | |
87 * @see Slider | |
88 * @see Scrollable | |
89 * @see Scrollable#getHorizontalBar | |
90 * @see Scrollable#getVerticalBar | |
259 | 91 * @see <a href="http://www.eclipse.org/swt/examples.php">DWT Example: ControlExample</a> |
92 * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a> | |
31 | 93 */ |
45 | 94 public class ScrollBar : Widget { |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
95 Scrollable parent; |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
96 GtkAdjustment* adjustmentHandle; |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
97 int detail; |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
98 bool dragSent; |
31 | 99 |
45 | 100 this () { |
31 | 101 } |
102 | |
103 /** | |
104 * Creates a new instance of the widget. | |
105 */ | |
45 | 106 this (Scrollable parent, int style) { |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
107 super (parent, checkStyle (style)); |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
108 this.parent = parent; |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
109 createWidget (0); |
31 | 110 } |
111 | |
112 /** | |
113 * Adds the listener to the collection of listeners who will | |
114 * be notified when the user changes the receiver's value, by sending | |
115 * it one of the messages defined in the <code>SelectionListener</code> | |
116 * interface. | |
117 * <p> | |
118 * When <code>widgetSelected</code> is called, the event object detail field contains one of the following values: | |
71 | 119 * <code>DWT.NONE</code> - for the end of a drag. |
120 * <code>DWT.DRAG</code>. | |
121 * <code>DWT.HOME</code>. | |
122 * <code>DWT.END</code>. | |
123 * <code>DWT.ARROW_DOWN</code>. | |
124 * <code>DWT.ARROW_UP</code>. | |
125 * <code>DWT.PAGE_DOWN</code>. | |
126 * <code>DWT.PAGE_UP</code>. | |
31 | 127 * <code>widgetDefaultSelected</code> is not called. |
128 * </p> | |
129 * | |
130 * @param listener the listener which should be notified when the user changes the receiver's value | |
131 * | |
132 * @exception IllegalArgumentException <ul> | |
133 * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> | |
134 * </ul> | |
71 | 135 * @exception DWTException <ul> |
31 | 136 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
137 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
138 * </ul> | |
139 * | |
140 * @see SelectionListener | |
141 * @see #removeSelectionListener | |
142 * @see SelectionEvent | |
143 */ | |
144 public void addSelectionListener (SelectionListener listener) { | |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
145 checkWidget (); |
71 | 146 if (listener is null) error (DWT.ERROR_NULL_ARGUMENT); |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
147 TypedListener typedListener = new TypedListener (listener); |
71 | 148 addListener (DWT.Selection,typedListener); |
149 addListener (DWT.DefaultSelection,typedListener); | |
31 | 150 } |
151 | |
152 static int checkStyle (int style) { | |
71 | 153 return checkBits (style, DWT.HORIZONTAL, DWT.VERTICAL, 0, 0, 0, 0); |
31 | 154 } |
155 | |
152
17f8449522fd
overloads second walkthrough
Frank Benoit <benoit@tionex.de>
parents:
124
diff
changeset
|
156 override void deregister () { |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
157 super.deregister (); |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
158 if (adjustmentHandle !is null) display.removeWidget (cast(GtkWidget*)adjustmentHandle); |
31 | 159 } |
160 | |
240 | 161 void destroyHandle () { |
162 super.destroyWidget (); | |
163 } | |
164 | |
165 void destroyWidget () { | |
166 parent.destroyScrollBar (this); | |
167 releaseHandle (); | |
168 //parent.sendEvent (DWT.Resize); | |
169 } | |
170 | |
31 | 171 /** |
172 * Returns <code>true</code> if the receiver is enabled, and | |
173 * <code>false</code> otherwise. A disabled control is typically | |
174 * not selectable from the user interface and draws with an | |
175 * inactive or "grayed" look. | |
176 * | |
177 * @return the receiver's enabled state | |
178 * | |
71 | 179 * @exception DWTException <ul> |
31 | 180 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
181 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
182 * </ul> | |
183 * | |
184 * @see #isEnabled | |
185 */ | |
45 | 186 public bool getEnabled () { |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
187 checkWidget (); |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
188 if (handle !is null) return OS.GTK_WIDGET_SENSITIVE (handle); |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
189 return true; |
31 | 190 } |
191 | |
192 /** | |
193 * Returns the amount that the receiver's value will be | |
194 * modified by when the up/down (or right/left) arrows | |
195 * are pressed. | |
196 * | |
197 * @return the increment | |
198 * | |
71 | 199 * @exception DWTException <ul> |
31 | 200 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
201 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
202 * </ul> | |
203 */ | |
204 public int getIncrement () { | |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
205 checkWidget (); |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
206 return cast(int)adjustmentHandle.step_increment; |
31 | 207 } |
208 | |
209 /** | |
210 * Returns the maximum value which the receiver will allow. | |
211 * | |
212 * @return the maximum | |
213 * | |
71 | 214 * @exception DWTException <ul> |
31 | 215 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
216 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
217 * </ul> | |
218 */ | |
219 public int getMaximum () { | |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
220 checkWidget (); |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
221 return cast(int)adjustmentHandle.upper; |
31 | 222 } |
223 | |
224 /** | |
225 * Returns the minimum value which the receiver will allow. | |
226 * | |
227 * @return the minimum | |
228 * | |
71 | 229 * @exception DWTException <ul> |
31 | 230 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
231 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
232 * </ul> | |
233 */ | |
234 public int getMinimum () { | |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
235 checkWidget (); |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
236 return cast(int)adjustmentHandle.lower; |
31 | 237 } |
238 | |
239 /** | |
240 * Returns the amount that the receiver's value will be | |
241 * modified by when the page increment/decrement areas | |
242 * are selected. | |
243 * | |
244 * @return the page increment | |
245 * | |
71 | 246 * @exception DWTException <ul> |
31 | 247 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
248 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
249 * </ul> | |
250 */ | |
251 public int getPageIncrement () { | |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
252 checkWidget (); |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
253 return cast(int)adjustmentHandle.page_increment; |
31 | 254 } |
255 | |
256 /** | |
257 * Returns the receiver's parent, which must be a Scrollable. | |
258 * | |
259 * @return the receiver's parent | |
260 * | |
71 | 261 * @exception DWTException <ul> |
31 | 262 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
263 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
264 * </ul> | |
265 */ | |
266 public Scrollable getParent () { | |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
267 checkWidget (); |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
268 return parent; |
31 | 269 } |
270 | |
271 /** | |
272 * Returns the single 'selection' that is the receiver's value. | |
273 * | |
274 * @return the selection | |
275 * | |
71 | 276 * @exception DWTException <ul> |
31 | 277 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
278 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
279 * </ul> | |
280 */ | |
281 public int getSelection () { | |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
282 checkWidget (); |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
283 return cast(int)adjustmentHandle.value; |
31 | 284 } |
285 | |
286 /** | |
287 * Returns a point describing the receiver's size. The | |
288 * x coordinate of the result is the width of the receiver. | |
289 * The y coordinate of the result is the height of the | |
290 * receiver. | |
291 * | |
292 * @return the receiver's size | |
293 * | |
71 | 294 * @exception DWTException <ul> |
31 | 295 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
296 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
297 * </ul> | |
298 */ | |
299 public Point getSize () { | |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
300 checkWidget (); |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
301 if (handle is null) return new Point (0,0); |
124
11b0a1324732
Fix various stack access from anon-class
Frank Benoit <benoit@tionex.de>
parents:
72
diff
changeset
|
302 GtkRequisition requisition; |
11b0a1324732
Fix various stack access from anon-class
Frank Benoit <benoit@tionex.de>
parents:
72
diff
changeset
|
303 OS.gtk_widget_size_request (handle, &requisition); |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
304 return new Point (requisition.width, requisition.height); |
31 | 305 } |
306 | |
307 /** | |
308 * Returns the size of the receiver's thumb relative to the | |
309 * difference between its maximum and minimum values. | |
310 * | |
311 * @return the thumb value | |
312 * | |
71 | 313 * @exception DWTException <ul> |
31 | 314 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
315 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
316 * </ul> | |
317 * | |
318 * @see ScrollBar | |
319 */ | |
320 public int getThumb () { | |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
321 checkWidget (); |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
322 return cast(int)adjustmentHandle.page_size; |
31 | 323 } |
324 | |
325 /** | |
326 * Returns <code>true</code> if the receiver is visible, and | |
327 * <code>false</code> otherwise. | |
328 * <p> | |
329 * If one of the receiver's ancestors is not visible or some | |
330 * other condition makes the receiver not visible, this method | |
331 * may still indicate that it is considered visible even though | |
332 * it may not actually be showing. | |
333 * </p> | |
334 * | |
335 * @return the receiver's visibility state | |
336 * | |
71 | 337 * @exception DWTException <ul> |
31 | 338 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
339 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
340 * </ul> | |
341 */ | |
45 | 342 public bool getVisible () { |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
343 checkWidget (); |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
344 auto scrolledHandle = parent.scrolledHandle; |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
345 int hsp, vsp; |
158
de2578a843a7
Tango update to rev 3158, TracedException>Exception, fromUtf8z>fromStringz,Fix Bug in MenuItem Thanx to nascent for the report.
Frank Benoit <benoit@tionex.de>
parents:
152
diff
changeset
|
346 OS.gtk_scrolled_window_get_policy (scrolledHandle, &hsp, &vsp); |
71 | 347 if ((style & DWT.HORIZONTAL) !is 0) { |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
348 return hsp !is OS.GTK_POLICY_NEVER; |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
349 } else { |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
350 return vsp !is OS.GTK_POLICY_NEVER; |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
351 } |
31 | 352 } |
353 | |
45 | 354 override int /*long*/ gtk_button_press_event (GtkWidget* widget, GdkEventButton* eventPtr) { |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
355 auto result = super.gtk_button_press_event (widget, eventPtr); |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
356 if (result !is 0) return result; |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
357 detail = OS.GTK_SCROLL_NONE; |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
358 dragSent = false; |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
359 return result; |
31 | 360 } |
361 | |
45 | 362 override int /*long*/ gtk_change_value (GtkWidget* widget, int /*long*/ scroll, int /*long*/ value1, int /*long*/ value2) { |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
363 detail = scroll; |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
364 return 0; |
31 | 365 } |
366 | |
45 | 367 override int /*long*/ gtk_value_changed (int /*long*/ adjustment) { |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
368 Event event = new Event (); |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
369 dragSent = detail is OS.GTK_SCROLL_JUMP; |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
370 switch (detail) { |
71 | 371 case OS.GTK_SCROLL_NONE: event.detail = DWT.NONE; break; |
372 case OS.GTK_SCROLL_JUMP: event.detail = DWT.DRAG; break; | |
373 case OS.GTK_SCROLL_START: event.detail = DWT.HOME; break; | |
374 case OS.GTK_SCROLL_END: event.detail = DWT.END; break; | |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
375 case OS.GTK_SCROLL_PAGE_DOWN: |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
376 case OS.GTK_SCROLL_PAGE_RIGHT: |
71 | 377 case OS.GTK_SCROLL_PAGE_FORWARD: event.detail = DWT.PAGE_DOWN; break; |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
378 case OS.GTK_SCROLL_PAGE_UP: |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
379 case OS.GTK_SCROLL_PAGE_LEFT: |
71 | 380 case OS.GTK_SCROLL_PAGE_BACKWARD: event.detail = DWT.PAGE_UP; break; |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
381 case OS.GTK_SCROLL_STEP_DOWN: |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
382 case OS.GTK_SCROLL_STEP_RIGHT: |
71 | 383 case OS.GTK_SCROLL_STEP_FORWARD: event.detail = DWT.ARROW_DOWN; break; |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
384 case OS.GTK_SCROLL_STEP_UP: |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
385 case OS.GTK_SCROLL_STEP_LEFT: |
71 | 386 case OS.GTK_SCROLL_STEP_BACKWARD: event.detail = DWT.ARROW_UP; break; |
55
93981635e709
Checked and inserted missing default switch cases.
Frank Benoit <benoit@tionex.de>
parents:
45
diff
changeset
|
387 default: |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
388 } |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
389 detail = OS.GTK_SCROLL_NONE; |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
390 if (!dragSent) detail = OS.GTK_SCROLL_NONE; |
71 | 391 postEvent (DWT.Selection, event); |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
392 parent.updateScrollBarValue (this); |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
393 return 0; |
31 | 394 } |
395 | |
45 | 396 override int /*long*/ gtk_event_after (GtkWidget* widget, GdkEvent* gdkEvent) { |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
397 switch (gdkEvent.type) { |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
398 case OS.GDK_BUTTON_RELEASE: { |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
399 GdkEventButton* gdkEventButton = cast(GdkEventButton*)gdkEvent; |
71 | 400 if (gdkEventButton.button is 1 && detail is DWT.DRAG) { |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
401 if (!dragSent) { |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
402 Event event = new Event (); |
71 | 403 event.detail = DWT.DRAG; |
404 postEvent (DWT.Selection, event); | |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
405 } |
71 | 406 postEvent (DWT.Selection); |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
407 } |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
408 detail = OS.GTK_SCROLL_NONE; |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
409 dragSent = false; |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
410 break; |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
411 } |
55
93981635e709
Checked and inserted missing default switch cases.
Frank Benoit <benoit@tionex.de>
parents:
45
diff
changeset
|
412 default: |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
413 } |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
414 return super.gtk_event_after (widget, gdkEvent); |
31 | 415 } |
416 | |
152
17f8449522fd
overloads second walkthrough
Frank Benoit <benoit@tionex.de>
parents:
124
diff
changeset
|
417 override void hookEvents () { |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
418 super.hookEvents (); |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
419 if (OS.GTK_VERSION >= OS.buildVERSION (2, 6, 0)) { |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
420 OS.g_signal_connect_closure (handle, OS.change_value.ptr, display.closures [CHANGE_VALUE], false); |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
421 } |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
422 OS.g_signal_connect_closure (adjustmentHandle, OS.value_changed.ptr, display.closures [VALUE_CHANGED], false); |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
423 OS.g_signal_connect_closure_by_id (handle, display.signalIds [EVENT_AFTER], 0, display.closures [EVENT_AFTER], false); |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
424 OS.g_signal_connect_closure_by_id (handle, display.signalIds [BUTTON_PRESS_EVENT], 0, display.closures [BUTTON_PRESS_EVENT], false); |
31 | 425 } |
426 | |
427 /** | |
428 * Returns <code>true</code> if the receiver is enabled and all | |
429 * of the receiver's ancestors are enabled, and <code>false</code> | |
430 * otherwise. A disabled control is typically not selectable from the | |
431 * user interface and draws with an inactive or "grayed" look. | |
432 * | |
433 * @return the receiver's enabled state | |
434 * | |
71 | 435 * @exception DWTException <ul> |
31 | 436 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
437 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
438 * </ul> | |
439 * | |
440 * @see #getEnabled | |
441 */ | |
45 | 442 public bool isEnabled () { |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
443 checkWidget (); |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
444 return getEnabled () && getParent ().getEnabled (); |
31 | 445 } |
446 | |
447 /** | |
448 * Returns <code>true</code> if the receiver is visible and all | |
449 * of the receiver's ancestors are visible and <code>false</code> | |
450 * otherwise. | |
451 * | |
452 * @return the receiver's visibility state | |
453 * | |
71 | 454 * @exception DWTException <ul> |
31 | 455 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
456 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
457 * </ul> | |
458 * | |
459 * @see #getVisible | |
460 */ | |
45 | 461 public bool isVisible () { |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
462 checkWidget (); |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
463 return getVisible () && getParent ().isVisible (); |
31 | 464 } |
465 | |
152
17f8449522fd
overloads second walkthrough
Frank Benoit <benoit@tionex.de>
parents:
124
diff
changeset
|
466 override void register () { |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
467 super.register (); |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
468 if (adjustmentHandle !is null) display.addWidget (cast(GtkWidget*)adjustmentHandle, this); |
31 | 469 } |
470 | |
240 | 471 void releaseHandle () { |
472 super.releaseHandle (); | |
473 parent = null; | |
474 } | |
475 | |
152
17f8449522fd
overloads second walkthrough
Frank Benoit <benoit@tionex.de>
parents:
124
diff
changeset
|
476 override void releaseParent () { |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
477 super.releaseParent (); |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
478 if (parent.horizontalBar is this) parent.horizontalBar = null; |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
479 if (parent.verticalBar is this) parent.verticalBar = null; |
31 | 480 } |
481 | |
152
17f8449522fd
overloads second walkthrough
Frank Benoit <benoit@tionex.de>
parents:
124
diff
changeset
|
482 override void releaseWidget () { |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
483 super.releaseWidget (); |
240 | 484 //parent = null; |
31 | 485 } |
486 | |
487 /** | |
488 * Removes the listener from the collection of listeners who will | |
489 * be notified when the user changes the receiver's value. | |
490 * | |
491 * @param listener the listener which should no longer be notified | |
492 * | |
493 * @exception IllegalArgumentException <ul> | |
494 * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> | |
495 * </ul> | |
71 | 496 * @exception DWTException <ul> |
31 | 497 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
498 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
499 * </ul> | |
500 * | |
501 * @see SelectionListener | |
502 * @see #addSelectionListener | |
503 */ | |
504 public void removeSelectionListener (SelectionListener listener) { | |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
505 checkWidget (); |
71 | 506 if (listener is null) error (DWT.ERROR_NULL_ARGUMENT); |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
507 if (eventTable is null) return; |
71 | 508 eventTable.unhook (DWT.Selection, listener); |
509 eventTable.unhook (DWT.DefaultSelection,listener); | |
31 | 510 } |
511 | |
512 /** | |
513 * Enables the receiver if the argument is <code>true</code>, | |
514 * and disables it otherwise. A disabled control is typically | |
515 * not selectable from the user interface and draws with an | |
516 * inactive or "grayed" look. | |
517 * | |
518 * @param enabled the new enabled state | |
519 * | |
71 | 520 * @exception DWTException <ul> |
31 | 521 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
522 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
523 * </ul> | |
524 */ | |
45 | 525 public void setEnabled (bool enabled) { |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
526 checkWidget (); |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
527 if (handle !is null) OS.gtk_widget_set_sensitive (handle, enabled); |
31 | 528 } |
529 | |
530 /** | |
531 * Sets the amount that the receiver's value will be | |
532 * modified by when the up/down (or right/left) arrows | |
533 * are pressed to the argument, which must be at least | |
534 * one. | |
535 * | |
536 * @param value the new increment (must be greater than zero) | |
537 * | |
71 | 538 * @exception DWTException <ul> |
31 | 539 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
540 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
541 * </ul> | |
542 */ | |
543 public void setIncrement (int value) { | |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
544 checkWidget (); |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
545 if (value < 1) return; |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
546 adjustmentHandle.step_increment = cast(float) value; |
66
bb2217c09e61
Fixed signal blocking/unblocking:
Frank Benoit <benoit@tionex.de>
parents:
59
diff
changeset
|
547 OS.g_signal_handlers_block_matched (adjustmentHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, null, null, udVALUE_CHANGED); |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
548 OS.gtk_adjustment_changed (adjustmentHandle); |
66
bb2217c09e61
Fixed signal blocking/unblocking:
Frank Benoit <benoit@tionex.de>
parents:
59
diff
changeset
|
549 OS.g_signal_handlers_unblock_matched (adjustmentHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, null, null, udVALUE_CHANGED); |
31 | 550 } |
551 | |
552 /** | |
553 * Sets the maximum. If this value is negative or less than or | |
554 * equal to the minimum, the value is ignored. If necessary, first | |
555 * the thumb and then the selection are adjusted to fit within the | |
556 * new range. | |
557 * | |
558 * @param value the new maximum | |
559 * | |
71 | 560 * @exception DWTException <ul> |
31 | 561 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
562 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
563 * </ul> | |
564 */ | |
565 public void setMaximum (int value) { | |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
566 checkWidget (); |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
567 int minimum = cast(int)adjustmentHandle.lower; |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
568 if (value <= minimum) return; |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
569 adjustmentHandle.upper = value; |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
570 adjustmentHandle.page_size = Math.min (adjustmentHandle.page_size, value - minimum); |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
571 adjustmentHandle.value = Math.min (adjustmentHandle.value, (value - adjustmentHandle.page_size)); |
66
bb2217c09e61
Fixed signal blocking/unblocking:
Frank Benoit <benoit@tionex.de>
parents:
59
diff
changeset
|
572 OS.g_signal_handlers_block_matched (adjustmentHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, null, null, udVALUE_CHANGED); |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
573 OS.gtk_adjustment_changed (adjustmentHandle); |
66
bb2217c09e61
Fixed signal blocking/unblocking:
Frank Benoit <benoit@tionex.de>
parents:
59
diff
changeset
|
574 OS.g_signal_handlers_unblock_matched (adjustmentHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, null, null, udVALUE_CHANGED); |
31 | 575 } |
576 | |
577 /** | |
578 * Sets the minimum value. If this value is negative or greater | |
579 * than or equal to the maximum, the value is ignored. If necessary, | |
580 * first the thumb and then the selection are adjusted to fit within | |
581 * the new range. | |
582 * | |
583 * @param value the new minimum | |
584 * | |
71 | 585 * @exception DWTException <ul> |
31 | 586 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
587 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
588 * </ul> | |
589 */ | |
590 public void setMinimum (int value) { | |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
591 checkWidget (); |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
592 if (value < 0) return; |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
593 int maximum = cast(int)adjustmentHandle.upper; |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
594 if (value >= maximum) return; |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
595 adjustmentHandle.lower = value; |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
596 adjustmentHandle.page_size = Math.min (adjustmentHandle.page_size, maximum - value); |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
597 adjustmentHandle.value = Math.max (adjustmentHandle.value, value); |
66
bb2217c09e61
Fixed signal blocking/unblocking:
Frank Benoit <benoit@tionex.de>
parents:
59
diff
changeset
|
598 OS.g_signal_handlers_block_matched (adjustmentHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, null, null, udVALUE_CHANGED); |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
599 OS.gtk_adjustment_changed (adjustmentHandle); |
66
bb2217c09e61
Fixed signal blocking/unblocking:
Frank Benoit <benoit@tionex.de>
parents:
59
diff
changeset
|
600 OS.g_signal_handlers_unblock_matched (adjustmentHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, null, null, udVALUE_CHANGED); |
31 | 601 } |
602 | |
240 | 603 void setOrientation () { |
604 super.setOrientation (); | |
605 if ((parent.style & DWT.MIRRORED) !is 0) { | |
606 if ((parent.state & CANVAS) !is 0) { | |
607 if ((style & DWT.HORIZONTAL) !is 0) { | |
608 OS.gtk_range_set_inverted (handle, true); | |
609 } | |
610 } | |
611 } | |
612 } | |
613 | |
31 | 614 /** |
615 * Sets the amount that the receiver's value will be | |
616 * modified by when the page increment/decrement areas | |
617 * are selected to the argument, which must be at least | |
618 * one. | |
619 * | |
620 * @param value the page increment (must be greater than zero) | |
621 * | |
71 | 622 * @exception DWTException <ul> |
31 | 623 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
624 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
625 * </ul> | |
626 */ | |
627 public void setPageIncrement (int value) { | |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
628 checkWidget (); |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
629 if (value < 1) return; |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
630 adjustmentHandle.page_increment = cast(float) value; |
66
bb2217c09e61
Fixed signal blocking/unblocking:
Frank Benoit <benoit@tionex.de>
parents:
59
diff
changeset
|
631 OS.g_signal_handlers_block_matched (adjustmentHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, null, null, udVALUE_CHANGED); |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
632 OS.gtk_adjustment_changed (adjustmentHandle); |
66
bb2217c09e61
Fixed signal blocking/unblocking:
Frank Benoit <benoit@tionex.de>
parents:
59
diff
changeset
|
633 OS.g_signal_handlers_unblock_matched (adjustmentHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, null, null, udVALUE_CHANGED); |
31 | 634 } |
635 | |
636 /** | |
637 * Sets the single <em>selection</em> that is the receiver's | |
638 * value to the argument which must be greater than or equal | |
639 * to zero. | |
640 * | |
641 * @param selection the new selection (must be zero or greater) | |
642 * | |
71 | 643 * @exception DWTException <ul> |
31 | 644 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
645 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
646 * </ul> | |
647 */ | |
648 public void setSelection (int value) { | |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
649 checkWidget (); |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
650 value = Math.min (value, getMaximum() - getThumb()); |
66
bb2217c09e61
Fixed signal blocking/unblocking:
Frank Benoit <benoit@tionex.de>
parents:
59
diff
changeset
|
651 OS.g_signal_handlers_block_matched (adjustmentHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, null, null, udVALUE_CHANGED); |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
652 OS.gtk_adjustment_set_value (adjustmentHandle, value); |
66
bb2217c09e61
Fixed signal blocking/unblocking:
Frank Benoit <benoit@tionex.de>
parents:
59
diff
changeset
|
653 OS.g_signal_handlers_unblock_matched (adjustmentHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, null, null, udVALUE_CHANGED); |
31 | 654 } |
655 | |
656 /** | |
657 * Sets the size of the receiver's thumb relative to the | |
658 * difference between its maximum and minimum values. This new | |
659 * value will be ignored if it is less than one, and will be | |
660 * clamped if it exceeds the receiver's current range. | |
661 * | |
662 * @param value the new thumb value, which must be at least one and not | |
663 * larger than the size of the current range | |
664 * | |
71 | 665 * @exception DWTException <ul> |
31 | 666 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
667 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
668 * </ul> | |
669 */ | |
670 public void setThumb (int value) { | |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
671 checkWidget (); |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
672 if (value < 1) return; |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
673 value = Math.min (value, cast(int)(adjustmentHandle.upper - adjustmentHandle.lower)); |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
674 adjustmentHandle.page_size = cast(double) value; |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
675 adjustmentHandle.value = Math.min (adjustmentHandle.value, (adjustmentHandle.upper - value)); |
66
bb2217c09e61
Fixed signal blocking/unblocking:
Frank Benoit <benoit@tionex.de>
parents:
59
diff
changeset
|
676 OS.g_signal_handlers_block_matched (adjustmentHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, null, null, udVALUE_CHANGED); |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
677 OS.gtk_adjustment_changed (adjustmentHandle); |
66
bb2217c09e61
Fixed signal blocking/unblocking:
Frank Benoit <benoit@tionex.de>
parents:
59
diff
changeset
|
678 OS.g_signal_handlers_unblock_matched (adjustmentHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, null, null, udVALUE_CHANGED); |
31 | 679 } |
680 | |
681 /** | |
682 * Sets the receiver's selection, minimum value, maximum | |
683 * value, thumb, increment and page increment all at once. | |
684 * <p> | |
685 * Note: This is similar to setting the values individually | |
686 * using the appropriate methods, but may be implemented in a | |
687 * more efficient fashion on some platforms. | |
688 * </p> | |
689 * | |
690 * @param selection the new selection value | |
691 * @param minimum the new minimum value | |
692 * @param maximum the new maximum value | |
693 * @param thumb the new thumb value | |
694 * @param increment the new increment value | |
695 * @param pageIncrement the new pageIncrement value | |
696 * | |
71 | 697 * @exception DWTException <ul> |
31 | 698 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
699 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
700 * </ul> | |
701 */ | |
702 public void setValues (int selection, int minimum, int maximum, int thumb, int increment, int pageIncrement) { | |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
703 checkWidget (); |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
704 if (minimum < 0) return; |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
705 if (maximum < 0) return; |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
706 if (thumb < 1) return; |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
707 if (increment < 1) return; |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
708 if (pageIncrement < 1) return; |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
709 thumb = Math.min (thumb, maximum - minimum); |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
710 adjustmentHandle.lower = minimum; |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
711 adjustmentHandle.upper = maximum; |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
712 adjustmentHandle.step_increment = increment; |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
713 adjustmentHandle.page_increment = pageIncrement; |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
714 adjustmentHandle.page_size = thumb; |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
715 adjustmentHandle.value = Math.min (Math.max (selection, minimum), maximum - thumb); |
66
bb2217c09e61
Fixed signal blocking/unblocking:
Frank Benoit <benoit@tionex.de>
parents:
59
diff
changeset
|
716 OS.g_signal_handlers_block_matched (adjustmentHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, null, null, udVALUE_CHANGED); |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
717 OS.gtk_adjustment_changed (adjustmentHandle); |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
718 OS.gtk_adjustment_value_changed (adjustmentHandle); |
66
bb2217c09e61
Fixed signal blocking/unblocking:
Frank Benoit <benoit@tionex.de>
parents:
59
diff
changeset
|
719 OS.g_signal_handlers_unblock_matched (adjustmentHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, null, null, udVALUE_CHANGED); |
31 | 720 } |
721 | |
722 /** | |
723 * Marks the receiver as visible if the argument is <code>true</code>, | |
724 * and marks it invisible otherwise. | |
725 * <p> | |
726 * If one of the receiver's ancestors is not visible or some | |
727 * other condition makes the receiver not visible, marking | |
728 * it visible may not actually cause it to be displayed. | |
729 * </p> | |
730 * | |
731 * @param visible the new visibility state | |
732 * | |
71 | 733 * @exception DWTException <ul> |
31 | 734 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
735 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
736 * </ul> | |
737 */ | |
45 | 738 public void setVisible (bool visible) { |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
739 checkWidget (); |
240 | 740 if (parent.setScrollBarVisible (this, visible)) { |
741 sendEvent (visible ? DWT.Show : DWT.Hide); | |
742 parent.sendEvent (DWT.Resize); | |
743 } | |
31 | 744 } |
745 | |
746 } |