annotate dwt/custom/ViewForm.d @ 155:a5afe31f5cdd

Added custom controls
author Frank Benoit <benoit@tionex.de>
date Thu, 14 Feb 2008 19:18:37 +0100
parents
children ab60f3309436
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
155
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
1 /*******************************************************************************
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
2 * Copyright (c) 2000, 2007 IBM Corporation and others.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
3 * All rights reserved. This program and the accompanying materials
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
4 * are made available under the terms of the Eclipse Public License v1.0
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
5 * which accompanies this distribution, and is available at
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
6 * http://www.eclipse.org/legal/epl-v10.html
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
7 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
8 * Contributors:
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
9 * IBM Corporation - initial API and implementation
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
10 * Port to the D programming language:
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
11 * Frank Benoit <benoit@tionex.de>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
12 *******************************************************************************/
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
13 module dwt.custom.ViewForm;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
14
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
15
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
16
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
17 import dwt.DWT;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
18 import dwt.DWTException;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
19 import dwt.graphics.Color;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
20 import dwt.graphics.GC;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
21 import dwt.graphics.Point;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
22 import dwt.graphics.RGB;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
23 import dwt.graphics.Rectangle;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
24 import dwt.widgets.Composite;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
25 import dwt.widgets.Control;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
26 import dwt.widgets.Event;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
27 import dwt.widgets.Layout;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
28 import dwt.widgets.Listener;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
29 import dwt.custom.ViewFormLayout;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
30
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
31 /**
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
32 * Instances of this class implement a Composite that positions and sizes
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
33 * children and allows programmatic control of layout and border parameters.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
34 * ViewForm is used in the workbench to lay out a view's label/menu/toolbar
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
35 * local bar.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
36 * <p>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
37 * Note that although this class is a subclass of <code>Composite</code>,
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
38 * it does not make sense to set a layout on it.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
39 * </p><p>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
40 * <dl>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
41 * <dt><b>Styles:</b></dt>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
42 * <dd>BORDER, FLAT</dd>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
43 * <dt><b>Events:</b></dt>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
44 * <dd>(None)</dd>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
45 * </dl>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
46 * <p>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
47 * IMPORTANT: This class is <em>not</em> intended to be subclassed.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
48 * </p>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
49 */
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
50
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
51 public class ViewForm : Composite {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
52
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
53 /**
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
54 * marginWidth specifies the number of pixels of horizontal margin
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
55 * that will be placed along the left and right edges of the form.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
56 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
57 * The default value is 0.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
58 */
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
59 public int marginWidth = 0;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
60 /**
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
61 * marginHeight specifies the number of pixels of vertical margin
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
62 * that will be placed along the top and bottom edges of the form.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
63 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
64 * The default value is 0.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
65 */
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
66 public int marginHeight = 0;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
67 /**
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
68 * horizontalSpacing specifies the number of pixels between the right
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
69 * edge of one cell and the left edge of its neighbouring cell to
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
70 * the right.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
71 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
72 * The default value is 1.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
73 */
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
74 public int horizontalSpacing = 1;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
75 /**
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
76 * verticalSpacing specifies the number of pixels between the bottom
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
77 * edge of one cell and the top edge of its neighbouring cell underneath.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
78 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
79 * The default value is 1.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
80 */
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
81 public int verticalSpacing = 1;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
82
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
83 /**
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
84 * Color of innermost line of drop shadow border.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
85 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
86 * NOTE This field is badly named and can not be fixed for backwards compatibility.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
87 * It should be capitalized.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
88 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
89 * @deprecated
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
90 */
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
91 public static RGB borderInsideRGB;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
92 /**
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
93 * Color of middle line of drop shadow border.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
94 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
95 * NOTE This field is badly named and can not be fixed for backwards compatibility.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
96 * It should be capitalized.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
97 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
98 * @deprecated
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
99 */
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
100 public static RGB borderMiddleRGB;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
101 /**
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
102 * Color of outermost line of drop shadow border.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
103 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
104 * NOTE This field is badly named and can not be fixed for backwards compatibility.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
105 * It should be capitalized.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
106 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
107 * @deprecated
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
108 */
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
109 public static RGB borderOutsideRGB;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
110
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
111 // DWT widgets
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
112 Control topLeft;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
113 Control topCenter;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
114 Control topRight;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
115 Control content;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
116
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
117 // Configuration and state info
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
118 bool separateTopCenter = false;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
119 bool showBorder = false;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
120
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
121 int separator = -1;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
122 int borderTop = 0;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
123 int borderBottom = 0;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
124 int borderLeft = 0;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
125 int borderRight = 0;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
126 int highlight = 0;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
127 Point oldSize;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
128
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
129 Color selectionBackground;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
130
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
131 static final int OFFSCREEN = -200;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
132 static final int BORDER1_COLOR = DWT.COLOR_WIDGET_NORMAL_SHADOW;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
133 static final int SELECTION_BACKGROUND = DWT.COLOR_LIST_BACKGROUND;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
134
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
135
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
136 static this(){
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
137 borderInsideRGB = new RGB (132, 130, 132);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
138 borderMiddleRGB = new RGB (143, 141, 138);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
139 borderOutsideRGB = new RGB (171, 168, 165);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
140 }
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
141 /**
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
142 * Constructs a new instance of this class given its parent
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
143 * and a style value describing its behavior and appearance.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
144 * <p>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
145 * The style value is either one of the style constants defined in
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
146 * class <code>DWT</code> which is applicable to instances of this
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
147 * class, or must be built by <em>bitwise OR</em>'ing together
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
148 * (that is, using the <code>int</code> "|" operator) two or more
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
149 * of those <code>DWT</code> style constants. The class description
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
150 * lists the style constants that are applicable to the class.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
151 * Style bits are also inherited from superclasses.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
152 * </p>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
153 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
154 * @param parent a widget which will be the parent of the new instance (cannot be null)
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
155 * @param style the style of widget to construct
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
156 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
157 * @exception IllegalArgumentException <ul>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
158 * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
159 * </ul>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
160 * @exception DWTException <ul>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
161 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
162 * </ul>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
163 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
164 * @see DWT#BORDER
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
165 * @see DWT#FLAT
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
166 * @see #getStyle()
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
167 */
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
168 public this(Composite parent, int style) {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
169 super(parent, checkStyle(style));
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
170 super.setLayout(new ViewFormLayout());
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
171
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
172 setBorderVisible((style & DWT.BORDER) !is 0);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
173
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
174 Listener listener = new class() Listener {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
175 public void handleEvent(Event e) {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
176 switch (e.type) {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
177 case DWT.Dispose: onDispose(); break;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
178 case DWT.Paint: onPaint(e.gc); break;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
179 case DWT.Resize: onResize(); break;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
180 default:
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
181 }
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
182 }
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
183 };
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
184
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
185 int[] events = [DWT.Dispose, DWT.Paint, DWT.Resize];
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
186
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
187 for (int i = 0; i < events.length; i++) {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
188 addListener(events[i], listener);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
189 }
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
190 }
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
191
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
192 static int checkStyle (int style) {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
193 int mask = DWT.FLAT | DWT.LEFT_TO_RIGHT | DWT.RIGHT_TO_LEFT;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
194 return style & mask | DWT.NO_REDRAW_RESIZE;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
195 }
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
196
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
197 //protected void checkSubclass () {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
198 // String name = getClass().getName ();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
199 // String validName = ViewForm.class.getName();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
200 // if (!validName.equals(name)) {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
201 // DWT.error (DWT.ERROR_INVALID_SUBCLASS);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
202 // }
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
203 //}
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
204
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
205 public override Rectangle computeTrim (int x, int y, int width, int height) {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
206 checkWidget ();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
207 int trimX = x - borderLeft - highlight;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
208 int trimY = y - borderTop - highlight;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
209 int trimWidth = width + borderLeft + borderRight + 2*highlight;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
210 int trimHeight = height + borderTop + borderBottom + 2*highlight;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
211 return new Rectangle(trimX, trimY, trimWidth, trimHeight);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
212 }
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
213 public override Rectangle getClientArea() {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
214 checkWidget();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
215 Rectangle clientArea = super.getClientArea();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
216 clientArea.x += borderLeft;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
217 clientArea.y += borderTop;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
218 clientArea.width -= borderLeft + borderRight;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
219 clientArea.height -= borderTop + borderBottom;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
220 return clientArea;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
221 }
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
222 /**
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
223 * Returns the content area.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
224 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
225 * @return the control in the content area of the pane or null
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
226 */
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
227 public Control getContent() {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
228 //checkWidget();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
229 return content;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
230 }
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
231 /**
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
232 * Returns Control that appears in the top center of the pane.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
233 * Typically this is a toolbar.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
234 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
235 * @return the control in the top center of the pane or null
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
236 */
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
237 public Control getTopCenter() {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
238 //checkWidget();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
239 return topCenter;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
240 }
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
241 /**
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
242 * Returns the Control that appears in the top left corner of the pane.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
243 * Typically this is a label such as CLabel.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
244 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
245 * @return the control in the top left corner of the pane or null
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
246 */
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
247 public Control getTopLeft() {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
248 //checkWidget();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
249 return topLeft;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
250 }
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
251 /**
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
252 * Returns the control in the top right corner of the pane.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
253 * Typically this is a Close button or a composite with a Menu and Close button.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
254 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
255 * @return the control in the top right corner of the pane or null
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
256 */
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
257 public Control getTopRight() {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
258 //checkWidget();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
259 return topRight;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
260 }
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
261 void onDispose() {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
262 topLeft = null;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
263 topCenter = null;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
264 topRight = null;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
265 content = null;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
266 oldSize = null;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
267 selectionBackground = null;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
268 }
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
269 void onPaint(GC gc) {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
270 Color gcForeground = gc.getForeground();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
271 Point size = getSize();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
272 Color border = getDisplay().getSystemColor(BORDER1_COLOR);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
273 if (showBorder) {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
274 gc.setForeground(border);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
275 gc.drawRectangle(0, 0, size.x - 1, size.y - 1);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
276 if (highlight > 0) {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
277 int x1 = 1;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
278 int y1 = 1;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
279 int x2 = size.x - 1;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
280 int y2 = size.y - 1;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
281 int[] shape = [x1,y1, x2,y1, x2,y2, x1,y2, x1,y1+highlight,
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
282 x1+highlight,y1+highlight, x1+highlight,y2-highlight,
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
283 x2-highlight,y2-highlight, x2-highlight,y1+highlight, x1,y1+highlight];
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
284 Color highlightColor = getDisplay().getSystemColor(DWT.COLOR_LIST_SELECTION);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
285 gc.setBackground(highlightColor);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
286 gc.fillPolygon(shape);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
287 }
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
288 }
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
289 if (separator > -1) {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
290 gc.setForeground(border);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
291 gc.drawLine(borderLeft + highlight, separator, size.x - borderLeft - borderRight - highlight, separator);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
292 }
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
293 gc.setForeground(gcForeground);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
294 }
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
295 void onResize() {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
296 Point size = getSize();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
297 if (oldSize is null || oldSize.x is 0 || oldSize.y is 0) {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
298 redraw();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
299 } else {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
300 int width = 0;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
301 if (oldSize.x < size.x) {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
302 width = size.x - oldSize.x + borderRight + highlight;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
303 } else if (oldSize.x > size.x) {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
304 width = borderRight + highlight;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
305 }
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
306 redraw(size.x - width, 0, width, size.y, false);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
307
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
308 int height = 0;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
309 if (oldSize.y < size.y) {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
310 height = size.y - oldSize.y + borderBottom + highlight;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
311 }
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
312 if (oldSize.y > size.y) {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
313 height = borderBottom + highlight;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
314 }
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
315 redraw(0, size.y - height, size.x, height, false);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
316 }
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
317 oldSize = size;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
318 }
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
319 /**
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
320 * Sets the content.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
321 * Setting the content to null will remove it from
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
322 * the pane - however, the creator of the content must dispose of the content.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
323 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
324 * @param content the control to be displayed in the content area or null
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
325 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
326 * @exception DWTException <ul>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
327 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
328 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
329 * <li>ERROR_INVALID_ARGUMENT - if the control is not a child of this ViewForm</li>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
330 * </ul>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
331 */
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
332 public void setContent(Control content) {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
333 checkWidget();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
334 if (content !is null && content.getParent() !is this) {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
335 DWT.error(DWT.ERROR_INVALID_ARGUMENT);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
336 }
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
337 if (this.content !is null && !this.content.isDisposed()) {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
338 this.content.setBounds(OFFSCREEN, OFFSCREEN, 0, 0);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
339 }
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
340 this.content = content;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
341 layout(false);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
342 }
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
343 /**
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
344 * Sets the layout which is associated with the receiver to be
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
345 * the argument which may be null.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
346 * <p>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
347 * Note: No Layout can be set on this Control because it already
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
348 * manages the size and position of its children.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
349 * </p>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
350 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
351 * @param layout the receiver's new layout or null
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
352 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
353 * @exception DWTException <ul>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
354 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
355 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
356 * </ul>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
357 */
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
358 public override void setLayout (Layout layout) {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
359 checkWidget();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
360 return;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
361 }
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
362 void setSelectionBackground (Color color) {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
363 checkWidget();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
364 if (selectionBackground is color) return;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
365 if (color is null) color = getDisplay().getSystemColor(SELECTION_BACKGROUND);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
366 selectionBackground = color;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
367 redraw();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
368 }
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
369 /**
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
370 * Set the control that appears in the top center of the pane.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
371 * Typically this is a toolbar.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
372 * The topCenter is optional. Setting the topCenter to null will remove it from
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
373 * the pane - however, the creator of the topCenter must dispose of the topCenter.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
374 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
375 * @param topCenter the control to be displayed in the top center or null
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
376 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
377 * @exception DWTException <ul>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
378 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
379 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
380 * <li>ERROR_INVALID_ARGUMENT - if the control is not a child of this ViewForm</li>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
381 * </ul>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
382 */
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
383 public void setTopCenter(Control topCenter) {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
384 checkWidget();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
385 if (topCenter !is null && topCenter.getParent() !is this) {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
386 DWT.error(DWT.ERROR_INVALID_ARGUMENT);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
387 }
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
388 if (this.topCenter !is null && !this.topCenter.isDisposed()) {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
389 Point size = this.topCenter.getSize();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
390 this.topCenter.setLocation(OFFSCREEN - size.x, OFFSCREEN - size.y);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
391 }
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
392 this.topCenter = topCenter;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
393 layout(false);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
394 }
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
395 /**
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
396 * Set the control that appears in the top left corner of the pane.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
397 * Typically this is a label such as CLabel.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
398 * The topLeft is optional. Setting the top left control to null will remove it from
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
399 * the pane - however, the creator of the control must dispose of the control.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
400 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
401 * @param c the control to be displayed in the top left corner or null
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
402 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
403 * @exception DWTException <ul>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
404 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
405 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
406 * <li>ERROR_INVALID_ARGUMENT - if the control is not a child of this ViewForm</li>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
407 * </ul>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
408 */
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
409 public void setTopLeft(Control c) {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
410 checkWidget();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
411 if (c !is null && c.getParent() !is this) {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
412 DWT.error(DWT.ERROR_INVALID_ARGUMENT);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
413 }
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
414 if (this.topLeft !is null && !this.topLeft.isDisposed()) {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
415 Point size = this.topLeft.getSize();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
416 this.topLeft.setLocation(OFFSCREEN - size.x, OFFSCREEN - size.y);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
417 }
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
418 this.topLeft = c;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
419 layout(false);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
420 }
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
421 /**
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
422 * Set the control that appears in the top right corner of the pane.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
423 * Typically this is a Close button or a composite with a Menu and Close button.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
424 * The topRight is optional. Setting the top right control to null will remove it from
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
425 * the pane - however, the creator of the control must dispose of the control.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
426 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
427 * @param c the control to be displayed in the top right corner or null
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
428 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
429 * @exception DWTException <ul>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
430 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
431 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
432 * <li>ERROR_INVALID_ARGUMENT - if the control is not a child of this ViewForm</li>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
433 * </ul>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
434 */
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
435 public void setTopRight(Control c) {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
436 checkWidget();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
437 if (c !is null && c.getParent() !is this) {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
438 DWT.error(DWT.ERROR_INVALID_ARGUMENT);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
439 }
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
440 if (this.topRight !is null && !this.topRight.isDisposed()) {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
441 Point size = this.topRight.getSize();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
442 this.topRight.setLocation(OFFSCREEN - size.x, OFFSCREEN - size.y);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
443 }
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
444 this.topRight = c;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
445 layout(false);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
446 }
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
447 /**
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
448 * Specify whether the border should be displayed or not.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
449 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
450 * @param show true if the border should be displayed
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
451 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
452 * @exception DWTException <ul>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
453 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
454 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
455 * </ul>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
456 */
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
457 public void setBorderVisible(bool show) {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
458 checkWidget();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
459 if (showBorder is show) return;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
460
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
461 showBorder = show;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
462 if (showBorder) {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
463 borderLeft = borderTop = borderRight = borderBottom = 1;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
464 if ((getStyle() & DWT.FLAT)is 0) highlight = 2;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
465 } else {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
466 borderBottom = borderTop = borderLeft = borderRight = 0;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
467 highlight = 0;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
468 }
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
469 layout(false);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
470 redraw();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
471 }
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
472 /**
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
473 * If true, the topCenter will always appear on a separate line by itself, otherwise the
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
474 * topCenter will appear in the top row if there is room and will be moved to the second row if
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
475 * required.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
476 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
477 * @param show true if the topCenter will always appear on a separate line by itself
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
478 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
479 * @exception DWTException <ul>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
480 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
481 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
482 * </ul>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
483 */
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
484 public void setTopCenterSeparate(bool show) {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
485 checkWidget();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
486 separateTopCenter = show;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
487 layout(false);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
488 }
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
489 }