annotate org.eclipse.swt.win32.win32.x86/src/org/eclipse/swt/widgets/Dialog.d @ 0:6dd524f61e62

add dwt win and basic java stuff
author Frank Benoit <benoit@tionex.de>
date Mon, 02 Mar 2009 14:44:16 +0100
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
1 /*******************************************************************************
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
2 * Copyright (c) 2000, 2008 IBM Corporation and others.
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
3 * All rights reserved. This program and the accompanying materials
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
4 * are made available under the terms of the Eclipse Public License v1.0
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
5 * which accompanies this distribution, and is available at
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
6 * http://www.eclipse.org/legal/epl-v10.html
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
7 *
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
8 * Contributors:
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
9 * IBM Corporation - initial API and implementation
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
10 * Port to the D programming language:
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
11 * Frank Benoit <benoit@tionex.de>
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
12 *******************************************************************************/
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
13 module org.eclipse.swt.widgets.Dialog;
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
14
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
15
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
16 import org.eclipse.swt.SWT;
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
17 import org.eclipse.swt.SWTException;
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
18 import org.eclipse.swt.widgets.Shell;
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
19 import org.eclipse.swt.widgets.Display;
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
20 import org.eclipse.swt.widgets.Widget;
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
21 import java.lang.all;
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
22
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
23 /**
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
24 * This class is the abstract superclass of the classes
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
25 * that represent the built in platform dialogs.
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
26 * A <code>Dialog</code> typically contains other widgets
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
27 * that are not accessible. A <code>Dialog</code> is not
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
28 * a <code>Widget</code>.
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
29 * <p>
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
30 * This class can also be used as the abstract superclass
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
31 * for user-designed dialogs. Such dialogs usually consist
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
32 * of a Shell with child widgets. The basic template for a
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
33 * user-defined dialog typically looks something like this:
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
34 * <pre><code>
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
35 * public class MyDialog extends Dialog {
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
36 * Object result;
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
37 *
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
38 * public MyDialog (Shell parent, int style) {
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
39 * super (parent, style);
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
40 * }
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
41 * public MyDialog (Shell parent) {
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
42 * this (parent, 0); // your default style bits go here (not the Shell's style bits)
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
43 * }
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
44 * public Object open () {
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
45 * Shell parent = getParent();
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
46 * Shell shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
47 * shell.setText(getText());
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
48 * // Your code goes here (widget creation, set result, etc).
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
49 * shell.open();
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
50 * Display display = parent.getDisplay();
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
51 * while (!shell.isDisposed()) {
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
52 * if (!display.readAndDispatch()) display.sleep();
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
53 * }
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
54 * return result;
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
55 * }
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
56 * }
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
57 * </pre></code>
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
58 * <p>
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
59 * Note: The <em>modality</em> styles supported by this class
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
60 * are treated as <em>HINT</em>s, because not all are supported
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
61 * by every subclass on every platform. If a modality style is
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
62 * not supported, it is "upgraded" to a more restrictive modality
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
63 * style that is supported. For example, if <code>PRIMARY_MODAL</code>
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
64 * is not supported by a particular dialog, it would be upgraded to
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
65 * <code>APPLICATION_MODAL</code>. In addition, as is the case
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
66 * for shells, the window manager for the desktop on which the
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
67 * instance is visible has ultimate control over the appearance
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
68 * and behavior of the instance, including its modality.
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
69 * <dl>
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
70 * <dt><b>Styles:</b></dt>
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
71 * <dd>APPLICATION_MODAL, PRIMARY_MODAL, SYSTEM_MODAL</dd>
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
72 * <dt><b>Events:</b></dt>
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
73 * <dd>(none)</dd>
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
74 * </dl>
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
75 * <p>
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
76 * Note: Only one of the styles APPLICATION_MODAL, PRIMARY_MODAL,
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
77 * and SYSTEM_MODAL may be specified.
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
78 * </p>
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
79 *
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
80 * @see Shell
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
81 * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ControlExample</a>
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
82 * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
83 */
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
84
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
85 public abstract class Dialog {
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
86 int style;
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
87 Shell parent;
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
88 String title;
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
89
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
90 /**
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
91 * Constructs a new instance of this class given only its
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
92 * parent.
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
93 *
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
94 * @param parent a shell which will be the parent of the new instance
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
95 *
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
96 * @exception IllegalArgumentException <ul>
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
97 * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
98 * </ul>
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
99 * @exception SWTException <ul>
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
100 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
101 * </ul>
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
102 */
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
103 public this (Shell parent) {
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
104 this (parent, SWT.PRIMARY_MODAL);
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
105 }
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
106
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
107 /**
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
108 * Constructs a new instance of this class given its parent
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
109 * and a style value describing its behavior and appearance.
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
110 * <p>
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
111 * The style value is either one of the style constants defined in
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
112 * class <code>SWT</code> which is applicable to instances of this
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
113 * class, or must be built by <em>bitwise OR</em>'ing together
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
114 * (that is, using the <code>int</code> "|" operator) two or more
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
115 * of those <code>SWT</code> style constants. The class description
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
116 * lists the style constants that are applicable to the class.
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
117 * Style bits are also inherited from superclasses.
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
118 *
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
119 * @param parent a shell which will be the parent of the new instance
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
120 * @param style the style of dialog to construct
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
121 *
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
122 * @exception IllegalArgumentException <ul>
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
123 * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
124 * </ul>
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
125 * @exception SWTException <ul>
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
126 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
127 * </ul>
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
128 *
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
129 * @see SWT#PRIMARY_MODAL
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
130 * @see SWT#APPLICATION_MODAL
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
131 * @see SWT#SYSTEM_MODAL
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
132 */
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
133 public this (Shell parent, int style) {
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
134 checkParent (parent);
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
135 this.parent = parent;
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
136 this.style = style;
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
137 title = "";
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
138 }
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
139
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
140 /**
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
141 * Checks that this class can be subclassed.
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
142 * <p>
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
143 * IMPORTANT: See the comment in <code>Widget.checkSubclass()</code>.
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
144 * </p>
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
145 *
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
146 * @exception SWTException <ul>
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
147 * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
148 * </ul>
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
149 *
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
150 * @see Widget#checkSubclass
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
151 */
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
152 protected void checkSubclass () {
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
153 //PORTING_TODO: implement Display.isValidClass and Class?
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
154 /+if (!Display.isValidClass (getClass ())) {
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
155 error (SWT.ERROR_INVALID_SUBCLASS);
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
156 }+/
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
157 }
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
158
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
159 /**
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
160 * Throws an exception if the specified widget can not be
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
161 * used as a parent for the receiver.
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
162 *
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
163 * @exception IllegalArgumentException <ul>
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
164 * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
165 * <li>ERROR_INVALID_ARGUMENT - if the parent is disposed</li>
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
166 * </ul>
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
167 * @exception SWTException <ul>
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
168 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
169 * </ul>
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
170 */
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
171 void checkParent (Shell parent) {
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
172 if (parent is null) error (SWT.ERROR_NULL_ARGUMENT);
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
173 parent.checkWidget ();
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
174 }
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
175
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
176 static int checkStyle (Shell parent, int style) {
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
177 if ((style & (SWT.PRIMARY_MODAL | SWT.APPLICATION_MODAL | SWT.SYSTEM_MODAL)) is 0) {
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
178 style |= SWT.APPLICATION_MODAL;
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
179 }
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
180 style &= ~SWT.MIRRORED;
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
181 if ((style & (SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT)) is 0) {
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
182 if (parent !is null) {
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
183 if ((parent.style & SWT.LEFT_TO_RIGHT) !is 0) style |= SWT.LEFT_TO_RIGHT;
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
184 if ((parent.style & SWT.RIGHT_TO_LEFT) !is 0) style |= SWT.RIGHT_TO_LEFT;
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
185 }
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
186 }
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
187 return Widget.checkBits (style, SWT.LEFT_TO_RIGHT, SWT.RIGHT_TO_LEFT, 0, 0, 0, 0);
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
188 }
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
189
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
190 /**
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
191 * Does whatever dialog specific cleanup is required, and then
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
192 * uses the code in <code>SWTError.error</code> to handle the error.
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
193 *
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
194 * @param code the descriptive error code
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
195 *
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
196 * @see SWT#error(int)
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
197 */
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
198 void error (int code) {
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
199 SWT.error(code);
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
200 }
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
201
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
202 /**
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
203 * Returns the receiver's parent, which must be a <code>Shell</code>
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
204 * or null.
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
205 *
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
206 * @return the receiver's parent
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
207 *
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
208 * @exception SWTException <ul>
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
209 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
210 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
211 * </ul>
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
212 */
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
213 public Shell getParent () {
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
214 return parent;
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
215 }
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
216
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
217 /**
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
218 * Returns the receiver's style information.
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
219 * <p>
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
220 * Note that, the value which is returned by this method <em>may
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
221 * not match</em> the value which was provided to the constructor
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
222 * when the receiver was created.
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
223 * </p>
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
224 *
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
225 * @return the style bits
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
226 *
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
227 * @exception SWTException <ul>
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
228 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
229 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
230 * </ul>
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
231 */
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
232 public int getStyle () {
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
233 return style;
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
234 }
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
235
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
236 /**
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
237 * Returns the receiver's text, which is the string that the
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
238 * window manager will typically display as the receiver's
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
239 * <em>title</em>. If the text has not previously been set,
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
240 * returns an empty string.
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
241 *
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
242 * @return the text
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
243 *
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
244 * @exception SWTException <ul>
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
245 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
246 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
247 * </ul>
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
248 */
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
249 public String getText () {
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
250 return title;
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
251 }
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
252
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
253 /**
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
254 * Sets the receiver's text, which is the string that the
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
255 * window manager will typically display as the receiver's
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
256 * <em>title</em>, to the argument, which must not be null.
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
257 *
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
258 * @param string the new text
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
259 *
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
260 * @exception SWTException <ul>
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
261 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
262 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
263 * </ul>
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
264 */
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
265 public void setText (String string) {
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
266 // SWT extension: allow null string
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
267 //if (string is null) error (SWT.ERROR_NULL_ARGUMENT);
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
268 title = string;
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
269 }
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
270
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
271 }