Mercurial > projects > dwt-addons
annotate dwtx/ui/internal/forms/widgets/SWTUtil.d @ 77:26c6c9dfd13c
ui.forms compile, just FormTextModel with xml reimpl left todo
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sat, 24 May 2008 06:59:31 +0200 |
parents | 5d489b9f966c |
children |
rev | line source |
---|---|
75 | 1 /******************************************************************************* |
2 * Copyright (c) 2000, 2005 IBM Corporation and others. | |
3 * All rights reserved. This program and the accompanying materials | |
4 * are made available under the terms of the Eclipse Public License v1.0 | |
5 * which accompanies this distribution, and is available at | |
6 * http://www.eclipse.org/legal/epl-v10.html | |
7 * | |
8 * Contributors: | |
9 * IBM Corporation - initial API and implementation | |
10 * Port to the D programming language: | |
11 * Frank Benoit <benoit@tionex.de> | |
12 *******************************************************************************/ | |
13 module dwtx.ui.internal.forms.widgets.SWTUtil; | |
14 import dwt.dnd.DragSource; | |
15 import dwt.dnd.DropTarget; | |
16 import dwt.widgets.Caret; | |
17 import dwt.widgets.Control; | |
18 import dwt.widgets.Display; | |
19 import dwt.widgets.Menu; | |
20 import dwt.widgets.ScrollBar; | |
21 import dwt.widgets.Shell; | |
22 import dwt.widgets.Widget; | |
23 | |
24 /** | |
77
26c6c9dfd13c
ui.forms compile, just FormTextModel with xml reimpl left todo
Frank Benoit <benoit@tionex.de>
parents:
75
diff
changeset
|
25 * Utility class to simplify access to some DWT resources. |
75 | 26 */ |
27 public class SWTUtil { | |
28 | |
29 /** | |
30 * Returns the standard display to be used. The method first checks, if | |
31 * the thread calling this method has an associated disaply. If so, this | |
32 * display is returned. Otherwise the method returns the default display. | |
33 */ | |
34 public static Display getStandardDisplay() { | |
35 Display display; | |
36 display = Display.getCurrent(); | |
37 if (display is null) | |
38 display = Display.getDefault(); | |
39 return display; | |
40 } | |
41 | |
42 /** | |
43 * Returns the shell for the given widget. If the widget doesn't represent | |
44 * a DWT object that manage a shell, <code>null</code> is returned. | |
77
26c6c9dfd13c
ui.forms compile, just FormTextModel with xml reimpl left todo
Frank Benoit <benoit@tionex.de>
parents:
75
diff
changeset
|
45 * |
75 | 46 * @return the shell for the given widget |
47 */ | |
48 public static Shell getShell(Widget widget) { | |
77
26c6c9dfd13c
ui.forms compile, just FormTextModel with xml reimpl left todo
Frank Benoit <benoit@tionex.de>
parents:
75
diff
changeset
|
49 if (null !is cast(Control)widget ) |
26c6c9dfd13c
ui.forms compile, just FormTextModel with xml reimpl left todo
Frank Benoit <benoit@tionex.de>
parents:
75
diff
changeset
|
50 return (cast(Control) widget).getShell(); |
26c6c9dfd13c
ui.forms compile, just FormTextModel with xml reimpl left todo
Frank Benoit <benoit@tionex.de>
parents:
75
diff
changeset
|
51 if (null !is cast(Caret)widget ) |
26c6c9dfd13c
ui.forms compile, just FormTextModel with xml reimpl left todo
Frank Benoit <benoit@tionex.de>
parents:
75
diff
changeset
|
52 return (cast(Caret) widget).getParent().getShell(); |
26c6c9dfd13c
ui.forms compile, just FormTextModel with xml reimpl left todo
Frank Benoit <benoit@tionex.de>
parents:
75
diff
changeset
|
53 if (null !is cast(DragSource)widget ) |
26c6c9dfd13c
ui.forms compile, just FormTextModel with xml reimpl left todo
Frank Benoit <benoit@tionex.de>
parents:
75
diff
changeset
|
54 return (cast(DragSource) widget).getControl().getShell(); |
26c6c9dfd13c
ui.forms compile, just FormTextModel with xml reimpl left todo
Frank Benoit <benoit@tionex.de>
parents:
75
diff
changeset
|
55 if (null !is cast(DropTarget)widget ) |
26c6c9dfd13c
ui.forms compile, just FormTextModel with xml reimpl left todo
Frank Benoit <benoit@tionex.de>
parents:
75
diff
changeset
|
56 return (cast(DropTarget) widget).getControl().getShell(); |
26c6c9dfd13c
ui.forms compile, just FormTextModel with xml reimpl left todo
Frank Benoit <benoit@tionex.de>
parents:
75
diff
changeset
|
57 if (null !is cast(Menu)widget ) |
26c6c9dfd13c
ui.forms compile, just FormTextModel with xml reimpl left todo
Frank Benoit <benoit@tionex.de>
parents:
75
diff
changeset
|
58 return (cast(Menu) widget).getParent().getShell(); |
26c6c9dfd13c
ui.forms compile, just FormTextModel with xml reimpl left todo
Frank Benoit <benoit@tionex.de>
parents:
75
diff
changeset
|
59 if (null !is cast(ScrollBar)widget ) |
26c6c9dfd13c
ui.forms compile, just FormTextModel with xml reimpl left todo
Frank Benoit <benoit@tionex.de>
parents:
75
diff
changeset
|
60 return (cast(ScrollBar) widget).getParent().getShell(); |
75 | 61 |
62 return null; | |
63 } | |
64 } |