| 1 |
/******************************************************************************* |
|---|
| 2 |
* Copyright (c) 2000, 2003 IBM Corporation and others. |
|---|
| 3 |
* All rights reserved. This program and the accompanying materials |
|---|
| 4 |
* are made available under the terms of the Common Public License v1.0 |
|---|
| 5 |
* which accompanies this distribution, and is available at |
|---|
| 6 |
* http://www.eclipse.org/legal/cpl-v10.html |
|---|
| 7 |
* |
|---|
| 8 |
* Contributors: |
|---|
| 9 |
* IBM Corporation - initial API and implementation |
|---|
| 10 |
*******************************************************************************/ |
|---|
| 11 |
module controlexample.ccombotab; |
|---|
| 12 |
|
|---|
| 13 |
private { |
|---|
| 14 |
import swt.all; |
|---|
| 15 |
import controlexample.tab; |
|---|
| 16 |
import controlexample.controlexample; |
|---|
| 17 |
} |
|---|
| 18 |
|
|---|
| 19 |
class CComboTab : Tab { |
|---|
| 20 |
|
|---|
| 21 |
/* Example widgets and groups that contain them */ |
|---|
| 22 |
CCombo combo1; |
|---|
| 23 |
Group comboGroup; |
|---|
| 24 |
|
|---|
| 25 |
/* Style widgets added to the "Style" group */ |
|---|
| 26 |
Button flatButton, readOnlyButton; |
|---|
| 27 |
|
|---|
| 28 |
static String [] ListData; |
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
/** |
|---|
| 32 |
* Creates the Tab within a given instance_ren of ControlExample. |
|---|
| 33 |
*/ |
|---|
| 34 |
this(ControlExample instance_ren) { |
|---|
| 35 |
if(ListData is null){ |
|---|
| 36 |
ListData ~= ControlExample.getResourceString("ListData0_0"); |
|---|
| 37 |
ListData ~= ControlExample.getResourceString("ListData0_1"); |
|---|
| 38 |
ListData ~= ControlExample.getResourceString("ListData0_2"); |
|---|
| 39 |
ListData ~= ControlExample.getResourceString("ListData0_3"); |
|---|
| 40 |
ListData ~= ControlExample.getResourceString("ListData0_4"); |
|---|
| 41 |
ListData ~= ControlExample.getResourceString("ListData0_5"); |
|---|
| 42 |
ListData ~= ControlExample.getResourceString("ListData0_6"); |
|---|
| 43 |
ListData ~= ControlExample.getResourceString("ListData0_7"); |
|---|
| 44 |
ListData ~= ControlExample.getResourceString("ListData0_8"); |
|---|
| 45 |
} |
|---|
| 46 |
|
|---|
| 47 |
super(instance_ren); |
|---|
| 48 |
} |
|---|
| 49 |
|
|---|
| 50 |
/** |
|---|
| 51 |
* Creates the "Example" group. |
|---|
| 52 |
*/ |
|---|
| 53 |
void createExampleGroup () { |
|---|
| 54 |
super.createExampleGroup (); |
|---|
| 55 |
|
|---|
| 56 |
/* Create a group for the combo box */ |
|---|
| 57 |
comboGroup = new Group (exampleGroup, SWT.NONE); |
|---|
| 58 |
comboGroup.setLayout (new GridLayout ()); |
|---|
| 59 |
comboGroup.setLayoutData (new GridData (GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL)); |
|---|
| 60 |
comboGroup.setText (ControlExample.getResourceString("Custom_Combo")); |
|---|
| 61 |
} |
|---|
| 62 |
|
|---|
| 63 |
/** |
|---|
| 64 |
* Creates the "Example" widgets. |
|---|
| 65 |
*/ |
|---|
| 66 |
void createExampleWidgets () { |
|---|
| 67 |
|
|---|
| 68 |
/* Compute the widget style */ |
|---|
| 69 |
int style = getDefaultStyle(); |
|---|
| 70 |
if (flatButton.getSelection ()) style |= SWT.FLAT; |
|---|
| 71 |
if (readOnlyButton.getSelection ()) style |= SWT.READ_ONLY; |
|---|
| 72 |
if (borderButton.getSelection ()) style |= SWT.BORDER; |
|---|
| 73 |
|
|---|
| 74 |
/* Create the example widgets */ |
|---|
| 75 |
combo1 = new CCombo (comboGroup, style); |
|---|
| 76 |
combo1.setItems (ListData); |
|---|
| 77 |
if (ListData.length >= 3) { |
|---|
| 78 |
combo1.setText(ListData [2]); |
|---|
| 79 |
} |
|---|
| 80 |
} |
|---|
| 81 |
|
|---|
| 82 |
/** |
|---|
| 83 |
* Creates the "Style" group. |
|---|
| 84 |
*/ |
|---|
| 85 |
void createStyleGroup () { |
|---|
| 86 |
super.createStyleGroup (); |
|---|
| 87 |
|
|---|
| 88 |
/* Create the extra widgets */ |
|---|
| 89 |
readOnlyButton = new Button (styleGroup, SWT.CHECK); |
|---|
| 90 |
readOnlyButton.setText ("SWT.READ_ONLY"); |
|---|
| 91 |
borderButton = new Button (styleGroup, SWT.CHECK); |
|---|
| 92 |
borderButton.setText ("SWT.BORDER"); |
|---|
| 93 |
flatButton = new Button (styleGroup, SWT.CHECK); |
|---|
| 94 |
flatButton.setText ("SWT.FLAT"); |
|---|
| 95 |
} |
|---|
| 96 |
|
|---|
| 97 |
/** |
|---|
| 98 |
* Gets the "Example" widget children. |
|---|
| 99 |
*/ |
|---|
| 100 |
Control [] getExampleWidgets () { |
|---|
| 101 |
Control[] result; |
|---|
| 102 |
result ~= combo1; |
|---|
| 103 |
return result; |
|---|
| 104 |
} |
|---|
| 105 |
|
|---|
| 106 |
/** |
|---|
| 107 |
* Gets the text for the tab folder item. |
|---|
| 108 |
*/ |
|---|
| 109 |
String getTabText () { |
|---|
| 110 |
return "CCombo"; |
|---|
| 111 |
} |
|---|
| 112 |
|
|---|
| 113 |
/** |
|---|
| 114 |
* Sets the state of the "Example" widgets. |
|---|
| 115 |
*/ |
|---|
| 116 |
void setExampleWidgetState () { |
|---|
| 117 |
super.setExampleWidgetState (); |
|---|
| 118 |
flatButton.setSelection ((combo1.getStyle () & SWT.FLAT) != 0); |
|---|
| 119 |
readOnlyButton.setSelection ((combo1.getStyle () & SWT.READ_ONLY) != 0); |
|---|
| 120 |
borderButton.setSelection ((combo1.getStyle () & SWT.BORDER) != 0); |
|---|
| 121 |
} |
|---|
| 122 |
} |
|---|