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 *******************************************************************************/
|
|
13 module examples.controlexample.ExpandBarTab;
|
|
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.Composite;
|
|
22 import dwt.widgets.ExpandBar;
|
|
23 import dwt.widgets.ExpandItem;
|
|
24 import dwt.widgets.Group;
|
|
25 import dwt.widgets.Label;
|
|
26 import dwt.widgets.Widget;
|
|
27
|
|
28 import examples.controlexample.Tab;
|
|
29 import examples.controlexample.ControlExample;
|
|
30
|
|
31 class ExpandBarTab : Tab {
|
|
32 /* Example widgets and groups that contain them */
|
|
33 ExpandBar expandBar1;
|
|
34 Group expandBarGroup;
|
|
35
|
|
36 /* Style widgets added to the "Style" group */
|
|
37 Button verticalButton;
|
|
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 "Example" group.
|
|
48 */
|
|
49 void createExampleGroup () {
|
|
50 super.createExampleGroup ();
|
|
51
|
|
52 /* Create a group for the list */
|
|
53 expandBarGroup = new Group (exampleGroup, DWT.NONE);
|
|
54 expandBarGroup.setLayout (new GridLayout ());
|
|
55 expandBarGroup.setLayoutData (new GridData (DWT.FILL, DWT.FILL, true, true));
|
|
56 expandBarGroup.setText ("ExpandBar");
|
|
57 }
|
|
58
|
|
59 /**
|
|
60 * Creates the "Example" widgets.
|
|
61 */
|
|
62 void createExampleWidgets () {
|
|
63
|
|
64 /* Compute the widget style */
|
|
65 int style = getDefaultStyle();
|
|
66 if (borderButton.getSelection ()) style |= DWT.BORDER;
|
|
67 if (verticalButton.getSelection()) style |= DWT.V_SCROLL;
|
|
68
|
|
69 /* Create the example widgets */
|
|
70 expandBar1 = new ExpandBar (expandBarGroup, style);
|
|
71
|
|
72 // First item
|
|
73 Composite composite = new Composite (expandBar1, DWT.NONE);
|
|
74 composite.setLayout(new GridLayout ());
|
|
75 (new Button (composite, DWT.PUSH)).setText("DWT.PUSH");
|
|
76 (new Button (composite, DWT.RADIO)).setText("DWT.RADIO");
|
|
77 (new Button (composite, DWT.CHECK)).setText("DWT.CHECK");
|
|
78 (new Button (composite, DWT.TOGGLE)).setText("DWT.TOGGLE");
|
|
79 ExpandItem item = new ExpandItem (expandBar1, DWT.NONE, 0);
|
|
80 item.setText(ControlExample.getResourceString("Item1_Text"));
|
|
81 item.setHeight(composite.computeSize(DWT.DEFAULT, DWT.DEFAULT).y);
|
|
82 item.setControl(composite);
|
|
83 item.setImage(instance.images[ControlExample.ciClosedFolder]);
|
|
84
|
|
85 // Second item
|
|
86 composite = new Composite (expandBar1, DWT.NONE);
|
|
87 composite.setLayout(new GridLayout (2, false));
|
|
88 (new Label (composite, DWT.NONE)).setImage(display.getSystemImage(DWT.ICON_ERROR));
|
|
89 (new Label (composite, DWT.NONE)).setText("DWT.ICON_ERROR");
|
|
90 (new Label (composite, DWT.NONE)).setImage(display.getSystemImage(DWT.ICON_INFORMATION));
|
|
91 (new Label (composite, DWT.NONE)).setText("DWT.ICON_INFORMATION");
|
|
92 (new Label (composite, DWT.NONE)).setImage(display.getSystemImage(DWT.ICON_WARNING));
|
|
93 (new Label (composite, DWT.NONE)).setText("DWT.ICON_WARNING");
|
|
94 (new Label (composite, DWT.NONE)).setImage(display.getSystemImage(DWT.ICON_QUESTION));
|
|
95 (new Label (composite, DWT.NONE)).setText("DWT.ICON_QUESTION");
|
|
96 item = new ExpandItem (expandBar1, DWT.NONE, 1);
|
|
97 item.setText(ControlExample.getResourceString("Item2_Text"));
|
|
98 item.setHeight(composite.computeSize(DWT.DEFAULT, DWT.DEFAULT).y);
|
|
99 item.setControl(composite);
|
|
100 item.setImage(instance.images[ControlExample.ciOpenFolder]);
|
|
101 item.setExpanded(true);
|
|
102 }
|
|
103
|
|
104 /**
|
|
105 * Creates the "Style" group.
|
|
106 */
|
|
107 void createStyleGroup() {
|
|
108 super.createStyleGroup ();
|
|
109
|
|
110 /* Create the extra widgets */
|
|
111 verticalButton = new Button (styleGroup, DWT.CHECK);
|
|
112 verticalButton.setText ("DWT.V_SCROLL");
|
|
113 verticalButton.setSelection(true);
|
|
114 borderButton = new Button(styleGroup, DWT.CHECK);
|
|
115 borderButton.setText("DWT.BORDER");
|
|
116 }
|
|
117
|
|
118 /**
|
|
119 * Gets the "Example" widget children.
|
|
120 */
|
|
121 Widget [] getExampleWidgets () {
|
|
122 return [ cast(Widget) expandBar1];
|
|
123 }
|
|
124
|
|
125 /**
|
|
126 * Returns a list of set/get API method names (without the set/get prefix)
|
|
127 * that can be used to set/get values in the example control(s).
|
|
128 */
|
|
129 char[][] getMethodNames() {
|
|
130 return ["Spacing"];
|
|
131 }
|
|
132
|
|
133 /**
|
|
134 * Gets the short text for the tab folder item.
|
|
135 */
|
|
136 public char[] getShortTabText() {
|
|
137 return "EB";
|
|
138 }
|
|
139
|
|
140 /**
|
|
141 * Gets the text for the tab folder item.
|
|
142 */
|
|
143 char[] getTabText () {
|
|
144 return "ExpandBar";
|
|
145 }
|
|
146
|
|
147 /**
|
|
148 * Sets the state of the "Example" widgets.
|
|
149 */
|
|
150 void setExampleWidgetState () {
|
|
151 super.setExampleWidgetState ();
|
|
152 Widget [] widgets = getExampleWidgets ();
|
|
153 if (widgets.length !is 0){
|
|
154 verticalButton.setSelection ((widgets [0].getStyle () & DWT.V_SCROLL) !is 0);
|
|
155 borderButton.setSelection ((widgets [0].getStyle () & DWT.BORDER) !is 0);
|
|
156 }
|
|
157 }
|
|
158 }
|