75
|
1 /*******************************************************************************
|
|
2 * Copyright (c) 2000, 2007 IBM Corporation and others.
|
|
3 * All rights reserved. This program and the accompanying materials
|
|
4 * are made available under the terms of the Eclipse Public License v1.0
|
|
5 * which accompanies this distribution, and is available at
|
|
6 * http://www.eclipse.org/legal/epl-v10.html
|
|
7 *
|
|
8 * Contributors:
|
|
9 * IBM Corporation - initial API and implementation
|
|
10 * Port to the D programming language:
|
|
11 * Frank Benoit <benoit@tionex.de>
|
|
12 *******************************************************************************/
|
|
13 module dwtx.ui.forms.widgets.ScrolledForm;
|
|
14
|
|
15 import dwtx.ui.forms.widgets.SharedScrolledComposite;
|
|
16 import dwtx.ui.forms.widgets.Form;
|
|
17
|
|
18 import dwt.DWT;
|
|
19 import dwt.graphics.Color;
|
|
20 import dwt.graphics.Image;
|
|
21 import dwt.widgets.Composite;
|
|
22 import dwt.widgets.Control;
|
|
23 import dwt.widgets.Menu;
|
|
24 import dwtx.jface.action.IToolBarManager;
|
|
25 import dwtx.ui.forms.IMessage;
|
|
26
|
|
27 import dwt.dwthelper.utils;
|
|
28
|
|
29 /**
|
|
30 * ScrolledForm is a control that is capable of scrolling an instance of the
|
|
31 * Form class. It should be created in a parent that will allow it to use all
|
|
32 * the available area (for example, a shell, a view or an editor).
|
|
33 * <p>
|
|
34 * Children of the form should typically be created using FormToolkit to match
|
|
35 * the appearance and behaviour. When creating children, use a form body as a
|
|
36 * parent by calling 'getBody()' on the form instance. Example:
|
|
37 *
|
|
38 * <pre>
|
|
39 * FormToolkit toolkit = new FormToolkit(parent.getDisplay());
|
|
40 * ScrolledForm form = toolkit.createScrolledForm(parent);
|
|
41 * form.setText("Sample form");
|
|
42 * form.getBody().setLayout(new GridLayout());
|
|
43 * toolkit.createButton(form.getBody(), "Checkbox", DWT.CHECK);
|
|
44 * </pre>
|
|
45 *
|
|
46 * <p>
|
|
47 * No layout manager has been set on the body. Clients are required to set the
|
|
48 * desired layout manager explicitly.
|
|
49 * <p>
|
|
50 * Although the class is not final, it is not expected to be be extended.
|
|
51 *
|
|
52 * @since 3.0
|
90
|
53 * @noextend This class is not intended to be subclassed by clients.
|
75
|
54 */
|
|
55 public class ScrolledForm : SharedScrolledComposite {
|
|
56 private Form content;
|
|
57
|
|
58 public this(Composite parent) {
|
|
59 this(parent, DWT.V_SCROLL | DWT.H_SCROLL);
|
|
60 }
|
|
61
|
|
62 /**
|
|
63 * Creates the form control as a child of the provided parent.
|
|
64 *
|
|
65 * @param parent
|
|
66 * the parent widget
|
|
67 */
|
|
68 public this(Composite parent, int style) {
|
|
69 super(parent, style);
|
|
70 super.setMenu(parent.getMenu());
|
|
71 content = new Form(this, DWT.NULL);
|
|
72 super.setContent(content);
|
|
73 content.setMenu(getMenu());
|
|
74 }
|
|
75
|
|
76 /**
|
|
77 * Passes the menu to the body.
|
|
78 *
|
|
79 * @param menu
|
|
80 */
|
|
81 public void setMenu(Menu menu) {
|
|
82 super.setMenu(menu);
|
|
83 if (content !is null)
|
|
84 content.setMenu(menu);
|
|
85 }
|
|
86
|
|
87 /**
|
|
88 * Returns the title text that will be rendered at the top of the form.
|
|
89 *
|
|
90 * @return the title text
|
|
91 */
|
|
92 public String getText() {
|
|
93 return content.getText();
|
|
94 }
|
|
95
|
|
96 /**
|
|
97 * Returns the title image that will be rendered to the left of the title.
|
|
98 *
|
|
99 * @return the title image
|
|
100 */
|
|
101 public Image getImage() {
|
|
102 return content.getImage();
|
|
103 }
|
|
104
|
|
105 /**
|
|
106 * Sets the foreground color of the form. This color will also be used for
|
|
107 * the body.
|
|
108 */
|
|
109 public void setForeground(Color fg) {
|
|
110 super.setForeground(fg);
|
|
111 content.setForeground(fg);
|
|
112 }
|
|
113
|
|
114 /**
|
|
115 * Sets the background color of the form. This color will also be used for
|
|
116 * the body.
|
|
117 */
|
|
118 public void setBackground(Color bg) {
|
|
119 super.setBackground(bg);
|
|
120 content.setBackground(bg);
|
|
121 }
|
|
122
|
|
123 /**
|
|
124 * The form sets the content widget. This method should not be called by
|
|
125 * classes that instantiate this widget.
|
|
126 */
|
|
127 public final void setContent(Control c) {
|
|
128 }
|
|
129
|
|
130 /**
|
|
131 * Sets the text to be rendered at the top of the form above the body as a
|
|
132 * title.
|
|
133 * <p>
|
|
134 * <strong>Note:</strong> Mnemonics are indicated by an '&' that causes
|
|
135 * the next character to be the mnemonic. Mnemonics are not applicable in
|
|
136 * the case of the form title but need to be taken into acount due to the
|
|
137 * usage of the underlying widget that renders mnemonics in the title area.
|
|
138 * The mnemonic indicator character '&' can be escaped by doubling it in
|
|
139 * the string, causing a single '&' to be displayed.
|
|
140 * </p>
|
|
141 *
|
|
142 * @param text
|
|
143 * the title text
|
|
144 */
|
|
145 public void setText(String text) {
|
|
146 content.setText(text);
|
|
147 reflow(true);
|
|
148 }
|
|
149
|
|
150 /**
|
|
151 * Sets the image to be rendered to the left of the title.
|
|
152 *
|
|
153 * @param image
|
|
154 * the title image or <code>null</code> for no image.
|
|
155 */
|
|
156 public void setImage(Image image) {
|
|
157 content.setImage(image);
|
|
158 reflow(true);
|
|
159 }
|
|
160
|
|
161 /**
|
|
162 * Returns the optional background image of this form. The image is rendered
|
|
163 * starting at the position 0,0 and is painted behind the title.
|
|
164 *
|
|
165 * @return Returns the background image.
|
|
166 */
|
|
167 public Image getBackgroundImage() {
|
|
168 return content.getBackgroundImage();
|
|
169 }
|
|
170
|
|
171 /**
|
|
172 * Sets the optional background image to be rendered behind the title
|
|
173 * starting at the position 0,0.
|
|
174 *
|
|
175 * @param backgroundImage
|
|
176 * The backgroundImage to set.
|
|
177 */
|
|
178 public void setBackgroundImage(Image backgroundImage) {
|
|
179 content.setBackgroundImage(backgroundImage);
|
|
180 }
|
|
181
|
|
182 /**
|
|
183 * Returns the tool bar manager that is used to manage tool items in the
|
|
184 * form's title area.
|
|
185 *
|
|
186 * @return form tool bar manager
|
|
187 */
|
|
188 public IToolBarManager getToolBarManager() {
|
|
189 return content.getToolBarManager();
|
|
190 }
|
|
191
|
|
192 /**
|
|
193 * Updates the local tool bar manager if used. Does nothing if local tool
|
|
194 * bar manager has not been created yet.
|
|
195 */
|
|
196 public void updateToolBar() {
|
|
197 content.updateToolBar();
|
|
198 }
|
|
199
|
|
200 /**
|
|
201 * Returns the container that occupies the body of the form (the form area
|
|
202 * below the title). Use this container as a parent for the controls that
|
|
203 * should be in the form. No layout manager has been set on the form body.
|
|
204 *
|
|
205 * @return Returns the body of the form.
|
|
206 */
|
|
207 public Composite getBody() {
|
|
208 return content.getBody();
|
|
209 }
|
|
210
|
|
211 /**
|
|
212 * Returns the instance of the form owned by the scrolled form.
|
|
213 *
|
|
214 * @return the form instance
|
|
215 */
|
|
216 public Form getForm() {
|
|
217 return content;
|
|
218 }
|
|
219
|
|
220 /**
|
|
221 * Sets the form's busy state. Busy form will display 'busy' animation in
|
|
222 * the area of the title image.
|
|
223 *
|
|
224 * @param busy
|
|
225 * the form's busy state
|
|
226 * @see Form#setBusy(bool)
|
|
227 * @since 3.3
|
|
228 */
|
|
229
|
|
230 public void setBusy(bool busy) {
|
|
231 content.setBusy(busy);
|
|
232 reflow(true);
|
|
233 }
|
|
234
|
|
235 /**
|
|
236 * Sets the optional head client.
|
|
237 *
|
|
238 * @param headClient
|
|
239 * the optional child of the head
|
|
240 * @see Form#setHeadClient(Control)
|
|
241 * @since 3.3
|
|
242 */
|
|
243 public void setHeadClient(Control headClient) {
|
|
244 content.setHeadClient(headClient);
|
|
245 reflow(true);
|
|
246 }
|
|
247
|
|
248 /**
|
|
249 * Sets the form message.
|
|
250 *
|
|
251 * @param newMessage
|
|
252 * the message text or <code>null</code> to reset.
|
|
253 * @param newType
|
|
254 * as defined in
|
|
255 * {@link dwtx.jface.dialogs.IMessageProvider}.
|
|
256 * @param messages
|
|
257 * an optional array of children that itemize individual
|
|
258 * messages or <code>null</code> for a simple message.
|
|
259 * @since 3.3
|
|
260 * @see Form#setMessage(String, int)
|
|
261 */
|
|
262 public void setMessage(String newMessage, int newType, IMessage[] messages) {
|
|
263 content.setMessage(newMessage, newType, messages);
|
|
264 reflow(true);
|
|
265 }
|
|
266
|
|
267 /*
|
|
268 * (non-Javadoc)
|
|
269 *
|
|
270 * @see dwtx.ui.forms.IMessageContainer#setMessage(java.lang.String,
|
|
271 * int)
|
|
272 */
|
|
273 public void setMessage(String newMessage, int newType) {
|
|
274 this.setMessage(newMessage, newType, null);
|
|
275 }
|
|
276
|
|
277 /*
|
|
278 * (non-Javadoc)
|
|
279 *
|
|
280 * @see dwtx.jface.dialogs.IMessageProvider#getMessage()
|
|
281 */
|
|
282 public String getMessage() {
|
|
283 return content.getMessage();
|
|
284 }
|
|
285
|
|
286 /*
|
|
287 * (non-Javadoc)
|
|
288 *
|
|
289 * @see dwtx.jface.dialogs.IMessageProvider#getMessageType()
|
|
290 */
|
|
291 public int getMessageType() {
|
|
292 return content.getMessageType();
|
|
293 }
|
|
294 }
|