Mercurial > projects > dwt-samples
annotate examples/controlexample/ProgressBarTab.d @ 161:eb84f9418bbf
Change module names to this not have examples in the FQN.
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Mon, 01 Sep 2008 22:24:27 +0200 |
parents | 4a04b6759f98 |
children |
rev | line source |
---|---|
78 | 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 *******************************************************************************/ | |
161
eb84f9418bbf
Change module names to this not have examples in the FQN.
Frank Benoit <benoit@tionex.de>
parents:
78
diff
changeset
|
13 module controlexample.ProgressBarTab; |
78 | 14 |
15 | |
16 | |
17 import dwt.DWT; | |
18 import dwt.layout.GridData; | |
19 import dwt.layout.GridLayout; | |
20 import dwt.widgets.Button; | |
21 import dwt.widgets.Group; | |
22 import dwt.widgets.ProgressBar; | |
23 import dwt.widgets.Widget; | |
24 | |
161
eb84f9418bbf
Change module names to this not have examples in the FQN.
Frank Benoit <benoit@tionex.de>
parents:
78
diff
changeset
|
25 import controlexample.Tab; |
eb84f9418bbf
Change module names to this not have examples in the FQN.
Frank Benoit <benoit@tionex.de>
parents:
78
diff
changeset
|
26 import controlexample.ControlExample; |
eb84f9418bbf
Change module names to this not have examples in the FQN.
Frank Benoit <benoit@tionex.de>
parents:
78
diff
changeset
|
27 import controlexample.RangeTab; |
78 | 28 |
29 class ProgressBarTab : RangeTab { | |
30 /* Example widgets and groups that contain them */ | |
31 ProgressBar progressBar1; | |
32 Group progressBarGroup; | |
33 | |
34 /* Style widgets added to the "Style" group */ | |
35 Button smoothButton; | |
36 Button indeterminateButton; | |
37 | |
38 /** | |
39 * Creates the Tab within a given instance of ControlExample. | |
40 */ | |
41 this(ControlExample instance) { | |
42 super(instance); | |
43 } | |
44 | |
45 /** | |
46 * Creates the "Example" group. | |
47 */ | |
48 void createExampleGroup() { | |
49 super.createExampleGroup (); | |
50 | |
51 /* Create a group for the progress bar */ | |
52 progressBarGroup = new Group (exampleGroup, DWT.NONE); | |
53 progressBarGroup.setLayout (new GridLayout ()); | |
54 progressBarGroup.setLayoutData (new GridData (DWT.FILL, DWT.FILL, true, true)); | |
55 progressBarGroup.setText ("ProgressBar"); | |
56 } | |
57 | |
58 /** | |
59 * Creates the "Example" widgets. | |
60 */ | |
61 void createExampleWidgets () { | |
62 | |
63 /* Compute the widget style */ | |
64 int style = getDefaultStyle(); | |
65 if (horizontalButton.getSelection ()) style |= DWT.HORIZONTAL; | |
66 if (verticalButton.getSelection ()) style |= DWT.VERTICAL; | |
67 if (smoothButton.getSelection ()) style |= DWT.SMOOTH; | |
68 if (borderButton.getSelection ()) style |= DWT.BORDER; | |
69 if (indeterminateButton.getSelection ()) style |= DWT.INDETERMINATE; | |
70 | |
71 /* Create the example widgets */ | |
72 progressBar1 = new ProgressBar (progressBarGroup, style); | |
73 } | |
74 | |
75 /** | |
76 * Creates the "Style" group. | |
77 */ | |
78 void createStyleGroup () { | |
79 super.createStyleGroup (); | |
80 | |
81 /* Create the extra widgets */ | |
82 smoothButton = new Button (styleGroup, DWT.CHECK); | |
83 smoothButton.setText ("DWT.SMOOTH"); | |
84 indeterminateButton = new Button (styleGroup, DWT.CHECK); | |
85 indeterminateButton.setText ("DWT.INDETERMINATE"); | |
86 } | |
87 | |
88 /** | |
89 * Gets the "Example" widget children. | |
90 */ | |
91 Widget [] getExampleWidgets () { | |
92 return [ cast(Widget) progressBar1]; | |
93 } | |
94 | |
95 /** | |
96 * Returns a list of set/get API method names (without the set/get prefix) | |
97 * that can be used to set/get values in the example control(s). | |
98 */ | |
99 char[][] getMethodNames() { | |
100 return ["Selection", "ToolTipText"]; | |
101 } | |
102 | |
103 /** | |
104 * Gets the short text for the tab folder item. | |
105 */ | |
106 public char[] getShortTabText() { | |
107 return "PB"; | |
108 } | |
109 | |
110 /** | |
111 * Gets the text for the tab folder item. | |
112 */ | |
113 char[] getTabText () { | |
114 return "ProgressBar"; | |
115 } | |
116 | |
117 /** | |
118 * Sets the state of the "Example" widgets. | |
119 */ | |
120 void setExampleWidgetState () { | |
121 super.setExampleWidgetState (); | |
122 if (indeterminateButton.getSelection ()) { | |
123 selectionSpinner.setEnabled (false); | |
124 minimumSpinner.setEnabled (false); | |
125 maximumSpinner.setEnabled (false); | |
126 } else { | |
127 selectionSpinner.setEnabled (true); | |
128 minimumSpinner.setEnabled (true); | |
129 maximumSpinner.setEnabled (true); | |
130 } | |
131 smoothButton.setSelection ((progressBar1.getStyle () & DWT.SMOOTH) !is 0); | |
132 indeterminateButton.setSelection ((progressBar1.getStyle () & DWT.INDETERMINATE) !is 0); | |
133 } | |
134 | |
135 /** | |
136 * Gets the default maximum of the "Example" widgets. | |
137 */ | |
138 int getDefaultMaximum () { | |
139 return progressBar1.getMaximum(); | |
140 } | |
141 | |
142 /** | |
143 * Gets the default minimim of the "Example" widgets. | |
144 */ | |
145 int getDefaultMinimum () { | |
146 return progressBar1.getMinimum(); | |
147 } | |
148 | |
149 /** | |
150 * Gets the default selection of the "Example" widgets. | |
151 */ | |
152 int getDefaultSelection () { | |
153 return progressBar1.getSelection(); | |
154 } | |
155 | |
156 /** | |
157 * Sets the maximum of the "Example" widgets. | |
158 */ | |
159 void setWidgetMaximum () { | |
160 progressBar1.setMaximum (maximumSpinner.getSelection ()); | |
161 updateSpinners (); | |
162 } | |
163 | |
164 /** | |
165 * Sets the minimim of the "Example" widgets. | |
166 */ | |
167 void setWidgetMinimum () { | |
168 progressBar1.setMinimum (minimumSpinner.getSelection ()); | |
169 updateSpinners (); | |
170 } | |
171 | |
172 /** | |
173 * Sets the selection of the "Example" widgets. | |
174 */ | |
175 void setWidgetSelection () { | |
176 progressBar1.setSelection (selectionSpinner.getSelection ()); | |
177 updateSpinners (); | |
178 } | |
179 | |
180 /** | |
181 * Update the Spinner widgets to reflect the actual value set | |
182 * on the "Example" widget. | |
183 */ | |
184 void updateSpinners () { | |
185 minimumSpinner.setSelection (progressBar1.getMinimum ()); | |
186 selectionSpinner.setSelection (progressBar1.getSelection ()); | |
187 maximumSpinner.setSelection (progressBar1.getMaximum ()); | |
188 } | |
189 } |