Mercurial > projects > dwt-linux
comparison dwt/widgets/Tray.d @ 47:f646579f309c
Tray, Tooltip, TrayItem, Item
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Fri, 11 Jan 2008 08:34:26 +0100 |
parents | ffa3c27c4328 |
children | 8cec8f536af3 |
comparison
equal
deleted
inserted
replaced
46:8015c460f713 | 47:f646579f309c |
---|---|
7 * | 7 * |
8 * Contributors: | 8 * Contributors: |
9 * IBM Corporation - initial API and implementation | 9 * IBM Corporation - initial API and implementation |
10 *******************************************************************************/ | 10 *******************************************************************************/ |
11 module dwt.widgets.Tray; | 11 module dwt.widgets.Tray; |
12 | |
12 import dwt.widgets.Display; | 13 import dwt.widgets.Display; |
13 class Tray{ | 14 import dwt.widgets.Widget; |
14 public this( Display, int ); | 15 import dwt.widgets.TrayItem; |
15 void dispose(); | 16 import dwt.SWT; |
16 } | 17 import dwt.dwthelper.System; |
17 | |
18 /++ | |
19 import dwt.*; | |
20 | 18 |
21 /** | 19 /** |
22 * Instances of this class represent the system tray that is part | 20 * Instances of this class represent the system tray that is part |
23 * of the task bar status area on some operating systems. | 21 * of the task bar status area on some operating systems. |
24 * | 22 * |
34 * | 32 * |
35 * @see Display#getSystemTray | 33 * @see Display#getSystemTray |
36 * | 34 * |
37 * @since 3.0 | 35 * @since 3.0 |
38 */ | 36 */ |
39 public class Tray extends Widget { | 37 public class Tray : Widget { |
40 int itemCount; | 38 int itemCount; |
41 TrayItem [] items = new TrayItem [4]; | 39 TrayItem [] items; |
42 | 40 |
43 Tray (Display display, int style) { | 41 this (Display display, int style) { |
44 if (display == null) display = Display.getCurrent (); | 42 items = new TrayItem [4]; |
45 if (display == null) display = Display.getDefault (); | 43 if (display is null) display = Display.getCurrent (); |
44 if (display is null) display = Display.getDefault (); | |
46 if (!display.isValidThread ()) { | 45 if (!display.isValidThread ()) { |
47 error (SWT.ERROR_THREAD_INVALID_ACCESS); | 46 error (SWT.ERROR_THREAD_INVALID_ACCESS); |
48 } | 47 } |
49 this.display = display; | 48 this.display = display; |
50 } | 49 } |
51 | 50 |
52 void createItem (TrayItem item, int index) { | 51 void createItem (TrayItem item, int index) { |
53 if (!(0 <= index && index <= itemCount)) error (SWT.ERROR_INVALID_RANGE); | 52 if (!(0 <= index && index <= itemCount)) error (SWT.ERROR_INVALID_RANGE); |
54 if (itemCount == items.length) { | 53 if (itemCount is items.length) { |
55 TrayItem [] newItems = new TrayItem [items.length + 4]; | 54 TrayItem [] newItems = new TrayItem [items.length + 4]; |
56 System.arraycopy (items, 0, newItems, 0, items.length); | 55 System.arraycopy (items, 0, newItems, 0, items.length); |
57 items = newItems; | 56 items = newItems; |
58 } | 57 } |
59 System.arraycopy (items, index, items, index + 1, itemCount++ - index); | 58 System.arraycopy (items, index, items, index + 1, itemCount++ - index); |
61 } | 60 } |
62 | 61 |
63 void destroyItem (TrayItem item) { | 62 void destroyItem (TrayItem item) { |
64 int index = 0; | 63 int index = 0; |
65 while (index < itemCount) { | 64 while (index < itemCount) { |
66 if (items [index] == item) break; | 65 if (items [index] is item) break; |
67 index++; | 66 index++; |
68 } | 67 } |
69 if (index == itemCount) return; | 68 if (index is itemCount) return; |
70 System.arraycopy (items, index + 1, items, index, --itemCount - index); | 69 System.arraycopy (items, index + 1, items, index, --itemCount - index); |
71 items [itemCount] = null; | 70 items [itemCount] = null; |
72 } | 71 } |
73 | 72 |
74 /** | 73 /** |
128 TrayItem [] result = new TrayItem [itemCount]; | 127 TrayItem [] result = new TrayItem [itemCount]; |
129 System.arraycopy (items, 0, result, 0, result.length); | 128 System.arraycopy (items, 0, result, 0, result.length); |
130 return result; | 129 return result; |
131 } | 130 } |
132 | 131 |
133 void releaseChildren (boolean destroy) { | 132 void releaseChildren (bool destroy) { |
134 if (items != null) { | 133 if (items !is null) { |
135 for (int i=0; i<items.length; i++) { | 134 for (int i=0; i<items.length; i++) { |
136 TrayItem item = items [i]; | 135 TrayItem item = items [i]; |
137 if (item != null && !item.isDisposed ()) { | 136 if (item !is null && !item.isDisposed ()) { |
138 item.release (false); | 137 item.release (false); |
139 } | 138 } |
140 } | 139 } |
141 items = null; | 140 items = null; |
142 } | 141 } |
143 super.releaseChildren (destroy); | 142 super.releaseChildren (destroy); |
144 } | 143 } |
145 | 144 |
146 void releaseParent () { | 145 void releaseParent () { |
147 super.releaseParent (); | 146 super.releaseParent (); |
148 if (display.tray == this) display.tray = null; | 147 if (display.tray is this) display.tray = null; |
149 } | 148 } |
150 | 149 |
151 } | 150 } |
152 ++/ |