Mercurial > projects > dwt-samples
annotate examples/controlexample/AlignableTab.d @ 161:eb84f9418bbf
Change module names to this not have examples in the FQN.
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Mon, 01 Sep 2008 22:24:27 +0200 |
parents | 8a1930f94cbb |
children |
rev | line source |
---|---|
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 *******************************************************************************/ | |
161
eb84f9418bbf
Change module names to this not have examples in the FQN.
Frank Benoit <benoit@tionex.de>
parents:
80
diff
changeset
|
13 module controlexample.AlignableTab; |
78 | 14 |
15 | |
16 | |
17 import dwt.DWT; | |
18 import dwt.events.SelectionAdapter; | |
19 import dwt.events.SelectionEvent; | |
20 import dwt.events.SelectionListener; | |
21 import dwt.layout.GridData; | |
22 import dwt.layout.GridLayout; | |
23 import dwt.widgets.Button; | |
24 import dwt.widgets.Group; | |
25 import dwt.widgets.Widget; | |
26 | |
161
eb84f9418bbf
Change module names to this not have examples in the FQN.
Frank Benoit <benoit@tionex.de>
parents:
80
diff
changeset
|
27 import controlexample.Tab; |
eb84f9418bbf
Change module names to this not have examples in the FQN.
Frank Benoit <benoit@tionex.de>
parents:
80
diff
changeset
|
28 import controlexample.ControlExample; |
78 | 29 |
30 /** | |
31 * <code>AlignableTab</code> is the abstract | |
32 * superclass of example controls that can be | |
33 * aligned. | |
34 */ | |
35 abstract class AlignableTab : Tab { | |
36 | |
37 /* Alignment Controls */ | |
38 Button leftButton, rightButton, centerButton; | |
39 | |
40 /* Alignment Group */ | |
41 Group alignmentGroup; | |
42 | |
43 /** | |
44 * Creates the Tab within a given instance of ControlExample. | |
45 */ | |
46 this(ControlExample instance) { | |
47 super(instance); | |
48 } | |
49 | |
50 /** | |
51 * Creates the "Other" group. | |
52 */ | |
53 void createOtherGroup () { | |
54 super.createOtherGroup (); | |
55 | |
56 /* Create the group */ | |
57 alignmentGroup = new Group (otherGroup, DWT.NONE); | |
58 alignmentGroup.setLayout (new GridLayout ()); | |
59 alignmentGroup.setLayoutData (new GridData(GridData.HORIZONTAL_ALIGN_FILL | | |
60 GridData.VERTICAL_ALIGN_FILL)); | |
61 alignmentGroup.setText (ControlExample.getResourceString("Alignment")); | |
62 | |
63 /* Create the controls */ | |
64 leftButton = new Button (alignmentGroup, DWT.RADIO); | |
65 leftButton.setText (ControlExample.getResourceString("Left")); | |
66 centerButton = new Button (alignmentGroup, DWT.RADIO); | |
67 centerButton.setText(ControlExample.getResourceString("Center")); | |
68 rightButton = new Button (alignmentGroup, DWT.RADIO); | |
69 rightButton.setText (ControlExample.getResourceString("Right")); | |
70 | |
71 /* Add the listeners */ | |
72 SelectionListener selectionListener = new class() SelectionAdapter { | |
73 public void widgetSelected(SelectionEvent event) { | |
74 if (!(cast(Button) event.widget).getSelection ()) return; | |
75 setExampleWidgetAlignment (); | |
76 } | |
77 }; | |
78 leftButton.addSelectionListener (selectionListener); | |
79 centerButton.addSelectionListener (selectionListener); | |
80 rightButton.addSelectionListener (selectionListener); | |
81 } | |
82 | |
83 /** | |
84 * Sets the alignment of the "Example" widgets. | |
85 */ | |
86 abstract void setExampleWidgetAlignment (); | |
87 | |
88 /** | |
89 * Sets the state of the "Example" widgets. | |
90 */ | |
91 void setExampleWidgetState () { | |
92 super.setExampleWidgetState (); | |
93 Widget [] widgets = getExampleWidgets (); | |
94 if (widgets.length !is 0) { | |
95 leftButton.setSelection ((widgets [0].getStyle () & DWT.LEFT) !is 0); | |
96 centerButton.setSelection ((widgets [0].getStyle () & DWT.CENTER) !is 0); | |
97 rightButton.setSelection ((widgets [0].getStyle () & DWT.RIGHT) !is 0); | |
98 } | |
99 } | |
100 } |