FILE COMPARISON
Produced: 2/18/2011 1:23:46 PM
   
Mode:  All Lines  
   
Left file: C:\Documents and Settings\krollins\My Documents\Admin\OpenSource\eRCP\eSWT\current\source\modified\original\Decorations.java  
Right file: C:\Documents and Settings\krollins\My Documents\Admin\OpenSource\eRCP\eSWT\current\source\modified\Decorations.java  
1 /******************************************************************************* = 1 /*******************************************************************************
2 * Copyright (c) 2000, 2005 IBM Corporation and others.   2 * Copyright (c) 2000, 2005 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials   3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0   4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at   5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html   6 * http://www.eclipse.org/legal/epl-v10.html
7 *   7 *
8 * Contributors:   8 * Contributors:
9 *     IBM Corporation - initial API and implementation   9 *     IBM Corporation - initial API and implementation
10 *******************************************************************************/   10 *******************************************************************************/
    <> 11 /*******************************************************************************
      12 * Additions/modifications to this source file by Oracle America, Inc. 2011
      13 *******************************************************************************/
11 package org.eclipse.swt.widgets; = 14 package org.eclipse.swt.widgets;
12     15  
13   16
14 import org.eclipse.swt.*;   17 import org.eclipse.swt.*;
15 import org.eclipse.swt.graphics.*;   18 import org.eclipse.swt.graphics.*;
16     19  
17 import com.ibm.ugl.eswt.*;   20 import com.ibm.ugl.eswt.*;
18     21  
19 /**   22 /**
20 * Instances of this class provide the appearance and   23 * Instances of this class provide the appearance and
21 * behavior of <code>Shells</code>, but are not top   24 * behavior of <code>Shells</code>, but are not top
22 * level shells or dialogs. Class <code>Shell</code>   25 * level shells or dialogs. Class <code>Shell</code>
23 * shares a significant amount of code with this class,   26 * shares a significant amount of code with this class,
24 * and is a subclass.   27 * and is a subclass.
25 * <p>   28 * <p>
26 * IMPORTANT: This class was intended to be abstract and   29 * IMPORTANT: This class was intended to be abstract and
27 * should <em>never</em> be referenced or instantiated.   30 * should <em>never</em> be referenced or instantiated.
28 * Instead, the class <code>Shell</code> should be used.   31 * Instead, the class <code>Shell</code> should be used.
29 * </p>   32 * </p>
30 * <p>   33 * <p>
31 * Instances are always displayed in one of the maximized,   34 * Instances are always displayed in one of the maximized,
32 * minimized or normal states:   35 * minimized or normal states:
33 * <ul>   36 * <ul>
34 * <li>   37 * <li>
35 * When an instance is marked as <em>maximized</em>, the   38 * When an instance is marked as <em>maximized</em>, the
36 * window manager will typically resize it to fill the   39 * window manager will typically resize it to fill the
37 * entire visible area of the display, and the instance   40 * entire visible area of the display, and the instance
38 * is usually put in a state where it can not be resized   41 * is usually put in a state where it can not be resized
39 * (even if it has style <code>RESIZE</code>) until it is   42 * (even if it has style <code>RESIZE</code>) until it is
40 * no longer maximized.   43 * no longer maximized.
41 * </li><li>   44 * </li><li>
42 * When an instance is in the <em>normal</em> state (neither   45 * When an instance is in the <em>normal</em> state (neither
43 * maximized or minimized), its appearance is controlled by   46 * maximized or minimized), its appearance is controlled by
44 * the style constants which were specified when it was created   47 * the style constants which were specified when it was created
45 * and the restrictions of the window manager (see below).   48 * and the restrictions of the window manager (see below).
46 * </li><li>   49 * </li><li>
47 * When an instance has been marked as <em>minimized</em>,   50 * When an instance has been marked as <em>minimized</em>,
48 * its contents (client area) will usually not be visible,   51 * its contents (client area) will usually not be visible,
49 * and depending on the window manager, it may be   52 * and depending on the window manager, it may be
50 * "iconified" (that is, replaced on the desktop by a small   53 * "iconified" (that is, replaced on the desktop by a small
51 * simplified representation of itself), relocated to a   54 * simplified representation of itself), relocated to a
52 * distinguished area of the screen, or hidden. Combinations   55 * distinguished area of the screen, or hidden. Combinations
53 * of these changes are also possible.   56 * of these changes are also possible.
54 * </li>   57 * </li>
55 * </ul>   58 * </ul>
56 * </p>   59 * </p>
57 * Note: The styles supported by this class must be treated   60 * Note: The styles supported by this class must be treated
58 * as <em>HINT</em>s, since the window manager for the   61 * as <em>HINT</em>s, since the window manager for the
59 * desktop on which the instance is visible has ultimate   62 * desktop on which the instance is visible has ultimate
60 * control over the appearance and behavior of decorations.   63 * control over the appearance and behavior of decorations.
61 * For example, some window managers only support resizable   64 * For example, some window managers only support resizable
62 * windows and will always assume the RESIZE style, even if   65 * windows and will always assume the RESIZE style, even if
63 * it is not set.   66 * it is not set.
64 * <dl>   67 * <dl>
65 * <dt><b>Styles:</b></dt>   68 * <dt><b>Styles:</b></dt>
66 * <dd>BORDER, CLOSE, MIN, MAX, NO_TRIM, RESIZE, TITLE, ON_TOP</dd>   69 * <dd>BORDER, CLOSE, MIN, MAX, NO_TRIM, RESIZE, TITLE, ON_TOP</dd>
67 * <dt><b>Events:</b></dt>   70 * <dt><b>Events:</b></dt>
68 * <dd>(none)</dd>   71 * <dd>(none)</dd>
69 * </dl>   72 * </dl>
70 * Class <code>SWT</code> provides two "convenience constants"   73 * Class <code>SWT</code> provides two "convenience constants"
71 * for the most commonly required style combinations:   74 * for the most commonly required style combinations:
72 * <dl>   75 * <dl>
73 * <dt><code>SHELL_TRIM</code></dt>   76 * <dt><code>SHELL_TRIM</code></dt>
74 * <dd>   77 * <dd>
75 * the result of combining the constants which are required   78 * the result of combining the constants which are required
76 * to produce a typical application top level shell: (that   79 * to produce a typical application top level shell: (that
77 * is, <code>CLOSE | TITLE | MIN | MAX | RESIZE</code>)   80 * is, <code>CLOSE | TITLE | MIN | MAX | RESIZE</code>)
78 * </dd>   81 * </dd>
79 * <dt><code>DIALOG_TRIM</code></dt>   82 * <dt><code>DIALOG_TRIM</code></dt>
80 * <dd>   83 * <dd>
81 * the result of combining the constants which are required   84 * the result of combining the constants which are required
82 * to produce a typical application dialog shell: (that   85 * to produce a typical application dialog shell: (that
83 * is, <code>TITLE | CLOSE | BORDER</code>)   86 * is, <code>TITLE | CLOSE | BORDER</code>)
84 * </dd>   87 * </dd>
85 * </dl>   88 * </dl>
86 * <p>   89 * <p>
87 * IMPORTANT: This class is intended to be subclassed <em>only</em>   90 * IMPORTANT: This class is intended to be subclassed <em>only</em>
88 * within the SWT implementation.   91 * within the SWT implementation.
89 * </p>   92 * </p>
90 *   93 *
91 * @see #getMinimized   94 * @see #getMinimized
92 * @see #getMaximized   95 * @see #getMaximized
93 * @see Shell   96 * @see Shell
94 * @see SWT   97 * @see SWT
95 */   98 */
96 public class Decorations extends Canvas {   99 public class Decorations extends Canvas {
97         Button saveDefault; // The first button used as the default button   100         Button saveDefault; // The first button used as the default button
98         Button currentDefault; // The current default button   101         Button currentDefault; // The current default button
99         Menu menuBar;   102         Menu menuBar;
100         Image image;   103         Image image;
101         boolean minimized, maximized;   104         boolean minimized, maximized;
102         Menu[] menus;   105         Menu[] menus;
103         String text;   106         String text;
104         Control savedFocus;   107         Control savedFocus;
105           108        
106 Decorations() {   109 Decorations() {
107         /* Do nothing */   110         /* Do nothing */
108 }   111 }
109 /**   112 /**
110 * Constructs a new instance of this class given its parent   113 * Constructs a new instance of this class given its parent
111 * and a style value describing its behavior and appearance.   114 * and a style value describing its behavior and appearance.
112 * <p>   115 * <p>
113 * The style value is either one of the style constants defined in   116 * The style value is either one of the style constants defined in
114 * class <code>SWT</code> which is applicable to instances of this   117 * class <code>SWT</code> which is applicable to instances of this
115 * class, or must be built by <em>bitwise OR</em>'ing together   118 * class, or must be built by <em>bitwise OR</em>'ing together
116 * (that is, using the <code>int</code> "|" operator) two or more   119 * (that is, using the <code>int</code> "|" operator) two or more
117 * of those <code>SWT</code> style constants. The class description   120 * of those <code>SWT</code> style constants. The class description
118 * lists the style constants that are applicable to the class.   121 * lists the style constants that are applicable to the class.
119 * Style bits are also inherited from superclasses.   122 * Style bits are also inherited from superclasses.
120 * </p>   123 * </p>
121 *   124 *
122 * @param parent a composite control which will be the parent of the new instance (cannot be null)   125 * @param parent a composite control which will be the parent of the new instance (cannot be null)
123 * @param style the style of control to construct   126 * @param style the style of control to construct
124 *   127 *
125 * @exception IllegalArgumentException <ul>   128 * @exception IllegalArgumentException <ul>
126 *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>   129 *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
127 * </ul>   130 * </ul>
128 * @exception SWTException <ul>   131 * @exception SWTException <ul>
129 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>   132 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
130 *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>   133 *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
131 * </ul>   134 * </ul>
132 *   135 *
133 * @see SWT#BORDER   136 * @see SWT#BORDER
134 * @see SWT#CLOSE   137 * @see SWT#CLOSE
135 * @see SWT#MIN   138 * @see SWT#MIN
136 * @see SWT#MAX   139 * @see SWT#MAX
137 * @see SWT#RESIZE   140 * @see SWT#RESIZE
138 * @see SWT#TITLE   141 * @see SWT#TITLE
139 * @see SWT#NO_TRIM   142 * @see SWT#NO_TRIM
140 * @see SWT#SHELL_TRIM   143 * @see SWT#SHELL_TRIM
141 * @see SWT#DIALOG_TRIM   144 * @see SWT#DIALOG_TRIM
142 * @see SWT#ON_TOP   145 * @see SWT#ON_TOP
143 * @see Widget#checkSubclass   146 * @see Widget#checkSubclass
144 * @see Widget#getStyle   147 * @see Widget#getStyle
145 */   148 */
146 public Decorations(Composite parent, int style) {   149 public Decorations(Composite parent, int style) {
147         super(parent, style);   150         super(parent, style);
148 }   151 }
149 void add (Menu menu) {   152 void add (Menu menu) {
150         if (menus == null) menus = new Menu [4];   153         if (menus == null) menus = new Menu [4];
151         for (int i=0; i<menus.length; i++) {   154         for (int i=0; i<menus.length; i++) {
152                 if (menus [i] == null) {   155                 if (menus [i] == null) {
153                         menus [i] = menu;   156                         menus [i] = menu;
154                         return;   157                         return;
155                 }   158                 }
156         }   159         }
157         Menu [] newMenus = new Menu [menus.length + 4];   160         Menu [] newMenus = new Menu [menus.length + 4];
158         newMenus [menus.length] = menu;   161         newMenus [menus.length] = menu;
159         System.arraycopy (menus, 0, newMenus, 0, menus.length);   162         System.arraycopy (menus, 0, newMenus, 0, menus.length);
160         menus = newMenus;   163         menus = newMenus;
161 }   164 }
162     165  
163 static int checkStyle(int style) {   166 static int checkStyle(int style) {
    <> 167         if ((style & (SWT.NO_TRIM)) == 0) {    
164         // Does SWT.MENU really imply SWT.TITLE???   168                 // Does SWT.MENU really imply SWT.TITLE???     
165         if ((style & (SWT.MENU | SWT.MIN | SWT.MAX | SWT.CLOSE)) != 0) {   169                 if ((style & (SWT.MENU | SWT.MIN | SWT.MAX | SWT.CLOSE)) != 0) {
166                 style |= SWT.TITLE;   170                         style |= SWT.TITLE;
      171                 }
167         } = 172         }
168         return style;   173         return style;
169 }   174 }
170     175  
171 Control computeTabGroup() {   176 Control computeTabGroup() {
172         return this;   177         return this;
173 }   178 }
174 Control computeTabRoot() {   179 Control computeTabRoot() {
175         return this;   180         return this;
176 }   181 }
177     182  
178 /**   183 /**
179 * Returns the receiver's default button if one had   184 * Returns the receiver's default button if one had
180 * previously been set, otherwise returns null.   185 * previously been set, otherwise returns null.
181 *   186 *
182 * @return the default button or null   187 * @return the default button or null
183 *   188 *
184 * @exception SWTException <ul>   189 * @exception SWTException <ul>
185 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>   190 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
186 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>   191 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
187 * </ul>   192 * </ul>
188 *   193 *
189 * @see #setDefaultButton   194 * @see #setDefaultButton
190 */   195 */
191 public Button getDefaultButton() {   196 public Button getDefaultButton() {
192         checkWidget();   197         checkWidget();
193           198        
194         return currentDefault;   199         return currentDefault;
195 }   200 }
196 /**   201 /**
197 * Returns the receiver's image if it had previously been   202 * Returns the receiver's image if it had previously been
198 * set using <code>setImage()</code>. The image is typically   203 * set using <code>setImage()</code>. The image is typically
199 * displayed by the window manager when the instance is   204 * displayed by the window manager when the instance is
200 * marked as iconified, and may also be displayed somewhere   205 * marked as iconified, and may also be displayed somewhere
201 * in the trim when the instance is in normal or maximized   206 * in the trim when the instance is in normal or maximized
202 * states.   207 * states.
203 * <p>   208 * <p>
204 * Note: This method will return null if called before   209 * Note: This method will return null if called before
205 * <code>setImage()</code> is called. It does not provide   210 * <code>setImage()</code> is called. It does not provide
206 * access to a window manager provided, "default" image   211 * access to a window manager provided, "default" image
207 * even if one exists.   212 * even if one exists.
208 * </p>   213 * </p>
209 *   214 *
210 * @return the image   215 * @return the image
211 *   216 *
212 * @exception SWTException <ul>   217 * @exception SWTException <ul>
213 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>   218 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
214 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>   219 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
215 * </ul>   220 * </ul>
216 */   221 */
217 public Image getImage() {   222 public Image getImage() {
218         checkWidget();   223         checkWidget();
219         return image;   224         return image;
220 }   225 }
221     226  
222 /**   227 /**
223 * Returns <code>true</code> if the receiver is currently   228 * Returns <code>true</code> if the receiver is currently
224 * maximized, and false otherwise.   229 * maximized, and false otherwise.
225 * <p>   230 * <p>
226 *   231 *
227 * @return the maximized state   232 * @return the maximized state
228 *   233 *
229 * @exception SWTException <ul>   234 * @exception SWTException <ul>
230 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>   235 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
231 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>   236 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
232 * </ul>   237 * </ul>
233 *   238 *
234 * @see #setMaximized   239 * @see #setMaximized
235 */   240 */
236 public boolean getMaximized() {   241 public boolean getMaximized() {
237         checkWidget();   242         checkWidget();
238         return maximized;   243         return maximized;
239 }   244 }
240     245  
241 /**   246 /**
242 * Returns the receiver's menu bar if one had previously   247 * Returns the receiver's menu bar if one had previously
243 * been set, otherwise returns null.   248 * been set, otherwise returns null.
244 *   249 *
245 * @return the menu bar or null   250 * @return the menu bar or null
246 *   251 *
247 * @exception SWTException <ul>   252 * @exception SWTException <ul>
248 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>   253 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
249 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>   254 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
250 * </ul>   255 * </ul>
251 */   256 */
252 public Menu getMenuBar() {   257 public Menu getMenuBar() {
253         checkWidget();   258         checkWidget();
254         return menuBar;   259         return menuBar;
255 }   260 }
256     261  
257 /**   262 /**
258 * Returns <code>true</code> if the receiver is currently   263 * Returns <code>true</code> if the receiver is currently
259 * minimized, and false otherwise.   264 * minimized, and false otherwise.
260 * <p>   265 * <p>
261 *   266 *
262 * @return the minimized state   267 * @return the minimized state
263 *   268 *
264 * @exception SWTException <ul>   269 * @exception SWTException <ul>
265 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>   270 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
266 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>   271 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
267 * </ul>   272 * </ul>
268 *   273 *
269 * @see #setMinimized   274 * @see #setMinimized
270 */   275 */
271 public boolean getMinimized() {   276 public boolean getMinimized() {
272         checkWidget();   277         checkWidget();
273         return minimized;   278         return minimized;
274 }   279 }
275     280  
276 protected int internal_getNativeStyle() {   281 protected int internal_getNativeStyle() {
277         int nativeStyle = super.internal_getNativeStyle();   282         int nativeStyle = super.internal_getNativeStyle();
278           283        
279         // According to the SWT comment, NO_TRIM will override all other styles   284         // According to the SWT comment, NO_TRIM will override all other styles
280         if ((internal_style & SWT.NO_TRIM) == 0) {   285         if ((internal_style & SWT.NO_TRIM) == 0) {
281                 if ((internal_style & SWT.CLOSE) == SWT.CLOSE) {   286                 if ((internal_style & SWT.CLOSE) == SWT.CLOSE) {
282                         nativeStyle |= OS.STYLE_CLOSE;   287                         nativeStyle |= OS.STYLE_CLOSE;
283                 }   288                 }
284                 if ((internal_style & SWT.MIN) == SWT.MIN) {   289                 if ((internal_style & SWT.MIN) == SWT.MIN) {
285                         nativeStyle |= OS.STYLE_MIN;   290                         nativeStyle |= OS.STYLE_MIN;
286                 }   291                 }
287                 if ((internal_style & SWT.MAX) == SWT.MAX) {   292                 if ((internal_style & SWT.MAX) == SWT.MAX) {
288                         nativeStyle |= OS.STYLE_MAX;   293                         nativeStyle |= OS.STYLE_MAX;
289                 }   294                 }
290                 if ((internal_style & SWT.TITLE) == SWT.TITLE) {   295                 if ((internal_style & SWT.TITLE) == SWT.TITLE) {
291                         nativeStyle |= OS.STYLE_TITLE;   296                         nativeStyle |= OS.STYLE_TITLE;
292                 }   297                 }
293                   298                
294                 // Don't convert the RESIZE style. Resize is set using Shell_SetResizable API.   299                 // Don't convert the RESIZE style. Resize is set using Shell_SetResizable API.
295         }   300         }
296         return nativeStyle;   301         return nativeStyle;
297 }   302 }
298     303  
299 /**   304 /**
300 * Returns the receiver's text, which is the string that the   305 * Returns the receiver's text, which is the string that the
301 * window manager will typically display as the receiver's   306 * window manager will typically display as the receiver's
302 * <em>title</em>. If the text has not previously been set,   307 * <em>title</em>. If the text has not previously been set,
303 * returns an empty string.   308 * returns an empty string.
304 *   309 *
305 * @return the text   310 * @return the text
306 *   311 *
307 * @exception SWTException <ul>   312 * @exception SWTException <ul>
308 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>   313 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
309 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>   314 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
310 * </ul>   315 * </ul>
311 */   316 */
312 public String getText() {   317 public String getText() {
313         checkWidget();   318         checkWidget();
314         return text;   319         return text;
315 }   320 }
316     321  
317 boolean isTabItem () {   322 boolean isTabItem () {
318         return false;   323         return false;
319 }   324 }
320 public boolean isReparentable () {   325 public boolean isReparentable () {
321         return false;   326         return false;
322 }   327 }
323 Decorations menuShell() {   328 Decorations menuShell() {
324         return this;   329         return this;
325 }   330 }
326 void releaseWidget() {   331 void releaseWidget() {
327         saveDefault = null;   332         saveDefault = null;
328         image = null;   333         image = null;
329         if (menus != null) {   334         if (menus != null) {
330                 for (int i=0; i<menus.length; i++) {   335                 for (int i=0; i<menus.length; i++) {
331                         Menu menu = menus [i];   336                         Menu menu = menus [i];
332                         if (menu != null && !menu.isDisposed ()) menu.releaseResources ();   337                         if (menu != null && !menu.isDisposed ()) menu.releaseResources ();
333                 }   338                 }
334         }   339         }
335     340  
336         // The menubar does not need to be explicitly   341         // The menubar does not need to be explicitly
337         // disposed because when it is created it is added   342         // disposed because when it is created it is added
338         // to the list of menu's that was disposed in the   343         // to the list of menu's that was disposed in the
339         // code above   344         // code above
340         menuBar = null;   345         menuBar = null;
341         menus = null;   346         menus = null;
342         super.releaseWidget ();   347         super.releaseWidget ();
343 }   348 }
344     349  
345 void remove (Menu menu) {   350 void remove (Menu menu) {
346         if (menus == null) return;   351         if (menus == null) return;
347         for (int i=0; i<menus.length; i++) {   352         for (int i=0; i<menus.length; i++) {
348                 if (menus [i] == menu) {   353                 if (menus [i] == menu) {
349                         menus [i] = null;   354                         menus [i] = null;
350                         return;   355                         return;
351                 }   356                 }
352         }   357         }
353 }   358 }
354     359  
355 /**   360 /**
356 * If the argument is not null, sets the receiver's default   361 * If the argument is not null, sets the receiver's default
357 * button to the argument, and if the argument is null, sets   362 * button to the argument, and if the argument is null, sets
358 * the receiver's default button to the first button which   363 * the receiver's default button to the first button which
359 * was set as the receiver's default button (called the   364 * was set as the receiver's default button (called the
360 * <em>saved default button</em>). If no default button had   365 * <em>saved default button</em>). If no default button had
361 * previously been set, or the saved default button was   366 * previously been set, or the saved default button was
362 * disposed, the receiver's default button will be set to   367 * disposed, the receiver's default button will be set to
363 * null.   368 * null.
364 * <p>   369 * <p>
365 * The default button is the button that is selected when   370 * The default button is the button that is selected when
366 * the receiver is active and the user presses ENTER.   371 * the receiver is active and the user presses ENTER.
367 * </p>   372 * </p>
368 *   373 *
369 * @param button the new default button   374 * @param button the new default button
370 *   375 *
371 * @exception IllegalArgumentException <ul>   376 * @exception IllegalArgumentException <ul>
372 *    <li>ERROR_INVALID_ARGUMENT - if the button has been disposed</li>   377 *    <li>ERROR_INVALID_ARGUMENT - if the button has been disposed</li>
373 * </ul>   378 * </ul>
374 * @exception SWTException <ul>   379 * @exception SWTException <ul>
375 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>   380 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
376 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>   381 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
377 * </ul>   382 * </ul>
378 */   383 */
379 public void setDefaultButton(Button button) {   384 public void setDefaultButton(Button button) {
380         checkWidget();   385         checkWidget();
381     386  
382         // Calculate whether the incomming button or   387         // Calculate whether the incomming button or
383         // the saved button button should get to be default   388         // the saved button button should get to be default
384         Button newDefault;   389         Button newDefault;
385         if (button == null) {   390         if (button == null) {
386                 // If there is a saved default then that should   391                 // If there is a saved default then that should
387                 // be used   392                 // be used
388                 if (saveDefault != null) {   393                 if (saveDefault != null) {
389                         if (saveDefault.isDisposed()) {   394                         if (saveDefault.isDisposed()) {
390                                 saveDefault = null;   395                                 saveDefault = null;
391                                 newDefault = null;   396                                 newDefault = null;
392                         } else {   397                         } else {
393                                 newDefault = saveDefault;   398                                 newDefault = saveDefault;
394                         }   399                         }
395                 } else {   400                 } else {
396                         newDefault = null;   401                         newDefault = null;
397                 }   402                 }
398         } else {   403         } else {
399                 if (button.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);   404                 if (button.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
400                 if ((button.getStyle() & SWT.PUSH) == 0) return;   405                 if ((button.getStyle() & SWT.PUSH) == 0) return;
401                   406                
402                 newDefault = button;   407                 newDefault = button;
403         }   408         }
404           409        
405         // Update new new default button   410         // Update new new default button
406         Button defaultButton = getDefaultButton();   411         Button defaultButton = getDefaultButton();
407         if (newDefault != defaultButton) {   412         if (newDefault != defaultButton) {
408                 OS.Shell_SetDefaultButton(internal_handle, newDefault == null ? 0 : newDefault.internal_handle);   413                 OS.Shell_SetDefaultButton(internal_handle, newDefault == null ? 0 : newDefault.internal_handle);
409                   414                
410                 if (newDefault != null) newDefault.setDefault(true);   415                 if (newDefault != null) newDefault.setDefault(true);
411                 if (defaultButton != null) defaultButton.setDefault(false);   416                 if (defaultButton != null) defaultButton.setDefault(false);
412                   417                
413                 if (saveDefault == null) saveDefault = newDefault;   418                 if (saveDefault == null) saveDefault = newDefault;
414                 currentDefault = newDefault;   419                 currentDefault = newDefault;
415         }   420         }
416 }   421 }
417     422  
418 /**   423 /**
419 * Sets the receiver's image to the argument, which may   424 * Sets the receiver's image to the argument, which may
420 * be null. The image is typically displayed by the window   425 * be null. The image is typically displayed by the window
421 * manager when the instance is marked as iconified, and   426 * manager when the instance is marked as iconified, and
422 * may also be displayed somewhere in the trim when the   427 * may also be displayed somewhere in the trim when the
423 * instance is in normal or maximized states.   428 * instance is in normal or maximized states.
424 *   429 *
425 * @param image the new image (or null)   430 * @param image the new image (or null)
426 *   431 *
427 * @exception IllegalArgumentException <ul>   432 * @exception IllegalArgumentException <ul>
428 *    <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>   433 *    <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
429 * </ul>   434 * </ul>
430 * @exception SWTException <ul>   435 * @exception SWTException <ul>
431 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>   436 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
432 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>   437 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
433 * </ul>   438 * </ul>
434 */   439 */
435 public void setImage(Image image) {   440 public void setImage(Image image) {
436         checkWidget();   441         checkWidget();
437         if (image != null && image.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);   442         if (image != null && image.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
438           443        
439         this.image = image;   444         this.image = image;
440 }   445 }
441     446  
442 /**   447 /**
443 * Sets the maximized state of the receiver.   448 * Sets the maximized state of the receiver.
444 * If the argument is <code>true</code> causes the receiver   449 * If the argument is <code>true</code> causes the receiver
445 * to switch to the maximized state, and if the argument is   450 * to switch to the maximized state, and if the argument is
446 * <code>false</code> and the receiver was previously maximized,   451 * <code>false</code> and the receiver was previously maximized,
447 * causes the receiver to switch back to either the minimized   452 * causes the receiver to switch back to either the minimized
448 * or normal states.   453 * or normal states.
449 * <p>   454 * <p>
450 * Note: The result of intermixing calls to <code>setMaximized(true)</code>   455 * Note: The result of intermixing calls to <code>setMaximized(true)</code>
451 * and <code>setMinimized(true)</code> will vary by platform. Typically,   456 * and <code>setMinimized(true)</code> will vary by platform. Typically,
452 * the behavior will match the platform user's expectations, but not   457 * the behavior will match the platform user's expectations, but not
453 * always. This should be avoided if possible.   458 * always. This should be avoided if possible.
454 * </p>   459 * </p>
455 *   460 *
456 * @param maximized the new maximized state   461 * @param maximized the new maximized state
457 *   462 *
458 * @exception SWTException <ul>   463 * @exception SWTException <ul>
459 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>   464 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
460 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>   465 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
461 * </ul>   466 * </ul>
462 *   467 *
463 * @see #setMinimized   468 * @see #setMinimized
464 */   469 */
465 public void setMaximized(boolean maximized) {   470 public void setMaximized(boolean maximized) {
466         checkWidget();   471         checkWidget();
467         if (this.maximized == maximized) return;          472         if (this.maximized == maximized) return;       
468         this.maximized = maximized;   473         this.maximized = maximized;
469 }   474 }
470     475  
471 /**   476 /**
472 * Sets the receiver's menu bar to the argument, which   477 * Sets the receiver's menu bar to the argument, which
473 * may be null.   478 * may be null.
474 *   479 *
475 * @param menu the new menu bar   480 * @param menu the new menu bar
476 *   481 *
477 * @exception IllegalArgumentException <ul>   482 * @exception IllegalArgumentException <ul>
478 *    <li>ERROR_INVALID_ARGUMENT - if the menu has been disposed</li>   483 *    <li>ERROR_INVALID_ARGUMENT - if the menu has been disposed</li>
479 *    <li>ERROR_INVALID_PARENT - if the menu is not in the same widget tree</li>   484 *    <li>ERROR_INVALID_PARENT - if the menu is not in the same widget tree</li>
480 * </ul>   485 * </ul>
481 * @exception SWTException <ul>   486 * @exception SWTException <ul>
482 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>   487 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
483 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>   488 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
484 * </ul>   489 * </ul>
485 */   490 */
486 public void setMenuBar(Menu menu) {   491 public void setMenuBar(Menu menu) {
487         checkWidget();   492         checkWidget();
488         if (menuBar == menu) return;   493         if (menuBar == menu) return;
489         if (menu != null) {   494         if (menu != null) {
490                 if (menu.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);   495                 if (menu.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
491                 if ((menu.internal_style & SWT.BAR) == 0) error(SWT.ERROR_MENU_NOT_BAR);   496                 if ((menu.internal_style & SWT.BAR) == 0) error(SWT.ERROR_MENU_NOT_BAR);
492                 if (menu.parent != this) error(SWT.ERROR_INVALID_PARENT);   497                 if (menu.parent != this) error(SWT.ERROR_INVALID_PARENT);
493         }   498         }
494         menuBar = menu;   499         menuBar = menu;
495 }   500 }
496     501  
497 /**   502 /**
498 * Sets the minimized stated of the receiver.   503 * Sets the minimized stated of the receiver.
499 * If the argument is <code>true</code> causes the receiver   504 * If the argument is <code>true</code> causes the receiver
500 * to switch to the minimized state, and if the argument is   505 * to switch to the minimized state, and if the argument is
501 * <code>false</code> and the receiver was previously minimized,   506 * <code>false</code> and the receiver was previously minimized,
502 * causes the receiver to switch back to either the maximized   507 * causes the receiver to switch back to either the maximized
503 * or normal states.   508 * or normal states.
504 * <p>   509 * <p>
505 * Note: The result of intermixing calls to <code>setMaximized(true)</code>   510 * Note: The result of intermixing calls to <code>setMaximized(true)</code>
506 * and <code>setMinimized(true)</code> will vary by platform. Typically,   511 * and <code>setMinimized(true)</code> will vary by platform. Typically,
507 * the behavior will match the platform user's expectations, but not   512 * the behavior will match the platform user's expectations, but not
508 * always. This should be avoided if possible.   513 * always. This should be avoided if possible.
509 * </p>   514 * </p>
510 *   515 *
511 * @param minimized the new maximized state   516 * @param minimized the new maximized state
512 *   517 *
513 * @exception SWTException <ul>   518 * @exception SWTException <ul>
514 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>   519 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
515 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>   520 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
516 * </ul>   521 * </ul>
517 *   522 *
518 * @see #setMaximized   523 * @see #setMaximized
519 */   524 */
520 public void setMinimized(boolean minimized) {   525 public void setMinimized(boolean minimized) {
521         checkWidget();   526         checkWidget();
522         if (this.minimized == minimized) return;   527         if (this.minimized == minimized) return;
523         this.minimized = minimized;   528         this.minimized = minimized;
524 }   529 }
525     530  
526 /**   531 /**
527 * Sets the receiver's text, which is the string that the   532 * Sets the receiver's text, which is the string that the
528 * window manager will typically display as the receiver's   533 * window manager will typically display as the receiver's
529 * <em>title</em>, to the argument, which must not be null.   534 * <em>title</em>, to the argument, which must not be null.
530 *   535 *
531 * @param string the new text   536 * @param string the new text
532 *   537 *
533 * @exception IllegalArgumentException <ul>   538 * @exception IllegalArgumentException <ul>
534 *    <li>ERROR_NULL_ARGUMENT - if the text is null</li>   539 *    <li>ERROR_NULL_ARGUMENT - if the text is null</li>
535 * </ul>   540 * </ul>
536 * @exception SWTException <ul>   541 * @exception SWTException <ul>
537 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>   542 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
538 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>   543 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
539 * </ul>   544 * </ul>
540 */   545 */
541 public void setText(String string) {   546 public void setText(String string) {
542         checkWidget();   547         checkWidget();
543         if (string == null) error(SWT.ERROR_NULL_ARGUMENT);   548         if (string == null) error(SWT.ERROR_NULL_ARGUMENT);
544           549        
545         text = string;   550         text = string;
546 }   551 }
547     552  
548 /* (non-Javadoc)   553 /* (non-Javadoc)
549 * @see org.eclipse.swt.widgets.Composite#setBounds(int, int, int, int)   554 * @see org.eclipse.swt.widgets.Composite#setBounds(int, int, int, int)
550 */   555 */
551 public void setBounds(int x, int y, int width, int height) {   556 public void setBounds(int x, int y, int width, int height) {
552         super.setBounds(x, y, width, height);   557         super.setBounds(x, y, width, height);
553         minimized = false;   558         minimized = false;
554         maximized = false;   559         maximized = false;
555 }   560 }
556     561  
557 /* (non-Javadoc)   562 /* (non-Javadoc)
558 * @see org.eclipse.swt.widgets.Control#setLocation(int, int)   563 * @see org.eclipse.swt.widgets.Control#setLocation(int, int)
559 */   564 */
560 public void setLocation(int x, int y) {   565 public void setLocation(int x, int y) {
561         super.setLocation(x, y);   566         super.setLocation(x, y);
562         minimized = false;   567         minimized = false;
563         maximized = false;   568         maximized = false;
564 }   569 }
565     570  
566 boolean traverseItem(boolean next) {   571 boolean traverseItem(boolean next) {
567         return false;   572         return false;
568 }   573 }
569 boolean traverseReturn() {   574 boolean traverseReturn() {
570         Button defaultButton = getDefaultButton();   575         Button defaultButton = getDefaultButton();
571         if (defaultButton == null || defaultButton.isDisposed()) return false;   576         if (defaultButton == null || defaultButton.isDisposed()) return false;
572         if (!defaultButton.isVisible() || !defaultButton.isEnabled()) return false;   577         if (!defaultButton.isVisible() || !defaultButton.isEnabled()) return false;
573         defaultButton.click();   578         defaultButton.click();
574         return true;   579         return true;
575 }   580 }
576     581  
577 boolean restoreFocus () {   582 boolean restoreFocus () {
578         if (savedFocus != null && savedFocus.isDisposed ()) savedFocus = null;   583         if (savedFocus != null && savedFocus.isDisposed ()) savedFocus = null;
579         if (savedFocus != null && savedFocus.setSavedFocus ()) return true;   584         if (savedFocus != null && savedFocus.setSavedFocus ()) return true;
580         /*   585         /*
581         * This code is intentionally commented.  When no widget   586         * This code is intentionally commented.  When no widget
582         * has been given focus, some platforms give focus to the   587         * has been given focus, some platforms give focus to the
583         * default button.  Windows doesn't do this.   588         * default button.  Windows doesn't do this.
584         */   589         */
585 //      if (defaultButton != null && !defaultButton.isDisposed ()) {   590 //      if (defaultButton != null && !defaultButton.isDisposed ()) {
586 //              if (defaultButton.setFocus ()) return true;   591 //              if (defaultButton.setFocus ()) return true;
587 //      }   592 //      }
588         return false;   593         return false;
589 }   594 }
590     595  
591 void saveFocus () {   596 void saveFocus () {
592         Control control = display.getFocusControl ();   597         Control control = display.getFocusControl ();
593         if (control != null && control != this && this == control.menuShell ()) {   598         if (control != null && control != this && this == control.menuShell ()) {
594                 setSavedFocus (control);   599                 setSavedFocus (control);
595         }   600         }
596 }   601 }
597     602  
598 void setSavedFocus (Control control) {   603 void setSavedFocus (Control control) {
599         savedFocus = control;   604         savedFocus = control;
600 }   605 }
601     606  
602 }   607 }