Mercurial > projects > dwt-win
annotate dwt/custom/ScrolledComposite.d @ 212:ab60f3309436
reverted the char[] to String and use the an alias.
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Mon, 05 May 2008 00:12:38 +0200 |
parents | a5afe31f5cdd |
children | 36f5cb12e1a2 |
rev | line source |
---|---|
155 | 1 /******************************************************************************* |
2 * Copyright (c) 2000, 2006 IBM Corporation and others. | |
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 | |
10 * Port to the D programming language: | |
11 * Frank Benoit <benoit@tionex.de> | |
12 *******************************************************************************/ | |
13 module dwt.custom.ScrolledComposite; | |
14 | |
15 | |
16 import dwt.DWT; | |
17 import dwt.DWTException; | |
18 import dwt.graphics.Point; | |
19 import dwt.graphics.Rectangle; | |
20 import dwt.widgets.Composite; | |
21 import dwt.widgets.Control; | |
22 import dwt.widgets.Event; | |
23 import dwt.widgets.Layout; | |
24 import dwt.widgets.Listener; | |
25 import dwt.widgets.ScrollBar; | |
26 import dwt.custom.ScrolledCompositeLayout; | |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
155
diff
changeset
|
27 import dwt.dwthelper.utils; |
155 | 28 |
29 /** | |
30 * A ScrolledComposite provides scrollbars and will scroll its content when the user | |
31 * uses the scrollbars. | |
32 * | |
33 * | |
34 * <p>There are two ways to use the ScrolledComposite: | |
35 * | |
36 * <p> | |
37 * 1) Set the size of the control that is being scrolled and the ScrolledComposite | |
38 * will show scrollbars when the contained control can not be fully seen. | |
39 * | |
40 * 2) The second way imitates the way a browser would work. Set the minimum size of | |
41 * the control and the ScrolledComposite will show scroll bars if the visible area is | |
42 * less than the minimum size of the control and it will expand the size of the control | |
43 * if the visible area is greater than the minimum size. This requires invoking | |
44 * both setMinWidth(), setMinHeight() and setExpandHorizontal(), setExpandVertical(). | |
45 * | |
46 * <code><pre> | |
47 * public static void main (String [] args) { | |
48 * Display display = new Display (); | |
49 * Color red = display.getSystemColor(DWT.COLOR_RED); | |
50 * Color blue = display.getSystemColor(DWT.COLOR_BLUE); | |
51 * Shell shell = new Shell (display); | |
52 * shell.setLayout(new FillLayout()); | |
53 * | |
54 * // set the size of the scrolled content - method 1 | |
55 * final ScrolledComposite sc1 = new ScrolledComposite(shell, DWT.H_SCROLL | DWT.V_SCROLL | DWT.BORDER); | |
56 * final Composite c1 = new Composite(sc1, DWT.NONE); | |
57 * sc1.setContent(c1); | |
58 * c1.setBackground(red); | |
59 * GridLayout layout = new GridLayout(); | |
60 * layout.numColumns = 4; | |
61 * c1.setLayout(layout); | |
62 * Button b1 = new Button (c1, DWT.PUSH); | |
63 * b1.setText("first button"); | |
64 * c1.setSize(c1.computeSize(DWT.DEFAULT, DWT.DEFAULT)); | |
65 * | |
66 * // set the minimum width and height of the scrolled content - method 2 | |
67 * final ScrolledComposite sc2 = new ScrolledComposite(shell, DWT.H_SCROLL | DWT.V_SCROLL | DWT.BORDER); | |
68 * sc2.setExpandHorizontal(true); | |
69 * sc2.setExpandVertical(true); | |
70 * final Composite c2 = new Composite(sc2, DWT.NONE); | |
71 * sc2.setContent(c2); | |
72 * c2.setBackground(blue); | |
73 * layout = new GridLayout(); | |
74 * layout.numColumns = 4; | |
75 * c2.setLayout(layout); | |
76 * Button b2 = new Button (c2, DWT.PUSH); | |
77 * b2.setText("first button"); | |
78 * sc2.setMinSize(c2.computeSize(DWT.DEFAULT, DWT.DEFAULT)); | |
79 * | |
80 * Button add = new Button (shell, DWT.PUSH); | |
81 * add.setText("add children"); | |
82 * final int[] index = new int[]{0}; | |
83 * add.addListener(DWT.Selection, new Listener() { | |
84 * public void handleEvent(Event e) { | |
85 * index[0]++; | |
86 * Button button = new Button(c1, DWT.PUSH); | |
87 * button.setText("button "+index[0]); | |
88 * // reset size of content so children can be seen - method 1 | |
89 * c1.setSize(c1.computeSize(DWT.DEFAULT, DWT.DEFAULT)); | |
90 * c1.layout(); | |
91 * | |
92 * button = new Button(c2, DWT.PUSH); | |
93 * button.setText("button "+index[0]); | |
94 * // reset the minimum width and height so children can be seen - method 2 | |
95 * sc2.setMinSize(c2.computeSize(DWT.DEFAULT, DWT.DEFAULT)); | |
96 * c2.layout(); | |
97 * } | |
98 * }); | |
99 * | |
100 * shell.open (); | |
101 * while (!shell.isDisposed ()) { | |
102 * if (!display.readAndDispatch ()) display.sleep (); | |
103 * } | |
104 * display.dispose (); | |
105 * } | |
106 * </pre></code> | |
107 * | |
108 * <dl> | |
109 * <dt><b>Styles:</b><dd>H_SCROLL, V_SCROLL | |
110 * </dl> | |
111 */ | |
112 public class ScrolledComposite : Composite { | |
113 | |
114 Control content; | |
115 Listener contentListener; | |
116 | |
117 int minHeight = 0; | |
118 int minWidth = 0; | |
119 bool expandHorizontal = false; | |
120 bool expandVertical = false; | |
121 bool alwaysShowScroll = false; | |
122 | |
123 /** | |
124 * Constructs a new instance of this class given its parent | |
125 * and a style value describing its behavior and appearance. | |
126 * <p> | |
127 * The style value is either one of the style constants defined in | |
128 * class <code>DWT</code> which is applicable to instances of this | |
129 * class, or must be built by <em>bitwise OR</em>'ing together | |
130 * (that is, using the <code>int</code> "|" operator) two or more | |
131 * of those <code>DWT</code> style constants. The class description | |
132 * lists the style constants that are applicable to the class. | |
133 * Style bits are also inherited from superclasses. | |
134 * </p> | |
135 * | |
136 * @param parent a widget which will be the parent of the new instance (cannot be null) | |
137 * @param style the style of widget to construct | |
138 * | |
139 * @exception IllegalArgumentException <ul> | |
140 * <li>ERROR_NULL_ARGUMENT - if the parent is null</li> | |
141 * </ul> | |
142 * @exception DWTException <ul> | |
143 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li> | |
144 * </ul> | |
145 * | |
146 * @see DWT#H_SCROLL | |
147 * @see DWT#V_SCROLL | |
148 * @see #getStyle() | |
149 */ | |
150 public this(Composite parent, int style) { | |
151 super(parent, checkStyle(style)); | |
152 super.setLayout(new ScrolledCompositeLayout()); | |
153 ScrollBar hBar = getHorizontalBar (); | |
154 if (hBar !is null) { | |
155 hBar.setVisible(false); | |
156 hBar.addListener (DWT.Selection, new class() Listener { | |
157 public void handleEvent (Event e) { | |
158 hScroll(); | |
159 } | |
160 }); | |
161 } | |
162 | |
163 ScrollBar vBar = getVerticalBar (); | |
164 if (vBar !is null) { | |
165 vBar.setVisible(false); | |
166 vBar.addListener (DWT.Selection, new class() Listener { | |
167 public void handleEvent (Event e) { | |
168 vScroll(); | |
169 } | |
170 }); | |
171 } | |
172 | |
173 contentListener = new class() Listener { | |
174 public void handleEvent(Event e) { | |
175 if (e.type !is DWT.Resize) return; | |
176 layout(false); | |
177 } | |
178 }; | |
179 } | |
180 | |
181 static int checkStyle (int style) { | |
182 int mask = DWT.H_SCROLL | DWT.V_SCROLL | DWT.BORDER | DWT.LEFT_TO_RIGHT | DWT.RIGHT_TO_LEFT; | |
183 return style & mask; | |
184 } | |
185 | |
186 /** | |
187 * Returns the Always Show Scrollbars flag. True if the scrollbars are | |
188 * always shown even if they are not required. False if the scrollbars are only | |
189 * visible when some part of the composite needs to be scrolled to be seen. | |
190 * The H_SCROLL and V_SCROLL style bits are also required to enable scrollbars in the | |
191 * horizontal and vertical directions. | |
192 * | |
193 * @return the Always Show Scrollbars flag value | |
194 */ | |
195 public bool getAlwaysShowScrollBars() { | |
196 //checkWidget(); | |
197 return alwaysShowScroll; | |
198 } | |
199 | |
200 /** | |
201 * Returns <code>true</code> if the content control | |
202 * will be expanded to fill available horizontal space. | |
203 * | |
204 * @return the receiver's horizontal expansion state | |
205 * | |
206 * @exception DWTException <ul> | |
207 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
208 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
209 * </ul> | |
210 * | |
211 * @since 3.2 | |
212 */ | |
213 public bool getExpandHorizontal() { | |
214 checkWidget(); | |
215 return expandHorizontal; | |
216 } | |
217 | |
218 /** | |
219 * Returns <code>true</code> if the content control | |
220 * will be expanded to fill available vertical space. | |
221 * | |
222 * @return the receiver's vertical expansion state | |
223 * | |
224 * @exception DWTException <ul> | |
225 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
226 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
227 * </ul> | |
228 * | |
229 * @since 3.2 | |
230 */ | |
231 public bool getExpandVertical() { | |
232 checkWidget(); | |
233 return expandVertical; | |
234 } | |
235 | |
236 /** | |
237 * Returns the minimum width of the content control. | |
238 * | |
239 * @return the minimum width | |
240 * | |
241 * @exception DWTException <ul> | |
242 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
243 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
244 * </ul> | |
245 * | |
246 * @since 3.2 | |
247 */ | |
248 public int getMinWidth() { | |
249 checkWidget(); | |
250 return minWidth; | |
251 } | |
252 | |
253 /** | |
254 * Returns the minimum height of the content control. | |
255 * | |
256 * @return the minimum height | |
257 * | |
258 * @exception DWTException <ul> | |
259 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
260 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
261 * </ul> | |
262 * | |
263 * @since 3.2 | |
264 */ | |
265 public int getMinHeight() { | |
266 checkWidget(); | |
267 return minHeight; | |
268 } | |
269 | |
270 /** | |
271 * Get the content that is being scrolled. | |
272 * | |
273 * @return the control displayed in the content area | |
274 */ | |
275 public Control getContent() { | |
276 //checkWidget(); | |
277 return content; | |
278 } | |
279 | |
280 void hScroll() { | |
281 if (content is null) return; | |
282 Point location = content.getLocation (); | |
283 ScrollBar hBar = getHorizontalBar (); | |
284 int hSelection = hBar.getSelection (); | |
285 content.setLocation (-hSelection, location.y); | |
286 } | |
287 bool needHScroll(Rectangle contentRect, bool vVisible) { | |
288 ScrollBar hBar = getHorizontalBar(); | |
289 if (hBar is null) return false; | |
290 | |
291 Rectangle hostRect = getBounds(); | |
292 int border = getBorderWidth(); | |
293 hostRect.width -= 2*border; | |
294 ScrollBar vBar = getVerticalBar(); | |
295 if (vVisible && vBar !is null) hostRect.width -= vBar.getSize().x; | |
296 | |
297 if (!expandHorizontal && contentRect.width > hostRect.width) return true; | |
298 if (expandHorizontal && minWidth > hostRect.width) return true; | |
299 return false; | |
300 } | |
301 | |
302 bool needVScroll(Rectangle contentRect, bool hVisible) { | |
303 ScrollBar vBar = getVerticalBar(); | |
304 if (vBar is null) return false; | |
305 | |
306 Rectangle hostRect = getBounds(); | |
307 int border = getBorderWidth(); | |
308 hostRect.height -= 2*border; | |
309 ScrollBar hBar = getHorizontalBar(); | |
310 if (hVisible && hBar !is null) hostRect.height -= hBar.getSize().y; | |
311 | |
312 if (!expandVertical && contentRect.height > hostRect.height) return true; | |
313 if (expandVertical && minHeight > hostRect.height) return true; | |
314 return false; | |
315 } | |
316 | |
317 /** | |
318 * Return the point in the content that currently appears in the top left | |
319 * corner of the scrolled composite. | |
320 * | |
321 * @return the point in the content that currently appears in the top left | |
322 * corner of the scrolled composite. If no content has been set, this returns | |
323 * (0, 0). | |
324 * | |
325 * @exception DWTException <ul> | |
326 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
327 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
328 * </ul> | |
329 * | |
330 * @since 2.0 | |
331 */ | |
332 public Point getOrigin() { | |
333 checkWidget(); | |
334 if (content is null) return new Point(0, 0); | |
335 Point location = content.getLocation(); | |
336 return new Point(-location.x, -location.y); | |
337 } | |
338 /** | |
339 * Scrolls the content so that the specified point in the content is in the top | |
340 * left corner. If no content has been set, nothing will occur. | |
341 * | |
342 * Negative values will be ignored. Values greater than the maximum scroll | |
343 * distance will result in scrolling to the end of the scrollbar. | |
344 * | |
345 * @param origin the point on the content to appear in the top left corner | |
346 * | |
347 * @exception DWTException <ul> | |
348 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
349 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
350 * <li>ERROR_INVALID_ARGUMENT - value of origin is outside of content | |
351 * </ul> | |
352 * @since 2.0 | |
353 */ | |
354 public void setOrigin(Point origin) { | |
355 setOrigin(origin.x, origin.y); | |
356 } | |
357 /** | |
358 * Scrolls the content so that the specified point in the content is in the top | |
359 * left corner. If no content has been set, nothing will occur. | |
360 * | |
361 * Negative values will be ignored. Values greater than the maximum scroll | |
362 * distance will result in scrolling to the end of the scrollbar. | |
363 * | |
364 * @param x the x coordinate of the content to appear in the top left corner | |
365 * | |
366 * @param y the y coordinate of the content to appear in the top left corner | |
367 * | |
368 * @exception DWTException <ul> | |
369 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
370 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
371 * </ul> | |
372 * | |
373 * @since 2.0 | |
374 */ | |
375 public void setOrigin(int x, int y) { | |
376 checkWidget(); | |
377 if (content is null) return; | |
378 ScrollBar hBar = getHorizontalBar (); | |
379 if (hBar !is null) { | |
380 hBar.setSelection(x); | |
381 x = -hBar.getSelection (); | |
382 } else { | |
383 x = 0; | |
384 } | |
385 ScrollBar vBar = getVerticalBar (); | |
386 if (vBar !is null) { | |
387 vBar.setSelection(y); | |
388 y = -vBar.getSelection (); | |
389 } else { | |
390 y = 0; | |
391 } | |
392 content.setLocation(x, y); | |
393 } | |
394 /** | |
395 * Set the Always Show Scrollbars flag. True if the scrollbars are | |
396 * always shown even if they are not required. False if the scrollbars are only | |
397 * visible when some part of the composite needs to be scrolled to be seen. | |
398 * The H_SCROLL and V_SCROLL style bits are also required to enable scrollbars in the | |
399 * horizontal and vertical directions. | |
400 * | |
401 * @param show true to show the scrollbars even when not required, false to show scrollbars only when required | |
402 * | |
403 * @exception DWTException <ul> | |
404 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
405 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
406 * </ul> | |
407 */ | |
408 public void setAlwaysShowScrollBars(bool show) { | |
409 checkWidget(); | |
410 if (show is alwaysShowScroll) return; | |
411 alwaysShowScroll = show; | |
412 ScrollBar hBar = getHorizontalBar (); | |
413 if (hBar !is null && alwaysShowScroll) hBar.setVisible(true); | |
414 ScrollBar vBar = getVerticalBar (); | |
415 if (vBar !is null && alwaysShowScroll) vBar.setVisible(true); | |
416 layout(false); | |
417 } | |
418 | |
419 /** | |
420 * Set the content that will be scrolled. | |
421 * | |
422 * @param content the control to be displayed in the content area | |
423 * | |
424 * @exception DWTException <ul> | |
425 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
426 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
427 * </ul> | |
428 */ | |
429 public void setContent(Control content) { | |
430 checkWidget(); | |
431 if (this.content !is null && !this.content.isDisposed()) { | |
432 this.content.removeListener(DWT.Resize, contentListener); | |
433 this.content.setBounds(new Rectangle(-200, -200, 0, 0)); | |
434 } | |
435 | |
436 this.content = content; | |
437 ScrollBar vBar = getVerticalBar (); | |
438 ScrollBar hBar = getHorizontalBar (); | |
439 if (this.content !is null) { | |
440 if (vBar !is null) { | |
441 vBar.setMaximum (0); | |
442 vBar.setThumb (0); | |
443 vBar.setSelection(0); | |
444 } | |
445 if (hBar !is null) { | |
446 hBar.setMaximum (0); | |
447 hBar.setThumb (0); | |
448 hBar.setSelection(0); | |
449 } | |
450 content.setLocation(0, 0); | |
451 layout(false); | |
452 this.content.addListener(DWT.Resize, contentListener); | |
453 } else { | |
454 if (hBar !is null) hBar.setVisible(alwaysShowScroll); | |
455 if (vBar !is null) vBar.setVisible(alwaysShowScroll); | |
456 } | |
457 } | |
458 /** | |
459 * Configure the ScrolledComposite to resize the content object to be as wide as the | |
460 * ScrolledComposite when the width of the ScrolledComposite is greater than the | |
461 * minimum width specified in setMinWidth. If the ScrolledComposite is less than the | |
462 * minimum width, the content will not be resized and instead the horizontal scroll bar will be | |
463 * used to view the entire width. | |
464 * If expand is false, this behaviour is turned off. By default, this behaviour is turned off. | |
465 * | |
466 * @param expand true to expand the content control to fill available horizontal space | |
467 * | |
468 * @exception DWTException <ul> | |
469 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
470 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
471 * </ul> | |
472 */ | |
473 public void setExpandHorizontal(bool expand) { | |
474 checkWidget(); | |
475 if (expand is expandHorizontal) return; | |
476 expandHorizontal = expand; | |
477 layout(false); | |
478 } | |
479 /** | |
480 * Configure the ScrolledComposite to resize the content object to be as tall as the | |
481 * ScrolledComposite when the height of the ScrolledComposite is greater than the | |
482 * minimum height specified in setMinHeight. If the ScrolledComposite is less than the | |
483 * minimum height, the content will not be resized and instead the vertical scroll bar will be | |
484 * used to view the entire height. | |
485 * If expand is false, this behaviour is turned off. By default, this behaviour is turned off. | |
486 * | |
487 * @param expand true to expand the content control to fill available vertical space | |
488 * | |
489 * @exception DWTException <ul> | |
490 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
491 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
492 * </ul> | |
493 */ | |
494 public void setExpandVertical(bool expand) { | |
495 checkWidget(); | |
496 if (expand is expandVertical) return; | |
497 expandVertical = expand; | |
498 layout(false); | |
499 } | |
500 /** | |
501 * Sets the layout which is associated with the receiver to be | |
502 * the argument which may be null. | |
503 * <p> | |
504 * Note: No Layout can be set on this Control because it already | |
505 * manages the size and position of its children. | |
506 * </p> | |
507 * | |
508 * @param layout the receiver's new layout or null | |
509 * | |
510 * @exception DWTException <ul> | |
511 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
512 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
513 * </ul> | |
514 */ | |
515 public override void setLayout (Layout layout) { | |
516 checkWidget(); | |
517 return; | |
518 } | |
519 /** | |
520 * Specify the minimum height at which the ScrolledComposite will begin scrolling the | |
521 * content with the vertical scroll bar. This value is only relevant if | |
522 * setExpandVertical(true) has been set. | |
523 * | |
524 * @param height the minimum height or 0 for default height | |
525 * | |
526 * @exception DWTException <ul> | |
527 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
528 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
529 * </ul> | |
530 */ | |
531 public void setMinHeight(int height) { | |
532 setMinSize(minWidth, height); | |
533 } | |
534 /** | |
535 * Specify the minimum width and height at which the ScrolledComposite will begin scrolling the | |
536 * content with the horizontal scroll bar. This value is only relevant if | |
537 * setExpandHorizontal(true) and setExpandVertical(true) have been set. | |
538 * | |
539 * @param size the minimum size or null for the default size | |
540 * | |
541 * @exception DWTException <ul> | |
542 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
543 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
544 * </ul> | |
545 */ | |
546 public void setMinSize(Point size) { | |
547 if (size is null) { | |
548 setMinSize(0, 0); | |
549 } else { | |
550 setMinSize(size.x, size.y); | |
551 } | |
552 } | |
553 /** | |
554 * Specify the minimum width and height at which the ScrolledComposite will begin scrolling the | |
555 * content with the horizontal scroll bar. This value is only relevant if | |
556 * setExpandHorizontal(true) and setExpandVertical(true) have been set. | |
557 * | |
558 * @param width the minimum width or 0 for default width | |
559 * @param height the minimum height or 0 for default height | |
560 * | |
561 * @exception DWTException <ul> | |
562 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
563 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
564 * </ul> | |
565 */ | |
566 public void setMinSize(int width, int height) { | |
567 checkWidget(); | |
568 if (width is minWidth && height is minHeight) return; | |
569 minWidth = Math.max(0, width); | |
570 minHeight = Math.max(0, height); | |
571 layout(false); | |
572 } | |
573 /** | |
574 * Specify the minimum width at which the ScrolledComposite will begin scrolling the | |
575 * content with the horizontal scroll bar. This value is only relevant if | |
576 * setExpandHorizontal(true) has been set. | |
577 * | |
578 * @param width the minimum width or 0 for default width | |
579 * | |
580 * @exception DWTException <ul> | |
581 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
582 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
583 * </ul> | |
584 */ | |
585 public void setMinWidth(int width) { | |
586 setMinSize(width, minHeight); | |
587 } | |
588 | |
589 void vScroll() { | |
590 if (content is null) return; | |
591 Point location = content.getLocation (); | |
592 ScrollBar vBar = getVerticalBar (); | |
593 int vSelection = vBar.getSelection (); | |
594 content.setLocation (location.x, -vSelection); | |
595 } | |
596 } |