annotate dwt/custom/ScrolledComposite.d @ 246:fd9c62a2998e

Updater SWT 3.4M7 to 3.4
author Frank Benoit <benoit@tionex.de>
date Tue, 01 Jul 2008 10:15:59 +0200
parents 36f5cb12e1a2
children 349b8c12e243
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 /*******************************************************************************
246
fd9c62a2998e Updater SWT 3.4M7 to 3.4
Frank Benoit <benoit@tionex.de>
parents: 213
diff changeset
2 * Copyright (c) 2000, 2008 IBM Corporation and others.
155
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;
213
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
18 import dwt.events.DisposeEvent;
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
19 import dwt.events.DisposeListener;
155
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
20 import dwt.graphics.Point;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
21 import dwt.graphics.Rectangle;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
22 import dwt.widgets.Composite;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
23 import dwt.widgets.Control;
213
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
24 import dwt.widgets.Display;
155
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
25 import dwt.widgets.Event;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
26 import dwt.widgets.Layout;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
27 import dwt.widgets.Listener;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
28 import dwt.widgets.ScrollBar;
213
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
29 import dwt.widgets.Shell;
155
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
30 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
31 import dwt.dwthelper.utils;
155
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 * A ScrolledComposite provides scrollbars and will scroll its content when the user
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
35 * uses the scrollbars.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
36 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
37 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
38 * <p>There are two ways to use the ScrolledComposite:
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 * <p>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
41 * 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
42 * will show scrollbars when the contained control can not be fully seen.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
43 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
44 * 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
45 * 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
46 * 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
47 * 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
48 * both setMinWidth(), setMinHeight() and setExpandHorizontal(), setExpandVertical().
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
49 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
50 * <code><pre>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
51 * public static void main (String [] args) {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
52 * Display display = new Display ();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
53 * Color red = display.getSystemColor(DWT.COLOR_RED);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
54 * Color blue = display.getSystemColor(DWT.COLOR_BLUE);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
55 * Shell shell = new Shell (display);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
56 * shell.setLayout(new FillLayout());
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
57 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
58 * // set the size of the scrolled content - method 1
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
59 * 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
60 * final Composite c1 = new Composite(sc1, DWT.NONE);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
61 * sc1.setContent(c1);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
62 * c1.setBackground(red);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
63 * GridLayout layout = new GridLayout();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
64 * layout.numColumns = 4;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
65 * c1.setLayout(layout);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
66 * Button b1 = new Button (c1, DWT.PUSH);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
67 * b1.setText("first button");
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
68 * c1.setSize(c1.computeSize(DWT.DEFAULT, DWT.DEFAULT));
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
69 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
70 * // set the minimum width and height of the scrolled content - method 2
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
71 * 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
72 * sc2.setExpandHorizontal(true);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
73 * sc2.setExpandVertical(true);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
74 * final Composite c2 = new Composite(sc2, DWT.NONE);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
75 * sc2.setContent(c2);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
76 * c2.setBackground(blue);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
77 * layout = new GridLayout();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
78 * layout.numColumns = 4;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
79 * c2.setLayout(layout);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
80 * Button b2 = new Button (c2, DWT.PUSH);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
81 * b2.setText("first button");
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
82 * sc2.setMinSize(c2.computeSize(DWT.DEFAULT, DWT.DEFAULT));
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
83 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
84 * Button add = new Button (shell, DWT.PUSH);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
85 * add.setText("add children");
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
86 * final int[] index = new int[]{0};
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
87 * add.addListener(DWT.Selection, new Listener() {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
88 * public void handleEvent(Event e) {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
89 * index[0]++;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
90 * Button button = new Button(c1, DWT.PUSH);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
91 * button.setText("button "+index[0]);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
92 * // reset size of content so children can be seen - method 1
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
93 * c1.setSize(c1.computeSize(DWT.DEFAULT, DWT.DEFAULT));
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
94 * c1.layout();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
95 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
96 * button = new Button(c2, DWT.PUSH);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
97 * button.setText("button "+index[0]);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
98 * // 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
99 * sc2.setMinSize(c2.computeSize(DWT.DEFAULT, DWT.DEFAULT));
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
100 * c2.layout();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
101 * }
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
102 * });
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 * shell.open ();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
105 * while (!shell.isDisposed ()) {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
106 * if (!display.readAndDispatch ()) display.sleep ();
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 * display.dispose ();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
109 * }
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
110 * </pre></code>
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 * <dl>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
113 * <dt><b>Styles:</b><dd>H_SCROLL, V_SCROLL
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
114 * </dl>
246
fd9c62a2998e Updater SWT 3.4M7 to 3.4
Frank Benoit <benoit@tionex.de>
parents: 213
diff changeset
115 *
fd9c62a2998e Updater SWT 3.4M7 to 3.4
Frank Benoit <benoit@tionex.de>
parents: 213
diff changeset
116 * @see <a href="http://www.eclipse.org/swt/snippets/#scrolledcomposite">ScrolledComposite snippets</a>
fd9c62a2998e Updater SWT 3.4M7 to 3.4
Frank Benoit <benoit@tionex.de>
parents: 213
diff changeset
117 * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
155
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
118 */
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
119 public class ScrolledComposite : Composite {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
120
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
121 Control content;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
122 Listener contentListener;
213
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
123 Listener filter;
155
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
124
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
125 int minHeight = 0;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
126 int minWidth = 0;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
127 bool expandHorizontal = false;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
128 bool expandVertical = false;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
129 bool alwaysShowScroll = false;
213
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
130 bool showFocusedControl = false;
155
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
131
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
132 /**
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
133 * Constructs a new instance of this class given its parent
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
134 * and a style value describing its behavior and appearance.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
135 * <p>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
136 * The style value is either one of the style constants defined in
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
137 * class <code>DWT</code> which is applicable to instances of this
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
138 * class, or must be built by <em>bitwise OR</em>'ing together
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
139 * (that is, using the <code>int</code> "|" operator) two or more
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
140 * of those <code>DWT</code> style constants. The class description
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
141 * lists the style constants that are applicable to the class.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
142 * Style bits are also inherited from superclasses.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
143 * </p>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
144 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
145 * @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
146 * @param style the style of widget to construct
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
147 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
148 * @exception IllegalArgumentException <ul>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
149 * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
150 * </ul>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
151 * @exception DWTException <ul>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
152 * <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
153 * </ul>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
154 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
155 * @see DWT#H_SCROLL
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
156 * @see DWT#V_SCROLL
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
157 * @see #getStyle()
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
158 */
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
159 public this(Composite parent, int style) {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
160 super(parent, checkStyle(style));
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
161 super.setLayout(new ScrolledCompositeLayout());
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
162 ScrollBar hBar = getHorizontalBar ();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
163 if (hBar !is null) {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
164 hBar.setVisible(false);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
165 hBar.addListener (DWT.Selection, new class() Listener {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
166 public void handleEvent (Event e) {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
167 hScroll();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
168 }
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 ScrollBar vBar = getVerticalBar ();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
173 if (vBar !is null) {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
174 vBar.setVisible(false);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
175 vBar.addListener (DWT.Selection, new class() Listener {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
176 public void handleEvent (Event e) {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
177 vScroll();
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
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
182 contentListener = new class() Listener {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
183 public void handleEvent(Event e) {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
184 if (e.type !is DWT.Resize) return;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
185 layout(false);
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 };
213
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
188
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
189 filter = new class() Listener {
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
190 public void handleEvent(Event event) {
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
191 if ( auto control = cast(Control)event.widget ) {
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
192 if (contains(control)) showControl(control);
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
193 }
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
194 }
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
195 };
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
196
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
197 addDisposeListener(new class() DisposeListener {
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
198 public void widgetDisposed(DisposeEvent e) {
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
199 getDisplay().removeFilter(DWT.FocusIn, filter);
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
200 }
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
201 });
155
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
202 }
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 static int checkStyle (int style) {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
205 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
206 return style & mask;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
207 }
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
208
213
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
209 bool contains(Control control) {
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
210 if (control is null || control.isDisposed()) return false;
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
211
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
212 Composite parent = control.getParent();
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
213 while (parent !is null && !( null !is cast(Shell)parent )) {
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
214 if (this is parent) return true;
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
215 parent = parent.getParent();
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
216 }
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
217 return false;
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
218 }
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
219
155
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
220 /**
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
221 * Returns the Always Show Scrollbars flag. True if the scrollbars are
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
222 * 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
223 * 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
224 * 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
225 * horizontal and vertical directions.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
226 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
227 * @return the Always Show Scrollbars flag value
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 public bool getAlwaysShowScrollBars() {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
230 //checkWidget();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
231 return alwaysShowScroll;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
232 }
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
233
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 * Returns <code>true</code> if the content control
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
236 * will be expanded to fill available horizontal space.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
237 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
238 * @return the receiver's horizontal expansion state
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
239 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
240 * @exception DWTException <ul>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
241 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
242 * <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
243 * </ul>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
244 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
245 * @since 3.2
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
246 */
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
247 public bool getExpandHorizontal() {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
248 checkWidget();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
249 return expandHorizontal;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
250 }
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 * Returns <code>true</code> if the content control
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
254 * will be expanded to fill available vertical space.
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 receiver's vertical expansion state
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 bool getExpandVertical() {
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 expandVertical;
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 * Returns the minimum width of the content control.
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 minimum width
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 * @exception DWTException <ul>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
276 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
277 * <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
278 * </ul>
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 * @since 3.2
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
281 */
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
282 public int getMinWidth() {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
283 checkWidget();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
284 return minWidth;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
285 }
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 /**
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
288 * Returns the minimum height of the content control.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
289 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
290 * @return the minimum height
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
291 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
292 * @exception DWTException <ul>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
293 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
294 * <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
295 * </ul>
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 * @since 3.2
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
298 */
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
299 public int getMinHeight() {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
300 checkWidget();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
301 return minHeight;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
302 }
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
303
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
304 /**
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
305 * Get the content that is being scrolled.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
306 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
307 * @return the control displayed in the content area
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
308 */
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
309 public Control getContent() {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
310 //checkWidget();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
311 return content;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
312 }
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
313
213
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
314 /**
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
315 * Returns <code>true</code> if the receiver automatically scrolls to a focused child control
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
316 * to make it visible. Otherwise, returns <code>false</code>.
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
317 *
246
fd9c62a2998e Updater SWT 3.4M7 to 3.4
Frank Benoit <benoit@tionex.de>
parents: 213
diff changeset
318 * @return a bool indicating whether focused child controls are automatically scrolled into the viewport
fd9c62a2998e Updater SWT 3.4M7 to 3.4
Frank Benoit <benoit@tionex.de>
parents: 213
diff changeset
319 *
213
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
320 * @exception DWTException <ul>
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
321 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
322 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
323 * </ul>
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
324 *
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
325 * @since 3.4
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
326 */
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
327 public bool getShowFocusedControl() {
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
328 checkWidget();
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
329 return showFocusedControl;
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
330 }
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
331
155
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
332 void hScroll() {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
333 if (content is null) return;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
334 Point location = content.getLocation ();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
335 ScrollBar hBar = getHorizontalBar ();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
336 int hSelection = hBar.getSelection ();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
337 content.setLocation (-hSelection, location.y);
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 bool needHScroll(Rectangle contentRect, bool vVisible) {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
340 ScrollBar hBar = getHorizontalBar();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
341 if (hBar is null) return false;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
342
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
343 Rectangle hostRect = getBounds();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
344 int border = getBorderWidth();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
345 hostRect.width -= 2*border;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
346 ScrollBar vBar = getVerticalBar();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
347 if (vVisible && vBar !is null) hostRect.width -= vBar.getSize().x;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
348
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
349 if (!expandHorizontal && contentRect.width > hostRect.width) return true;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
350 if (expandHorizontal && minWidth > hostRect.width) return true;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
351 return false;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
352 }
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 bool needVScroll(Rectangle contentRect, bool hVisible) {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
355 ScrollBar vBar = getVerticalBar();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
356 if (vBar is null) return false;
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 Rectangle hostRect = getBounds();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
359 int border = getBorderWidth();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
360 hostRect.height -= 2*border;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
361 ScrollBar hBar = getHorizontalBar();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
362 if (hVisible && hBar !is null) hostRect.height -= hBar.getSize().y;
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 if (!expandVertical && contentRect.height > hostRect.height) return true;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
365 if (expandVertical && minHeight > hostRect.height) return true;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
366 return false;
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
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
369 /**
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
370 * 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
371 * corner of the scrolled composite.
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 * @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
374 * 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
375 * (0, 0).
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
376 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
377 * @exception DWTException <ul>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
378 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
379 * <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
380 * </ul>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
381 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
382 * @since 2.0
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
383 */
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
384 public Point getOrigin() {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
385 checkWidget();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
386 if (content is null) return new Point(0, 0);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
387 Point location = content.getLocation();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
388 return new Point(-location.x, -location.y);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
389 }
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
390 /**
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
391 * 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
392 * left corner. If no content has been set, nothing will occur.
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 * Negative values will be ignored. Values greater than the maximum scroll
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
395 * distance will result in scrolling to the end of the scrollbar.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
396 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
397 * @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
398 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
399 * @exception DWTException <ul>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
400 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
401 * <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
402 * <li>ERROR_INVALID_ARGUMENT - value of origin is outside of content
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
403 * </ul>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
404 * @since 2.0
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
405 */
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
406 public void setOrigin(Point origin) {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
407 setOrigin(origin.x, origin.y);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
408 }
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
409 /**
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
410 * 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
411 * left corner. If no content has been set, nothing will occur.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
412 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
413 * Negative values will be ignored. Values greater than the maximum scroll
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
414 * distance will result in scrolling to the end of the scrollbar.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
415 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
416 * @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
417 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
418 * @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
419 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
420 * @exception DWTException <ul>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
421 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
422 * <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
423 * </ul>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
424 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
425 * @since 2.0
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
426 */
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
427 public void setOrigin(int x, int y) {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
428 checkWidget();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
429 if (content is null) return;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
430 ScrollBar hBar = getHorizontalBar ();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
431 if (hBar !is null) {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
432 hBar.setSelection(x);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
433 x = -hBar.getSelection ();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
434 } else {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
435 x = 0;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
436 }
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 if (vBar !is null) {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
439 vBar.setSelection(y);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
440 y = -vBar.getSelection ();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
441 } else {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
442 y = 0;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
443 }
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
444 content.setLocation(x, y);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
445 }
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
446 /**
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
447 * Set the Always Show Scrollbars flag. True if the scrollbars are
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
448 * 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
449 * 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
450 * 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
451 * horizontal and vertical directions.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
452 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
453 * @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
454 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
455 * @exception DWTException <ul>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
456 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
457 * <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
458 * </ul>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
459 */
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
460 public void setAlwaysShowScrollBars(bool show) {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
461 checkWidget();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
462 if (show is alwaysShowScroll) return;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
463 alwaysShowScroll = show;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
464 ScrollBar hBar = getHorizontalBar ();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
465 if (hBar !is null && alwaysShowScroll) hBar.setVisible(true);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
466 ScrollBar vBar = getVerticalBar ();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
467 if (vBar !is null && alwaysShowScroll) vBar.setVisible(true);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
468 layout(false);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
469 }
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
470
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
471 /**
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
472 * Set the content that will be scrolled.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
473 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
474 * @param content the control to be displayed in the content area
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
475 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
476 * @exception DWTException <ul>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
477 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
478 * <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
479 * </ul>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
480 */
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
481 public void setContent(Control content) {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
482 checkWidget();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
483 if (this.content !is null && !this.content.isDisposed()) {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
484 this.content.removeListener(DWT.Resize, contentListener);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
485 this.content.setBounds(new Rectangle(-200, -200, 0, 0));
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
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
488 this.content = content;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
489 ScrollBar vBar = getVerticalBar ();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
490 ScrollBar hBar = getHorizontalBar ();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
491 if (this.content !is null) {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
492 if (vBar !is null) {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
493 vBar.setMaximum (0);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
494 vBar.setThumb (0);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
495 vBar.setSelection(0);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
496 }
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
497 if (hBar !is null) {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
498 hBar.setMaximum (0);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
499 hBar.setThumb (0);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
500 hBar.setSelection(0);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
501 }
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
502 content.setLocation(0, 0);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
503 layout(false);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
504 this.content.addListener(DWT.Resize, contentListener);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
505 } else {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
506 if (hBar !is null) hBar.setVisible(alwaysShowScroll);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
507 if (vBar !is null) vBar.setVisible(alwaysShowScroll);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
508 }
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 /**
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
511 * 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
512 * ScrolledComposite when the width of the ScrolledComposite is greater than the
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
513 * minimum width specified in setMinWidth. If the ScrolledComposite is less than the
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
514 * 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
515 * used to view the entire width.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
516 * 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
517 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
518 * @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
519 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
520 * @exception DWTException <ul>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
521 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
522 * <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
523 * </ul>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
524 */
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
525 public void setExpandHorizontal(bool expand) {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
526 checkWidget();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
527 if (expand is expandHorizontal) return;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
528 expandHorizontal = expand;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
529 layout(false);
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 /**
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
532 * 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
533 * ScrolledComposite when the height of the ScrolledComposite is greater than the
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
534 * minimum height specified in setMinHeight. If the ScrolledComposite is less than the
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
535 * 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
536 * used to view the entire height.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
537 * 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
538 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
539 * @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
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 setExpandVertical(bool expand) {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
547 checkWidget();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
548 if (expand is expandVertical) return;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
549 expandVertical = expand;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
550 layout(false);
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 * Sets the layout which is associated with the receiver to be
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
554 * the argument which may be null.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
555 * <p>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
556 * Note: No Layout can be set on this Control because it already
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
557 * manages the size and position of its children.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
558 * </p>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
559 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
560 * @param layout the receiver's new layout or null
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
561 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
562 * @exception DWTException <ul>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
563 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
564 * <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
565 * </ul>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
566 */
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
567 public override void setLayout (Layout layout) {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
568 checkWidget();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
569 return;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
570 }
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
571 /**
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
572 * Specify the minimum height at which the ScrolledComposite will begin scrolling the
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
573 * content with the vertical scroll bar. This value is only relevant if
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
574 * setExpandVertical(true) has been set.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
575 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
576 * @param height the minimum height or 0 for default height
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 * @exception DWTException <ul>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
579 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
580 * <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
581 * </ul>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
582 */
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
583 public void setMinHeight(int height) {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
584 setMinSize(minWidth, height);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
585 }
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
586 /**
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
587 * 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
588 * content with the horizontal scroll bar. This value is only relevant if
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
589 * setExpandHorizontal(true) and setExpandVertical(true) have been set.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
590 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
591 * @param size the minimum size or null for the default size
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
592 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
593 * @exception DWTException <ul>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
594 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
595 * <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
596 * </ul>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
597 */
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
598 public void setMinSize(Point size) {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
599 if (size is null) {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
600 setMinSize(0, 0);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
601 } else {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
602 setMinSize(size.x, size.y);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
603 }
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
604 }
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
605 /**
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
606 * 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
607 * content with the horizontal scroll bar. This value is only relevant if
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
608 * setExpandHorizontal(true) and setExpandVertical(true) have been set.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
609 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
610 * @param width the minimum width or 0 for default width
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
611 * @param height the minimum height or 0 for default height
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
612 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
613 * @exception DWTException <ul>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
614 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
615 * <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
616 * </ul>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
617 */
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
618 public void setMinSize(int width, int height) {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
619 checkWidget();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
620 if (width is minWidth && height is minHeight) return;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
621 minWidth = Math.max(0, width);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
622 minHeight = Math.max(0, height);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
623 layout(false);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
624 }
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
625 /**
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
626 * Specify the minimum width at which the ScrolledComposite will begin scrolling the
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
627 * content with the horizontal scroll bar. This value is only relevant if
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
628 * setExpandHorizontal(true) has been set.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
629 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
630 * @param width the minimum width or 0 for default width
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
631 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
632 * @exception DWTException <ul>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
633 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
634 * <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
635 * </ul>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
636 */
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
637 public void setMinWidth(int width) {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
638 setMinSize(width, minHeight);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
639 }
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
640
213
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
641 /**
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
642 * Configure the receiver to automatically scroll to a focused child control
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
643 * to make it visible.
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
644 *
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
645 * If show is <code>false</code>, show a focused control is off.
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
646 * By default, show a focused control is off.
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
647 *
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
648 * @param show <code>true</code> to show a focused control.
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
649 *
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
650 * @exception DWTException <ul>
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
651 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
652 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
653 * </ul>
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
654 *
246
fd9c62a2998e Updater SWT 3.4M7 to 3.4
Frank Benoit <benoit@tionex.de>
parents: 213
diff changeset
655 * @since 3.4
213
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
656 */
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
657 public void setShowFocusedControl(bool show) {
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
658 checkWidget();
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
659 if (showFocusedControl is show) return;
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
660 Display display = getDisplay();
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
661 display.removeFilter(DWT.FocusIn, filter);
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
662 showFocusedControl = show;
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
663 if (!showFocusedControl) return;
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
664 display.addFilter(DWT.FocusIn, filter);
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
665 Control control = display.getFocusControl();
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
666 if (contains(control)) showControl(control);
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
667 }
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
668
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
669 /**
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
670 * Scrolls the content of the receiver so that the control is visible.
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
671 *
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
672 * @param control the control to be shown
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
673 *
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
674 * @exception IllegalArgumentException <ul>
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
675 * <li>ERROR_NULL_ARGUMENT - if the control is null</li>
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
676 * <li>ERROR_INVALID_ARGUMENT - if the control has been disposed</li>
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
677 * </ul>
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
678 * @exception DWTException <ul>
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
679 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
680 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
681 * </ul>
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
682 *
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
683 * @since 3.4
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
684 */
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
685 public void showControl(Control control) {
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
686 checkWidget ();
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
687 if (control is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
688 if (control.isDisposed ()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
689 if (!contains(control)) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
690
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
691 Rectangle itemRect = getDisplay().map(control.getParent(), this, control.getBounds());
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
692 Rectangle area = getClientArea();
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
693 Point origin = getOrigin();
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
694 if (itemRect.x < 0) origin.x = Math.max(0, origin.x + itemRect.x);
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
695 if (itemRect.y < 0) origin.y = Math.max(0, origin.y + itemRect.y);
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
696 if (area.width < itemRect.x + itemRect.width) origin.x = Math.max(0, origin.x + itemRect.x + itemRect.width - area.width);
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
697 if (area.height < itemRect.y + itemRect.height) origin.y = Math.max(0, origin.y + itemRect.y + itemRect.height - area.height);
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
698 setOrigin(origin);
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
699 }
36f5cb12e1a2 Update to SWT 3.4M7
Frank Benoit <benoit@tionex.de>
parents: 212
diff changeset
700
155
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
701 void vScroll() {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
702 if (content is null) return;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
703 Point location = content.getLocation ();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
704 ScrollBar vBar = getVerticalBar ();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
705 int vSelection = vBar.getSelection ();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
706 content.setLocation (location.x, -vSelection);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
707 }
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
708 }