annotate examples/controlexample/TableTab.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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
78
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
1 /*******************************************************************************
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
2 * Copyright (c) 2000, 2007 IBM Corporation and others.
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
3 * All rights reserved. This program and the accompanying materials
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
4 * are made available under the terms of the Eclipse Public License v1.0
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
5 * which accompanies this distribution, and is available at
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
6 * http://www.eclipse.org/legal/epl-v10.html
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
7 *
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
8 * Contributors:
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
9 * IBM Corporation - initial API and implementation
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
10 * Port to the D programming language:
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
11 * Frank Benoit <benoit@tionex.de>
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
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.TableTab;
78
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
14
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
15
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
16
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
17 import dwt.DWT;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
18 import dwt.events.DisposeEvent;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
19 import dwt.events.DisposeListener;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
20 import dwt.events.SelectionAdapter;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
21 import dwt.events.SelectionEvent;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
22 import dwt.events.SelectionListener;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
23 import dwt.graphics.Color;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
24 import dwt.graphics.Font;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
25 import dwt.graphics.FontData;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
26 import dwt.graphics.Image;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
27 import dwt.graphics.Point;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
28 import dwt.graphics.RGB;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
29 import dwt.layout.GridData;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
30 import dwt.layout.GridLayout;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
31 import dwt.widgets.Button;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
32 import dwt.widgets.Event;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
33 import dwt.widgets.Group;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
34 import dwt.widgets.Item;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
35 import dwt.widgets.Menu;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
36 import dwt.widgets.MenuItem;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
37 import dwt.widgets.Table;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
38 import dwt.widgets.TableColumn;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
39 import dwt.widgets.TableItem;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
40 import dwt.widgets.Widget;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
41
161
eb84f9418bbf Change module names to this not have examples in the FQN.
Frank Benoit <benoit@tionex.de>
parents: 78
diff changeset
42 import controlexample.Tab;
eb84f9418bbf Change module names to this not have examples in the FQN.
Frank Benoit <benoit@tionex.de>
parents: 78
diff changeset
43 import controlexample.ControlExample;
eb84f9418bbf Change module names to this not have examples in the FQN.
Frank Benoit <benoit@tionex.de>
parents: 78
diff changeset
44 import controlexample.ScrollableTab;
78
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
45
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
46 import dwt.dwthelper.utils;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
47
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
48 import tango.text.convert.Format;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
49 import tango.util.Convert;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
50 import tango.core.Exception;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
51
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
52 class TableTab : ScrollableTab {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
53 /* Example widgets and groups that contain them */
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
54 Table table1;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
55 Group tableGroup;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
56
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
57 /* Size widgets added to the "Size" group */
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
58 Button packColumnsButton;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
59
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
60 /* Style widgets added to the "Style" group */
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
61 Button checkButton, fullSelectionButton, hideSelectionButton;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
62
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
63 /* Other widgets added to the "Other" group */
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
64 Button multipleColumns, moveableColumns, resizableColumns, headerVisibleButton, sortIndicatorButton, headerImagesButton, linesVisibleButton, subImagesButton;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
65
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
66 /* Controls and resources added to the "Colors and Fonts" group */
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
67 static const int ITEM_FOREGROUND_COLOR = 3;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
68 static const int ITEM_BACKGROUND_COLOR = 4;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
69 static const int ITEM_FONT = 5;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
70 static const int CELL_FOREGROUND_COLOR = 6;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
71 static const int CELL_BACKGROUND_COLOR = 7;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
72 static const int CELL_FONT = 8;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
73 Color itemForegroundColor, itemBackgroundColor, cellForegroundColor, cellBackgroundColor;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
74 Font itemFont, cellFont;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
75
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
76 static char[] [] columnTitles;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
77 static char[][][] tableData;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
78
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
79 Point menuMouseCoords;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
80
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
81 /**
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
82 * Creates the Tab within a given instance of ControlExample.
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
83 */
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
84 this(ControlExample instance) {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
85 super(instance);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
86 if( columnTitles.length is 0 ){
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
87 columnTitles = [
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
88 ControlExample.getResourceString("TableTitle_0"),
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
89 ControlExample.getResourceString("TableTitle_1"),
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
90 ControlExample.getResourceString("TableTitle_2"),
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
91 ControlExample.getResourceString("TableTitle_3")];
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
92 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
93 if( tableData.length is 0 ){
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
94 tableData = [
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
95 [ ControlExample.getResourceString("TableLine0_0"),
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
96 ControlExample.getResourceString("TableLine0_1"),
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
97 ControlExample.getResourceString("TableLine0_2"),
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
98 ControlExample.getResourceString("TableLine0_3") ],
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
99 [ ControlExample.getResourceString("TableLine1_0"),
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
100 ControlExample.getResourceString("TableLine1_1"),
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
101 ControlExample.getResourceString("TableLine1_2"),
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
102 ControlExample.getResourceString("TableLine1_3") ],
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
103 [ ControlExample.getResourceString("TableLine2_0"),
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
104 ControlExample.getResourceString("TableLine2_1"),
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
105 ControlExample.getResourceString("TableLine2_2"),
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
106 ControlExample.getResourceString("TableLine2_3") ]];
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
107 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
108 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
109
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
110 /**
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
111 * Creates the "Colors and Fonts" group.
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
112 */
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
113 void createColorAndFontGroup () {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
114 super.createColorAndFontGroup();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
115
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
116 TableItem item = new TableItem(colorAndFontTable, DWT.None);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
117 item.setText(ControlExample.getResourceString ("Item_Foreground_Color"));
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
118 item = new TableItem(colorAndFontTable, DWT.None);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
119 item.setText(ControlExample.getResourceString ("Item_Background_Color"));
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
120 item = new TableItem(colorAndFontTable, DWT.None);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
121 item.setText(ControlExample.getResourceString ("Item_Font"));
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
122 item = new TableItem(colorAndFontTable, DWT.None);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
123 item.setText(ControlExample.getResourceString ("Cell_Foreground_Color"));
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
124 item = new TableItem(colorAndFontTable, DWT.None);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
125 item.setText(ControlExample.getResourceString ("Cell_Background_Color"));
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
126 item = new TableItem(colorAndFontTable, DWT.None);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
127 item.setText(ControlExample.getResourceString ("Cell_Font"));
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
128
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
129 shell.addDisposeListener(new class() DisposeListener {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
130 public void widgetDisposed(DisposeEvent event) {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
131 if (itemBackgroundColor !is null) itemBackgroundColor.dispose();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
132 if (itemForegroundColor !is null) itemForegroundColor.dispose();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
133 if (itemFont !is null) itemFont.dispose();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
134 if (cellBackgroundColor !is null) cellBackgroundColor.dispose();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
135 if (cellForegroundColor !is null) cellForegroundColor.dispose();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
136 if (cellFont !is null) cellFont.dispose();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
137 itemBackgroundColor = null;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
138 itemForegroundColor = null;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
139 itemFont = null;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
140 cellBackgroundColor = null;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
141 cellForegroundColor = null;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
142 cellFont = null;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
143 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
144 });
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
145 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
146
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
147 void changeFontOrColor(int index) {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
148 switch (index) {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
149 case ITEM_FOREGROUND_COLOR: {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
150 Color oldColor = itemForegroundColor;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
151 if (oldColor is null) oldColor = table1.getItem (0).getForeground ();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
152 colorDialog.setRGB(oldColor.getRGB());
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
153 RGB rgb = colorDialog.open();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
154 if (rgb is null) return;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
155 oldColor = itemForegroundColor;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
156 itemForegroundColor = new Color (display, rgb);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
157 setItemForeground ();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
158 if (oldColor !is null) oldColor.dispose ();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
159 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
160 break;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
161 case ITEM_BACKGROUND_COLOR: {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
162 Color oldColor = itemBackgroundColor;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
163 if (oldColor is null) oldColor = table1.getItem (0).getBackground ();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
164 colorDialog.setRGB(oldColor.getRGB());
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
165 RGB rgb = colorDialog.open();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
166 if (rgb is null) return;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
167 oldColor = itemBackgroundColor;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
168 itemBackgroundColor = new Color (display, rgb);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
169 setItemBackground ();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
170 if (oldColor !is null) oldColor.dispose ();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
171 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
172 break;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
173 case ITEM_FONT: {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
174 Font oldFont = itemFont;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
175 if (oldFont is null) oldFont = table1.getItem (0).getFont ();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
176 fontDialog.setFontList(oldFont.getFontData());
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
177 FontData fontData = fontDialog.open ();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
178 if (fontData is null) return;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
179 oldFont = itemFont;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
180 itemFont = new Font (display, fontData);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
181 setItemFont ();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
182 setExampleWidgetSize ();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
183 if (oldFont !is null) oldFont.dispose ();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
184 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
185 break;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
186 case CELL_FOREGROUND_COLOR: {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
187 Color oldColor = cellForegroundColor;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
188 if (oldColor is null) oldColor = table1.getItem (0).getForeground (1);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
189 colorDialog.setRGB(oldColor.getRGB());
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
190 RGB rgb = colorDialog.open();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
191 if (rgb is null) return;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
192 oldColor = cellForegroundColor;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
193 cellForegroundColor = new Color (display, rgb);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
194 setCellForeground ();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
195 if (oldColor !is null) oldColor.dispose ();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
196 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
197 break;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
198 case CELL_BACKGROUND_COLOR: {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
199 Color oldColor = cellBackgroundColor;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
200 if (oldColor is null) oldColor = table1.getItem (0).getBackground (1);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
201 colorDialog.setRGB(oldColor.getRGB());
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
202 RGB rgb = colorDialog.open();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
203 if (rgb is null) return;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
204 oldColor = cellBackgroundColor;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
205 cellBackgroundColor = new Color (display, rgb);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
206 setCellBackground ();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
207 if (oldColor !is null) oldColor.dispose ();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
208 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
209 break;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
210 case CELL_FONT: {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
211 Font oldFont = cellFont;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
212 if (oldFont is null) oldFont = table1.getItem (0).getFont (1);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
213 fontDialog.setFontList(oldFont.getFontData());
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
214 FontData fontData = fontDialog.open ();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
215 if (fontData is null) return;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
216 oldFont = cellFont;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
217 cellFont = new Font (display, fontData);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
218 setCellFont ();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
219 setExampleWidgetSize ();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
220 if (oldFont !is null) oldFont.dispose ();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
221 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
222 break;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
223 default:
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
224 super.changeFontOrColor(index);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
225 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
226 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
227
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
228 /**
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
229 * Creates the "Other" group.
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
230 */
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
231 void createOtherGroup () {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
232 super.createOtherGroup ();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
233
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
234 /* Create display controls specific to this example */
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
235 linesVisibleButton = new Button (otherGroup, DWT.CHECK);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
236 linesVisibleButton.setText (ControlExample.getResourceString("Lines_Visible"));
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
237 multipleColumns = new Button (otherGroup, DWT.CHECK);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
238 multipleColumns.setText (ControlExample.getResourceString("Multiple_Columns"));
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
239 multipleColumns.setSelection(true);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
240 headerVisibleButton = new Button (otherGroup, DWT.CHECK);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
241 headerVisibleButton.setText (ControlExample.getResourceString("Header_Visible"));
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
242 sortIndicatorButton = new Button (otherGroup, DWT.CHECK);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
243 sortIndicatorButton.setText (ControlExample.getResourceString("Sort_Indicator"));
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
244 moveableColumns = new Button (otherGroup, DWT.CHECK);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
245 moveableColumns.setText (ControlExample.getResourceString("Moveable_Columns"));
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
246 resizableColumns = new Button (otherGroup, DWT.CHECK);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
247 resizableColumns.setText (ControlExample.getResourceString("Resizable_Columns"));
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
248 headerImagesButton = new Button (otherGroup, DWT.CHECK);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
249 headerImagesButton.setText (ControlExample.getResourceString("Header_Images"));
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
250 subImagesButton = new Button (otherGroup, DWT.CHECK);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
251 subImagesButton.setText (ControlExample.getResourceString("Sub_Images"));
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
252
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
253 /* Add the listeners */
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
254 linesVisibleButton.addSelectionListener (new class() SelectionAdapter {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
255 public void widgetSelected (SelectionEvent event) {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
256 setWidgetLinesVisible ();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
257 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
258 });
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
259 multipleColumns.addSelectionListener (new class() SelectionAdapter {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
260 public void widgetSelected (SelectionEvent event) {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
261 recreateExampleWidgets ();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
262 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
263 });
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
264 headerVisibleButton.addSelectionListener (new class() SelectionAdapter {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
265 public void widgetSelected (SelectionEvent event) {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
266 setWidgetHeaderVisible ();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
267 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
268 });
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
269 sortIndicatorButton.addSelectionListener (new class() SelectionAdapter {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
270 public void widgetSelected (SelectionEvent event) {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
271 setWidgetSortIndicator ();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
272 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
273 });
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
274 moveableColumns.addSelectionListener (new class() SelectionAdapter {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
275 public void widgetSelected (SelectionEvent event) {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
276 setColumnsMoveable ();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
277 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
278 });
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
279 resizableColumns.addSelectionListener (new class() SelectionAdapter {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
280 public void widgetSelected (SelectionEvent event) {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
281 setColumnsResizable ();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
282 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
283 });
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
284 headerImagesButton.addSelectionListener (new class() SelectionAdapter {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
285 public void widgetSelected (SelectionEvent event) {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
286 recreateExampleWidgets ();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
287 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
288 });
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
289 subImagesButton.addSelectionListener (new class() SelectionAdapter {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
290 public void widgetSelected (SelectionEvent event) {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
291 recreateExampleWidgets ();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
292 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
293 });
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
294 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
295
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
296 /**
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
297 * Creates the "Example" group.
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
298 */
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
299 void createExampleGroup () {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
300 super.createExampleGroup ();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
301
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
302 /* Create a group for the table */
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
303 tableGroup = new Group (exampleGroup, DWT.NONE);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
304 tableGroup.setLayout (new GridLayout ());
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
305 tableGroup.setLayoutData (new GridData (DWT.FILL, DWT.FILL, true, true));
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
306 tableGroup.setText ("Table");
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
307 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
308
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
309 /**
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
310 * Creates the "Example" widgets.
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
311 */
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
312 void createExampleWidgets () {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
313 /* Compute the widget style */
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
314 int style = getDefaultStyle();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
315 if (singleButton.getSelection ()) style |= DWT.SINGLE;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
316 if (multiButton.getSelection ()) style |= DWT.MULTI;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
317 if (verticalButton.getSelection ()) style |= DWT.V_SCROLL;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
318 if (horizontalButton.getSelection ()) style |= DWT.H_SCROLL;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
319 if (checkButton.getSelection ()) style |= DWT.CHECK;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
320 if (fullSelectionButton.getSelection ()) style |= DWT.FULL_SELECTION;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
321 if (hideSelectionButton.getSelection ()) style |= DWT.HIDE_SELECTION;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
322 if (borderButton.getSelection ()) style |= DWT.BORDER;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
323
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
324 /* Create the table widget */
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
325 table1 = new Table (tableGroup, style);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
326
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
327 /* Fill the table with data */
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
328 bool multiColumn = multipleColumns.getSelection();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
329 if (multiColumn) {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
330 for (int i = 0; i < columnTitles.length; i++) {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
331 TableColumn tableColumn = new TableColumn(table1, DWT.NONE);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
332 tableColumn.setText(columnTitles[i]);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
333 tableColumn.setToolTipText( Format( ControlExample.getResourceString("Tooltip"), columnTitles[i] ));
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
334 if (headerImagesButton.getSelection()) tableColumn.setImage(instance.images [i % 3]);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
335 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
336 table1.setSortColumn(table1.getColumn(0));
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
337 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
338 for (int i=0; i<16; i++) {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
339 TableItem item = new TableItem (table1, DWT.NONE);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
340 if (multiColumn && subImagesButton.getSelection()) {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
341 for (int j = 0; j < columnTitles.length; j++) {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
342 item.setImage(j, instance.images [i % 3]);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
343 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
344 } else {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
345 item.setImage(instance.images [i % 3]);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
346 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
347 setItemText (item, i, ControlExample.getResourceString("Index") ~ to!(char[])(i));
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
348 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
349 packColumns();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
350 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
351
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
352 void setItemText(TableItem item, int i, char[] node) {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
353 int index = i % 3;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
354 if (multipleColumns.getSelection()) {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
355 tableData [index][0] = node;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
356 item.setText (tableData [index]);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
357 } else {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
358 item.setText (node);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
359 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
360 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
361
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
362 /**
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
363 * Creates the "Size" group. The "Size" group contains
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
364 * controls that allow the user to change the size of
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
365 * the example widgets.
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
366 */
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
367 void createSizeGroup () {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
368 super.createSizeGroup();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
369
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
370 packColumnsButton = new Button (sizeGroup, DWT.PUSH);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
371 packColumnsButton.setText (ControlExample.getResourceString("Pack_Columns"));
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
372 packColumnsButton.addSelectionListener(new class() SelectionAdapter {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
373 public void widgetSelected (SelectionEvent event) {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
374 packColumns ();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
375 setExampleWidgetSize ();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
376 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
377 });
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
378 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
379
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
380 /**
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
381 * Creates the "Style" group.
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
382 */
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
383 void createStyleGroup () {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
384 super.createStyleGroup ();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
385
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
386 /* Create the extra widgets */
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
387 checkButton = new Button (styleGroup, DWT.CHECK);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
388 checkButton.setText ("DWT.CHECK");
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
389 fullSelectionButton = new Button (styleGroup, DWT.CHECK);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
390 fullSelectionButton.setText ("DWT.FULL_SELECTION");
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
391 hideSelectionButton = new Button (styleGroup, DWT.CHECK);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
392 hideSelectionButton.setText ("DWT.HIDE_SELECTION");
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
393 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
394
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
395 /**
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
396 * Gets the "Example" widget children's items, if any.
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
397 *
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
398 * @return an array containing the example widget children's items
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
399 */
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
400 Item [] getExampleWidgetItems () {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
401 Item [] columns = table1.getColumns();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
402 Item [] items = table1.getItems();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
403 Item [] allItems = new Item [columns.length + items.length];
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
404 System.arraycopy(columns, 0, allItems, 0, columns.length);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
405 System.arraycopy(items, 0, allItems, columns.length, items.length);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
406 return allItems;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
407 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
408
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
409 /**
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
410 * Gets the "Example" widget children.
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
411 */
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
412 Widget [] getExampleWidgets () {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
413 return [ cast(Widget) table1 ];
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
414 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
415
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
416 /**
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
417 * Returns a list of set/get API method names (without the set/get prefix)
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
418 * that can be used to set/get values in the example control(s).
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
419 */
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
420 char[][] getMethodNames() {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
421 return ["ColumnOrder", "ItemCount", "Selection", "SelectionIndex", "ToolTipText", "TopIndex"];
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
422 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
423
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
424 char[] setMethodName(char[] methodRoot) {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
425 /* Override to handle special case of int getSelectionIndex()/setSelection(int) */
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
426 return (methodRoot == "SelectionIndex" ) ? "setSelection" : "set" ~ methodRoot;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
427 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
428
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
429 void packColumns () {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
430 int columnCount = table1.getColumnCount();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
431 for (int i = 0; i < columnCount; i++) {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
432 TableColumn tableColumn = table1.getColumn(i);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
433 tableColumn.pack();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
434 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
435 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
436
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
437 //PORTING_LEFT
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
438 /+
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
439 Object[] parameterForType(char[] typeName, char[] value, Widget widget) {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
440 if (value.length is 0 ) return [new TableItem[0]]; // bug in Table?
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
441 if (typeName.equals("org.eclipse.swt.widgets.TableItem")) {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
442 TableItem item = findItem(value, ((Table) widget).getItems());
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
443 if (item !is null) return new Object[] {item};
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
444 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
445 if (typeName.equals("[Lorg.eclipse.swt.widgets.TableItem;")) {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
446 char[][] values = split(value, ',');
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
447 TableItem[] items = new TableItem[values.length];
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
448 for (int i = 0; i < values.length; i++) {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
449 items[i] = findItem(values[i], ((Table) widget).getItems());
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
450 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
451 return new Object[] {items};
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
452 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
453 return super.parameterForType(typeName, value, widget);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
454 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
455 +/
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
456 TableItem findItem(char[] value, TableItem[] items) {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
457 for (int i = 0; i < items.length; i++) {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
458 TableItem item = items[i];
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
459 if (item.getText() == value ) return item;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
460 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
461 return null;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
462 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
463
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
464 /**
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
465 * Gets the text for the tab folder item.
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
466 */
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
467 char[] getTabText () {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
468 return "Table";
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
469 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
470
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
471 /**
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
472 * Sets the foreground color, background color, and font
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
473 * of the "Example" widgets to their default settings.
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
474 * Also sets foreground and background color of TableItem [0]
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
475 * to default settings.
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
476 */
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
477 void resetColorsAndFonts () {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
478 super.resetColorsAndFonts ();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
479 Color oldColor = itemForegroundColor;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
480 itemForegroundColor = null;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
481 setItemForeground ();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
482 if (oldColor !is null) oldColor.dispose();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
483 oldColor = itemBackgroundColor;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
484 itemBackgroundColor = null;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
485 setItemBackground ();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
486 if (oldColor !is null) oldColor.dispose();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
487 Font oldFont = font;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
488 itemFont = null;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
489 setItemFont ();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
490 if (oldFont !is null) oldFont.dispose();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
491 oldColor = cellForegroundColor;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
492 cellForegroundColor = null;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
493 setCellForeground ();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
494 if (oldColor !is null) oldColor.dispose();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
495 oldColor = cellBackgroundColor;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
496 cellBackgroundColor = null;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
497 setCellBackground ();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
498 if (oldColor !is null) oldColor.dispose();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
499 oldFont = font;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
500 cellFont = null;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
501 setCellFont ();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
502 if (oldFont !is null) oldFont.dispose();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
503 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
504
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
505 /**
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
506 * Sets the background color of the Row 0 TableItem in column 1.
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
507 */
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
508 void setCellBackground () {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
509 if (!instance.startup) {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
510 table1.getItem (0).setBackground (1, cellBackgroundColor);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
511 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
512 /* Set the background color item's image to match the background color of the cell. */
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
513 Color color = cellBackgroundColor;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
514 if (color is null) color = table1.getItem (0).getBackground (1);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
515 TableItem item = colorAndFontTable.getItem(CELL_BACKGROUND_COLOR);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
516 Image oldImage = item.getImage();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
517 if (oldImage !is null) oldImage.dispose();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
518 item.setImage (colorImage(color));
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
519 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
520
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
521 /**
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
522 * Sets the foreground color of the Row 0 TableItem in column 1.
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
523 */
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
524 void setCellForeground () {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
525 if (!instance.startup) {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
526 table1.getItem (0).setForeground (1, cellForegroundColor);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
527 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
528 /* Set the foreground color item's image to match the foreground color of the cell. */
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
529 Color color = cellForegroundColor;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
530 if (color is null) color = table1.getItem (0).getForeground (1);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
531 TableItem item = colorAndFontTable.getItem(CELL_FOREGROUND_COLOR);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
532 Image oldImage = item.getImage();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
533 if (oldImage !is null) oldImage.dispose();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
534 item.setImage (colorImage(color));
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
535 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
536
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
537 /**
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
538 * Sets the font of the Row 0 TableItem in column 1.
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
539 */
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
540 void setCellFont () {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
541 if (!instance.startup) {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
542 table1.getItem (0).setFont (1, cellFont);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
543 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
544 /* Set the font item's image to match the font of the item. */
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
545 Font ft = cellFont;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
546 if (ft is null) ft = table1.getItem (0).getFont (1);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
547 TableItem item = colorAndFontTable.getItem(CELL_FONT);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
548 Image oldImage = item.getImage();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
549 if (oldImage !is null) oldImage.dispose();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
550 item.setImage (fontImage(ft));
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
551 item.setFont(ft);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
552 colorAndFontTable.layout ();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
553 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
554
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
555 /**
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
556 * Sets the background color of TableItem [0].
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
557 */
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
558 void setItemBackground () {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
559 if (!instance.startup) {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
560 table1.getItem (0).setBackground (itemBackgroundColor);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
561 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
562 /* Set the background color item's image to match the background color of the item. */
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
563 Color color = itemBackgroundColor;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
564 if (color is null) color = table1.getItem (0).getBackground ();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
565 TableItem item = colorAndFontTable.getItem(ITEM_BACKGROUND_COLOR);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
566 Image oldImage = item.getImage();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
567 if (oldImage !is null) oldImage.dispose();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
568 item.setImage (colorImage(color));
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
569 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
570
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
571 /**
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
572 * Sets the foreground color of TableItem [0].
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
573 */
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
574 void setItemForeground () {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
575 if (!instance.startup) {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
576 table1.getItem (0).setForeground (itemForegroundColor);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
577 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
578 /* Set the foreground color item's image to match the foreground color of the item. */
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
579 Color color = itemForegroundColor;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
580 if (color is null) color = table1.getItem (0).getForeground ();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
581 TableItem item = colorAndFontTable.getItem(ITEM_FOREGROUND_COLOR);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
582 Image oldImage = item.getImage();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
583 if (oldImage !is null) oldImage.dispose();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
584 item.setImage (colorImage(color));
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
585 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
586
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
587 /**
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
588 * Sets the font of TableItem 0.
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
589 */
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
590 void setItemFont () {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
591 if (!instance.startup) {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
592 table1.getItem (0).setFont (itemFont);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
593 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
594 /* Set the font item's image to match the font of the item. */
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
595 Font ft = itemFont;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
596 if (ft is null) ft = table1.getItem (0).getFont ();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
597 TableItem item = colorAndFontTable.getItem(ITEM_FONT);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
598 Image oldImage = item.getImage();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
599 if (oldImage !is null) oldImage.dispose();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
600 item.setImage (fontImage(ft));
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
601 item.setFont(ft);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
602 colorAndFontTable.layout ();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
603 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
604
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
605 /**
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
606 * Sets the moveable columns state of the "Example" widgets.
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
607 */
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
608 void setColumnsMoveable () {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
609 bool selection = moveableColumns.getSelection();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
610 TableColumn[] columns = table1.getColumns();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
611 for (int i = 0; i < columns.length; i++) {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
612 columns[i].setMoveable(selection);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
613 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
614 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
615
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
616 /**
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
617 * Sets the resizable columns state of the "Example" widgets.
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
618 */
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
619 void setColumnsResizable () {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
620 bool selection = resizableColumns.getSelection();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
621 TableColumn[] columns = table1.getColumns();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
622 for (int i = 0; i < columns.length; i++) {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
623 columns[i].setResizable(selection);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
624 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
625 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
626
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
627 /**
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
628 * Sets the state of the "Example" widgets.
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
629 */
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
630 void setExampleWidgetState () {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
631 setItemBackground ();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
632 setItemForeground ();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
633 setItemFont ();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
634 setCellBackground ();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
635 setCellForeground ();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
636 setCellFont ();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
637 if (!instance.startup) {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
638 setColumnsMoveable ();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
639 setColumnsResizable ();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
640 setWidgetHeaderVisible ();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
641 setWidgetSortIndicator ();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
642 setWidgetLinesVisible ();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
643 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
644 super.setExampleWidgetState ();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
645 checkButton.setSelection ((table1.getStyle () & DWT.CHECK) !is 0);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
646 fullSelectionButton.setSelection ((table1.getStyle () & DWT.FULL_SELECTION) !is 0);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
647 hideSelectionButton.setSelection ((table1.getStyle () & DWT.HIDE_SELECTION) !is 0);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
648 try {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
649 TableColumn column = table1.getColumn(0);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
650 moveableColumns.setSelection (column.getMoveable());
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
651 resizableColumns.setSelection (column.getResizable());
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
652 } catch (IllegalArgumentException ex) {}
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
653 headerVisibleButton.setSelection (table1.getHeaderVisible());
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
654 linesVisibleButton.setSelection (table1.getLinesVisible());
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
655 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
656
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
657 /**
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
658 * Sets the header visible state of the "Example" widgets.
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
659 */
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
660 void setWidgetHeaderVisible () {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
661 table1.setHeaderVisible (headerVisibleButton.getSelection ());
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
662 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
663
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
664 /**
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
665 * Sets the sort indicator state of the "Example" widgets.
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
666 */
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
667 void setWidgetSortIndicator () {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
668 if (sortIndicatorButton.getSelection ()) {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
669 /* Reset to known state: 'down' on column 0. */
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
670 table1.setSortDirection (DWT.DOWN);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
671 TableColumn [] columns = table1.getColumns();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
672 for (int i = 0; i < columns.length; i++) {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
673 TableColumn column = columns[i];
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
674 if (i is 0) table1.setSortColumn(column);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
675 SelectionListener listener = new class() SelectionAdapter {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
676 public void widgetSelected(SelectionEvent e) {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
677 int sortDirection = DWT.DOWN;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
678 if (e.widget is table1.getSortColumn()) {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
679 /* If the sort column hasn't changed, cycle down -> up -> none. */
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
680 switch (table1.getSortDirection ()) {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
681 case DWT.DOWN: sortDirection = DWT.UP; break;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
682 case DWT.UP: sortDirection = DWT.NONE; break;
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
683 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
684 } else {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
685 table1.setSortColumn(cast(TableColumn)e.widget);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
686 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
687 table1.setSortDirection (sortDirection);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
688 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
689 };
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
690 column.addSelectionListener(listener);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
691 column.setData("SortListener", cast(Object)listener); //$NON-NLS-1$
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
692 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
693 } else {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
694 table1.setSortDirection (DWT.NONE);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
695 TableColumn [] columns = table1.getColumns();
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
696 for (int i = 0; i < columns.length; i++) {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
697 SelectionListener listener = cast(SelectionListener)columns[i].getData("SortListener"); //$NON-NLS-1$
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
698 if (listener !is null) columns[i].removeSelectionListener(listener);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
699 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
700 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
701 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
702
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
703 /**
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
704 * Sets the lines visible state of the "Example" widgets.
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
705 */
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
706 void setWidgetLinesVisible () {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
707 table1.setLinesVisible (linesVisibleButton.getSelection ());
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
708 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
709
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
710 protected void specialPopupMenuItems(Menu menu, Event event) {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
711 MenuItem item = new MenuItem(menu, DWT.PUSH);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
712 item.setText("getItem(Point) on mouse coordinates");
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
713 menuMouseCoords = table1.toControl(new Point(event.x, event.y));
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
714 item.addSelectionListener(new class() SelectionAdapter {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
715 public void widgetSelected(SelectionEvent e) {
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
716 eventConsole.append ("getItem(Point(" ~ menuMouseCoords.toString() ~ ")) returned: " ~ ((table1.getItem(menuMouseCoords))).toString);
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
717 eventConsole.append ("\n");
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
718 };
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
719 });
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
720 }
4a04b6759f98 Clean up directory names
John Reimer <terminal.node@gmail.com>
parents:
diff changeset
721 }