-
Notifications
You must be signed in to change notification settings - Fork 33
/
Snippet223.d
executable file
·164 lines (157 loc) · 5.55 KB
/
Snippet223.d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#!/usr/bin/env dub
/+
dub.sdl:
name "snippet223"
dependency "dwt" path="../../../../../../"
stringImportPaths "../../../../../res"
libs \
"atk-1.0" \
"cairo" \
"dl" \
"fontconfig" \
"gdk-x11-2.0" \
"gdk_pixbuf-2.0" \
"glib-2.0" \
"gmodule-2.0" \
"gnomeui-2" \
"gnomevfs-2" \
"gobject-2.0" \
"gthread-2.0" \
"gtk-x11-2.0" \
"pango-1.0" \
"pangocairo-1.0" \
"X11" \
"Xcomposite" \
"Xcursor" \
"Xdamage" \
"Xext" \
"Xfixes" \
"Xi" \
"Xinerama" \
"Xrandr" \
"Xrender" \
"Xtst" \
platform="linux"
+/
/*******************************************************************************
* Copyright (c) 2000, 2006 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
* D Port:
* Jesse Phillips <Jesse.K.Phillips+D> gmail.com
*******************************************************************************/
module org.eclipse.swt.snippets.Snippet223;
/*
* example snippet: ExpandBar example
*
* For a list of all SWT example snippets see
* http://www.eclipse.org/swt/snippets/
*
* @since 3.2
*/
import org.eclipse.swt.SWT;
import java.io.ByteArrayInputStream;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.ExpandBar;
import org.eclipse.swt.widgets.ExpandItem;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Scale;
import org.eclipse.swt.widgets.Spinner;
import org.eclipse.swt.widgets.Slider;
void main () {
auto display = new Display ();
auto shell = new Shell (display);
shell.setLayout(new FillLayout());
shell.setText("ExpandBar Example");
auto bar = new ExpandBar (shell, SWT.V_SCROLL);
auto image = new Image(display, new ImageData(new ByteArrayInputStream( cast(byte[]) import("eclipse.png"))));
// First item
Composite composite = new Composite (bar, SWT.NONE);
GridLayout layout = new GridLayout ();
layout.marginLeft = layout.marginTop = layout.marginRight = layout.marginBottom = 10;
layout.verticalSpacing = 10;
composite.setLayout(layout);
Button button = new Button (composite, SWT.PUSH);
button.setText("SWT.PUSH");
button = new Button (composite, SWT.RADIO);
button.setText("SWT.RADIO");
button = new Button (composite, SWT.CHECK);
button.setText("SWT.CHECK");
button = new Button (composite, SWT.TOGGLE);
button.setText("SWT.TOGGLE");
ExpandItem item0 = new ExpandItem (bar, SWT.NONE, 0);
item0.setText("What is your favorite button");
item0.setHeight(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT).y);
item0.setControl(composite);
item0.setImage(image);
// Second item
composite = new Composite (bar, SWT.NONE);
layout = new GridLayout (2, false);
layout.marginLeft = layout.marginTop = layout.marginRight = layout.marginBottom = 10;
layout.verticalSpacing = 10;
composite.setLayout(layout);
Label label = new Label (composite, SWT.NONE);
label.setImage(display.getSystemImage(SWT.ICON_ERROR));
label = new Label (composite, SWT.NONE);
label.setText("SWT.ICON_ERROR");
label = new Label (composite, SWT.NONE);
label.setImage(display.getSystemImage(SWT.ICON_INFORMATION));
label = new Label (composite, SWT.NONE);
label.setText("SWT.ICON_INFORMATION");
label = new Label (composite, SWT.NONE);
label.setImage(display.getSystemImage(SWT.ICON_WARNING));
label = new Label (composite, SWT.NONE);
label.setText("SWT.ICON_WARNING");
label = new Label (composite, SWT.NONE);
label.setImage(display.getSystemImage(SWT.ICON_QUESTION));
label = new Label (composite, SWT.NONE);
label.setText("SWT.ICON_QUESTION");
ExpandItem item1 = new ExpandItem (bar, SWT.NONE, 1);
item1.setText("What is your favorite icon");
item1.setHeight(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT).y);
item1.setControl(composite);
item1.setImage(image);
// Third item
composite = new Composite (bar, SWT.NONE);
layout = new GridLayout (2, true);
layout.marginLeft = layout.marginTop = layout.marginRight = layout.marginBottom = 10;
layout.verticalSpacing = 10;
composite.setLayout(layout);
label = new Label (composite, SWT.NONE);
label.setText("Scale");
new Scale (composite, SWT.NONE);
label = new Label (composite, SWT.NONE);
label.setText("Spinner");
new Spinner (composite, SWT.BORDER);
label = new Label (composite, SWT.NONE);
label.setText("Slider");
new Slider (composite, SWT.NONE);
ExpandItem item2 = new ExpandItem (bar, SWT.NONE, 2);
item2.setText("What is your favorite range widget");
item2.setHeight(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT).y);
item2.setControl(composite);
item2.setImage(image);
item1.setExpanded(true);
bar.setSpacing(8);
shell.setSize(400, 350);
shell.open();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) {
display.sleep ();
}
}
image.dispose();
display.dispose();
}