comparison examples/controlexample/GroupTab.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.GroupTab;
14
15
16
17 import dwt.DWT;
18 import dwt.events.SelectionAdapter;
19 import dwt.events.SelectionEvent;
20 import dwt.layout.GridData;
21 import dwt.layout.GridLayout;
22 import dwt.widgets.Button;
23 import dwt.widgets.Group;
24 import dwt.widgets.Widget;
25
26 import examples.controlexample.Tab;
27 import examples.controlexample.ControlExample;
28
29 class GroupTab : Tab {
30 Button titleButton;
31
32 /* Example widgets and groups that contain them */
33 Group group1;
34 Group groupGroup;
35
36 /* Style widgets added to the "Style" group */
37 Button shadowEtchedInButton, shadowEtchedOutButton, shadowInButton, shadowOutButton, shadowNoneButton;
38
39 /**
40 * Creates the Tab within a given instance of ControlExample.
41 */
42 this(ControlExample instance) {
43 super(instance);
44 }
45
46 /**
47 * Creates the "Other" group.
48 */
49 void createOtherGroup () {
50 super.createOtherGroup ();
51
52 /* Create display controls specific to this example */
53 titleButton = new Button (otherGroup, DWT.CHECK);
54 titleButton.setText (ControlExample.getResourceString("Title_Text"));
55
56 /* Add the listeners */
57 titleButton.addSelectionListener (new class() SelectionAdapter {
58 public void widgetSelected (SelectionEvent event) {
59 setTitleText ();
60 }
61 });
62 }
63
64 /**
65 * Creates the "Example" group.
66 */
67 void createExampleGroup () {
68 super.createExampleGroup ();
69
70 /* Create a group for the Group */
71 groupGroup = new Group (exampleGroup, DWT.NONE);
72 groupGroup.setLayout (new GridLayout ());
73 groupGroup.setLayoutData (new GridData (DWT.FILL, DWT.FILL, true, true));
74 groupGroup.setText ("Group");
75 }
76
77 /**
78 * Creates the "Example" widgets.
79 */
80 void createExampleWidgets () {
81
82 /* Compute the widget style */
83 int style = getDefaultStyle();
84 if (shadowEtchedInButton.getSelection ()) style |= DWT.SHADOW_ETCHED_IN;
85 if (shadowEtchedOutButton.getSelection ()) style |= DWT.SHADOW_ETCHED_OUT;
86 if (shadowInButton.getSelection ()) style |= DWT.SHADOW_IN;
87 if (shadowOutButton.getSelection ()) style |= DWT.SHADOW_OUT;
88 if (shadowNoneButton.getSelection ()) style |= DWT.SHADOW_NONE;
89 if (borderButton.getSelection ()) style |= DWT.BORDER;
90
91 /* Create the example widgets */
92 group1 = new Group (groupGroup, style);
93 }
94
95 /**
96 * Creates the "Style" group.
97 */
98 void createStyleGroup() {
99 super.createStyleGroup ();
100
101 /* Create the extra widgets */
102 shadowEtchedInButton = new Button (styleGroup, DWT.RADIO);
103 shadowEtchedInButton.setText ("DWT.SHADOW_ETCHED_IN");
104 shadowEtchedInButton.setSelection(true);
105 shadowEtchedOutButton = new Button (styleGroup, DWT.RADIO);
106 shadowEtchedOutButton.setText ("DWT.SHADOW_ETCHED_OUT");
107 shadowInButton = new Button (styleGroup, DWT.RADIO);
108 shadowInButton.setText ("DWT.SHADOW_IN");
109 shadowOutButton = new Button (styleGroup, DWT.RADIO);
110 shadowOutButton.setText ("DWT.SHADOW_OUT");
111 shadowNoneButton = new Button (styleGroup, DWT.RADIO);
112 shadowNoneButton.setText ("DWT.SHADOW_NONE");
113 borderButton = new Button (styleGroup, DWT.CHECK);
114 borderButton.setText ("DWT.BORDER");
115 }
116
117 /**
118 * Gets the "Example" widget children.
119 */
120 Widget [] getExampleWidgets () {
121 return [ cast(Widget) group1];
122 }
123
124 /**
125 * Returns a list of set/get API method names (without the set/get prefix)
126 * that can be used to set/get values in the example control(s).
127 */
128 char[][] getMethodNames() {
129 return ["ToolTipText"];
130 }
131
132 /**
133 * Gets the text for the tab folder item.
134 */
135 char[] getTabText () {
136 return "Group";
137 }
138
139 /**
140 * Sets the title text of the "Example" widgets.
141 */
142 void setTitleText () {
143 if (titleButton.getSelection ()) {
144 group1.setText (ControlExample.getResourceString("Title_Text"));
145 } else {
146 group1.setText ("");
147 }
148 setExampleWidgetSize ();
149 }
150
151 /**
152 * Sets the state of the "Example" widgets.
153 */
154 void setExampleWidgetState () {
155 super.setExampleWidgetState ();
156 shadowEtchedInButton.setSelection ((group1.getStyle () & DWT.SHADOW_ETCHED_IN) !is 0);
157 shadowEtchedOutButton.setSelection ((group1.getStyle () & DWT.SHADOW_ETCHED_OUT) !is 0);
158 shadowInButton.setSelection ((group1.getStyle () & DWT.SHADOW_IN) !is 0);
159 shadowOutButton.setSelection ((group1.getStyle () & DWT.SHADOW_OUT) !is 0);
160 shadowNoneButton.setSelection ((group1.getStyle () & DWT.SHADOW_NONE) !is 0);
161 borderButton.setSelection ((group1.getStyle () & DWT.BORDER) !is 0);
162 if (!instance.startup) setTitleText ();
163 }
164 }