diff dwt/widgets/TableItem.d @ 213:36f5cb12e1a2

Update to SWT 3.4M7
author Frank Benoit <benoit@tionex.de>
date Sat, 17 May 2008 17:34:28 +0200
parents ab60f3309436
children fd9c62a2998e
line wrap: on
line diff
--- a/dwt/widgets/TableItem.d	Mon May 05 00:12:38 2008 +0200
+++ b/dwt/widgets/TableItem.d	Sat May 17 17:34:28 2008 +0200
@@ -45,11 +45,11 @@
     Table parent;
     String [] strings;
     Image [] images;
+    Font font;
+    Font [] cellFont;
     bool checked, grayed, cached;
     int imageIndent, background = -1, foreground = -1;
-    HFONT font = cast(HFONT)-1;
     int [] cellBackground, cellForeground;
-    HFONT[] cellFont;
 
 /**
  * Constructs a new instance of this class given its parent
@@ -143,8 +143,9 @@
     images = null;
     imageIndent = 0;
     checked = grayed = false;
+    font = null;
     background = foreground = -1;
-    font = cast(HFONT)-1;
+    cellFont = null;
     cellBackground = cellForeground = null;
     cellFont = null;
     if ((parent.style & DWT.VIRTUAL) !is 0) cached = false;
@@ -155,6 +156,12 @@
     releaseHandle ();
 }
 
+HFONT fontHandle (int index) {
+    if (cellFont !is null && cellFont [index] !is null) return cellFont [index].handle;
+    if (font !is null) return font.handle;
+    return cast(HFONT)-1;
+}
+
 /**
  * Returns the receiver's background color.
  *
@@ -264,8 +271,7 @@
             if (code is 0) return RECT.init;
             if (getText) {
                 int width = 0;
-                auto hFont = cellFont !is null ? cellFont [column] : cast(HFONT)-1;
-                if (hFont is cast(HFONT)-1) hFont = font;
+                auto hFont = fontHandle (column);
                 if (hFont is cast(HFONT)-1 && hDC is null) {
                     TCHAR* buffer = StrToTCHARz (parent.getCodePage (), text);
                     width = OS.SendMessage (hwnd, OS.LVM_GETSTRINGWIDTH, 0, buffer);
@@ -444,7 +450,7 @@
 public Font getFont () {
     checkWidget ();
     if (!parent.checkData (this, true)) error (DWT.ERROR_WIDGET_DISPOSED);
-    return font is cast(HFONT)-1 ? parent.getFont () : Font.win32_new (display, font);
+    return font !is null ? font : parent.getFont ();
 }
 
 /**
@@ -466,8 +472,8 @@
     if (!parent.checkData (this, true)) error (DWT.ERROR_WIDGET_DISPOSED);
     int count = Math.max (1, parent.getColumnCount ());
     if (0 > index || index > count -1) return getFont ();
-    auto hFont = (cellFont !is null) ? cellFont [index] : font;
-    return hFont is cast(HFONT)-1 ? getFont () : Font.win32_new (display, hFont);
+    if (cellFont is null || cellFont [index] is null) return getFont ();
+    return cellFont [index];
 }
 
 /**
@@ -711,8 +717,8 @@
     super.releaseWidget ();
     strings = null;
     images = null;
+    cellFont = null;
     cellBackground = cellForeground = null;
-    cellFont = null;
 }
 
 /**
@@ -842,13 +848,11 @@
     if (font !is null && font.isDisposed ()) {
         DWT.error (DWT.ERROR_INVALID_ARGUMENT);
     }
-    HFONT hFont = cast(HFONT)-1;
-    if (font !is null) {
-        parent.setCustomDraw (true);
-        hFont = font.handle;
-    }
-    if (this.font is hFont) return;
-    this.font = hFont;
+    Font oldFont = this.font;
+    if (oldFont is font) return;
+    this.font = font;
+    if (oldFont !is null && oldFont.opEquals (font)) return;
+    if (font !is null) parent.setCustomDraw (true);
     if ((parent.style & DWT.VIRTUAL) !is 0) cached = true;
     /*
     * Bug in Windows.  Despite the fact that every item in the
@@ -903,19 +907,15 @@
     }
     int count = Math.max (1, parent.getColumnCount ());
     if (0 > index || index > count - 1) return;
-    auto hFont = cast(HFONT)-1;
-    if (font !is null) {
-        parent.setCustomDraw (true);
-        hFont = font.handle;
+    if (cellFont is null) {
+        if (font is null) return;
+        cellFont = new Font [count];
     }
-    if (cellFont is null) {
-        cellFont = new HFONT [count];
-        for (int i = 0; i < count; i++) {
-            cellFont [i] = cast(HFONT)-1;
-        }
-    }
-    if (cellFont [index] is hFont) return;
-    cellFont [index] = hFont;
+    Font oldFont = cellFont [index];
+    if (oldFont is font) return;
+    cellFont [index] = font;
+    if (oldFont !is null && oldFont.opEquals (font)) return;
+    if (font !is null) parent.setCustomDraw (true);
     if ((parent.style & DWT.VIRTUAL) !is 0) cached = true;
     if (index is 0) {
         /*