diff dwt/widgets/Table.d @ 240:ce446666f5a2

Update to SWT 3.4M7
author Frank Benoit <benoit@tionex.de>
date Mon, 12 May 2008 19:13:01 +0200
parents 380bad9f6852
children 5a30aa9820f3
line wrap: on
line diff
--- a/dwt/widgets/Table.d	Mon May 12 15:36:37 2008 +0200
+++ b/dwt/widgets/Table.d	Mon May 12 19:13:01 2008 +0200
@@ -184,11 +184,17 @@
 
 static int checkStyle (int style) {
     /*
-    * To be compatible with Windows, force the H_SCROLL
-    * and V_SCROLL style bits.  On Windows, it is not
-    * possible to create a table without scroll bars.
+    * Feature in Windows.  Even when WS_HSCROLL or
+    * WS_VSCROLL is not specified, Windows creates
+    * trees and tables with scroll bars.  The fix
+    * is to set H_SCROLL and V_SCROLL.
+    *
+    * NOTE: This code appears on all platforms so that
+    * applications have consistent scroll bar behavior.
     */
-    style |= DWT.H_SCROLL | DWT.V_SCROLL;
+    if ((style & DWT.NO_SCROLL) is 0) {
+        style |= DWT.H_SCROLL | DWT.V_SCROLL;
+    }
     /* GTK is always FULL_SELECTION */
     style |= DWT.FULL_SELECTION;
     return checkBits (style, DWT.SINGLE, DWT.MULTI, 0, 0, 0, 0);
@@ -1153,6 +1159,13 @@
     return new Rectangle (fixedX - binX, fixedY - binY, width, height);
 }
 
+int getClientWidth () {
+    int w, h;
+    OS.gtk_widget_realize (handle);
+    OS.gdk_drawable_get_size(OS.gtk_tree_view_get_bin_window(handle), &w, &h);
+    return w;
+}
+
 /**
  * Returns the column at the given, zero-relative index in the
  * receiver. Throws an exception if the index is out of range.
@@ -2362,22 +2375,9 @@
     }
     items = new TableItem [4];
     itemCount = 0;
-
-    /*
-    * Bug in GTK.  In version 2.3.2, when the property fixed-height-mode
-    * is set and there are items in the list, OS.gtk_list_store_clear()
-    * segment faults.  The fix is to create a new empty model instead.
-    */
     auto selection = OS.gtk_tree_view_get_selection (handle);
     OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, null, null, udCHANGED);
-//  OS.gtk_list_store_clear (modelHandle);
-    auto oldModel = modelHandle;
-    auto types = getColumnTypes (Math.max (1,columnCount));
-    auto newModel = OS.gtk_list_store_newv (types.length, types.ptr);
-    if (newModel is null) error (DWT.ERROR_NO_HANDLES);
-    OS.gtk_tree_view_set_model (handle, newModel);
-    OS.g_object_unref (oldModel);
-    modelHandle = cast(GtkWidget*)newModel;
+    OS.gtk_list_store_clear (modelHandle);
     OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, null, null, udCHANGED);
 
     resetCustomDraw ();
@@ -2485,7 +2485,7 @@
                 sendEvent (DWT.MeasureItem, event);
                 gc.dispose ();
                 contentWidth = event.width - imageWidth;
-                contentHeight = event.height;
+                if (contentHeight < event.height) contentHeight = event.height;
                 if (width !is null) *width = contentWidth;
                 if (height !is null) *height = contentHeight;
             }
@@ -2562,6 +2562,7 @@
                     gc.setForeground (item.getForeground (columnIndex));
                 }
                 gc.setFont (item.getFont (columnIndex));
+                if ((style & DWT.MIRRORED) !is 0) rect.x = getClientWidth () - rect.width - rect.x;
                 gc.setClipping (rect.x, rect.y, rect.width, rect.height);
                 Event event = new Event ();
                 event.item = item;
@@ -2634,6 +2635,7 @@
                     gc.setForeground (foreground);
                 }
                 gc.setFont (item.getFont (columnIndex));
+                if ((style & DWT.MIRRORED) !is 0) rect.x = getClientWidth () - rect.width - rect.x;
                 gc.setClipping (rect.x, rect.y, rect.width, rect.height);
                 Event event = new Event ();
                 event.item = item;