changeset 72:14663720fb36

TrayItem
author Frank Benoit <benoit@tionex.de>
date Mon, 04 Feb 2008 22:32:14 +0100
parents effe4929903f
children 42fc35b18200
files dwt/widgets/Tray.d dwt/widgets/TrayItem.d
diffstat 2 files changed, 43 insertions(+), 51 deletions(-) [+]
line wrap: on
line diff
--- a/dwt/widgets/Tray.d	Mon Feb 04 22:23:04 2008 +0100
+++ b/dwt/widgets/Tray.d	Mon Feb 04 22:32:14 2008 +0100
@@ -12,11 +12,14 @@
  *******************************************************************************/
 module dwt.widgets.Tray;
 
+import dwt.DWT;
+import dwt.dwthelper.System;
+
 import dwt.widgets.Display;
 import dwt.widgets.Widget;
 import dwt.widgets.TrayItem;
-import dwt.DWT;
-import dwt.dwthelper.System;
+
+import dwt.dwthelper.utils;
 
 /**
  * Instances of this class represent the system tray that is part
--- a/dwt/widgets/TrayItem.d	Mon Feb 04 22:23:04 2008 +0100
+++ b/dwt/widgets/TrayItem.d	Mon Feb 04 22:32:14 2008 +0100
@@ -10,34 +10,23 @@
  *******************************************************************************/
 module dwt.widgets.TrayItem;
 
-import dwt.widgets.Item;
-import dwt.widgets.Widget;
-import dwt.widgets.ToolTip;
-import dwt.internal.win32.OS;
-
-class TrayItem : Item {
-    int id;
-    public this (Widget parent, int style) {
-        super (parent, style);
-    }
-int messageProc (HWND hwnd, int msg, int wParam, int lParam) ;
-void recreate () ;
-public bool getVisible () ;
-    ToolTip toolTip;
-}
-/++
-
 import dwt.DWT;
 import dwt.DWTException;
 import dwt.events.MenuDetectListener;
 import dwt.events.SelectionEvent;
 import dwt.events.SelectionListener;
 import dwt.graphics.Image;
-import dwt.internal.win32.NOTIFYICONDATA;
-import dwt.internal.win32.NOTIFYICONDATAA;
-import dwt.internal.win32.NOTIFYICONDATAW;
 import dwt.internal.win32.OS;
-import dwt.internal.win32.TCHAR;
+
+import dwt.widgets.Item;
+import dwt.widgets.Widget;
+import dwt.widgets.ToolTip;
+import dwt.widgets.Tray;
+import dwt.widgets.TypedListener;
+import dwt.widgets.Display;
+
+import dwt.dwthelper.utils;
+
 
 /**
  * Instances of this class represent icons that can be placed on the
@@ -55,12 +44,12 @@
  *
  * @since 3.0
  */
