Mercurial > projects > dwt-samples
annotate examples/controlexample/DateTimeTab.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 | 4a04b6759f98 |
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:
78
diff
changeset
|
13 module controlexample.DateTimeTab; |
78 | 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.DateTime; | |
22 import dwt.widgets.Group; | |
23 import dwt.widgets.Widget; | |
24 | |
161
eb84f9418bbf
Change module names to this not have examples in the FQN.
Frank Benoit <benoit@tionex.de>
parents:
78
diff
changeset
|
25 import controlexample.Tab; |
eb84f9418bbf
Change module names to this not have examples in the FQN.
Frank Benoit <benoit@tionex.de>
parents:
78
diff
changeset
|
26 import controlexample.ControlExample; |
78 | 27 |
28 class DateTimeTab : Tab { | |
29 /* Example widgets and groups that contain them */ | |
30 DateTime dateTime1; | |
31 Group dateTimeGroup; | |
32 | |
33 /* Style widgets added to the "Style" group */ | |
34 Button dateButton, timeButton, calendarButton, shortButton, mediumButton, longButton; | |
35 | |
36 /** | |
37 * Creates the Tab within a given instance of ControlExample. | |
38 */ | |
39 this(ControlExample instance) { | |
40 super(instance); | |
41 } | |
42 | |
43 /** | |
44 * Creates the "Example" group. | |
45 */ | |
46 void createExampleGroup () { | |
47 super.createExampleGroup (); | |
48 | |
49 /* Create a group for the list */ | |
50 dateTimeGroup = new Group (exampleGroup, DWT.NONE); | |
51 dateTimeGroup.setLayout (new GridLayout ()); | |
52 dateTimeGroup.setLayoutData (new GridData (DWT.FILL, DWT.FILL, true, true)); | |
53 dateTimeGroup.setText ("DateTime"); | |
54 } | |
55 | |
56 /** | |
57 * Creates the "Example" widgets. | |
58 */ | |
59 void createExampleWidgets () { | |
60 | |
61 /* Compute the widget style */ | |
62 int style = getDefaultStyle(); | |
63 if (dateButton.getSelection ()) style |= DWT.DATE; | |
64 if (timeButton.getSelection ()) style |= DWT.TIME; | |
65 if (calendarButton.getSelection ()) style |= DWT.CALENDAR; | |
66 if (shortButton.getSelection ()) style |= DWT.SHORT; | |
67 if (mediumButton.getSelection ()) style |= DWT.MEDIUM; | |
68 if (longButton.getSelection ()) style |= DWT.LONG; | |
69 if (borderButton.getSelection ()) style |= DWT.BORDER; | |
70 | |
71 /* Create the example widgets */ | |
72 dateTime1 = new DateTime (dateTimeGroup, style); | |
73 } | |
74 | |
75 /** | |
76 * Creates the "Style" group. | |
77 */ | |
78 void createStyleGroup() { | |
79 super.createStyleGroup (); | |
80 | |
81 /* Create the extra widgets */ | |
82 dateButton = new Button(styleGroup, DWT.RADIO); | |
83 dateButton.setText("DWT.DATE"); | |
84 timeButton = new Button(styleGroup, DWT.RADIO); | |
85 timeButton.setText("DWT.TIME"); | |
86 calendarButton = new Button(styleGroup, DWT.RADIO); | |
87 calendarButton.setText("DWT.CALENDAR"); | |
88 Group formatGroup = new Group(styleGroup, DWT.NONE); | |
89 formatGroup.setLayout(new GridLayout()); | |
90 shortButton = new Button(formatGroup, DWT.RADIO); | |
91 shortButton.setText("DWT.SHORT"); | |
92 mediumButton = new Button(formatGroup, DWT.RADIO); | |
93 mediumButton.setText("DWT.MEDIUM"); | |
94 longButton = new Button(formatGroup, DWT.RADIO); | |
95 longButton.setText("DWT.LONG"); | |
96 borderButton = new Button(styleGroup, DWT.CHECK); | |
97 borderButton.setText("DWT.BORDER"); | |
98 } | |
99 | |
100 /** | |
101 * Gets the "Example" widget children. | |
102 */ | |
103 Widget [] getExampleWidgets () { | |
104 return [dateTime1]; | |
105 } | |
106 | |
107 /** | |
108 * Returns a list of set/get API method names (without the set/get prefix) | |
109 * that can be used to set/get values in the example control(s). | |
110 */ | |
111 char[][] getMethodNames() { | |
112 return ["Day", "Hours", "Minutes", "Month", "Seconds", "Year"]; | |
113 } | |
114 | |
115 /** | |
116 * Gets the text for the tab folder item. | |
117 */ | |
118 char[] getTabText () { | |
119 return "DateTime"; | |
120 } | |
121 | |
122 /** | |
123 * Sets the state of the "Example" widgets. | |
124 */ | |
125 void setExampleWidgetState () { | |
126 super.setExampleWidgetState (); | |
127 dateButton.setSelection ((dateTime1.getStyle () & DWT.DATE) !is 0); | |
128 timeButton.setSelection ((dateTime1.getStyle () & DWT.TIME) !is 0); | |
129 calendarButton.setSelection ((dateTime1.getStyle () & DWT.CALENDAR) !is 0); | |
130 shortButton.setSelection ((dateTime1.getStyle () & DWT.SHORT) !is 0); | |
131 mediumButton.setSelection ((dateTime1.getStyle () & DWT.MEDIUM) !is 0); | |
132 longButton.setSelection ((dateTime1.getStyle () & DWT.LONG) !is 0); | |
133 borderButton.setSelection ((dateTime1.getStyle () & DWT.BORDER) !is 0); | |
134 } | |
135 } |