comparison dwtexamples/controlexample/CComboTab.d @ 0:052c3aebd1d3

initial import
author Frank Benoit <benoit@tionex.de>
date Fri, 01 Feb 2008 21:46:26 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:052c3aebd1d3
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 dwtexamples.controlexample.CComboTab;
14
15
16
17 import dwt.DWT;
18 import dwt.custom.CCombo;
19 import dwt.layout.GridData;
20 import dwt.layout.GridLayout;
21 import dwt.widgets.Button;
22 import dwt.widgets.Group;
23 import dwt.widgets.Widget;
24
25 import dwtexamples.controlexample.Tab;
26 import dwtexamples.controlexample.ControlExample;
27
28 class CComboTab : Tab {
29
30 /* Example widgets and groups that contain them */
31 CCombo combo1;
32 Group comboGroup;
33
34 /* Style widgets added to the "Style" group */
35 Button flatButton, readOnlyButton;
36
37 static char[] [] ListData;
38
39 /**
40 * Creates the Tab within a given instance of ControlExample.
41 */
42 this(ControlExample instance) {
43 super(instance);
44 if( ListData is null ){
45 ListData = [
46 ControlExample.getResourceString("ListData1_0"),
47 ControlExample.getResourceString("ListData1_1"),
48 ControlExample.getResourceString("ListData1_2"),
49 ControlExample.getResourceString("ListData1_3"),
50 ControlExample.getResourceString("ListData1_4"),
51 ControlExample.getResourceString("ListData1_5"),
52 ControlExample.getResourceString("ListData1_6"),
53 ControlExample.getResourceString("ListData1_7"),
54 ControlExample.getResourceString("ListData1_8")];
55 }
56 }
57
58 /**
59 * Creates the "Example" group.
60 */
61 void createExampleGroup () {
62 super.createExampleGroup ();
63
64 /* Create a group for the combo box */
65 comboGroup = new Group (exampleGroup, DWT.NONE);
66 comboGroup.setLayout (new GridLayout ());
67 comboGroup.setLayoutData (new GridData (DWT.FILL, DWT.FILL, true, true));
68 comboGroup.setText (ControlExample.getResourceString("Custom_Combo"));
69 }
70
71 /**
72 * Creates the "Example" widgets.
73 */
74 void createExampleWidgets () {
75
76 /* Compute the widget style */
77 int style = getDefaultStyle();
78 if (flatButton.getSelection ()) style |= DWT.FLAT;
79 if (readOnlyButton.getSelection ()) style |= DWT.READ_ONLY;
80 if (borderButton.getSelection ()) style |= DWT.BORDER;
81
82 /* Create the example widgets */
83 combo1 = new CCombo (comboGroup, style);
84 combo1.setItems (ListData);
85 if (ListData.length >= 3) {
86 combo1.setText(ListData [2]);
87 }
88 }
89
90 /**
91 * Creates the "Style" group.
92 */
93 void createStyleGroup () {
94 super.createStyleGroup ();
95
96 /* Create the extra widgets */
97 readOnlyButton = new Button (styleGroup, DWT.CHECK);
98 readOnlyButton.setText ("DWT.READ_ONLY");
99 borderButton = new Button (styleGroup, DWT.CHECK);
100 borderButton.setText ("DWT.BORDER");
101 flatButton = new Button (styleGroup, DWT.CHECK);
102 flatButton.setText ("DWT.FLAT");
103 }
104
105 /**
106 * Gets the "Example" widget children.
107 */
108 Widget [] getExampleWidgets () {
109 return [cast(Widget) combo1];
110 }
111
112 /**
113 * Returns a list of set/get API method names (without the set/get prefix)
114 * that can be used to set/get values in the example control(s).
115 */
116 char[][] getMethodNames() {
117 return ["Editable", "Items", "Selection", "Text", "TextLimit", "ToolTipText", "VisibleItemCount"];
118 }
119
120 /**
121 * Gets the text for the tab folder item.
122 */
123 char[] getTabText () {
124 return "CCombo";
125 }
126
127 /**
128 * Sets the state of the "Example" widgets.
129 */
130 void setExampleWidgetState () {
131 super.setExampleWidgetState ();
132 flatButton.setSelection ((combo1.getStyle () & DWT.FLAT) !is 0);
133 readOnlyButton.setSelection ((combo1.getStyle () & DWT.READ_ONLY) !is 0);
134 borderButton.setSelection ((combo1.getStyle () & DWT.BORDER) !is 0);
135 }
136 }