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