-public class TrayItem extends Item {
+public class TrayItem : Item {
     Tray parent;
     int id;
     Image image2;
     ToolTip toolTip;
-    String toolTipText;
+    char[] toolTipText;
     bool visible = true;
 
 /**
@@ -93,7 +82,7 @@
  * @see Widget#checkSubclass
  * @see Widget#getStyle
  */
-public TrayItem (Tray parent, int style) {
+public this (Tray parent, int style) {
     super (parent, style);
     this.parent = parent;
     parent.createItem (this, parent.getItemCount ());
@@ -165,13 +154,13 @@
 }
 
 void createWidget () {
-    NOTIFYICONDATA iconData = OS.IsUnicode ? (NOTIFYICONDATA) new NOTIFYICONDATAW () : new NOTIFYICONDATAA ();
+    NOTIFYICONDATA iconData;
     iconData.cbSize = NOTIFYICONDATA.sizeof;
     iconData.uID = id = display.nextTrayId++;
     iconData.hWnd = display.hwndMessage;
     iconData.uFlags = OS.NIF_MESSAGE;
     iconData.uCallbackMessage = Display.SWT_TRAYICONMSG;
-    OS.Shell_NotifyIcon (OS.NIM_ADD, iconData);
+    OS.Shell_NotifyIcon (OS.NIM_ADD, &iconData);
 }
 
 override void destroyWidget () {
@@ -225,7 +214,7 @@
  *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
  * </ul>
  */
-public String getToolTipText () {
+public char[] getToolTipText () {
     checkWidget ();
     return toolTipText;
 }
@@ -323,7 +312,7 @@
 void recreate () {
     createWidget ();
     if (!visible) setVisible (false);
-    if (text.length () !is 0) setText (text);
+    if (text.length  !is 0) setText (text);
     if (image !is null) setImage (image);
     if (toolTipText !is null) setToolTipText (toolTipText);
 }
@@ -340,11 +329,11 @@
     if (image2 !is null) image2.dispose ();
     image2 = null;
     toolTipText = null;
-    NOTIFYICONDATA iconData = OS.IsUnicode ? (NOTIFYICONDATA) new NOTIFYICONDATAW () : new NOTIFYICONDATAA ();
+    NOTIFYICONDATA iconData;
     iconData.cbSize = NOTIFYICONDATA.sizeof;
     iconData.uID = id;
     iconData.hWnd = display.hwndMessage;
-    OS.Shell_NotifyIcon (OS.NIM_DELETE, iconData);
+    OS.Shell_NotifyIcon (OS.NIM_DELETE, &iconData);
 }
 
 /**
@@ -418,7 +407,7 @@
     super.setImage (image);
     if (image2 !is null) image2.dispose ();
     image2 = null;
-    int hIcon = 0;
+    HICON hIcon;
     Image icon = image;
     if (icon !is null) {
         switch (icon.type) {
@@ -431,13 +420,13 @@
                 break;
         }
     }
-    NOTIFYICONDATA iconData = OS.IsUnicode ? (NOTIFYICONDATA) new NOTIFYICONDATAW () : new NOTIFYICONDATAA ();
+    NOTIFYICONDATA iconData;
     iconData.cbSize = NOTIFYICONDATA.sizeof;
     iconData.uID = id;
     iconData.hWnd = display.hwndMessage;
     iconData.hIcon = hIcon;
     iconData.uFlags = OS.NIF_ICON;
-    OS.Shell_NotifyIcon (OS.NIM_MODIFY, iconData);
+    OS.Shell_NotifyIcon (OS.NIM_MODIFY, &iconData);
 }
 
 /**
@@ -472,29 +461,29 @@
  *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
  * </ul>
  */
-public void setToolTipText (String value) {
+public void setToolTipText (char[] value) {
     checkWidget ();
     toolTipText = value;
-    NOTIFYICONDATA iconData = OS.IsUnicode ? (NOTIFYICONDATA) new NOTIFYICONDATAW () : new NOTIFYICONDATAA ();
-    TCHAR buffer = new TCHAR (0, toolTipText is null ? "" : toolTipText, true);
+    NOTIFYICONDATA iconData;
+    TCHAR[] buffer = StrToTCHARs (0, toolTipText is null ? "" : toolTipText, true);
     /*
     * Note that the size of the szTip field is different in version 5.0 of shell32.dll.
     */
     int length = OS.SHELL32_MAJOR < 5 ? 64 : 128;
-    if (OS.IsUnicode) {
-        char [] szTip = ((NOTIFYICONDATAW) iconData).szTip;
-        length = Math.min (length - 1, buffer.length ());
-        System.arraycopy (buffer.chars, 0, szTip, 0, length);
+    static if (OS.IsUnicode) {
+        TCHAR [] szTip = iconData.szTip;
+        length = Math.min (length - 1, buffer.length );
+        System.arraycopy (buffer, 0, szTip, 0, length);
     } else {
-        byte [] szTip = ((NOTIFYICONDATAA) iconData).szTip;
-        length = Math.min (length - 1, buffer.length ());
-        System.arraycopy (buffer.bytes, 0, szTip, 0, length);
+        TCHAR [] szTip = iconData.szTip;
+        length = Math.min (length - 1, buffer.length );
+        System.arraycopy (buffer, 0, szTip, 0, length);
     }
     iconData.cbSize = NOTIFYICONDATA.sizeof;
     iconData.uID = id;
     iconData.hWnd = display.hwndMessage;
     iconData.uFlags = OS.NIF_TIP;
-    OS.Shell_NotifyIcon (OS.NIM_MODIFY, iconData);
+    OS.Shell_NotifyIcon (OS.NIM_MODIFY, &iconData);
 }
 
 /**
@@ -521,7 +510,7 @@
         if (isDisposed ()) return;
     }
     this.visible = visible;
-    NOTIFYICONDATA iconData = OS.IsUnicode ? (NOTIFYICONDATA) new NOTIFYICONDATAW () : new NOTIFYICONDATAA ();
+    NOTIFYICONDATA iconData;
     iconData.cbSize = NOTIFYICONDATA.sizeof;
     iconData.uID = id;
     iconData.hWnd = display.hwndMessage;
@@ -529,20 +518,20 @@
         if (visible) {
             iconData.uFlags = OS.NIF_MESSAGE;
             iconData.uCallbackMessage = Display.SWT_TRAYICONMSG;
-            OS.Shell_NotifyIcon (OS.NIM_ADD, iconData);
+            OS.Shell_NotifyIcon (OS.NIM_ADD, &iconData);
             setImage (image);
             setToolTipText (toolTipText);
         } else {
-            OS.Shell_NotifyIcon (OS.NIM_DELETE, iconData);
+            OS.Shell_NotifyIcon (OS.NIM_DELETE, &iconData);
         }
     } else {
         iconData.uFlags = OS.NIF_STATE;
         iconData.dwState = visible ? 0 : OS.NIS_HIDDEN;
         iconData.dwStateMask = OS.NIS_HIDDEN;
-        OS.Shell_NotifyIcon (OS.NIM_MODIFY, iconData);
+        OS.Shell_NotifyIcon (OS.NIM_MODIFY, &iconData);
     }
     if (!visible) sendEvent (DWT.Hide);
 }
 
 }
-++/
+