diff dwt/widgets/Widget.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/Widget.d	Mon May 12 15:36:37 2008 +0200
+++ b/dwt/widgets/Widget.d	Mon May 12 19:13:01 2008 +0200
@@ -152,32 +152,33 @@
     static const int MOTION_NOTIFY_EVENT_INVERSE = 34;
     static const int MOVE_FOCUS = 35;
     static const int OUTPUT = 36;
-    static const int POPUP_MENU = 37;
-    static const int PREEDIT_CHANGED = 38;
-    static const int REALIZE = 39;
-    static const int ROW_ACTIVATED = 40;
-    static const int SCROLL_CHILD = 41;
-    static const int SCROLL_EVENT = 42;
-    static const int SELECT = 43;
-    static const int SHOW = 44;
-    static const int SHOW_HELP = 45;
-    static const int SIZE_ALLOCATE = 46;
-    static const int STYLE_SET = 47;
-    static const int SWITCH_PAGE = 48;
-    static const int TEST_COLLAPSE_ROW = 49;
-    static const int TEST_EXPAND_ROW = 50;
-    static const int TEXT_BUFFER_INSERT_TEXT = 51;
-    static const int TOGGLED = 52;
-    static const int UNMAP = 53;
-    static const int UNMAP_EVENT = 54;
-    static const int UNREALIZE = 55;
-    static const int VALUE_CHANGED = 56;
-    static const int VISIBILITY_NOTIFY_EVENT = 57;
-    static const int WINDOW_STATE_EVENT = 58;
-    static const int ACTIVATE_INVERSE = 59;
-    static const int DAY_SELECTED = 60;
-    static const int MONTH_CHANGED = 61;
-    static const int LAST_SIGNAL = 62;
+    static const int POPULATE_POPUP = 37;
+    static const int POPUP_MENU = 38;
+    static const int PREEDIT_CHANGED = 39;
+    static const int REALIZE = 40;
+    static const int ROW_ACTIVATED = 41;
+    static const int SCROLL_CHILD = 42;
+    static const int SCROLL_EVENT = 43;
+    static const int SELECT = 44;
+    static const int SHOW = 45;
+    static const int SHOW_HELP = 46;
+    static const int SIZE_ALLOCATE = 47;
+    static const int STYLE_SET = 48;
+    static const int SWITCH_PAGE = 49;
+    static const int TEST_COLLAPSE_ROW = 50;
+    static const int TEST_EXPAND_ROW = 51;
+    static const int TEXT_BUFFER_INSERT_TEXT = 52;
+    static const int TOGGLED = 53;
+    static const int UNMAP = 54;
+    static const int UNMAP_EVENT = 55;
+    static const int UNREALIZE = 56;
+    static const int VALUE_CHANGED = 57;
+    static const int VISIBILITY_NOTIFY_EVENT = 58;
+    static const int WINDOW_STATE_EVENT = 59;
+    static const int ACTIVATE_INVERSE = 60;
+    static const int DAY_SELECTED = 61;
+    static const int MONTH_CHANGED = 62;
+    static const int LAST_SIGNAL = 63;
 
     template UD_Getter( String name ){
         const String UD_Getter = "void* ud"~name~"(){ return getDisplay().getWindowProcUserData( "~name~"); }\n";
@@ -219,6 +220,7 @@
     mixin ( UD_Getter!( "MOTION_NOTIFY_EVENT_INVERSE" ));
     mixin ( UD_Getter!( "MOVE_FOCUS" ));
     mixin ( UD_Getter!( "OUTPUT" ));
+    mixin ( UD_Getter!( "POPULATE_POPUP" ));
     mixin ( UD_Getter!( "POPUP_MENU" ));
     mixin ( UD_Getter!( "PREEDIT_CHANGED" ));
     mixin ( UD_Getter!( "REALIZE" ));
@@ -385,6 +387,11 @@
         }
     }
     style = checkBits (style, DWT.LEFT_TO_RIGHT, DWT.RIGHT_TO_LEFT, 0, 0, 0, 0);
