Mercurial > projects > dwt-samples
comparison examples/controlexample/SashFormTab.d @ 78:4a04b6759f98
Clean up directory names
author | John Reimer <terminal.node@gmail.com> |
---|---|
date | Sat, 10 May 2008 13:32:45 -0700 |
parents | |
children | eb84f9418bbf |
comparison
equal
deleted
inserted
replaced
76:04f122e90b0a | 78:4a04b6759f98 |
---|---|
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 examples.controlexample.SashFormTab; | |
14 | |
15 | |
16 | |
17 import dwt.DWT; | |
18 import dwt.custom.SashForm; | |
19 import dwt.layout.GridData; | |
20 import dwt.layout.GridLayout; | |
21 import dwt.widgets.Button; | |
22 import dwt.widgets.Group; | |
23 import dwt.widgets.List; | |
24 import dwt.widgets.Text; | |
25 import dwt.widgets.Widget; | |
26 | |
27 import examples.controlexample.Tab; | |
28 import examples.controlexample.ControlExample; | |
29 | |
30 | |
31 class SashFormTab : Tab { | |
32 /* Example widgets and groups that contain them */ | |
33 Group sashFormGroup; | |
34 SashForm form; | |
35 List list1, list2; | |
36 Text text; | |
37 | |
38 /* Style widgets added to the "Style" group */ | |
39 Button horizontalButton, verticalButton, smoothButton; | |
40 | |
41 static char[] [] ListData0; | |
42 static char[] [] ListData1; | |
43 | |
44 | |
45 /** | |
46 * Creates the Tab within a given instance of ControlExample. | |
47 */ | |
48 this(ControlExample instance) { | |
49 super(instance); | |
50 if( ListData0 is null ){ | |
51 ListData0 = [ | |
52 ControlExample.getResourceString("ListData0_0"), //$NON-NLS-1$ | |
53 ControlExample.getResourceString("ListData0_1"), //$NON-NLS-1$ | |
54 ControlExample.getResourceString("ListData0_2"), //$NON-NLS-1$ | |
55 ControlExample.getResourceString("ListData0_3"), //$NON-NLS-1$ | |
56 ControlExample.getResourceString("ListData0_4"), //$NON-NLS-1$ | |
57 ControlExample.getResourceString("ListData0_5"), //$NON-NLS-1$ | |
58 ControlExample.getResourceString("ListData0_6"), //$NON-NLS-1$ | |
59 ControlExample.getResourceString("ListData0_7")]; //$NON-NLS-1$ | |
60 | |
61 } | |
62 if( ListData1 is null ){ | |
63 ListData1 = [ | |
64 ControlExample.getResourceString("ListData1_0"), //$NON-NLS-1$ | |
65 ControlExample.getResourceString("ListData1_1"), //$NON-NLS-1$ | |
66 ControlExample.getResourceString("ListData1_2"), //$NON-NLS-1$ | |
67 ControlExample.getResourceString("ListData1_3"), //$NON-NLS-1$ | |
68 ControlExample.getResourceString("ListData1_4"), //$NON-NLS-1$ | |
69 ControlExample.getResourceString("ListData1_5"), //$NON-NLS-1$ | |
70 ControlExample.getResourceString("ListData1_6"), //$NON-NLS-1$ | |
71 ControlExample.getResourceString("ListData1_7")]; //$NON-NLS-1$ | |
72 } | |
73 } | |
74 void createExampleGroup () { | |
75 super.createExampleGroup (); | |
76 | |
77 /* Create a group for the sashform widget */ | |
78 sashFormGroup = new Group (exampleGroup, DWT.NONE); | |
79 sashFormGroup.setLayout (new GridLayout ()); | |
80 sashFormGroup.setLayoutData (new GridData (DWT.FILL, DWT.FILL, true, true)); | |
81 sashFormGroup.setText ("SashForm"); | |
82 } | |
83 void createExampleWidgets () { | |
84 | |
85 /* Compute the widget style */ | |
86 int style = getDefaultStyle(); | |
87 if (horizontalButton.getSelection ()) style |= DWT.H_SCROLL; | |
88 if (verticalButton.getSelection ()) style |= DWT.V_SCROLL; | |
89 if (smoothButton.getSelection ()) style |= DWT.SMOOTH; | |
90 | |
91 /* Create the example widgets */ | |
92 form = new SashForm (sashFormGroup, style); | |
93 list1 = new List (form, DWT.V_SCROLL | DWT.H_SCROLL | DWT.BORDER); | |
94 list1.setItems (ListData0); | |
95 list2 = new List (form, DWT.V_SCROLL | DWT.H_SCROLL | DWT.BORDER); | |
96 list2.setItems (ListData1); | |
97 text = new Text (form, DWT.MULTI | DWT.BORDER); | |
98 text.setText (ControlExample.getResourceString("Multi_line")); //$NON-NLS-1$ | |
99 form.setWeights([1, 1, 1]); | |
100 } | |
101 /** | |
102 * Creates the "Style" group. | |
103 */ | |
104 void createStyleGroup() { | |
105 super.createStyleGroup(); | |
106 | |
107 /* Create the extra widgets */ | |
108 horizontalButton = new Button (styleGroup, DWT.RADIO); | |
109 horizontalButton.setText ("DWT.HORIZONTAL"); | |
110 horizontalButton.setSelection(true); | |
111 verticalButton = new Button (styleGroup, DWT.RADIO); | |
112 verticalButton.setText ("DWT.VERTICAL"); | |
113 verticalButton.setSelection(false); | |
114 smoothButton = new Button (styleGroup, DWT.CHECK); | |
115 smoothButton.setText ("DWT.SMOOTH"); | |
116 smoothButton.setSelection(false); | |
117 } | |
118 | |
119 /** | |
120 * Gets the "Example" widget children. | |
121 */ | |
122 Widget [] getExampleWidgets () { | |
123 return [ cast(Widget) form]; | |
124 } | |
125 | |
126 /** | |
127 * Gets the text for the tab folder item. | |
128 */ | |
129 char[] getTabText () { | |
130 return "SashForm"; //$NON-NLS-1$ | |
131 } | |
132 | |
133 /** | |
134 * Sets the state of the "Example" widgets. | |
135 */ | |
136 void setExampleWidgetState () { | |
137 super.setExampleWidgetState (); | |
138 horizontalButton.setSelection ((form.getStyle () & DWT.H_SCROLL) !is 0); | |
139 verticalButton.setSelection ((form.getStyle () & DWT.V_SCROLL) !is 0); | |
140 smoothButton.setSelection ((form.getStyle () & DWT.SMOOTH) !is 0); | |
141 } | |
142 } |