+    /* Versions of GTK prior to 2.8 do not render RTL text properly */
+    if (OS.GTK_VERSION < OS.buildVERSION (2, 8, 0)) {
+        style &= ~DWT.RIGHT_TO_LEFT;
+        style |= DWT.LEFT_TO_RIGHT;
+    }
 }
 
 /**
@@ -612,6 +619,33 @@
     return display;
 }
 
+/**
+ * Returns an array of listeners who will be notified when an event
+ * of the given type occurs. The event type is one of the event constants
+ * defined in class <code>DWT</code>.
+ *
+ * @param eventType the type of event to listen for
+ * @return an array of listeners that will be notified when the event occurs
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Listener
+ * @see DWT
+ * @see #addListener(int, Listener)
+ * @see #removeListener(int, Listener)
+ * @see #notifyListeners
+ *
+ * @since 3.4
+ */
+public Listener[] getListeners (int eventType) {
+    checkWidget();
+    if (eventTable is null) return new Listener[0];
+    return eventTable.getListeners(eventType);
+}
+
 String getName () {
 //  String str = getClass ().getName ();
 //  int index = str.lastIndexOf ('.');
@@ -788,6 +822,10 @@
     return 0;
 }
 
+int /*long*/ gtk_populate_popup (GtkWidget* widget, GtkWidget* menu) {
+    return 0;
+}
+
 int /*long*/ gtk_popup_menu (GtkWidget* widget) {
     return 0;
 }
@@ -909,7 +947,15 @@
     return 0;
 }
 
+void fixedSizeAllocateProc(GtkWidget* widget, GtkAllocation* allocationPtr) {
+    return Display.oldFixedSizeAllocateProc(widget, allocationPtr);
+}
+
 char [] fixMnemonic (String str) {
+    return fixMnemonic (str, true);
+}
+
+char [] fixMnemonic (String str, bool replace) {
     int len = str.length;
     String text = str[0 .. len].dup;
     int i = 0, j = 0;
@@ -920,11 +966,15 @@
                 if (i + 1 < len && text [i + 1] is '&') {
                     i++;
                 } else {
-                    text [i] = '_';
+                    if (replace) {
+                        text [i] = '_';
+                    } else {
+                        i++;
+                    }
                 }
                 break;
             case '_':
-                result [j++] = '_';
+                if (replace) result [j++] = '_';
                 break;
             default:
         }
@@ -1019,6 +1069,10 @@
     return keyval1 is keyval2;
 }
 
+void modifyStyle (GtkWidget* handle, GtkRcStyle* style) {
+    OS.gtk_widget_modify_style (handle, style);
+}
+
 /**
  * Notifies all of the receiver's listeners for events
  * of the given type that one such event has occurred by
@@ -1258,7 +1312,7 @@
     return sendIMKeyEvent (type, keyEvent, chars) !is null;
 }
 
-char [] sendIMKeyEvent (int type, GdkEventKey* keyEvent, char  [] chars) {
+char [] sendIMKeyEvent (int type, GdkEventKey* keyEvent, char [] chars) {
     int index = 0, count = 0, state = 0;
     GdkEvent*  ptr = null;
     if (keyEvent is null) {
@@ -1453,7 +1507,7 @@
     flags = OS.gtk_rc_style_get_color_flags (style, OS.GTK_STATE_ACTIVE);
     flags = (color is null) ? flags & ~OS.GTK_RC_TEXT: flags | OS.GTK_RC_TEXT;
     OS.gtk_rc_style_set_color_flags (style, OS.GTK_STATE_ACTIVE, flags);
-    OS.gtk_widget_modify_style (handle, style);
+    modifyStyle (handle, style);
 }
 
 bool setInputState (Event event, int state) {
@@ -1661,6 +1715,9 @@
         case EVENT:
             trace( "EVENT" );
             return gtk_event (handle, cast(GdkEvent*)arg0);
+        case POPULATE_POPUP:
+            trace( "POPULATE_POPUP" );
+            return gtk_populate_popup (handle, cast(GtkWidget*)arg0);
         case EVENT_AFTER:
             trace( "EVENT_AFTER" );
             return gtk_event_after (handle, cast(GdkEvent*)arg0);