# HG changeset patch # User Frank Benoit # Date 1199837302 -3600 # Node ID ffa3c27c4328df978bcaae06384c43767fd38820 # Parent 09f5459a5014c1db68ff97e1a26f8a5f8b3be413 Display diff -r 09f5459a5014 -r ffa3c27c4328 dwt/dwthelper/utils.d --- a/dwt/dwthelper/utils.d Tue Jan 08 08:07:04 2008 +0100 +++ b/dwt/dwthelper/utils.d Wed Jan 09 01:08:22 2008 +0100 @@ -18,7 +18,10 @@ } class ArrayWrapperT(T) : ArrayWrapper { - T[] array; + public T[] array; + public this( T[] data ){ + array = data; + } } alias ArrayWrapperT!(int) ArrayWrapperInt; diff -r 09f5459a5014 -r ffa3c27c4328 dwt/internal/gtk/OS.d --- a/dwt/internal/gtk/OS.d Tue Jan 08 08:07:04 2008 +0100 +++ b/dwt/internal/gtk/OS.d Wed Jan 09 01:08:22 2008 +0100 @@ -140,6 +140,9 @@ extern uint gtk_major_version; extern uint gtk_minor_version; extern uint gtk_micro_version; + + void * gdk_atom_intern(char *, int); + int gdk_property_get(GdkDrawable *, void *, void *, uint, uint, int, void **, int *, int *, char ** ); } @@ -205,7 +208,36 @@ private GType GTK_TYPE_CELL_RENDERER_PIXBUF(); private GType GTK_TYPE_CELL_RENDERER_TOGGLE(); private bool GTK_IS_WINDOW(GtkWidget *); - +private bool GTK_IS_CONTAINER(GtkWidget*); +private GType GTK_TYPE_MENU(); +private GType GTK_TYPE_WIDGET(); +private GType GTK_WIDGET_FLAGS(); +private GType GTK_WIDGET_STATE(); +private GType GTK_WIDGET_HAS_DEFAULT(); +private GType GTK_WIDGET_HAS_FOCUS(); +private GType GTK_WIDGET_IS_SENSITIVE(); +private GType GTK_WIDGET_MAPPED(); +private GType GTK_WIDGET_SENSITIVE(); +private GType GTK_WIDGET_SET_FLAGS(); +private GType GTK_WIDGET_UNSET_FLAGS(); +private GType GTK_WIDGET_VISIBLE(); +private GType G_OBJECT_CLASS (); +private GType G_OBJECT_GET_CLASS (); +private GType G_OBJECT_TYPE_NAME (); +private GType G_TYPE_BOOLEAN(); +private GType G_TYPE_INT(); +private GType G_OBJECT_TYPE( ); +private GType G_TYPE_STRING(); +private char* gdk_x11_screen_get_window_manager_name(GdkScreen*); +private char XKeysymToKeycode(void *, uint); +private int XTestFakeKeyEvent(void *, uint, int, uint); +int XTestFakeMotionEvent(void *, int, int, int, uint); +int XTestFakeButtonEvent(void *, uint, int, uint); +uint XDefaultRootWindow(void *); +int XWarpPointer(void *, uint, uint, int, int, uint, uint, int, int); +int g_signal_connect( void* instance, char* sig, GCallback handle, void* ptr ){ + return g_signal_connect_data( instance, sig, handle, ptr, 0, 0 ); +} template NameOfFunc(alias f) { // Note: highly dependent on the .stringof formatting // the value begins with "& " which is why the first two chars are cut off @@ -871,13 +903,13 @@ // mixin ForwardGtkOsCFunc!(.XCheckWindowEvent); mixin ForwardGtkOsCFunc!(.XCheckIfEvent); // mixin ForwardGtkOsCFunc!(.XDefaultScreen); -// mixin ForwardGtkOsCFunc!(.XDefaultRootWindow); + mixin ForwardGtkOsCFunc!(.XDefaultRootWindow); mixin ForwardGtkOsCFunc!(.XFlush); // mixin ForwardGtkOsCFunc!(.XFree); // mixin ForwardGtkOsCFunc!(.XGetSelectionOwner); // mixin ForwardGtkOsCFunc!(.XInternAtom); // mixin ForwardGtkOsCFunc!(.XQueryTree); -// mixin ForwardGtkOsCFunc!(.XKeysymToKeycode); + mixin ForwardGtkOsCFunc!(.XKeysymToKeycode); // mixin ForwardGtkOsCFunc!(.XListProperties); // mixin ForwardGtkOsCFunc!(.XReconfigureWMWindow); // mixin ForwardGtkOsCFunc!(.XSendEvent); @@ -886,11 +918,11 @@ mixin ForwardGtkOsCFunc!(.XSetErrorHandler); //mixin ForwardGtkOsCFunc!(.XSetInputFocus); mixin ForwardGtkOsCFunc!(.XSynchronize); - /+ mixin ForwardGtkOsCFunc!(.XTestFakeButtonEvent); mixin ForwardGtkOsCFunc!(.XTestFakeKeyEvent); mixin ForwardGtkOsCFunc!(.XTestFakeMotionEvent); mixin ForwardGtkOsCFunc!(.XWarpPointer); + /+ mixin ForwardGtkOsCFunc!(.gdk_x11_atom_to_xatom); mixin ForwardGtkOsCFunc!(.gdk_x11_colormap_get_xcolormap); @@ -898,7 +930,7 @@ +/ mixin ForwardGtkOsCFunc!(.gdk_x11_drawable_get_xid); //mixin ForwardGtkOsCFunc!(.gdk_x11_screen_lookup_visual); - //mixin ForwardGtkOsCFunc!(.gdk_x11_screen_get_window_manager_name); + mixin ForwardGtkOsCFunc!(.gdk_x11_screen_get_window_manager_name); mixin ForwardGtkOsCFunc!(.gdk_x11_visual_get_xvisual); // mixin ForwardGtkOsCFunc!(.gdk_pixmap_foreign_new); mixin ForwardGtkOsCFunc!(.gdk_window_lookup); @@ -927,7 +959,7 @@ // mixin ForwardGtkOsCFunc!(.GTK_IS_CELL_RENDERER_PIXBUF); // mixin ForwardGtkOsCFunc!(.GTK_IS_CELL_RENDERER_TEXT); // mixin ForwardGtkOsCFunc!(.GTK_IS_CELL_RENDERER_TOGGLE); -// mixin ForwardGtkOsCFunc!(.GTK_IS_CONTAINER); + mixin ForwardGtkOsCFunc!(.GTK_IS_CONTAINER); // mixin ForwardGtkOsCFunc!(.GTK_IS_IMAGE_MENU_ITEM); // mixin ForwardGtkOsCFunc!(.GTK_IS_PLUG); // mixin ForwardGtkOsCFunc!(.GTK_STOCK_CANCEL); @@ -936,25 +968,26 @@ mixin ForwardGtkOsCFunc!(.GTK_TYPE_CELL_RENDERER_PIXBUF); mixin ForwardGtkOsCFunc!(.GTK_TYPE_CELL_RENDERER_TOGGLE); mixin ForwardGtkOsCFunc!(.GTK_TYPE_FIXED); -// mixin ForwardGtkOsCFunc!(.GTK_TYPE_MENU); -// mixin ForwardGtkOsCFunc!(.GTK_TYPE_WIDGET); -// mixin ForwardGtkOsCFunc!(.GTK_WIDGET_FLAGS); -// mixin ForwardGtkOsCFunc!(.GTK_WIDGET_STATE); -// mixin ForwardGtkOsCFunc!(.GTK_WIDGET_HAS_DEFAULT); -// mixin ForwardGtkOsCFunc!(.GTK_WIDGET_HAS_FOCUS); -// mixin ForwardGtkOsCFunc!(.GTK_WIDGET_IS_SENSITIVE); -// mixin ForwardGtkOsCFunc!(.GTK_WIDGET_MAPPED); -// mixin ForwardGtkOsCFunc!(.GTK_WIDGET_SENSITIVE); -// mixin ForwardGtkOsCFunc!(.GTK_WIDGET_SET_FLAGS); -// mixin ForwardGtkOsCFunc!(.GTK_WIDGET_UNSET_FLAGS); -// mixin ForwardGtkOsCFunc!(.GTK_WIDGET_VISIBLE); -// mixin ForwardGtkOsCFunc!(.G_OBJECT_CLASS ); -// mixin ForwardGtkOsCFunc!(.G_OBJECT_GET_CLASS ); -// mixin ForwardGtkOsCFunc!(.G_OBJECT_TYPE_NAME ); -// mixin ForwardGtkOsCFunc!(.G_TYPE_BOOLEAN); -// mixin ForwardGtkOsCFunc!(.G_TYPE_INT); -// mixin ForwardGtkOsCFunc!(.G_OBJECT_TYPE ); -// mixin ForwardGtkOsCFunc!(.G_TYPE_STRING); + + mixin ForwardGtkOsCFunc!(.GTK_TYPE_MENU); + mixin ForwardGtkOsCFunc!(.GTK_TYPE_WIDGET); + mixin ForwardGtkOsCFunc!(.GTK_WIDGET_FLAGS); + mixin ForwardGtkOsCFunc!(.GTK_WIDGET_STATE); + mixin ForwardGtkOsCFunc!(.GTK_WIDGET_HAS_DEFAULT); + mixin ForwardGtkOsCFunc!(.GTK_WIDGET_HAS_FOCUS); + mixin ForwardGtkOsCFunc!(.GTK_WIDGET_IS_SENSITIVE); + mixin ForwardGtkOsCFunc!(.GTK_WIDGET_MAPPED); + mixin ForwardGtkOsCFunc!(.GTK_WIDGET_SENSITIVE); + mixin ForwardGtkOsCFunc!(.GTK_WIDGET_SET_FLAGS); + mixin ForwardGtkOsCFunc!(.GTK_WIDGET_UNSET_FLAGS); + mixin ForwardGtkOsCFunc!(.GTK_WIDGET_VISIBLE); + mixin ForwardGtkOsCFunc!(.G_OBJECT_CLASS ); + mixin ForwardGtkOsCFunc!(.G_OBJECT_GET_CLASS ); + mixin ForwardGtkOsCFunc!(.G_OBJECT_TYPE_NAME ); + mixin ForwardGtkOsCFunc!(.G_TYPE_BOOLEAN); + mixin ForwardGtkOsCFunc!(.G_TYPE_INT); + mixin ForwardGtkOsCFunc!(.G_OBJECT_TYPE ); + mixin ForwardGtkOsCFunc!(.G_TYPE_STRING); mixin ForwardGtkOsCFunc!(.PANGO_PIXELS); //mixin ForwardGtkOsCFunc!(.PANGO_TYPE_FONT_DESCRIPTION); @@ -1010,7 +1043,7 @@ mixin ForwardGtkOsCFunc!(.g_object_unref); mixin ForwardGtkOsCFunc!(.g_quark_from_string); mixin ForwardGtkOsCFunc!(.g_set_prgname); -// mixin ForwardGtkOsCFunc!(.g_signal_connect); + mixin ForwardGtkOsCFunc!(.g_signal_connect); mixin ForwardGtkOsCFunc!(.g_signal_connect_closure); mixin ForwardGtkOsCFunc!(.g_signal_connect_closure_by_id); // mixin ForwardGtkOsCFunc!(.g_signal_connect_after); @@ -1049,7 +1082,7 @@ mixin ForwardGtkOsCFunc!(.g_utf8_strlen); mixin ForwardGtkOsCFunc!(.g_utf8_to_utf16); mixin ForwardGtkOsCFunc!(.g_utf8_to_utf16); -// mixin ForwardGtkOsCFunc!(.gdk_atom_intern); + mixin ForwardGtkOsCFunc!(.gdk_atom_intern); // mixin ForwardGtkOsCFunc!(.gdk_atom_name); mixin ForwardGtkOsCFunc!(.gdk_beep); mixin ForwardGtkOsCFunc!(.gdk_bitmap_create_from_data); @@ -1141,7 +1174,7 @@ mixin ForwardGtkOsCFunc!(.gdk_pointer_grab); mixin ForwardGtkOsCFunc!(.gdk_pointer_is_grabbed); mixin ForwardGtkOsCFunc!(.gdk_pointer_ungrab); -// mixin ForwardGtkOsCFunc!(.gdk_property_get); + mixin ForwardGtkOsCFunc!(.gdk_property_get); mixin ForwardGtkOsCFunc!(.gdk_region_destroy); mixin ForwardGtkOsCFunc!(.gdk_region_empty); mixin ForwardGtkOsCFunc!(.gdk_region_get_clipbox); @@ -1397,7 +1430,6 @@ mixin ForwardGtkOsCFunc!(.gtk_label_set_justify); mixin ForwardGtkOsCFunc!(.gtk_label_set_line_wrap); mixin ForwardGtkOsCFunc!(.gtk_label_set_text); - mixin ForwardGtkOsCFunc!(.gtk_label_set_text); mixin ForwardGtkOsCFunc!(.gtk_label_set_text_with_mnemonic); // mixin ForwardGtkOsCFunc!(.gtk_list_append_items); // mixin ForwardGtkOsCFunc!(.gtk_list_clear_items); @@ -2017,14 +2049,41 @@ gtk_rc_style_set_fg(arg0, arg1, arg2) if (arg2) (arg0)->fg[arg1] = *arg2 gtk_rc_style_set_text(arg0, arg1, arg2) if (arg2) (arg0)->text[arg1] = *arg2 - gtk_style_get_font_desc(arg0) (arg0)->font_desc - gtk_style_get_base(arg0, arg1, arg2) *arg2 = (arg0)->base[arg1] - gtk_style_get_bg(arg0, arg1, arg2) *arg2 = (arg0)->bg[arg1] - gtk_style_get_black(arg0, arg1) *arg1 = (arg0)->black - gtk_style_get_dark(arg0, arg1, arg2) *arg2 = (arg0)->dark[arg1] - gtk_style_get_fg(arg0, arg1, arg2) *arg2 = (arg0)->fg[arg1] - gtk_style_get_light(arg0, arg1, arg2) *arg2 = (arg0)->light[arg1] - gtk_style_get_text(arg0, arg1, arg2) *arg2 = (arg0)->text[arg1] + +/ + //gtk_style_get_font_desc(arg0) (arg0)->font_desc + static PangoFontDescription* gtk_style_get_font_desc( GtkStyle* arg0 ) { + return arg0.font_desc; + } + //gtk_style_get_base(arg0, arg1, arg2) *arg2 = (arg0)->base[arg1] + static void gtk_style_get_base( GtkStyle* arg0, int arg1, GdkColor* arg2 ) { + *arg2 = arg0.base[arg1]; + } + //gtk_style_get_bg(arg0, arg1, arg2) *arg2 = (arg0)->bg[arg1] + static void gtk_style_get_bg( GtkStyle* arg0, int arg1, GdkColor* arg2 ) { + *arg2 = arg0.bg[arg1]; + } + //gtk_style_get_black(arg0, arg1) *arg1 = (arg0)->black + static void gtk_style_get_black( GtkStyle* arg0, GdkColor* arg1 ) { + *arg1 = arg0.black; + } + //gtk_style_get_dark(arg0, arg1, arg2) *arg2 = (arg0)->dark[arg1] + static void gtk_style_get_dark( GtkStyle* arg0, int arg1, GdkColor* arg2 ) { + *arg2 = arg0.dark[arg1]; + } + //gtk_style_get_fg(arg0, arg1, arg2) *arg2 = (arg0)->fg[arg1] + static void gtk_style_get_fg( GtkStyle* arg0, int arg1, GdkColor* arg2 ) { + *arg2 = arg0.fg[arg1]; + } + //gtk_style_get_light(arg0, arg1, arg2) *arg2 = (arg0)->light[arg1] + static void gtk_style_get_light( GtkStyle* arg0, int arg1, GdkColor* arg2 ) { + *arg2 = arg0.light[arg1]; + } + //gtk_style_get_text(arg0, arg1, arg2) *arg2 = (arg0)->text[arg1] + static void gtk_style_get_text( GtkStyle* arg0, int arg1, GdkColor* arg2 ) { + *arg2 = arg0.text[arg1]; + } + + /+ gtk_style_get_xthickness(arg0) (arg0)->xthickness gtk_style_get_ythickness(arg0) (arg0)->ythickness gtk_style_get_fg_gc(arg0, arg1, arg2) *arg2 = (arg0)->fg_gc[arg1] diff -r 09f5459a5014 -r ffa3c27c4328 dwt/internal/gtk/c/gdktypes.d --- a/dwt/internal/gtk/c/gdktypes.d Tue Jan 08 08:07:04 2008 +0100 +++ b/dwt/internal/gtk/c/gdktypes.d Wed Jan 09 01:08:22 2008 +0100 @@ -1948,7 +1948,24 @@ * guint * pixel_from_rgb (GdkVisual *visual, */ -public struct GdkVisual{} +public struct GdkVisual{ + GObject parent_instance; + int type; + int depth; + int byte_order; + int colormap_size; + int bits_per_rgb; + uint red_mask; + int red_shift; + int red_prec; + uint green_mask; + int green_shift; + int green_prec; + uint blue_mask; + int blue_shift; + int blue_prec; +} + // GObject parentInstance; // gdk-Visuals.html // GdkVisualType type; diff -r 09f5459a5014 -r ffa3c27c4328 dwt/internal/gtk/c/gtktypes.d --- a/dwt/internal/gtk/c/gtktypes.d Tue Jan 08 08:07:04 2008 +0100 +++ b/dwt/internal/gtk/c/gtktypes.d Wed Jan 09 01:08:22 2008 +0100 @@ -2469,7 +2469,9 @@ /** * Main Gtk struct. */ -public struct GtkWindow{} +public struct GtkWindow{ + GtkBin bin; +} /** @@ -4444,7 +4446,9 @@ * GtkWidget *child; * the child widget. */ -public struct GtkBin{} +public struct GtkBin{ + GtkContainer container; +} /** diff -r 09f5459a5014 -r ffa3c27c4328 dwt/widgets/Caret.d --- a/dwt/widgets/Caret.d Tue Jan 08 08:07:04 2008 +0100 +++ b/dwt/widgets/Caret.d Wed Jan 09 01:08:22 2008 +0100 @@ -11,6 +11,8 @@ module dwt.widgets.Caret; class Caret{ + int blinkRate; + bool blinkCaret(); } /+++ diff -r 09f5459a5014 -r ffa3c27c4328 dwt/widgets/Control.d --- a/dwt/widgets/Control.d Tue Jan 08 08:07:04 2008 +0100 +++ b/dwt/widgets/Control.d Wed Jan 09 01:08:22 2008 +0100 @@ -13,11 +13,22 @@ import dwt.internal.gtk.c.gtktypes; import dwt.widgets.Widget; import dwt.widgets.Shell; +import dwt.graphics.Point; class Control : Widget { GdkWindow* paintWindow () { return null; }; public Shell getShell(); bool isEnabled(); + bool isDisposed(); + GdkWindow* eventWindow (); + GtkIMContext * imHandle(); + Control findBackgroundControl (); + GdkColor* getBackgroundColor () ; + GdkColor* getForegroundColor () ; + PangoFontDescription* getFontDescription (); + public Point toDisplay (int x, int y); + public Point toDisplay (Point point) ; + Point getIMCaretPos () ; } /+++ import dwt.*; diff -r 09f5459a5014 -r ffa3c27c4328 dwt/widgets/Display.d --- a/dwt/widgets/Display.d Tue Jan 08 08:07:04 2008 +0100 +++ b/dwt/widgets/Display.d Wed Jan 09 01:08:22 2008 +0100 @@ -26,6 +26,7 @@ import dwt.internal.Compatibility; import dwt.internal.Converter; import dwt.internal.Lock; +import dwt.internal.LONG; import dwt.internal.gtk.c.gdktypes; import dwt.internal.gtk.c.gtktypes; import dwt.internal.gtk.OS; @@ -126,31 +127,37 @@ */ public class Display : Device { + package struct CallbackData { + Display display; + void* data; + } + /* Events Dispatching and Callback */ int gdkEventCount; GdkEvent* [] gdkEvents; Widget [] gdkEventWidgets; int [] dispatchEvents; Event [] eventQueue; - int /*long*/ fds; + GPollFD[] fds; int allocated_nfds; bool wake_state; int max_priority, timeout; void*/*Callback*/ eventCallback, filterCallback; - int /*long*/ eventProc, filterProc, windowProc2, windowProc3, windowProc4, windowProc5; - void*/*Callback*/ windowCallback2, windowCallback3, windowCallback4, windowCallback5; + + CallbackData*[] windowProcCallbackDatas; // to prevent GC from collect + + CallbackData filterProcCallbackData; EventTable eventTable, filterTable; static char[] APP_NAME = "SWT"; static const char[] DISPATCH_EVENT_KEY = "dwt.internal.gtk.dispatchEvent"; static const char[] ADD_WIDGET_KEY = "dwt.internal.addWidget"; - int /*long*/ [] closures; + GClosure*[] closures; int [] signalIds; - int /*long*/ shellMapProcClosure; /* Widget Table */ int [] indexTable; int freeSlot; - int /*long*/ lastHandle; + GtkWidget* lastHandle; Widget lastWidget; Widget [] widgetTable; const static int GROW_SIZE = 1024; @@ -167,7 +174,8 @@ /* Input method resources */ Control imControl; - int /*long*/ preeditWindow, preeditLabel; + GtkWindow* preeditWindow; + GtkLabel* preeditLabel; /* Sync/Async Widget Communication */ Synchronizer synchronizer; @@ -182,43 +190,30 @@ /* Timers */ int [] timerIds; Runnable [] timerList; - void*/*Callback*/ timerCallback; - int /*long*/ timerProc; - void*/*Callback*/ windowTimerCallback; - int /*long*/ windowTimerProc; + CallbackData timerProcCallbackData; /* Caret */ Caret currentCaret; - void*/*Callback*/ caretCallback; int caretId; - int /*long*/ caretProc; + CallbackData caretProcCallbackData; /* Mnemonics */ Control mnemonicControl; /* Mouse hover */ int mouseHoverId; - int /*long*/ mouseHoverHandle, mouseHoverProc; - void*/*Callback*/ mouseHoverCallback; - + GObject* mouseHoverHandle; /* Menu position callback */ - int /*long*/ menuPositionProc; - void*/*Callback*/ menuPositionCallback; /* Tooltip size allocate callback */ - int /*long*/ sizeAllocateProc; - void*/*Callback*/ sizeAllocateCallback; - int /*long*/ sizeRequestProc; - void*/*Callback*/ sizeRequestCallback; /* Shell map callback */ - int /*long*/ shellMapProc; - void*/*Callback*/ shellMapCallback; + CallbackData shellMapProcCallbackData; + GClosure* shellMapProcClosure; /* Idle proc callback */ - int /*long*/ idleProc; + CallbackData idleProcCallbackData; int idleHandle; - void*/*Callback*/ idleCallback; static const char[] ADD_IDLE_PROC_KEY; static const char[] REMOVE_IDLE_PROC_KEY; Object idleLock; @@ -227,25 +222,18 @@ /* GtkTreeView callbacks */ int[] treeSelection; int treeSelectionLength; - int /*long*/ treeSelectionProc; - void*/*Callback*/ treeSelectionCallback; - int /*long*/ cellDataProcFld; - void*/*Callback*/ cellDataCallback; /* Set direction callback */ - int /*long*/ setDirectionProc; - void*/*Callback*/ setDirectionCallback; + CallbackData setDirectionCallbackData; /* Get all children callback */ - int /*long*/ allChildrenProc; + CallbackData allChildrenCallbackData; GList* allChildren; - void*/*Callback*/ allChildrenCallback; /* Settings callbacks */ - int /*long*/ styleSetProc; - void*/*Callback*/ styleSetCallback; GtkWidget* shellHandle; - bool settingsChanged, runSettings; + bool settingsChanged, runSettingsFld; + CallbackData styleSetProcCallbackData; /* Entry focus behaviour */ bool entrySelectOnFocus; @@ -271,12 +259,12 @@ static const int RESOURCE_SIZE = 1 + 4 + SWT.CURSOR_HAND + 1; /* Colors */ - GdkColor COLOR_WIDGET_DARK_SHADOW, COLOR_WIDGET_NORMAL_SHADOW, COLOR_WIDGET_LIGHT_SHADOW; - GdkColor COLOR_WIDGET_HIGHLIGHT_SHADOW, COLOR_WIDGET_BACKGROUND, COLOR_WIDGET_FOREGROUND, COLOR_WIDGET_BORDER; - GdkColor COLOR_LIST_FOREGROUND, COLOR_LIST_BACKGROUND, COLOR_LIST_SELECTION, COLOR_LIST_SELECTION_TEXT; - GdkColor COLOR_INFO_BACKGROUND, COLOR_INFO_FOREGROUND; - GdkColor COLOR_TITLE_FOREGROUND, COLOR_TITLE_BACKGROUND, COLOR_TITLE_BACKGROUND_GRADIENT; - GdkColor COLOR_TITLE_INACTIVE_FOREGROUND, COLOR_TITLE_INACTIVE_BACKGROUND, COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT; + GdkColor* COLOR_WIDGET_DARK_SHADOW, COLOR_WIDGET_NORMAL_SHADOW, COLOR_WIDGET_LIGHT_SHADOW; + GdkColor* COLOR_WIDGET_HIGHLIGHT_SHADOW, COLOR_WIDGET_BACKGROUND, COLOR_WIDGET_FOREGROUND, COLOR_WIDGET_BORDER; + GdkColor* COLOR_LIST_FOREGROUND, COLOR_LIST_BACKGROUND, COLOR_LIST_SELECTION, COLOR_LIST_SELECTION_TEXT; + GdkColor* COLOR_INFO_BACKGROUND, COLOR_INFO_FOREGROUND; + GdkColor* COLOR_TITLE_FOREGROUND, COLOR_TITLE_BACKGROUND, COLOR_TITLE_BACKGROUND_GRADIENT; + GdkColor* COLOR_TITLE_INACTIVE_FOREGROUND, COLOR_TITLE_INACTIVE_BACKGROUND, COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT; /* Popup Menus */ Menu [] popups; @@ -290,16 +278,10 @@ /* Fixed Subclass */ static int /*long*/ fixed_type; static int /*long*/ fixed_info_ptr; - static void*/*Callback*/ fixedClassInitCallback; - //static void* fixedMapCallback; - static int /*long*/ fixedClassInitProc; - //static int fixedMapProc; /* Renderer Subclass */ static int /*long*/ text_renderer_type, pixbuf_renderer_type, toggle_renderer_type; static int /*long*/ text_renderer_info_ptr, pixbuf_renderer_info_ptr, toggle_renderer_info_ptr; - static void*/*Callback*/ rendererClassInitCallback, rendererRenderCallback, rendererGetSizeCallback; - static int /*long*/ rendererClassInitProc, rendererRenderProc, rendererGetSizeProc; /* Key Mappings */ static const int [] [] KeyTable = [ @@ -581,7 +563,9 @@ synchronized (idleLock){ this.idleNeeded = true; if (idleHandle is 0) { - idleHandle = OS.g_idle_add ( &idleProcFunc, cast(void*) this ); + idleProcCallbackData.display = this; + idleProcCallbackData.data = null; + idleHandle = OS.g_idle_add ( &idleProcFunc, &idleProcCallbackData ); } } } @@ -926,7 +910,9 @@ /* Initialize the filter and event callback */ OS.gdk_event_handler_set (&eventProcFunc, cast(void*)this, cast(GDestroyNotify) 0); - OS.gdk_window_add_filter (null, &filterProcFunc, cast(void*)this ); + filterProcCallbackData.display = this; + filterProcCallbackData.data = null; + OS.gdk_window_add_filter (null, &filterProcFunc, cast(void*)&filterProcCallbackData ); } Image createImage (char[] name) { @@ -1420,1561 +1406,1495 @@ } private static extern(C) GdkFilterReturn filterProcFunc (GdkXEvent* xEvent, GdkEvent* gdkEvent, void* data) { - auto disp = cast(Display)data; - return disp.filterProcMeth(xEvent,gdkEvent); + auto callbackdata = cast(CallbackData*)data; + auto disp = callbackdata.display; + if( disp is null ) return GdkFilterReturn.CONTINUE; + return disp.filterProcMeth(xEvent,gdkEvent,callbackdata); +} + +GdkFilterReturn filterProcMeth (GdkXEvent* xEvent, GdkEvent* gdkEvent, CallbackData* callbackData) { + if( callbackData.data is null ){ + /* + * Feature in GTK. When button 4, 5, 6, or 7 is released, GTK + * does not deliver a corresponding GTK event. Button 6 and 7 + * are mapped to buttons 4 and 5 in SWT. The fix is to change + * the button number of the event to a negative number so that + * it gets dispatched by GTK. SWT has been modified to look + * for negative button numbers. + */ + XButtonEvent* mouseEvent = cast(XButtonEvent*) xEvent; + if (mouseEvent.type is OS.ButtonRelease) { + switch (mouseEvent.button) { + case 6: + case 7: + mouseEvent.button = -mouseEvent.button; + break; + } + } + } + Widget widget = getWidget (cast(GtkWidget*)callbackData.data); + if (widget is null) return GdkFilterReturn.CONTINUE; + return widget.filterProc (xEvent, gdkEvent, callbackData.data); +} + +/** + * Returns the location of the on-screen pointer relative + * to the top left corner of the screen. + * + * @return the cursor location + * + * @exception SWTException + */ +public Point getCursorLocation () { + checkDevice (); + int x, y; + OS.gdk_window_get_pointer (null, &x, &y, null); + return new Point (x, y); +} + +/** + * Returns an array containing the recommended cursor sizes. + * + * @return the array of cursor sizes + * + * @exception SWTException + * + * @since 3.0 + */ +public Point [] getCursorSizes () { + checkDevice (); + return [new Point (16, 16), new Point (32, 32)]; } -GdkFilterReturn filterProcMeth (GdkXEvent* xEvent, GdkEvent* gdkEvent) { -// /* -// * Feature in GTK. When button 4, 5, 6, or 7 is released, GTK -// * does not deliver a corresponding GTK event. Button 6 and 7 -// * are mapped to buttons 4 and 5 in SWT. The fix is to change -// * the button number of the event to a negative number so that -// * it gets dispatched by GTK. SWT has been modified to look -// * for negative button numbers. -// */ -// XButtonEvent* mouseEvent = cast(XButtonEvent*) xEvent; -// if (mouseEvent.type is OS.ButtonRelease) { -// switch (mouseEvent.button) { -// case 6: -// case 7: -// mouseEvent.button = -mouseEvent.button; -// break; -// } -// } -// Widget widget = getWidget (data); -// if (widget is null) return 0; -// return widget.filterProc (xEvent, gdkEvent, data); -return GdkFilterReturn.init; +/** + * Returns the application defined property of the receiver + * with the specified name, or null if it has not been set. + *

+ * Applications may have associated arbitrary objects with the + * receiver in this fashion. If the objects stored in the + * properties need to be notified when the display is disposed + * of, it is the application's responsibility to provide a + * disposeExec() handler which does so. + *

+ * + * @param key the name of the property + * @return the value of the property or null if it has not been set + * + * @exception IllegalArgumentException + * @exception SWTException + * + * @see #setData(String, Object) + * @see #disposeExec(Runnable) + */ +public Object getData (char[] key) { + checkDevice (); + if (key is null) error (SWT.ERROR_NULL_ARGUMENT); + if (key ==/*eq*/ DISPATCH_EVENT_KEY) { + return new ArrayWrapperInt(dispatchEvents); + } + if (keys is null) return null; + for (int i=0; i -// *
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  • -// *
  • ERROR_DEVICE_DISPOSED - if the receiver has been disposed
  • -// * -// */ -// public Point getCursorLocation () { -// checkDevice (); -// int [] x = new int [1], y = new int [1]; -// OS.gdk_window_get_pointer (0, x, y, null); -// return new Point (x [0], y [0]); -// } -// -// /** -// * Returns an array containing the recommended cursor sizes. -// * -// * @return the array of cursor sizes -// * -// * @exception SWTException -// * -// * @since 3.0 -// */ -// public Point [] getCursorSizes () { -// checkDevice (); -// return [new Point (16, 16), new Point (32, 32)]; -// } -// -// /** -// * Returns the application defined property of the receiver -// * with the specified name, or null if it has not been set. -// *

    -// * Applications may have associated arbitrary objects with the -// * receiver in this fashion. If the objects stored in the -// * properties need to be notified when the display is disposed -// * of, it is the application's responsibility to provide a -// * disposeExec() handler which does so. -// *

    -// * -// * @param key the name of the property -// * @return the value of the property or null if it has not been set -// * -// * @exception IllegalArgumentException -// * @exception SWTException -// * -// * @see #setData(String, Object) -// * @see #disposeExec(Runnable) -// */ -// public Object getData (char[] key) { -// checkDevice (); -// if (key is null) error (SWT.ERROR_NULL_ARGUMENT); -// if (key ==/*eq*/ DISPATCH_EVENT_KEY) { -// return dispatchEvents; -// } -// if (keys is null) return null; -// for (int i=0; idisplay specific data is a single, -// * unnamed field that is stored with every display. -// *

    -// * Applications may put arbitrary objects in this field. If -// * the object stored in the display specific data needs to -// * be notified when the display is disposed of, it is the -// * application's responsibility to provide a -// * disposeExec() handler which does so. -// *

    -// * -// * @return the display specific data -// * -// * @exception SWTException
      -// *
    • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • -// *
    • ERROR_DEVICE_DISPOSED - if the receiver has been disposed
    • -// *
    -// * -// * @see #setData(Object) -// * @see #disposeExec(Runnable) -// */ -// public Object getData () { -// checkDevice (); -// return data; -// } -// -// /** -// * Returns a point whose x coordinate is the horizontal -// * dots per inch of the display, and whose y coordinate -// * is the vertical dots per inch of the display. -// * -// * @return the horizontal and vertical DPI -// * -// * @exception SWTException
      -// *
    • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • -// *
    -// */ -// public Point getDPI () { -// checkDevice (); -// int widthMM = OS.gdk_screen_width_mm (); -// int width = OS.gdk_screen_width (); -// int dpi = Compatibility.round (254 * width, widthMM * 10); -// return new Point (dpi, dpi); -// } -// -// int /*long*/ gtk_fixed_get_type () { -// return fixed_type; -// } -// -// int /*long*/ gtk_cell_renderer_text_get_type () { -// return text_renderer_type; -// } -// -// int /*long*/ gtk_cell_renderer_pixbuf_get_type () { -// return pixbuf_renderer_type; -// } -// -// int /*long*/ gtk_cell_renderer_toggle_get_type () { -// return toggle_renderer_type; -// } -// -// /** -// * Returns the default display. One is created (making the -// * thread that invokes this method its user-interface thread) -// * if it did not already exist. -// * -// * @return the default display -// */ + +/** + * Returns the application defined, display specific data + * associated with the receiver, or null if it has not been + * set. The display specific data is a single, + * unnamed field that is stored with every display. + *

    + * Applications may put arbitrary objects in this field. If + * the object stored in the display specific data needs to + * be notified when the display is disposed of, it is the + * application's responsibility to provide a + * disposeExec() handler which does so. + *

    + * + * @return the display specific data + * + * @exception SWTException
      + *
    • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • + *
    • ERROR_DEVICE_DISPOSED - if the receiver has been disposed
    • + *
    + * + * @see #setData(Object) + * @see #disposeExec(Runnable) + */ +public Object getData () { + checkDevice (); + return data; +} + +/** + * Returns a point whose x coordinate is the horizontal + * dots per inch of the display, and whose y coordinate + * is the vertical dots per inch of the display. + * + * @return the horizontal and vertical DPI + * + * @exception SWTException
      + *
    • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • + *
    + */ +public Point getDPI () { + checkDevice (); + int widthMM = OS.gdk_screen_width_mm (); + int width = OS.gdk_screen_width (); + int dpi = Compatibility.round (254 * width, widthMM * 10); + return new Point (dpi, dpi); +} + +int /*long*/ gtk_fixed_get_type () { + return fixed_type; +} + +int /*long*/ gtk_cell_renderer_text_get_type () { + return text_renderer_type; +} + +int /*long*/ gtk_cell_renderer_pixbuf_get_type () { + return pixbuf_renderer_type; +} + +int /*long*/ gtk_cell_renderer_toggle_get_type () { + return toggle_renderer_type; +} + +/** + * Returns the default display. One is created (making the + * thread that invokes this method its user-interface thread) + * if it did not already exist. + * + * @return the default display + */ public static synchronized Display getDefault () { if (Default is null) Default = new Display (); return Default; } -// + // /+static bool isValidClass (Class clazz) { // //PROTING_TODO char[] name = clazz.getName (); // //PROTING_TODO int index = name.lastIndexOf ('.'); // //PROTING_TODO return name.substring (0, index + 1)==/*eq*/ PACKAGE_PREFIX; // return true; // }+/ -// -// /** -// * Returns the button dismissal alignment, one of LEFT or RIGHT. -// * The button dismissal alignment is the ordering that should be used when positioning the -// * default dismissal button for a dialog. For example, in a dialog that contains an OK and -// * CANCEL button, on platforms where the button dismissal alignment is LEFT, the -// * button ordering should be OK/CANCEL. When button dismissal alignment is RIGHT, -// * the button ordering should be CANCEL/OK. -// * -// * @return the button dismissal order -// * -// * @exception SWTException
      -// *
    • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • -// *
    • ERROR_DEVICE_DISPOSED - if the receiver has been disposed
    • -// *
    -// * -// * @since 2.1 -// */ -// public int getDismissalAlignment () { -// checkDevice (); -// return SWT.RIGHT; -// } -// -// /** -// * Returns the longest duration, in milliseconds, between -// * two mouse button clicks that will be considered a -// * double click by the underlying operating system. -// * -// * @return the double click time -// * -// * @exception SWTException
      -// *
    • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • -// *
    • ERROR_DEVICE_DISPOSED - if the receiver has been disposed
    • -// *
    -// */ -// public int getDoubleClickTime () { -// checkDevice (); -// auto settings = OS.gtk_settings_get_default (); -// int [] buffer = new int [1]; -// OS.g_object_get (settings, OS.gtk_double_click_time, buffer, 0); -// return buffer [0]; -// } -// -// /** -// * Returns the control which currently has keyboard focus, -// * or null if keyboard events are not currently going to -// * any of the controls built by the currently running -// * application. -// * -// * @return the control under the cursor -// * -// * @exception SWTException
      -// *
    • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • -// *
    • ERROR_DEVICE_DISPOSED - if the receiver has been disposed
    • -// *
    -// */ -// public Control getFocusControl () { -// checkDevice (); -// if (focusControl !is null && !focusControl.isDisposed ()) { -// return focusControl; -// } -// if (activeShell is null) return null; -// auto shellHandle = activeShell.shellHandle; -// auto handle = OS.gtk_window_get_focus (shellHandle); -// if (handle is null) return null; -// do { -// Widget widget = getWidget (handle); -// if (widget !is null && (null !is cast(Control)widget)) { -// Control control = cast(Control) widget; -// return control.isEnabled () ? control : null; -// } -// } while ((handle = OS.gtk_widget_get_parent (handle)) !is null); -// return null; -// } -// -// /** -// * Returns true when the high contrast mode is enabled. -// * Otherwise, false is returned. -// *

    -// * Note: This operation is a hint and is not supported on -// * platforms that do not have this concept. -// *

    -// * -// * @return the high contrast mode -// * -// * @exception SWTException
      -// *
    • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • -// *
    • ERROR_DEVICE_DISPOSED - if the receiver has been disposed
    • -// *
    -// * -// * @since 3.0 -// */ -// public bool getHighContrast () { -// checkDevice (); -// return false; -// } -// -// public int getDepth () { -// checkDevice (); -// GdkVisual* visual = new GdkVisual (); -// memmove (visual, OS.gdk_visual_get_system()); -// return visual.depth; -// } -// -// /** -// * Returns the maximum allowed depth of icons on this display, in bits per pixel. -// * On some platforms, this may be different than the actual depth of the display. -// * -// * @return the maximum icon depth -// * -// * @exception SWTException
      -// *
    • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • -// *
    • ERROR_DEVICE_DISPOSED - if the receiver has been disposed
    • -// *
    -// * -// * @see Device#getDepth -// */ -// public int getIconDepth () { -// checkDevice (); -// return getDepth (); -// } -// -// /** -// * Returns an array containing the recommended icon sizes. -// * -// * @return the array of icon sizes -// * -// * @exception SWTException
      -// *
    • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • -// *
    • ERROR_DEVICE_DISPOSED - if the receiver has been disposed
    • -// *
    -// * -// * @see Decorations#setImages(Image[]) -// * -// * @since 3.0 -// */ -// public Point [] getIconSizes () { -// checkDevice (); -// return [new Point (16, 16), new Point (32, 32)]; -// } -// -// int getLastEventTime () { -// return lastEventTime; -// } -// -// int getMessageCount () { -// return synchronizer.getMessageCount (); -// } -// -// /** -// * Returns the work area, an EWMH property to store the size -// * and position of the screen not covered by dock and panel -// * windows. See http://freedesktop.org/Standards/wm-spec. -// */ -// Rectangle getWorkArea() { -// byte[] name = Converter.wcsToMbcs (null, "_NET_WORKAREA", true); -// auto atom = OS.gdk_atom_intern (name, true); -// if (atom is OS.GDK_NONE) return null; -// int /*long*/[] actualType = new int /*long*/[1]; -// int[] actualFormat = new int[1]; -// int[] actualLength = new int[1]; -// int /*long*/[] data = new int /*long*/[1]; -// if (!OS.gdk_property_get (OS.GDK_ROOT_PARENT (), atom, OS.GDK_NONE, 0, 16, 0, actualType, actualFormat, actualLength, data)) { -// return null; -// } -// Rectangle result = null; -// if (data [0] !is 0) { -// if (actualLength [0] is 16) { -// int values [] = new int [4]; -// memmove (values, data[0], 16); -// result = new Rectangle (values [0],values [1],values [2],values [3]); -// } else if (actualLength [0] is 32) { -// long values [] = new long [4]; -// memmove (values, data[0], 32); -// result = new Rectangle (cast(int)values [0],cast(int)values [1],cast(int)values [2],cast(int)values [3]); -// } -// OS.g_free (data [0]); -// } -// return result; -// } -// -// /** -// * Returns an array of monitors attached to the device. -// * -// * @return the array of monitors -// * -// * @since 3.0 -// */ -// public Monitor [] getMonitors () { -// checkDevice (); -// Monitor [] monitors = null; -// Rectangle workArea = getWorkArea(); -// auto screen = OS.gdk_screen_get_default (); -// if (screen !is null) { -// int monitorCount = OS.gdk_screen_get_n_monitors (screen); -// if (monitorCount > 0) { -// monitors = new Monitor [monitorCount]; -// GdkRectangle* dest = new GdkRectangle (); -// for (int i = 0; i < monitorCount; i++) { -// OS.gdk_screen_get_monitor_geometry (screen, i, dest); -// Monitor monitor = new Monitor (); -// monitor.handle = i; -// monitor.x = dest.x; -// monitor.y = dest.y; -// monitor.width = dest.width; -// monitor.height = dest.height; -// if (i is 0 && workArea !is null) { -// monitor.clientX = workArea.x; -// monitor.clientY = workArea.y; -// monitor.clientWidth = workArea.width; -// monitor.clientHeight = workArea.height; -// } else { -// monitor.clientX = monitor.x; -// monitor.clientY = monitor.y; -// monitor.clientWidth = monitor.width; -// monitor.clientHeight = monitor.height; -// } -// monitors [i] = monitor; -// } -// } -// } -// if (monitors is null) { -// /* No multimonitor support detected, default to one monitor */ -// Monitor monitor = new Monitor (); -// Rectangle bounds = getBounds (); -// monitor.x = bounds.x; -// monitor.y = bounds.y; -// monitor.width = bounds.width; -// monitor.height = bounds.height; -// if (workArea !is null) { -// monitor.clientX = workArea.x; -// monitor.clientY = workArea.y; -// monitor.clientWidth = workArea.width; -// monitor.clientHeight = workArea.height; -// } else { -// monitor.clientX = monitor.x; -// monitor.clientY = monitor.y; -// monitor.clientWidth = monitor.width; -// monitor.clientHeight = monitor.height; -// } -// monitors = [ monitor ]; -// } -// return monitors; -// } -// -// /** -// * Returns the primary monitor for that device. -// * -// * @return the primary monitor -// * -// * @since 3.0 -// */ -// public Monitor getPrimaryMonitor () { -// checkDevice (); -// Monitor [] monitors = getMonitors (); -// return monitors [0]; -// } -// -// /** -// * Returns a (possibly empty) array containing all shells which have -// * not been disposed and have the receiver as their display. -// * -// * @return the receiver's shells -// * -// * @exception SWTException
      -// *
    • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • -// *
    • ERROR_DEVICE_DISPOSED - if the receiver has been disposed
    • -// *
    -// */ -// public Shell [] getShells () { -// checkDevice (); -// int index = 0; -// Shell [] result = new Shell [16]; -// for (int i = 0; i < widgetTable.length; i++) { -// Widget widget = widgetTable [i]; -// if (widget !is null && (null !is cast(Shell)widget)) { -// int j = 0; -// while (j < index) { -// if (result [j] is widget) break; -// j++; -// } -// if (j is index) { -// if (index is result.length) { -// Shell [] newResult = new Shell [index + 16]; -// System.arraycopy (result, 0, newResult, 0, index); -// result = newResult; -// } -// result [index++] = cast(Shell) widget; -// } -// } -// } -// if (index is result.length) return result; -// Shell [] newResult = new Shell [index]; -// System.arraycopy (result, 0, newResult, 0, index); -// return newResult; -// } -// -// /** -// * Returns the thread that has invoked syncExec -// * or null if no such runnable is currently being invoked by -// * the user-interface thread. -// *

    -// * Note: If a runnable invoked by asyncExec is currently -// * running, this method will return null. -// *

    -// * -// * @return the receiver's sync-interface thread -// * -// * @exception SWTException
      -// *
    • ERROR_DEVICE_DISPOSED - if the receiver has been disposed
    • -// *
    -// */ -// public Thread getSyncThread () { -// if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED); -// return synchronizer.syncThread; -// } -// -// /** -// * Returns the matching standard color for the given -// * constant, which should be one of the color constants -// * specified in class SWT. Any value other -// * than one of the SWT color constants which is passed -// * in will result in the color black. This color should -// * not be free'd because it was allocated by the system, -// * not the application. -// * -// * @param id the color constant -// * @return the matching color -// * -// * @exception SWTException
      -// *
    • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • -// *
    • ERROR_DEVICE_DISPOSED - if the receiver has been disposed
    • -// *
    -// * -// * @see SWT -// */ -// public Color getSystemColor (int id) { -// checkDevice (); -// GdkColor gdkColor = null; -// switch (id) { -// case SWT.COLOR_INFO_FOREGROUND: gdkColor = COLOR_INFO_FOREGROUND; break; -// case SWT.COLOR_INFO_BACKGROUND: gdkColor = COLOR_INFO_BACKGROUND; break; -// case SWT.COLOR_TITLE_FOREGROUND: gdkColor = COLOR_TITLE_FOREGROUND; break; -// case SWT.COLOR_TITLE_BACKGROUND: gdkColor = COLOR_TITLE_BACKGROUND; break; -// case SWT.COLOR_TITLE_BACKGROUND_GRADIENT: gdkColor = COLOR_TITLE_BACKGROUND_GRADIENT; break; -// case SWT.COLOR_TITLE_INACTIVE_FOREGROUND: gdkColor = COLOR_TITLE_INACTIVE_FOREGROUND; break; -// case SWT.COLOR_TITLE_INACTIVE_BACKGROUND: gdkColor = COLOR_TITLE_INACTIVE_BACKGROUND; break; -// case SWT.COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT: gdkColor = COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT; break; -// case SWT.COLOR_WIDGET_DARK_SHADOW: gdkColor = COLOR_WIDGET_DARK_SHADOW; break; -// case SWT.COLOR_WIDGET_NORMAL_SHADOW: gdkColor = COLOR_WIDGET_NORMAL_SHADOW; break; -// case SWT.COLOR_WIDGET_LIGHT_SHADOW: gdkColor = COLOR_WIDGET_LIGHT_SHADOW; break; -// case SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW: gdkColor = COLOR_WIDGET_HIGHLIGHT_SHADOW; break; -// case SWT.COLOR_WIDGET_BACKGROUND: gdkColor = COLOR_WIDGET_BACKGROUND; break; -// case SWT.COLOR_WIDGET_FOREGROUND: gdkColor = COLOR_WIDGET_FOREGROUND; break; -// case SWT.COLOR_WIDGET_BORDER: gdkColor = COLOR_WIDGET_BORDER; break; -// case SWT.COLOR_LIST_FOREGROUND: gdkColor = COLOR_LIST_FOREGROUND; break; -// case SWT.COLOR_LIST_BACKGROUND: gdkColor = COLOR_LIST_BACKGROUND; break; -// case SWT.COLOR_LIST_SELECTION: gdkColor = COLOR_LIST_SELECTION; break; -// case SWT.COLOR_LIST_SELECTION_TEXT: gdkColor = COLOR_LIST_SELECTION_TEXT; break; -// default: -// return super.getSystemColor (id); -// } -// if (gdkColor is null) return super.getSystemColor (SWT.COLOR_BLACK); -// return Color.gtk_new (this, gdkColor); -// } -// -// /** -// * Returns the matching standard platform cursor for the given -// * constant, which should be one of the cursor constants -// * specified in class SWT. This cursor should -// * not be free'd because it was allocated by the system, -// * not the application. A value of null will -// * be returned if the supplied constant is not an SWT cursor -// * constant. -// * -// * @param id the SWT cursor constant -// * @return the corresponding cursor or null -// * -// * @exception SWTException
      -// *
    • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • -// *
    • ERROR_DEVICE_DISPOSED - if the receiver has been disposed
    • -// *
    -// * -// * @see SWT#CURSOR_ARROW -// * @see SWT#CURSOR_WAIT -// * @see SWT#CURSOR_CROSS -// * @see SWT#CURSOR_APPSTARTING -// * @see SWT#CURSOR_HELP -// * @see SWT#CURSOR_SIZEALL -// * @see SWT#CURSOR_SIZENESW -// * @see SWT#CURSOR_SIZENS -// * @see SWT#CURSOR_SIZENWSE -// * @see SWT#CURSOR_SIZEWE -// * @see SWT#CURSOR_SIZEN -// * @see SWT#CURSOR_SIZES -// * @see SWT#CURSOR_SIZEE -// * @see SWT#CURSOR_SIZEW -// * @see SWT#CURSOR_SIZENE -// * @see SWT#CURSOR_SIZESE -// * @see SWT#CURSOR_SIZESW -// * @see SWT#CURSOR_SIZENW -// * @see SWT#CURSOR_UPARROW -// * @see SWT#CURSOR_IBEAM -// * @see SWT#CURSOR_NO -// * @see SWT#CURSOR_HAND -// * -// * @since 3.0 -// */ -// public Cursor getSystemCursor (int id) { -// checkDevice (); -// if (!(0 <= id && id < cursors.length)) return null; -// if (cursors [id] is null) { -// cursors [id] = new Cursor (this, id); -// } -// return cursors [id]; -// } -// -// /** -// * Returns the matching standard platform image for the given -// * constant, which should be one of the icon constants -// * specified in class SWT. This image should -// * not be free'd because it was allocated by the system, -// * not the application. A value of null will -// * be returned either if the supplied constant is not an -// * SWT icon constant or if the platform does not define an -// * image that corresponds to the constant. -// * -// * @param id the SWT icon constant -// * @return the corresponding image or null -// * -// * @exception SWTException
      -// *
    • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • -// *
    • ERROR_DEVICE_DISPOSED - if the receiver has been disposed
    • -// *
    -// * -// * @see SWT#ICON_ERROR -// * @see SWT#ICON_INFORMATION -// * @see SWT#ICON_QUESTION -// * @see SWT#ICON_WARNING -// * @see SWT#ICON_WORKING -// * -// * @since 3.0 -// */ -// public Image getSystemImage (int id) { -// checkDevice (); -// switch (id) { -// case SWT.ICON_ERROR: -// if (errorImage is null) { -// errorImage = createImage ("gtk-dialog-error"); -// } -// return errorImage; -// case SWT.ICON_INFORMATION: -// case SWT.ICON_WORKING: -// if (infoImage is null) { -// infoImage = createImage ("gtk-dialog-info"); -// } -// return infoImage; -// case SWT.ICON_QUESTION: -// if (questionImage is null) { -// questionImage = createImage ("gtk-dialog-question"); -// } -// return questionImage; -// case SWT.ICON_WARNING: -// if (warningImage is null) { -// warningImage = createImage ("gtk-dialog-warning"); -// } -// return warningImage; -// } -// return null; -// } -// -// void initializeSystemColors () { -// GdkColor gdkColor; -// -// /* Get Tooltip resources */ -// auto tooltipShellHandle = OS.gtk_window_new (OS.GTK_WINDOW_POPUP); -// if (tooltipShellHandle is null) SWT.error (SWT.ERROR_NO_HANDLES); -// byte[] gtk_tooltips = Converter.wcsToMbcs (null, "gtk-tooltips", true); -// OS.gtk_widget_set_name (tooltipShellHandle, gtk_tooltips); -// OS.gtk_widget_realize (tooltipShellHandle); -// auto tooltipStyle = OS.gtk_widget_get_style (tooltipShellHandle); -// gdkColor = new GdkColor(); -// OS.gtk_style_get_fg (tooltipStyle, OS.GTK_STATE_NORMAL, gdkColor); -// COLOR_INFO_FOREGROUND = gdkColor; -// gdkColor = new GdkColor(); -// OS.gtk_style_get_bg (tooltipStyle, OS.GTK_STATE_NORMAL, gdkColor); -// COLOR_INFO_BACKGROUND = gdkColor; -// OS.gtk_widget_destroy (tooltipShellHandle); -// -// /* Get Shell resources */ -// auto style = OS.gtk_widget_get_style (shellHandle); -// gdkColor = new GdkColor(); -// OS.gtk_style_get_black (style, gdkColor); -// COLOR_WIDGET_DARK_SHADOW = gdkColor; -// gdkColor = new GdkColor(); -// OS.gtk_style_get_dark (style, OS.GTK_STATE_NORMAL, gdkColor); -// COLOR_WIDGET_NORMAL_SHADOW = gdkColor; -// gdkColor = new GdkColor(); -// OS.gtk_style_get_bg (style, OS.GTK_STATE_NORMAL, gdkColor); -// COLOR_WIDGET_LIGHT_SHADOW = gdkColor; -// gdkColor = new GdkColor(); -// OS.gtk_style_get_light (style, OS.GTK_STATE_NORMAL, gdkColor); -// COLOR_WIDGET_HIGHLIGHT_SHADOW = gdkColor; -// gdkColor = new GdkColor(); -// OS.gtk_style_get_fg (style, OS.GTK_STATE_NORMAL, gdkColor); -// COLOR_WIDGET_FOREGROUND = gdkColor; -// gdkColor = new GdkColor(); -// OS.gtk_style_get_bg (style, OS.GTK_STATE_NORMAL, gdkColor); -// COLOR_WIDGET_BACKGROUND = gdkColor; -// //gdkColor = new GdkColor(); -// //OS.gtk_style_get_text (style, OS.GTK_STATE_NORMAL, gdkColor); -// //COLOR_TEXT_FOREGROUND = gdkColor; -// //gdkColor = new GdkColor(); -// //OS.gtk_style_get_base (style, OS.GTK_STATE_NORMAL, gdkColor); -// //COLOR_TEXT_BACKGROUND = gdkColor; -// gdkColor = new GdkColor(); -// OS.gtk_style_get_text (style, OS.GTK_STATE_NORMAL, gdkColor); -// COLOR_LIST_FOREGROUND = gdkColor; -// gdkColor = new GdkColor(); -// OS.gtk_style_get_base (style, OS.GTK_STATE_NORMAL, gdkColor); -// COLOR_LIST_BACKGROUND = gdkColor; -// gdkColor = new GdkColor(); -// OS.gtk_style_get_text (style, OS.GTK_STATE_SELECTED, gdkColor); -// COLOR_LIST_SELECTION_TEXT = gdkColor; -// gdkColor = new GdkColor(); -// OS.gtk_style_get_base (style, OS.GTK_STATE_SELECTED, gdkColor); -// COLOR_LIST_SELECTION = gdkColor; -// gdkColor = new GdkColor(); -// OS.gtk_style_get_bg (style, OS.GTK_STATE_SELECTED, gdkColor); -// COLOR_TITLE_BACKGROUND = gdkColor; -// gdkColor = new GdkColor(); -// OS.gtk_style_get_fg (style, OS.GTK_STATE_SELECTED, gdkColor); -// COLOR_TITLE_FOREGROUND = gdkColor; -// gdkColor = new GdkColor(); -// OS.gtk_style_get_light (style, OS.GTK_STATE_SELECTED, gdkColor); -// COLOR_TITLE_BACKGROUND_GRADIENT = gdkColor; -// gdkColor = new GdkColor(); -// OS.gtk_style_get_bg (style, OS.GTK_STATE_INSENSITIVE, gdkColor); -// COLOR_TITLE_INACTIVE_BACKGROUND = gdkColor; -// gdkColor = new GdkColor(); -// OS.gtk_style_get_fg (style, OS.GTK_STATE_INSENSITIVE, gdkColor); -// COLOR_TITLE_INACTIVE_FOREGROUND = gdkColor; -// gdkColor = new GdkColor(); -// OS.gtk_style_get_light (style, OS.GTK_STATE_INSENSITIVE, gdkColor); -// COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT = gdkColor; -// } -// -// /** -// * Returns a reasonable font for applications to use. -// * On some platforms, this will match the "default font" -// * or "system font" if such can be found. This font -// * should not be free'd because it was allocated by the -// * system, not the application. -// *

    -// * Typically, applications which want the default look -// * should simply not set the font on the widgets they -// * create. Widgets are always created with the correct -// * default font for the class of user-interface component -// * they represent. -// *

    -// * -// * @return a font -// * -// * @exception SWTException
      -// *
    • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • -// *
    • ERROR_DEVICE_DISPOSED - if the receiver has been disposed
    • -// *
    -// */ -// public Font getSystemFont () { -// checkDevice (); -// if (systemFont !is null) return systemFont; -// auto style = OS.gtk_widget_get_style (shellHandle); -// auto defaultFont = OS.pango_font_description_copy (OS.gtk_style_get_font_desc (style)); -// return systemFont = Font.gtk_new (this, defaultFont); -// } -// -// /** -// * Returns the single instance of the system tray or null -// * when there is no system tray available for the platform. -// * -// * @return the system tray or null -// * -// * @exception SWTException
      -// *
    • ERROR_DEVICE_DISPOSED - if the receiver has been disposed
    • -// *
    -// * -// * @since 3.0 -// */ -// public Tray getSystemTray () { -// checkDevice (); -// if (tray !is null) return tray; -// return tray = new Tray (this, SWT.NONE); -// } -// -// /** -// * Returns the user-interface thread for the receiver. -// * -// * @return the receiver's user-interface thread -// * -// * @exception SWTException
      -// *
    • ERROR_DEVICE_DISPOSED - if the receiver has been disposed
    • -// *
    -// */ -// public Thread getThread () { -// if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED); -// return thread; -// } -// + +/** + * Returns the button dismissal alignment, one of LEFT or RIGHT. + * The button dismissal alignment is the ordering that should be used when positioning the + * default dismissal button for a dialog. For example, in a dialog that contains an OK and + * CANCEL button, on platforms where the button dismissal alignment is LEFT, the + * button ordering should be OK/CANCEL. When button dismissal alignment is RIGHT, + * the button ordering should be CANCEL/OK. + * + * @return the button dismissal order + * + * @exception SWTException
      + *
    • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • + *
    • ERROR_DEVICE_DISPOSED - if the receiver has been disposed
    • + *
    + * + * @since 2.1 + */ +public int getDismissalAlignment () { + checkDevice (); + return SWT.RIGHT; +} + +/** + * Returns the longest duration, in milliseconds, between + * two mouse button clicks that will be considered a + * double click by the underlying operating system. + * + * @return the double click time + * + * @exception SWTException
      + *
    • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • + *
    • ERROR_DEVICE_DISPOSED - if the receiver has been disposed
    • + *
    + */ +public int getDoubleClickTime () { + checkDevice (); + auto settings = OS.gtk_settings_get_default (); + int buffer; + OS.g_object_get1 (settings, OS.gtk_double_click_time.ptr, &buffer); + return buffer; +} + +/** + * Returns the control which currently has keyboard focus, + * or null if keyboard events are not currently going to + * any of the controls built by the currently running + * application. + * + * @return the control under the cursor + * + * @exception SWTException
      + *
    • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • + *
    • ERROR_DEVICE_DISPOSED - if the receiver has been disposed
    • + *
    + */ +public Control getFocusControl () { + checkDevice (); + if (focusControl !is null && !focusControl.isDisposed ()) { + return focusControl; + } + if (activeShell is null) return null; + auto shellHandle = activeShell.shellHandle; + auto handle = OS.gtk_window_get_focus (cast(GtkWindow*)shellHandle); + if (handle is null) return null; + do { + Widget widget = getWidget (handle); + if (widget !is null && (null !is cast(Control)widget)) { + Control control = cast(Control) widget; + return control.isEnabled () ? control : null; + } + } while ((handle = OS.gtk_widget_get_parent (handle)) !is null); + return null; +} + +/** + * Returns true when the high contrast mode is enabled. + * Otherwise, false is returned. + *

    + * Note: This operation is a hint and is not supported on + * platforms that do not have this concept. + *

    + * + * @return the high contrast mode + * + * @exception SWTException
      + *
    • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • + *
    • ERROR_DEVICE_DISPOSED - if the receiver has been disposed
    • + *
    + * + * @since 3.0 + */ +public bool getHighContrast () { + checkDevice (); + return false; +} + +public int getDepth () { + checkDevice (); + auto visual = OS.gdk_visual_get_system(); + return visual.depth; +} + +/** + * Returns the maximum allowed depth of icons on this display, in bits per pixel. + * On some platforms, this may be different than the actual depth of the display. + * + * @return the maximum icon depth + * + * @exception SWTException
      + *
    • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • + *
    • ERROR_DEVICE_DISPOSED - if the receiver has been disposed
    • + *
    + * + * @see Device#getDepth + */ +public int getIconDepth () { + checkDevice (); + return getDepth (); +} + +/** + * Returns an array containing the recommended icon sizes. + * + * @return the array of icon sizes + * + * @exception SWTException
      + *
    • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • + *
    • ERROR_DEVICE_DISPOSED - if the receiver has been disposed
    • + *
    + * + * @see Decorations#setImages(Image[]) + * + * @since 3.0 + */ +public Point [] getIconSizes () { + checkDevice (); + return [new Point (16, 16), new Point (32, 32)]; +} + +int getLastEventTime () { + return lastEventTime; +} + +int getMessageCount () { + return synchronizer.getMessageCount (); +} + +/** + * Returns the work area, an EWMH property to store the size + * and position of the screen not covered by dock and panel + * windows. See http://freedesktop.org/Standards/wm-spec. + */ +Rectangle getWorkArea() { + auto atom = OS.gdk_atom_intern ("_NET_WORKAREA".ptr, true); + if (atom is null/*OS.GDK_NONE*/) return null; + void* actualType; + int actualFormat; + int actualLength; + char* data; + if (!OS.gdk_property_get (cast(GdkDrawable*)OS.GDK_ROOT_PARENT (), atom, null/*OS.GDK_NONE*/, 0, 16, 0, &actualType, &actualFormat, &actualLength, &data)) { + return null; + } + Rectangle result = null; + if (data !is null) { + if (actualLength is 16) { + int[] values = (cast(int*)data)[0..4]; + result = new Rectangle (values [0],values [1],values [2],values [3]); + } else if (actualLength is 32) { + long[] values = (cast(long*)data)[0..4]; + result = new Rectangle (cast(int)values [0],cast(int)values [1],cast(int)values [2],cast(int)values [3]); + } + OS.g_free (data); + } + return result; +} + +/** + * Returns an array of monitors attached to the device. + * + * @return the array of monitors + * + * @since 3.0 + */ +public dwt.widgets.Monitor.Monitor [] getMonitors () { + checkDevice (); + dwt.widgets.Monitor.Monitor [] monitors = null; + Rectangle workArea = getWorkArea(); + auto screen = OS.gdk_screen_get_default (); + if (screen !is null) { + int monitorCount = OS.gdk_screen_get_n_monitors (screen); + if (monitorCount > 0) { + monitors = new dwt.widgets.Monitor.Monitor [monitorCount]; + GdkRectangle* dest = new GdkRectangle (); + for (int i = 0; i < monitorCount; i++) { + OS.gdk_screen_get_monitor_geometry (screen, i, dest); + auto monitor = new dwt.widgets.Monitor.Monitor (); + monitor.handle = i; + monitor.x = dest.x; + monitor.y = dest.y; + monitor.width = dest.width; + monitor.height = dest.height; + if (i is 0 && workArea !is null) { + monitor.clientX = workArea.x; + monitor.clientY = workArea.y; + monitor.clientWidth = workArea.width; + monitor.clientHeight = workArea.height; + } else { + monitor.clientX = monitor.x; + monitor.clientY = monitor.y; + monitor.clientWidth = monitor.width; + monitor.clientHeight = monitor.height; + } + monitors [i] = monitor; + } + } + } + if (monitors is null) { + /* No multimonitor support detected, default to one monitor */ + auto monitor = new dwt.widgets.Monitor.Monitor (); + Rectangle bounds = getBounds (); + monitor.x = bounds.x; + monitor.y = bounds.y; + monitor.width = bounds.width; + monitor.height = bounds.height; + if (workArea !is null) { + monitor.clientX = workArea.x; + monitor.clientY = workArea.y; + monitor.clientWidth = workArea.width; + monitor.clientHeight = workArea.height; + } else { + monitor.clientX = monitor.x; + monitor.clientY = monitor.y; + monitor.clientWidth = monitor.width; + monitor.clientHeight = monitor.height; + } + monitors = [ monitor ]; + } + return monitors; +} + +/** + * Returns the primary monitor for that device. + * + * @return the primary monitor + * + * @since 3.0 + */ +public dwt.widgets.Monitor.Monitor getPrimaryMonitor () { + checkDevice (); + auto monitors = getMonitors (); + return monitors [0]; +} + +/** + * Returns a (possibly empty) array containing all shells which have + * not been disposed and have the receiver as their display. + * + * @return the receiver's shells + * + * @exception SWTException
      + *
    • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • + *
    • ERROR_DEVICE_DISPOSED - if the receiver has been disposed
    • + *
    + */ +public Shell [] getShells () { + checkDevice (); + int index = 0; + Shell [] result = new Shell [16]; + for (int i = 0; i < widgetTable.length; i++) { + Widget widget = widgetTable [i]; + if (widget !is null && (null !is cast(Shell)widget)) { + int j = 0; + while (j < index) { + if (result [j] is widget) break; + j++; + } + if (j is index) { + if (index is result.length) { + Shell [] newResult = new Shell [index + 16]; + System.arraycopy (result, 0, newResult, 0, index); + result = newResult; + } + result [index++] = cast(Shell) widget; + } + } + } + if (index is result.length) return result; + Shell [] newResult = new Shell [index]; + System.arraycopy (result, 0, newResult, 0, index); + return newResult; +} + +/** + * Returns the thread that has invoked syncExec + * or null if no such runnable is currently being invoked by + * the user-interface thread. + *

    + * Note: If a runnable invoked by asyncExec is currently + * running, this method will return null. + *

    + * + * @return the receiver's sync-interface thread + * + * @exception SWTException
      + *
    • ERROR_DEVICE_DISPOSED - if the receiver has been disposed
    • + *
    + */ +public Thread getSyncThread () { + if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED); + return synchronizer.syncThread; +} + +/** + * Returns the matching standard color for the given + * constant, which should be one of the color constants + * specified in class SWT. Any value other + * than one of the SWT color constants which is passed + * in will result in the color black. This color should + * not be free'd because it was allocated by the system, + * not the application. + * + * @param id the color constant + * @return the matching color + * + * @exception SWTException
      + *
    • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • + *
    • ERROR_DEVICE_DISPOSED - if the receiver has been disposed
    • + *
    + * + * @see SWT + */ +public Color getSystemColor (int id) { + checkDevice (); + GdkColor* gdkColor = null; + switch (id) { + case SWT.COLOR_INFO_FOREGROUND: gdkColor = COLOR_INFO_FOREGROUND; break; + case SWT.COLOR_INFO_BACKGROUND: gdkColor = COLOR_INFO_BACKGROUND; break; + case SWT.COLOR_TITLE_FOREGROUND: gdkColor = COLOR_TITLE_FOREGROUND; break; + case SWT.COLOR_TITLE_BACKGROUND: gdkColor = COLOR_TITLE_BACKGROUND; break; + case SWT.COLOR_TITLE_BACKGROUND_GRADIENT: gdkColor = COLOR_TITLE_BACKGROUND_GRADIENT; break; + case SWT.COLOR_TITLE_INACTIVE_FOREGROUND: gdkColor = COLOR_TITLE_INACTIVE_FOREGROUND; break; + case SWT.COLOR_TITLE_INACTIVE_BACKGROUND: gdkColor = COLOR_TITLE_INACTIVE_BACKGROUND; break; + case SWT.COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT: gdkColor = COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT; break; + case SWT.COLOR_WIDGET_DARK_SHADOW: gdkColor = COLOR_WIDGET_DARK_SHADOW; break; + case SWT.COLOR_WIDGET_NORMAL_SHADOW: gdkColor = COLOR_WIDGET_NORMAL_SHADOW; break; + case SWT.COLOR_WIDGET_LIGHT_SHADOW: gdkColor = COLOR_WIDGET_LIGHT_SHADOW; break; + case SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW: gdkColor = COLOR_WIDGET_HIGHLIGHT_SHADOW; break; + case SWT.COLOR_WIDGET_BACKGROUND: gdkColor = COLOR_WIDGET_BACKGROUND; break; + case SWT.COLOR_WIDGET_FOREGROUND: gdkColor = COLOR_WIDGET_FOREGROUND; break; + case SWT.COLOR_WIDGET_BORDER: gdkColor = COLOR_WIDGET_BORDER; break; + case SWT.COLOR_LIST_FOREGROUND: gdkColor = COLOR_LIST_FOREGROUND; break; + case SWT.COLOR_LIST_BACKGROUND: gdkColor = COLOR_LIST_BACKGROUND; break; + case SWT.COLOR_LIST_SELECTION: gdkColor = COLOR_LIST_SELECTION; break; + case SWT.COLOR_LIST_SELECTION_TEXT: gdkColor = COLOR_LIST_SELECTION_TEXT; break; + default: + return super.getSystemColor (id); + } + if (gdkColor is null) return super.getSystemColor (SWT.COLOR_BLACK); + return Color.gtk_new (this, gdkColor); +} + +/** + * Returns the matching standard platform cursor for the given + * constant, which should be one of the cursor constants + * specified in class SWT. This cursor should + * not be free'd because it was allocated by the system, + * not the application. A value of null will + * be returned if the supplied constant is not an SWT cursor + * constant. + * + * @param id the SWT cursor constant + * @return the corresponding cursor or null + * + * @exception SWTException
      + *
    • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • + *
    • ERROR_DEVICE_DISPOSED - if the receiver has been disposed
    • + *
    + * + * @see SWT#CURSOR_ARROW + * @see SWT#CURSOR_WAIT + * @see SWT#CURSOR_CROSS + * @see SWT#CURSOR_APPSTARTING + * @see SWT#CURSOR_HELP + * @see SWT#CURSOR_SIZEALL + * @see SWT#CURSOR_SIZENESW + * @see SWT#CURSOR_SIZENS + * @see SWT#CURSOR_SIZENWSE + * @see SWT#CURSOR_SIZEWE + * @see SWT#CURSOR_SIZEN + * @see SWT#CURSOR_SIZES + * @see SWT#CURSOR_SIZEE + * @see SWT#CURSOR_SIZEW + * @see SWT#CURSOR_SIZENE + * @see SWT#CURSOR_SIZESE + * @see SWT#CURSOR_SIZESW + * @see SWT#CURSOR_SIZENW + * @see SWT#CURSOR_UPARROW + * @see SWT#CURSOR_IBEAM + * @see SWT#CURSOR_NO + * @see SWT#CURSOR_HAND + * + * @since 3.0 + */ +public Cursor getSystemCursor (int id) { + checkDevice (); + if (!(0 <= id && id < cursors.length)) return null; + if (cursors [id] is null) { + cursors [id] = new Cursor (this, id); + } + return cursors [id]; +} + +/** + * Returns the matching standard platform image for the given + * constant, which should be one of the icon constants + * specified in class SWT. This image should + * not be free'd because it was allocated by the system, + * not the application. A value of null will + * be returned either if the supplied constant is not an + * SWT icon constant or if the platform does not define an + * image that corresponds to the constant. + * + * @param id the SWT icon constant + * @return the corresponding image or null + * + * @exception SWTException
      + *
    • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • + *
    • ERROR_DEVICE_DISPOSED - if the receiver has been disposed
    • + *
    + * + * @see SWT#ICON_ERROR + * @see SWT#ICON_INFORMATION + * @see SWT#ICON_QUESTION + * @see SWT#ICON_WARNING + * @see SWT#ICON_WORKING + * + * @since 3.0 + */ +public Image getSystemImage (int id) { + checkDevice (); + switch (id) { + case SWT.ICON_ERROR: + if (errorImage is null) { + errorImage = createImage ("gtk-dialog-error"); + } + return errorImage; + case SWT.ICON_INFORMATION: + case SWT.ICON_WORKING: + if (infoImage is null) { + infoImage = createImage ("gtk-dialog-info"); + } + return infoImage; + case SWT.ICON_QUESTION: + if (questionImage is null) { + questionImage = createImage ("gtk-dialog-question"); + } + return questionImage; + case SWT.ICON_WARNING: + if (warningImage is null) { + warningImage = createImage ("gtk-dialog-warning"); + } + return warningImage; + } + return null; +} + +void initializeSystemColors () { + GdkColor* gdkColor; + + /* Get Tooltip resources */ + auto tooltipShellHandle = OS.gtk_window_new (cast(GtkWindowType)OS.GTK_WINDOW_POPUP); + if (tooltipShellHandle is null) SWT.error (SWT.ERROR_NO_HANDLES); +// byte[] gtk_tooltips = Converter.wcsToMbcs (null, "gtk-tooltips", true); + OS.gtk_widget_set_name (tooltipShellHandle, "gtk-tooltips".ptr ); + OS.gtk_widget_realize (tooltipShellHandle); + auto tooltipStyle = OS.gtk_widget_get_style (tooltipShellHandle); + gdkColor = new GdkColor(); + OS.gtk_style_get_fg (tooltipStyle, OS.GTK_STATE_NORMAL, gdkColor); + COLOR_INFO_FOREGROUND = gdkColor; + gdkColor = new GdkColor(); + OS.gtk_style_get_bg (tooltipStyle, OS.GTK_STATE_NORMAL, gdkColor); + COLOR_INFO_BACKGROUND = gdkColor; + OS.gtk_widget_destroy (tooltipShellHandle); + + /* Get Shell resources */ + auto style = OS.gtk_widget_get_style (shellHandle); + gdkColor = new GdkColor(); + OS.gtk_style_get_black (style, gdkColor); + COLOR_WIDGET_DARK_SHADOW = gdkColor; + gdkColor = new GdkColor(); + OS.gtk_style_get_dark (style, OS.GTK_STATE_NORMAL, gdkColor); + COLOR_WIDGET_NORMAL_SHADOW = gdkColor; + gdkColor = new GdkColor(); + OS.gtk_style_get_bg (style, OS.GTK_STATE_NORMAL, gdkColor); + COLOR_WIDGET_LIGHT_SHADOW = gdkColor; + gdkColor = new GdkColor(); + OS.gtk_style_get_light (style, OS.GTK_STATE_NORMAL, gdkColor); + COLOR_WIDGET_HIGHLIGHT_SHADOW = gdkColor; + gdkColor = new GdkColor(); + OS.gtk_style_get_fg (style, OS.GTK_STATE_NORMAL, gdkColor); + COLOR_WIDGET_FOREGROUND = gdkColor; + gdkColor = new GdkColor(); + OS.gtk_style_get_bg (style, OS.GTK_STATE_NORMAL, gdkColor); + COLOR_WIDGET_BACKGROUND = gdkColor; + //gdkColor = new GdkColor(); + //OS.gtk_style_get_text (style, OS.GTK_STATE_NORMAL, gdkColor); + //COLOR_TEXT_FOREGROUND = gdkColor; + //gdkColor = new GdkColor(); + //OS.gtk_style_get_base (style, OS.GTK_STATE_NORMAL, gdkColor); + //COLOR_TEXT_BACKGROUND = gdkColor; + gdkColor = new GdkColor(); + OS.gtk_style_get_text (style, OS.GTK_STATE_NORMAL, gdkColor); + COLOR_LIST_FOREGROUND = gdkColor; + gdkColor = new GdkColor(); + OS.gtk_style_get_base (style, OS.GTK_STATE_NORMAL, gdkColor); + COLOR_LIST_BACKGROUND = gdkColor; + gdkColor = new GdkColor(); + OS.gtk_style_get_text (style, OS.GTK_STATE_SELECTED, gdkColor); + COLOR_LIST_SELECTION_TEXT = gdkColor; + gdkColor = new GdkColor(); + OS.gtk_style_get_base (style, OS.GTK_STATE_SELECTED, gdkColor); + COLOR_LIST_SELECTION = gdkColor; + gdkColor = new GdkColor(); + OS.gtk_style_get_bg (style, OS.GTK_STATE_SELECTED, gdkColor); + COLOR_TITLE_BACKGROUND = gdkColor; + gdkColor = new GdkColor(); + OS.gtk_style_get_fg (style, OS.GTK_STATE_SELECTED, gdkColor); + COLOR_TITLE_FOREGROUND = gdkColor; + gdkColor = new GdkColor(); + OS.gtk_style_get_light (style, OS.GTK_STATE_SELECTED, gdkColor); + COLOR_TITLE_BACKGROUND_GRADIENT = gdkColor; + gdkColor = new GdkColor(); + OS.gtk_style_get_bg (style, OS.GTK_STATE_INSENSITIVE, gdkColor); + COLOR_TITLE_INACTIVE_BACKGROUND = gdkColor; + gdkColor = new GdkColor(); + OS.gtk_style_get_fg (style, OS.GTK_STATE_INSENSITIVE, gdkColor); + COLOR_TITLE_INACTIVE_FOREGROUND = gdkColor; + gdkColor = new GdkColor(); + OS.gtk_style_get_light (style, OS.GTK_STATE_INSENSITIVE, gdkColor); + COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT = gdkColor; +} + +/** + * Returns a reasonable font for applications to use. + * On some platforms, this will match the "default font" + * or "system font" if such can be found. This font + * should not be free'd because it was allocated by the + * system, not the application. + *

    + * Typically, applications which want the default look + * should simply not set the font on the widgets they + * create. Widgets are always created with the correct + * default font for the class of user-interface component + * they represent. + *

    + * + * @return a font + * + * @exception SWTException
      + *
    • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • + *
    • ERROR_DEVICE_DISPOSED - if the receiver has been disposed
    • + *
    + */ +public Font getSystemFont () { + checkDevice (); + if (systemFont !is null) return systemFont; + auto style = OS.gtk_widget_get_style (shellHandle); + auto defaultFont = OS.pango_font_description_copy (OS.gtk_style_get_font_desc (style)); + return systemFont = Font.gtk_new (this, defaultFont); +} + +/** + * Returns the single instance of the system tray or null + * when there is no system tray available for the platform. + * + * @return the system tray or null + * + * @exception SWTException
      + *
    • ERROR_DEVICE_DISPOSED - if the receiver has been disposed
    • + *
    + * + * @since 3.0 + */ +public Tray getSystemTray () { + checkDevice (); + if (tray !is null) return tray; + return tray = new Tray (this, SWT.NONE); +} + +/** + * Returns the user-interface thread for the receiver. + * + * @return the receiver's user-interface thread + * + * @exception SWTException
      + *
    • ERROR_DEVICE_DISPOSED - if the receiver has been disposed
    • + *
    + */ +public Thread getThread () { + if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED); + return thread; +} + Widget getWidget (GtkWidget* handle) { -// if (handle is null) return null; -// if (lastWidget !is null && lastHandle is handle) return lastWidget; -// auto index = OS.g_object_get_qdata (handle, SWT_OBJECT_INDEX) - 1; -// if (0 <= index && index < widgetTable.length) { -// lastHandle = handle; -// return lastWidget = widgetTable [cast(int)/*64*/index]; -// } + if (handle is null) return null; + if (lastWidget !is null && lastHandle is handle) return lastWidget; + auto index = cast(int) OS.g_object_get_qdata ( cast(GObject*)handle, SWT_OBJECT_INDEX) - 1; + if (0 <= index && index < widgetTable.length) { + lastHandle = handle; + return lastWidget = widgetTable [cast(int)/*64*/index]; + } return null; } private static extern(C) int idleProcFunc (void* data) { - Display display = cast(Display)data; - return display.idleProcMeth(); + auto dbdata = cast(CallbackData*)data; + return dbdata.display.idleProc(); } -private int idleProcMeth () { -// bool result = runAsyncMessages (false); -// if (!result) { -// synchronized (idleLock) { -// idleHandle = 0; -// } -// } -// return result ? 1 : 0; +private int idleProc () { + bool result = runAsyncMessages (false); + if (!result) { + synchronized (idleLock) { + idleHandle = 0; + } + } + return result ? 1 : 0; return 0; } -// -// /** -// * Initializes any internal resources needed by the -// * device. -// *

    -// * This method is called after create. -// *

    -// * -// * @see #create -// */ -// protected void init () { -// super.init (); -// initializeCallbacks (); -// initializeSystemColors (); -// initializeSystemSettings (); -// initializeWidgetTable (); -// initializeWindowManager (); -// } -// -// void initializeCallbacks () { -// closures = new int /*long*/ [Widget.LAST_SIGNAL]; -// signalIds = new int [Widget.LAST_SIGNAL]; -// -// /* Cache signals for GtkWidget */ -// signalIds [Widget.BUTTON_PRESS_EVENT] = OS.g_signal_lookup (OS.button_press_event, OS.GTK_TYPE_WIDGET ()); -// signalIds [Widget.BUTTON_RELEASE_EVENT] = OS.g_signal_lookup (OS.button_release_event, OS.GTK_TYPE_WIDGET ()); -// signalIds [Widget.CONFIGURE_EVENT] = OS.g_signal_lookup (OS.configure_event, OS.GTK_TYPE_WIDGET ()); -// signalIds [Widget.DELETE_EVENT] = OS.g_signal_lookup (OS.delete_event, OS.GTK_TYPE_WIDGET ()); -// signalIds [Widget.ENTER_NOTIFY_EVENT] = OS.g_signal_lookup (OS.enter_notify_event, OS.GTK_TYPE_WIDGET ()); -// signalIds [Widget.EVENT] = OS.g_signal_lookup (OS.event, OS.GTK_TYPE_WIDGET ()); -// signalIds [Widget.EVENT_AFTER] = OS.g_signal_lookup (OS.event_after, OS.GTK_TYPE_WIDGET ()); -// signalIds [Widget.EXPOSE_EVENT] = OS.g_signal_lookup (OS.expose_event, OS.GTK_TYPE_WIDGET ()); -// signalIds [Widget.FOCUS] = OS.g_signal_lookup (OS.focus, OS.GTK_TYPE_WIDGET ()); -// signalIds [Widget.FOCUS_IN_EVENT] = OS.g_signal_lookup (OS.focus_in_event, OS.GTK_TYPE_WIDGET ()); -// signalIds [Widget.FOCUS_OUT_EVENT] = OS.g_signal_lookup (OS.focus_out_event, OS.GTK_TYPE_WIDGET ()); -// signalIds [Widget.GRAB_FOCUS] = OS.g_signal_lookup (OS.grab_focus, OS.GTK_TYPE_WIDGET ()); -// signalIds [Widget.HIDE] = OS.g_signal_lookup (OS.hide, OS.GTK_TYPE_WIDGET ()); -// signalIds [Widget.KEY_PRESS_EVENT] = OS.g_signal_lookup (OS.key_press_event, OS.GTK_TYPE_WIDGET ()); -// signalIds [Widget.KEY_RELEASE_EVENT] = OS.g_signal_lookup (OS.key_release_event, OS.GTK_TYPE_WIDGET ()); -// signalIds [Widget.LEAVE_NOTIFY_EVENT] = OS.g_signal_lookup (OS.leave_notify_event, OS.GTK_TYPE_WIDGET ()); -// signalIds [Widget.MAP] = OS.g_signal_lookup (OS.map, OS.GTK_TYPE_WIDGET ()); -// signalIds [Widget.MAP_EVENT] = OS.g_signal_lookup (OS.map_event, OS.GTK_TYPE_WIDGET ()); -// signalIds [Widget.MNEMONIC_ACTIVATE] = OS.g_signal_lookup (OS.mnemonic_activate, OS.GTK_TYPE_WIDGET ()); -// signalIds [Widget.MOTION_NOTIFY_EVENT] = OS.g_signal_lookup (OS.motion_notify_event, OS.GTK_TYPE_WIDGET ()); -// signalIds [Widget.POPUP_MENU] = OS.g_signal_lookup (OS.popup_menu, OS.GTK_TYPE_WIDGET ()); -// signalIds [Widget.REALIZE] = OS.g_signal_lookup (OS.realize, OS.GTK_TYPE_WIDGET ()); -// signalIds [Widget.SCROLL_EVENT] = OS.g_signal_lookup (OS.scroll_event, OS.GTK_TYPE_WIDGET ()); -// signalIds [Widget.SHOW] = OS.g_signal_lookup (OS.show, OS.GTK_TYPE_WIDGET ()); -// signalIds [Widget.SHOW_HELP] = OS.g_signal_lookup (OS.show_help, OS.GTK_TYPE_WIDGET ()); -// signalIds [Widget.SIZE_ALLOCATE] = OS.g_signal_lookup (OS.size_allocate, OS.GTK_TYPE_WIDGET ()); -// signalIds [Widget.STYLE_SET] = OS.g_signal_lookup (OS.style_set, OS.GTK_TYPE_WIDGET ()); -// signalIds [Widget.UNMAP] = OS.g_signal_lookup (OS.unmap, OS.GTK_TYPE_WIDGET ()); -// signalIds [Widget.UNMAP_EVENT] = OS.g_signal_lookup (OS.unmap_event, OS.GTK_TYPE_WIDGET ()); -// signalIds [Widget.UNREALIZE] = OS.g_signal_lookup (OS.realize, OS.GTK_TYPE_WIDGET ()); -// signalIds [Widget.VISIBILITY_NOTIFY_EVENT] = OS.g_signal_lookup (OS.visibility_notify_event, OS.GTK_TYPE_WIDGET ()); -// signalIds [Widget.WINDOW_STATE_EVENT] = OS.g_signal_lookup (OS.window_state_event, OS.GTK_TYPE_WIDGET ()); -// -// windowCallback2 = new void*/*Callback*/ (this, "windowProc", 2); -// windowProc2 = windowCallback2.getAddress (); -// if (windowProc2 is null) SWT.error (SWT.ERROR_NO_MORE_CALLBACKS); -// -// closures [Widget.ACTIVATE] = OS.g_cclosure_new (windowProc2, Widget.ACTIVATE, 0); -// closures [Widget.ACTIVATE_INVERSE] = OS.g_cclosure_new (windowProc2, Widget.ACTIVATE_INVERSE, 0); -// closures [Widget.CHANGED] = OS.g_cclosure_new (windowProc2, Widget.CHANGED, 0); -// closures [Widget.CLICKED] = OS.g_cclosure_new (windowProc2, Widget.CLICKED, 0); -// closures [Widget.DAY_SELECTED] = OS.g_cclosure_new (windowProc2, Widget.DAY_SELECTED, 0); -// closures [Widget.HIDE] = OS.g_cclosure_new (windowProc2, Widget.HIDE, 0); -// closures [Widget.GRAB_FOCUS] = OS.g_cclosure_new (windowProc2, Widget.GRAB_FOCUS, 0); -// closures [Widget.MAP] = OS.g_cclosure_new (windowProc2, Widget.MAP, 0); -// closures [Widget.MONTH_CHANGED] = OS.g_cclosure_new (windowProc2, Widget.MONTH_CHANGED, 0); -// closures [Widget.OUTPUT] = OS.g_cclosure_new (windowProc2, Widget.OUTPUT, 0); -// closures [Widget.POPUP_MENU] = OS.g_cclosure_new (windowProc2, Widget.POPUP_MENU, 0); -// closures [Widget.PREEDIT_CHANGED] = OS.g_cclosure_new (windowProc2, Widget.PREEDIT_CHANGED, 0); -// closures [Widget.REALIZE] = OS.g_cclosure_new (windowProc2, Widget.REALIZE, 0); -// closures [Widget.SELECT] = OS.g_cclosure_new (windowProc2, Widget.SELECT, 0); -// closures [Widget.SHOW] = OS.g_cclosure_new (windowProc2, Widget.SHOW, 0); -// closures [Widget.VALUE_CHANGED] = OS.g_cclosure_new (windowProc2, Widget.VALUE_CHANGED, 0); -// closures [Widget.UNMAP] = OS.g_cclosure_new (windowProc2, Widget.UNMAP, 0); -// closures [Widget.UNREALIZE] = OS.g_cclosure_new (windowProc2, Widget.UNREALIZE, 0); -// -// windowCallback3 = new void*/*Callback*/ (this, "windowProc", 3); -// windowProc3 = windowCallback3.getAddress (); -// if (windowProc3 is null) SWT.error (SWT.ERROR_NO_MORE_CALLBACKS); -// -// closures [Widget.BUTTON_PRESS_EVENT] = OS.g_cclosure_new (windowProc3, Widget.BUTTON_PRESS_EVENT, 0); -// closures [Widget.BUTTON_PRESS_EVENT_INVERSE] = OS.g_cclosure_new (windowProc3, Widget.BUTTON_PRESS_EVENT_INVERSE, 0); -// closures [Widget.BUTTON_RELEASE_EVENT] = OS.g_cclosure_new (windowProc3, Widget.BUTTON_RELEASE_EVENT, 0); -// closures [Widget.BUTTON_RELEASE_EVENT_INVERSE] = OS.g_cclosure_new (windowProc3, Widget.BUTTON_RELEASE_EVENT_INVERSE, 0); -// closures [Widget.COMMIT] = OS.g_cclosure_new (windowProc3, Widget.COMMIT, 0); -// closures [Widget.CONFIGURE_EVENT] = OS.g_cclosure_new (windowProc3, Widget.CONFIGURE_EVENT, 0); -// closures [Widget.DELETE_EVENT] = OS.g_cclosure_new (windowProc3, Widget.DELETE_EVENT, 0); -// closures [Widget.ENTER_NOTIFY_EVENT] = OS.g_cclosure_new (windowProc3, Widget.ENTER_NOTIFY_EVENT, 0); -// closures [Widget.EVENT] = OS.g_cclosure_new (windowProc3, Widget.EVENT, 0); -// closures [Widget.EVENT_AFTER] = OS.g_cclosure_new (windowProc3, Widget.EVENT_AFTER, 0); -// closures [Widget.EXPOSE_EVENT] = OS.g_cclosure_new (windowProc3, Widget.EXPOSE_EVENT, 0); -// closures [Widget.EXPOSE_EVENT_INVERSE] = OS.g_cclosure_new (windowProc3, Widget.EXPOSE_EVENT_INVERSE, 0); -// closures [Widget.FOCUS] = OS.g_cclosure_new (windowProc3, Widget.FOCUS, 0); -// closures [Widget.FOCUS_IN_EVENT] = OS.g_cclosure_new (windowProc3, Widget.FOCUS_IN_EVENT, 0); -// closures [Widget.FOCUS_OUT_EVENT] = OS.g_cclosure_new (windowProc3, Widget.FOCUS_OUT_EVENT, 0); -// closures [Widget.KEY_PRESS_EVENT] = OS.g_cclosure_new (windowProc3, Widget.KEY_PRESS_EVENT, 0); -// closures [Widget.KEY_RELEASE_EVENT] = OS.g_cclosure_new (windowProc3, Widget.KEY_RELEASE_EVENT, 0); -// closures [Widget.INPUT] = OS.g_cclosure_new (windowProc3, Widget.INPUT, 0); -// closures [Widget.LEAVE_NOTIFY_EVENT] = OS.g_cclosure_new (windowProc3, Widget.LEAVE_NOTIFY_EVENT, 0); -// closures [Widget.MAP_EVENT] = OS.g_cclosure_new (windowProc3, Widget.MAP_EVENT, 0); -// closures [Widget.MNEMONIC_ACTIVATE] = OS.g_cclosure_new (windowProc3, Widget.MNEMONIC_ACTIVATE, 0); -// closures [Widget.MOTION_NOTIFY_EVENT] = OS.g_cclosure_new (windowProc3, Widget.MOTION_NOTIFY_EVENT, 0); -// closures [Widget.MOTION_NOTIFY_EVENT_INVERSE] = OS.g_cclosure_new (windowProc3, Widget.MOTION_NOTIFY_EVENT_INVERSE, 0); -// closures [Widget.MOVE_FOCUS] = OS.g_cclosure_new (windowProc3, Widget.MOVE_FOCUS, 0); -// closures [Widget.SCROLL_EVENT] = OS.g_cclosure_new (windowProc3, Widget.SCROLL_EVENT, 0); -// closures [Widget.SHOW_HELP] = OS.g_cclosure_new (windowProc3, Widget.SHOW_HELP, 0); -// closures [Widget.SIZE_ALLOCATE] = OS.g_cclosure_new (windowProc3, Widget.SIZE_ALLOCATE, 0); -// closures [Widget.STYLE_SET] = OS.g_cclosure_new (windowProc3, Widget.STYLE_SET, 0); -// closures [Widget.TOGGLED] = OS.g_cclosure_new (windowProc3, Widget.TOGGLED, 0); -// closures [Widget.UNMAP_EVENT] = OS.g_cclosure_new (windowProc3, Widget.UNMAP_EVENT, 0); -// closures [Widget.VISIBILITY_NOTIFY_EVENT] = OS.g_cclosure_new (windowProc3, Widget.VISIBILITY_NOTIFY_EVENT, 0); -// closures [Widget.WINDOW_STATE_EVENT] = OS.g_cclosure_new (windowProc3, Widget.WINDOW_STATE_EVENT, 0); -// -// windowCallback4 = new void*/*Callback*/ (this, "windowProc", 4); -// windowProc4 = windowCallback4.getAddress (); -// if (windowProc4 is null) SWT.error (SWT.ERROR_NO_MORE_CALLBACKS); -// -// closures [Widget.DELETE_RANGE] = OS.g_cclosure_new (windowProc4, Widget.DELETE_RANGE, 0); -// closures [Widget.DELETE_TEXT] = OS.g_cclosure_new (windowProc4, Widget.DELETE_TEXT, 0); -// closures [Widget.ROW_ACTIVATED] = OS.g_cclosure_new (windowProc4, Widget.ROW_ACTIVATED, 0); -// closures [Widget.SCROLL_CHILD] = OS.g_cclosure_new (windowProc4, Widget.SCROLL_CHILD, 0); -// closures [Widget.SWITCH_PAGE] = OS.g_cclosure_new (windowProc4, Widget.SWITCH_PAGE, 0); -// closures [Widget.TEST_COLLAPSE_ROW] = OS.g_cclosure_new (windowProc4, Widget.TEST_COLLAPSE_ROW, 0); -// closures [Widget.TEST_EXPAND_ROW] = OS.g_cclosure_new (windowProc4, Widget.TEST_EXPAND_ROW, 0); -// -// windowCallback5 = new void*/*Callback*/ (this, "windowProc", 5); -// windowProc5 = windowCallback5.getAddress (); -// if (windowProc5 is null) SWT.error (SWT.ERROR_NO_MORE_CALLBACKS); -// -// closures [Widget.CHANGE_VALUE] = OS.g_cclosure_new (windowProc5, Widget.CHANGE_VALUE, 0); -// closures [Widget.EXPAND_COLLAPSE_CURSOR_ROW] = OS.g_cclosure_new (windowProc5, Widget.EXPAND_COLLAPSE_CURSOR_ROW, 0); -// closures [Widget.INSERT_TEXT] = OS.g_cclosure_new (windowProc5, Widget.INSERT_TEXT, 0); -// closures [Widget.TEXT_BUFFER_INSERT_TEXT] = OS.g_cclosure_new (windowProc5, Widget.TEXT_BUFFER_INSERT_TEXT, 0); -// -// for (int i = 0; i < Widget.LAST_SIGNAL; i++) { -// if (closures [i] !is null) OS.g_closure_ref (closures [i]); -// } -// -// timerCallback = new void*/*Callback*/ (this, "timerProc", 1); -// timerProc = timerCallback.getAddress (); -// if (timerProc is null) error (SWT.ERROR_NO_MORE_CALLBACKS); -// -// windowTimerCallback = new void*/*Callback*/ (this, "windowTimerProc", 1); -// windowTimerProc = windowTimerCallback.getAddress (); -// if (windowTimerProc is null) error (SWT.ERROR_NO_MORE_CALLBACKS); -// -// mouseHoverCallback = new void*/*Callback*/ (this, "mouseHoverProc", 1); -// mouseHoverProc = mouseHoverCallback.getAddress (); -// if (mouseHoverProc is null) error (SWT.ERROR_NO_MORE_CALLBACKS); -// -// caretCallback = new void*/*Callback*/(this, "caretProc", 1); -// caretProc = caretCallback.getAddress(); -// if (caretProc is null) error (SWT.ERROR_NO_MORE_CALLBACKS); -// -// menuPositionCallback = new void*/*Callback*/(this, "menuPositionProc", 5); -// menuPositionProc = menuPositionCallback.getAddress(); -// if (menuPositionProc is null) error (SWT.ERROR_NO_MORE_CALLBACKS); -// -// sizeAllocateCallback = new void*/*Callback*/(this, "sizeAllocateProc", 3); -// sizeAllocateProc = sizeAllocateCallback.getAddress(); -// if (sizeAllocateProc is null) error (SWT.ERROR_NO_MORE_CALLBACKS); -// -// sizeRequestCallback = new void*/*Callback*/(this, "sizeRequestProc", 3); -// sizeRequestProc = sizeRequestCallback.getAddress(); -// if (sizeRequestProc is null) error (SWT.ERROR_NO_MORE_CALLBACKS); -// -// shellMapCallback = new void*/*Callback*/(this, "shellMapProc", 3); -// shellMapProc = shellMapCallback.getAddress(); -// if (shellMapProc is null) error (SWT.ERROR_NO_MORE_CALLBACKS); -// -// shellMapProcClosure = OS.g_cclosure_new (shellMapProc, 0, 0); -// OS.g_closure_ref (shellMapProcClosure); -// -// treeSelectionCallback = new void*/*Callback*/(this, "treeSelectionProc", 4); -// treeSelectionProc = treeSelectionCallback.getAddress(); -// if (treeSelectionProc is null) error (SWT.ERROR_NO_MORE_CALLBACKS); -// -// cellDataCallback = new void*/*Callback*/ (this, "cellDataProc", 5); -// cellDataProcFld = cellDataCallback.getAddress (); -// if (cellDataProcFld is null) error (SWT.ERROR_NO_MORE_CALLBACKS); -// -// setDirectionCallback = new void*/*Callback*/ (this, "setDirectionProc", 2); -// setDirectionProc = setDirectionCallback.getAddress (); -// if (setDirectionProc is null) error (SWT.ERROR_NO_MORE_CALLBACKS); -// -// allChildrenCallback = new void*/*Callback*/ (this, "allChildrenProc", 2); -// allChildrenProc = allChildrenCallback.getAddress (); -// if (allChildrenProc is null) error (SWT.ERROR_NO_MORE_CALLBACKS); -// -// checkIfEventCallback = new void*/*Callback*/ (this, "checkIfEventProc", 3); -// checkIfEventProc = checkIfEventCallback.getAddress (); -// if (checkIfEventProc is null) error (SWT.ERROR_NO_MORE_CALLBACKS); -// -// idleCallback = new void*/*Callback*/ (this, "idleProc", 1); -// idleProc = idleCallback.getAddress (); -// if (idleProc is null) error (SWT.ERROR_NO_MORE_CALLBACKS); -// } -// -// void initializeSystemSettings () { -// styleSetCallback = new void*/*Callback*/ (this, "styleSetProc", 3); -// styleSetProc = styleSetCallback.getAddress (); -// if (styleSetProc is null) SWT.error (SWT.ERROR_NO_MORE_CALLBACKS); -// OS.g_signal_connect (shellHandle, OS.style_set, styleSetProc, 0); -// -// /* -// * Feature in GTK. Despite the fact that the -// * gtk-entry-select-on-focus property is a global -// * setting, it is initialized when the GtkEntry -// * is initialized. This means that it cannot be -// * accessed before a GtkEntry is created. The -// * fix is to for the initializaion by creating -// * a temporary GtkEntry. -// */ -// auto entry = OS.gtk_entry_new (); -// OS.gtk_widget_destroy (entry); -// int [] buffer2 = new int [1]; -// auto settings = OS.gtk_settings_get_default (); -// OS.g_object_get (settings, OS.gtk_entry_select_on_focus, buffer2, 0); -// entrySelectOnFocus = buffer2 [0] !is 0; -// } -// -// void initializeWidgetTable () { -// indexTable = new int [GROW_SIZE]; -// widgetTable = new Widget [GROW_SIZE]; -// for (int i=0; i= OS.VERSION (2, 2, 0)) { -// auto screen = OS.gdk_screen_get_default (); -// if (screen !is null) { -// auto ptr2 = OS.gdk_x11_screen_get_window_manager_name (screen); -// if (ptr2 !is null) { -// int length = OS.strlen (ptr2); -// if (length > 0) { -// byte [] buffer2 = new byte [length]; -// memmove (buffer2, ptr2, length); -// windowManager = new char[] (Converter.mbcsToWcs (null, buffer2)); -// } -// } -// } -// } -// } -// -// /** -// * Invokes platform specific functionality to dispose a GC handle. -// *

    -// * IMPORTANT: This method is not part of the public -// * API for Display. It is marked public only so that it -// * can be shared within the packages provided by SWT. It is not -// * available on all platforms, and should never be called from -// * application code. -// *

    -// * -// * @param hDC the platform specific GC handle -// * @param data the platform specific GC data -// */ + +/** + * Initializes any internal resources needed by the + * device. + *

    + * This method is called after create. + *

    + * + * @see #create + */ +protected void init () { + super.init (); + initializeCallbacks (); + initializeSystemColors (); + initializeSystemSettings (); + initializeWidgetTable (); + initializeWindowManager (); +} + +void initializeCallbacks () { + closures = new GClosure* [Widget.LAST_SIGNAL]; + signalIds = new int [Widget.LAST_SIGNAL]; + + /* Cache signals for GtkWidget */ + signalIds [Widget.BUTTON_PRESS_EVENT] = OS.g_signal_lookup (OS.button_press_event.ptr, OS.GTK_TYPE_WIDGET ()); + signalIds [Widget.BUTTON_RELEASE_EVENT] = OS.g_signal_lookup (OS.button_release_event.ptr, OS.GTK_TYPE_WIDGET ()); + signalIds [Widget.CONFIGURE_EVENT] = OS.g_signal_lookup (OS.configure_event.ptr, OS.GTK_TYPE_WIDGET ()); + signalIds [Widget.DELETE_EVENT] = OS.g_signal_lookup (OS.delete_event.ptr, OS.GTK_TYPE_WIDGET ()); + signalIds [Widget.ENTER_NOTIFY_EVENT] = OS.g_signal_lookup (OS.enter_notify_event.ptr, OS.GTK_TYPE_WIDGET ()); + signalIds [Widget.EVENT] = OS.g_signal_lookup (OS.event.ptr, OS.GTK_TYPE_WIDGET ()); + signalIds [Widget.EVENT_AFTER] = OS.g_signal_lookup (OS.event_after.ptr, OS.GTK_TYPE_WIDGET ()); + signalIds [Widget.EXPOSE_EVENT] = OS.g_signal_lookup (OS.expose_event.ptr, OS.GTK_TYPE_WIDGET ()); + signalIds [Widget.FOCUS] = OS.g_signal_lookup (OS.focus.ptr, OS.GTK_TYPE_WIDGET ()); + signalIds [Widget.FOCUS_IN_EVENT] = OS.g_signal_lookup (OS.focus_in_event.ptr, OS.GTK_TYPE_WIDGET ()); + signalIds [Widget.FOCUS_OUT_EVENT] = OS.g_signal_lookup (OS.focus_out_event.ptr, OS.GTK_TYPE_WIDGET ()); + signalIds [Widget.GRAB_FOCUS] = OS.g_signal_lookup (OS.grab_focus.ptr, OS.GTK_TYPE_WIDGET ()); + signalIds [Widget.HIDE] = OS.g_signal_lookup (OS.hide.ptr, OS.GTK_TYPE_WIDGET ()); + signalIds [Widget.KEY_PRESS_EVENT] = OS.g_signal_lookup (OS.key_press_event.ptr, OS.GTK_TYPE_WIDGET ()); + signalIds [Widget.KEY_RELEASE_EVENT] = OS.g_signal_lookup (OS.key_release_event.ptr, OS.GTK_TYPE_WIDGET ()); + signalIds [Widget.LEAVE_NOTIFY_EVENT] = OS.g_signal_lookup (OS.leave_notify_event.ptr, OS.GTK_TYPE_WIDGET ()); + signalIds [Widget.MAP] = OS.g_signal_lookup (OS.map.ptr, OS.GTK_TYPE_WIDGET ()); + signalIds [Widget.MAP_EVENT] = OS.g_signal_lookup (OS.map_event.ptr, OS.GTK_TYPE_WIDGET ()); + signalIds [Widget.MNEMONIC_ACTIVATE] = OS.g_signal_lookup (OS.mnemonic_activate.ptr, OS.GTK_TYPE_WIDGET ()); + signalIds [Widget.MOTION_NOTIFY_EVENT] = OS.g_signal_lookup (OS.motion_notify_event.ptr, OS.GTK_TYPE_WIDGET ()); + signalIds [Widget.POPUP_MENU] = OS.g_signal_lookup (OS.popup_menu.ptr, OS.GTK_TYPE_WIDGET ()); + signalIds [Widget.REALIZE] = OS.g_signal_lookup (OS.realize.ptr, OS.GTK_TYPE_WIDGET ()); + signalIds [Widget.SCROLL_EVENT] = OS.g_signal_lookup (OS.scroll_event.ptr, OS.GTK_TYPE_WIDGET ()); + signalIds [Widget.SHOW] = OS.g_signal_lookup (OS.show.ptr, OS.GTK_TYPE_WIDGET ()); + signalIds [Widget.SHOW_HELP] = OS.g_signal_lookup (OS.show_help.ptr, OS.GTK_TYPE_WIDGET ()); + signalIds [Widget.SIZE_ALLOCATE] = OS.g_signal_lookup (OS.size_allocate.ptr, OS.GTK_TYPE_WIDGET ()); + signalIds [Widget.STYLE_SET] = OS.g_signal_lookup (OS.style_set.ptr, OS.GTK_TYPE_WIDGET ()); + signalIds [Widget.UNMAP] = OS.g_signal_lookup (OS.unmap.ptr, OS.GTK_TYPE_WIDGET ()); + signalIds [Widget.UNMAP_EVENT] = OS.g_signal_lookup (OS.unmap_event.ptr, OS.GTK_TYPE_WIDGET ()); + signalIds [Widget.UNREALIZE] = OS.g_signal_lookup (OS.realize.ptr, OS.GTK_TYPE_WIDGET ()); + signalIds [Widget.VISIBILITY_NOTIFY_EVENT] = OS.g_signal_lookup (OS.visibility_notify_event.ptr, OS.GTK_TYPE_WIDGET ()); + signalIds [Widget.WINDOW_STATE_EVENT] = OS.g_signal_lookup (OS.window_state_event.ptr, OS.GTK_TYPE_WIDGET ()); + + GClosure* do_cclosure_new( GCallback cb, int value, int notify ){ + CallbackData* res= new CallbackData; + res.display = this; + res.data = cast(void*)value; + windowProcCallbackDatas ~= res; + return OS.g_cclosure_new( cb, cast(void*)res, cast(GClosureNotify)notify ); + } + + GCallback windowProc2 = cast(GCallback)&windowProcFunc2; + closures [Widget.ACTIVATE] = do_cclosure_new (windowProc2, Widget.ACTIVATE, 0); + closures [Widget.ACTIVATE_INVERSE] = do_cclosure_new (windowProc2, Widget.ACTIVATE_INVERSE, 0); + closures [Widget.CHANGED] = do_cclosure_new (windowProc2, Widget.CHANGED, 0); + closures [Widget.CLICKED] = do_cclosure_new (windowProc2, Widget.CLICKED, 0); + closures [Widget.DAY_SELECTED] = do_cclosure_new (windowProc2, Widget.DAY_SELECTED, 0); + closures [Widget.HIDE] = do_cclosure_new (windowProc2, Widget.HIDE, 0); + closures [Widget.GRAB_FOCUS] = do_cclosure_new (windowProc2, Widget.GRAB_FOCUS, 0); + closures [Widget.MAP] = do_cclosure_new (windowProc2, Widget.MAP, 0); + closures [Widget.MONTH_CHANGED] = do_cclosure_new (windowProc2, Widget.MONTH_CHANGED, 0); + closures [Widget.OUTPUT] = do_cclosure_new (windowProc2, Widget.OUTPUT, 0); + closures [Widget.POPUP_MENU] = do_cclosure_new (windowProc2, Widget.POPUP_MENU, 0); + closures [Widget.PREEDIT_CHANGED] = do_cclosure_new (windowProc2, Widget.PREEDIT_CHANGED, 0); + closures [Widget.REALIZE] = do_cclosure_new (windowProc2, Widget.REALIZE, 0); + closures [Widget.SELECT] = do_cclosure_new (windowProc2, Widget.SELECT, 0); + closures [Widget.SHOW] = do_cclosure_new (windowProc2, Widget.SHOW, 0); + closures [Widget.VALUE_CHANGED] = do_cclosure_new (windowProc2, Widget.VALUE_CHANGED, 0); + closures [Widget.UNMAP] = do_cclosure_new (windowProc2, Widget.UNMAP, 0); + closures [Widget.UNREALIZE] = do_cclosure_new (windowProc2, Widget.UNREALIZE, 0); + + GCallback windowProc3 = cast(GCallback)&windowProcFunc3; + closures [Widget.BUTTON_PRESS_EVENT] = do_cclosure_new (windowProc3, Widget.BUTTON_PRESS_EVENT, 0); + closures [Widget.BUTTON_PRESS_EVENT_INVERSE] = do_cclosure_new (windowProc3, Widget.BUTTON_PRESS_EVENT_INVERSE, 0); + closures [Widget.BUTTON_RELEASE_EVENT] = do_cclosure_new (windowProc3, Widget.BUTTON_RELEASE_EVENT, 0); + closures [Widget.BUTTON_RELEASE_EVENT_INVERSE] = do_cclosure_new (windowProc3, Widget.BUTTON_RELEASE_EVENT_INVERSE, 0); + closures [Widget.COMMIT] = do_cclosure_new (windowProc3, Widget.COMMIT, 0); + closures [Widget.CONFIGURE_EVENT] = do_cclosure_new (windowProc3, Widget.CONFIGURE_EVENT, 0); + closures [Widget.DELETE_EVENT] = do_cclosure_new (windowProc3, Widget.DELETE_EVENT, 0); + closures [Widget.ENTER_NOTIFY_EVENT] = do_cclosure_new (windowProc3, Widget.ENTER_NOTIFY_EVENT, 0); + closures [Widget.EVENT] = do_cclosure_new (windowProc3, Widget.EVENT, 0); + closures [Widget.EVENT_AFTER] = do_cclosure_new (windowProc3, Widget.EVENT_AFTER, 0); + closures [Widget.EXPOSE_EVENT] = do_cclosure_new (windowProc3, Widget.EXPOSE_EVENT, 0); + closures [Widget.EXPOSE_EVENT_INVERSE] = do_cclosure_new (windowProc3, Widget.EXPOSE_EVENT_INVERSE, 0); + closures [Widget.FOCUS] = do_cclosure_new (windowProc3, Widget.FOCUS, 0); + closures [Widget.FOCUS_IN_EVENT] = do_cclosure_new (windowProc3, Widget.FOCUS_IN_EVENT, 0); + closures [Widget.FOCUS_OUT_EVENT] = do_cclosure_new (windowProc3, Widget.FOCUS_OUT_EVENT, 0); + closures [Widget.KEY_PRESS_EVENT] = do_cclosure_new (windowProc3, Widget.KEY_PRESS_EVENT, 0); + closures [Widget.KEY_RELEASE_EVENT] = do_cclosure_new (windowProc3, Widget.KEY_RELEASE_EVENT, 0); + closures [Widget.INPUT] = do_cclosure_new (windowProc3, Widget.INPUT, 0); + closures [Widget.LEAVE_NOTIFY_EVENT] = do_cclosure_new (windowProc3, Widget.LEAVE_NOTIFY_EVENT, 0); + closures [Widget.MAP_EVENT] = do_cclosure_new (windowProc3, Widget.MAP_EVENT, 0); + closures [Widget.MNEMONIC_ACTIVATE] = do_cclosure_new (windowProc3, Widget.MNEMONIC_ACTIVATE, 0); + closures [Widget.MOTION_NOTIFY_EVENT] = do_cclosure_new (windowProc3, Widget.MOTION_NOTIFY_EVENT, 0); + closures [Widget.MOTION_NOTIFY_EVENT_INVERSE] = do_cclosure_new (windowProc3, Widget.MOTION_NOTIFY_EVENT_INVERSE, 0); + closures [Widget.MOVE_FOCUS] = do_cclosure_new (windowProc3, Widget.MOVE_FOCUS, 0); + closures [Widget.SCROLL_EVENT] = do_cclosure_new (windowProc3, Widget.SCROLL_EVENT, 0); + closures [Widget.SHOW_HELP] = do_cclosure_new (windowProc3, Widget.SHOW_HELP, 0); + closures [Widget.SIZE_ALLOCATE] = do_cclosure_new (windowProc3, Widget.SIZE_ALLOCATE, 0); + closures [Widget.STYLE_SET] = do_cclosure_new (windowProc3, Widget.STYLE_SET, 0); + closures [Widget.TOGGLED] = do_cclosure_new (windowProc3, Widget.TOGGLED, 0); + closures [Widget.UNMAP_EVENT] = do_cclosure_new (windowProc3, Widget.UNMAP_EVENT, 0); + closures [Widget.VISIBILITY_NOTIFY_EVENT] = do_cclosure_new (windowProc3, Widget.VISIBILITY_NOTIFY_EVENT, 0); + closures [Widget.WINDOW_STATE_EVENT] = do_cclosure_new (windowProc3, Widget.WINDOW_STATE_EVENT, 0); + + GCallback windowProc4 = cast(GCallback)&windowProcFunc4; + closures [Widget.DELETE_RANGE] = do_cclosure_new (windowProc4, Widget.DELETE_RANGE, 0); + closures [Widget.DELETE_TEXT] = do_cclosure_new (windowProc4, Widget.DELETE_TEXT, 0); + closures [Widget.ROW_ACTIVATED] = do_cclosure_new (windowProc4, Widget.ROW_ACTIVATED, 0); + closures [Widget.SCROLL_CHILD] = do_cclosure_new (windowProc4, Widget.SCROLL_CHILD, 0); + closures [Widget.SWITCH_PAGE] = do_cclosure_new (windowProc4, Widget.SWITCH_PAGE, 0); + closures [Widget.TEST_COLLAPSE_ROW] = do_cclosure_new (windowProc4, Widget.TEST_COLLAPSE_ROW, 0); + closures [Widget.TEST_EXPAND_ROW] = do_cclosure_new (windowProc4, Widget.TEST_EXPAND_ROW, 0); + + GCallback windowProc5 = cast(GCallback)&windowProcFunc5; + closures [Widget.CHANGE_VALUE] = do_cclosure_new (windowProc5, Widget.CHANGE_VALUE, 0); + closures [Widget.EXPAND_COLLAPSE_CURSOR_ROW] = do_cclosure_new (windowProc5, Widget.EXPAND_COLLAPSE_CURSOR_ROW, 0); + closures [Widget.INSERT_TEXT] = do_cclosure_new (windowProc5, Widget.INSERT_TEXT, 0); + closures [Widget.TEXT_BUFFER_INSERT_TEXT] = do_cclosure_new (windowProc5, Widget.TEXT_BUFFER_INSERT_TEXT, 0); + + for (int i = 0; i < Widget.LAST_SIGNAL; i++) { + if (closures [i] !is null) OS.g_closure_ref (closures [i]); + } + shellMapProcCallbackData.display = this; + shellMapProcCallbackData.data = null; + shellMapProcClosure = OS.g_cclosure_new (cast(GCallback)&shellMapProcFunc, &shellMapProcCallbackData, cast(GClosureNotify)0); + OS.g_closure_ref (shellMapProcClosure); +} + +void initializeSystemSettings () { + styleSetProcCallbackData.display = this; + styleSetProcCallbackData.data = null; + OS.g_signal_connect (shellHandle, OS.style_set.ptr, cast(GCallback)&styleSetProcFunc, &styleSetProcCallbackData); + + /* + * Feature in GTK. Despite the fact that the + * gtk-entry-select-on-focus property is a global + * setting, it is initialized when the GtkEntry + * is initialized. This means that it cannot be + * accessed before a GtkEntry is created. The + * fix is to for the initializaion by creating + * a temporary GtkEntry. + */ + auto entry = OS.gtk_entry_new (); + OS.gtk_widget_destroy (entry); + int buffer2; + auto settings = OS.gtk_settings_get_default (); + OS.g_object_get1 (settings, OS.gtk_entry_select_on_focus.ptr, &buffer2); + entrySelectOnFocus = buffer2 !is 0; +} + +void initializeWidgetTable () { + indexTable = new int [GROW_SIZE]; + widgetTable = new Widget [GROW_SIZE]; + for (int i=0; i= OS.buildVERSION (2, 2, 0)) { + auto screen = OS.gdk_screen_get_default (); + if (screen !is null) { + auto ptr2 = OS.gdk_x11_screen_get_window_manager_name (screen); + windowManager = fromUtf8z( ptr2 ); + } + } +} + +/** + * Invokes platform specific functionality to dispose a GC handle. + *

    + * IMPORTANT: This method is not part of the public + * API for Display. It is marked public only so that it + * can be shared within the packages provided by SWT. It is not + * available on all platforms, and should never be called from + * application code. + *

    + * + * @param hDC the platform specific GC handle + * @param data the platform specific GC data + */ public void internal_dispose_GC (GdkGC* gdkGC, GCData data) { -// OS.g_object_unref (gdkGC); + OS.g_object_unref (gdkGC); } -// -// /** -// * Invokes platform specific functionality to allocate a new GC handle. -// *

    -// * IMPORTANT: This method is not part of the public -// * API for Display. It is marked public only so that it -// * can be shared within the packages provided by SWT. It is not -// * available on all platforms, and should never be called from -// * application code. -// *

    -// * -// * @param data the platform specific GC data -// * @return the platform specific GC handle -// * -// * @exception SWTException
      -// *
    • ERROR_DEVICE_DISPOSED - if the receiver has been disposed
    • -// *
    -// * @exception SWTError
      -// *
    • ERROR_NO_HANDLES if a handle could not be obtained for gc creation
    • -// *
    -// */ + +/** + * Invokes platform specific functionality to allocate a new GC handle. + *

    + * IMPORTANT: This method is not part of the public + * API for Display. It is marked public only so that it + * can be shared within the packages provided by SWT. It is not + * available on all platforms, and should never be called from + * application code. + *

    + * + * @param data the platform specific GC data + * @return the platform specific GC handle + * + * @exception SWTException
      + *
    • ERROR_DEVICE_DISPOSED - if the receiver has been disposed
    • + *
    + * @exception SWTError
      + *
    • ERROR_NO_HANDLES if a handle could not be obtained for gc creation
    • + *
    + */ public GdkGC* internal_new_GC (GCData data) { -// if (isDisposed()) SWT.error(SWT.ERROR_DEVICE_DISPOSED); -// auto root = OS.GDK_ROOT_PARENT (); -// auto gdkGC = OS.gdk_gc_new (root); -// if (gdkGC is null) SWT.error (SWT.ERROR_NO_HANDLES); -// OS.gdk_gc_set_subwindow (gdkGC, OS.GDK_INCLUDE_INFERIORS); -// if (data !is null) { -// int mask = SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT; -// if ((data.style & mask) is 0) { -// data.style |= SWT.LEFT_TO_RIGHT; -// } -// data.device = this; -// data.drawable = root; -// data.background = getSystemColor (SWT.COLOR_WHITE).handle; -// data.foreground = getSystemColor (SWT.COLOR_BLACK).handle; -// data.font = getSystemFont ().handle; -// } -// return gdkGC; + if (isDisposed()) SWT.error(SWT.ERROR_DEVICE_DISPOSED); + auto root = cast(GdkDrawable *) OS.GDK_ROOT_PARENT (); + auto gdkGC = OS.gdk_gc_new (root); + if (gdkGC is null) SWT.error (SWT.ERROR_NO_HANDLES); + OS.gdk_gc_set_subwindow (gdkGC, cast(GdkSubwindowMode)OS.GDK_INCLUDE_INFERIORS); + if (data !is null) { + int mask = SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT; + if ((data.style & mask) is 0) { + data.style |= SWT.LEFT_TO_RIGHT; + } + data.device = this; + data.drawable = root; + data.background = getSystemColor (SWT.COLOR_WHITE).handle; + data.foreground = getSystemColor (SWT.COLOR_BLACK).handle; + data.font = getSystemFont ().handle; + } + return gdkGC; return null; } -// + bool isValidThread () { return thread is Thread.getThis (); } -// -// /** -// * Maps a point from one coordinate system to another. -// * When the control is null, coordinates are mapped to -// * the display. -// *

    -// * NOTE: On right-to-left platforms where the coordinate -// * systems are mirrored, special care needs to be taken -// * when mapping coordinates from one control to another -// * to ensure the result is correctly mirrored. -// * -// * Mapping a point that is the origin of a rectangle and -// * then adding the width and height is not equivalent to -// * mapping the rectangle. When one control is mirrored -// * and the other is not, adding the width and height to a -// * point that was mapped causes the rectangle to extend -// * in the wrong direction. Mapping the entire rectangle -// * instead of just one point causes both the origin and -// * the corner of the rectangle to be mapped. -// *

    -// * -// * @param from the source Control or null -// * @param to the destination Control or null -// * @param point to be mapped -// * @return point with mapped coordinates -// * -// * @exception IllegalArgumentException
      -// *
    • ERROR_NULL_ARGUMENT - if the point is null
    • -// *
    • ERROR_INVALID_ARGUMENT - if the Control from or the Control to have been disposed
    • -// *
    -// * @exception SWTException
      -// *
    • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • -// *
    • ERROR_DEVICE_DISPOSED - if the receiver has been disposed
    • -// *
    -// * -// * @since 2.1.2 -// */ -// public Point map (Control from, Control to, Point point) { -// checkDevice (); -// if (point is null) error (SWT.ERROR_NULL_ARGUMENT); -// return map (from, to, point.x, point.y); -// } -// -// /** -// * Maps a point from one coordinate system to another. -// * When the control is null, coordinates are mapped to -// * the display. -// *

    -// * NOTE: On right-to-left platforms where the coordinate -// * systems are mirrored, special care needs to be taken -// * when mapping coordinates from one control to another -// * to ensure the result is correctly mirrored. -// * -// * Mapping a point that is the origin of a rectangle and -// * then adding the width and height is not equivalent to -// * mapping the rectangle. When one control is mirrored -// * and the other is not, adding the width and height to a -// * point that was mapped causes the rectangle to extend -// * in the wrong direction. Mapping the entire rectangle -// * instead of just one point causes both the origin and -// * the corner of the rectangle to be mapped. -// *

    -// * -// * @param from the source Control or null -// * @param to the destination Control or null -// * @param x coordinates to be mapped -// * @param y coordinates to be mapped -// * @return point with mapped coordinates -// * -// * @exception IllegalArgumentException
      -// *
    • ERROR_INVALID_ARGUMENT - if the Control from or the Control to have been disposed
    • -// *
    -// * @exception SWTException
      -// *
    • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • -// *
    • ERROR_DEVICE_DISPOSED - if the receiver has been disposed
    • -// *
    -// * -// * @since 2.1.2 -// */ -// public Point map (Control from, Control to, int x, int y) { -// checkDevice (); -// if (from !is null && from.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT); -// if (to !is null && to.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT); -// Point point = new Point (x, y); -// if (from is to) return point; -// if (from !is null) { -// auto window = from.eventWindow (); -// int [] origin_x = new int [1], origin_y = new int [1]; -// OS.gdk_window_get_origin (window, origin_x, origin_y); -// point.x += origin_x [0]; -// point.y += origin_y [0]; -// } -// if (to !is null) { -// auto window = to.eventWindow (); -// int [] origin_x = new int [1], origin_y = new int [1]; -// OS.gdk_window_get_origin (window, origin_x, origin_y); -// point.x -= origin_x [0]; -// point.y -= origin_y [0]; -// } -// return point; -// } -// -// /** -// * Maps a point from one coordinate system to another. -// * When the control is null, coordinates are mapped to -// * the display. -// *

    -// * NOTE: On right-to-left platforms where the coordinate -// * systems are mirrored, special care needs to be taken -// * when mapping coordinates from one control to another -// * to ensure the result is correctly mirrored. -// * -// * Mapping a point that is the origin of a rectangle and -// * then adding the width and height is not equivalent to -// * mapping the rectangle. When one control is mirrored -// * and the other is not, adding the width and height to a -// * point that was mapped causes the rectangle to extend -// * in the wrong direction. Mapping the entire rectangle -// * instead of just one point causes both the origin and -// * the corner of the rectangle to be mapped. -// *

    -// * -// * @param from the source Control or null -// * @param to the destination Control or null -// * @param rectangle to be mapped -// * @return rectangle with mapped coordinates -// * -// * @exception IllegalArgumentException
      -// *
    • ERROR_NULL_ARGUMENT - if the rectangle is null
    • -// *
    • ERROR_INVALID_ARGUMENT - if the Control from or the Control to have been disposed
    • -// *
    -// * @exception SWTException
      -// *
    • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • -// *
    • ERROR_DEVICE_DISPOSED - if the receiver has been disposed
    • -// *
    -// * -// * @since 2.1.2 -// */ -// public Rectangle map (Control from, Control to, Rectangle rectangle) { -// checkDevice(); -// if (rectangle is null) error (SWT.ERROR_NULL_ARGUMENT); -// return map (from, to, rectangle.x, rectangle.y, rectangle.width, rectangle.height); -// } -// -// static char mbcsToWcs (char ch) { -// int key = ch & 0xFFFF; -// if (key <= 0x7F) return ch; -// byte [] buffer; -// if (key <= 0xFF) { -// buffer = new byte [1]; -// buffer [0] = cast(byte) key; -// } else { -// buffer = new byte [2]; -// buffer [0] = cast(byte) ((key >> 8) & 0xFF); -// buffer [1] = cast(byte) (key & 0xFF); -// } -// char [] result = Converter.mbcsToWcs (null, buffer); -// if (result.length is 0) return 0; -// return result [0]; -// } -// -// int /*long*/ menuPositionProcMeth (int /*long*/ menu, int /*long*/ x, int /*long*/ y, int /*long*/ push_in, int /*long*/ user_data) { -// Widget widget = getWidget (menu); -// if (widget is null) return 0; -// return widget.menuPositionProc (menu, x, y, push_in, user_data); -// } -// -// /** -// * Maps a point from one coordinate system to another. -// * When the control is null, coordinates are mapped to -// * the display. -// *

    -// * NOTE: On right-to-left platforms where the coordinate -// * systems are mirrored, special care needs to be taken -// * when mapping coordinates from one control to another -// * to ensure the result is correctly mirrored. -// * -// * Mapping a point that is the origin of a rectangle and -// * then adding the width and height is not equivalent to -// * mapping the rectangle. When one control is mirrored -// * and the other is not, adding the width and height to a -// * point that was mapped causes the rectangle to extend -// * in the wrong direction. Mapping the entire rectangle -// * instead of just one point causes both the origin and -// * the corner of the rectangle to be mapped. -// *

    -// * -// * @param from the source Control or null -// * @param to the destination Control or null -// * @param x coordinates to be mapped -// * @param y coordinates to be mapped -// * @param width coordinates to be mapped -// * @param height coordinates to be mapped -// * @return rectangle with mapped coordinates -// * -// * @exception IllegalArgumentException
      -// *
    • ERROR_INVALID_ARGUMENT - if the Control from or the Control to have been disposed
    • -// *
    -// * @exception SWTException
      -// *
    • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • -// *
    • ERROR_DEVICE_DISPOSED - if the receiver has been disposed
    • -// *
    -// * -// * @since 2.1.2 -// */ -// public Rectangle map (Control from, Control to, int x, int y, int width, int height) { -// checkDevice(); -// if (from !is null && from.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT); -// if (to !is null && to.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT); -// Rectangle rect = new Rectangle (x, y, width, height); -// if (from is to) return rect; -// if (from !is null) { -// auto window = from.eventWindow (); -// int [] origin_x = new int [1], origin_y = new int [1]; -// OS.gdk_window_get_origin (window, origin_x, origin_y); -// rect.x += origin_x [0]; -// rect.y += origin_y [0]; -// } -// if (to !is null) { -// auto window = to.eventWindow (); -// int [] origin_x = new int [1], origin_y = new int [1]; -// OS.gdk_window_get_origin (window, origin_x, origin_y); -// rect.x -= origin_x [0]; -// rect.y -= origin_y [0]; -// } -// return rect; -// } -// -// private extern(C) int mouseHoverProcMeth (void* handle) { -// } -// -// int /*long*/ mouseHoverProcMeth (int /*long*/ handle) { -// Widget widget = getWidget (handle); -// if (widget is null) return 0; -// return widget.hoverProc (handle); -// } -// -// /** -// * Generate a low level system event. -// * -// * post is used to generate low level keyboard -// * and mouse events. The intent is to enable automated UI -// * testing by simulating the input from the user. Most -// * SWT applications should never need to call this method. -// *

    -// * Note that this operation can fail when the operating system -// * fails to generate the event for any reason. For example, -// * this can happen when there is no such key or mouse button -// * or when the system event queue is full. -// *

    -// *

    -// * Event Types: -// *

    KeyDown, KeyUp -// *

    The following fields in the Event apply: -// *

      -// *
    • (in) type KeyDown or KeyUp
    • -// *

      Either one of: -// *

    • (in) character a character that corresponds to a keyboard key
    • -// *
    • (in) keyCode the key code of the key that was typed, -// * as defined by the key code constants in class SWT
    • -// *
    -// *

    MouseDown, MouseUp

    -// *

    The following fields in the Event apply: -// *

      -// *
    • (in) type MouseDown or MouseUp -// *
    • (in) button the button that is pressed or released -// *
    -// *

    MouseMove

    -// *

    The following fields in the Event apply: -// *

      -// *
    • (in) type MouseMove -// *
    • (in) x the x coordinate to move the mouse pointer to in screen coordinates -// *
    • (in) y the y coordinate to move the mouse pointer to in screen coordinates -// *
    -// * -// * -// * @param event the event to be generated -// * -// * @return true if the event was generated or false otherwise -// * -// * @exception IllegalArgumentException
      -// *
    • ERROR_NULL_ARGUMENT - if the event is null
    • -// *
    -// * @exception SWTException
      -// *
    • ERROR_DEVICE_DISPOSED - if the receiver has been disposed
    • -// *
    -// * -// * @since 3.0 -// * -// */ -// public bool post (Event event) { -// if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED); -// if (event is null) error (SWT.ERROR_NULL_ARGUMENT); -// if (!OS.GDK_WINDOWING_X11()) return false; -// auto xDisplay = OS.GDK_DISPLAY (); -// int type = event.type; -// switch (type) { -// case SWT.KeyDown: -// case SWT.KeyUp: { -// int keyCode = 0; -// auto keysym = untranslateKey (event.keyCode); -// if (keysym !is 0) keyCode = OS.XKeysymToKeycode (xDisplay, keysym); -// if (keyCode is 0) { -// char key = event.character; -// switch (key) { -// case SWT.BS: keysym = OS.GDK_BackSpace; break; -// case SWT.CR: keysym = OS.GDK_Return; break; -// case SWT.DEL: keysym = OS.GDK_Delete; break; -// case SWT.ESC: keysym = OS.GDK_Escape; break; -// case SWT.TAB: keysym = OS.GDK_Tab; break; -// case SWT.LF: keysym = OS.GDK_Linefeed; break; -// default: -// keysym = wcsToMbcs (key); -// } -// keyCode = OS.XKeysymToKeycode (xDisplay, keysym); -// if (keyCode is 0) return false; -// } -// OS.XTestFakeKeyEvent (xDisplay, keyCode, type is SWT.KeyDown, 0); -// return true; -// } -// case SWT.MouseDown: -// case SWT.MouseMove: -// case SWT.MouseUp: { -// if (type is SWT.MouseMove) { -// OS.XTestFakeMotionEvent (xDisplay, -1, event.x, event.y, 0); -// } else { -// int button = event.button; -// switch (button) { -// case 1: -// case 2: -// case 3: break; -// case 4: button = 6; break; -// case 5: button = 7; break; -// default: return false; -// } -// OS.XTestFakeButtonEvent (xDisplay, button, type is SWT.MouseDown, 0); -// } -// return true; -// } -// /* -// * This code is intentionally commented. After posting a -// * mouse wheel event the system may respond unpredictably -// * to subsequent mouse actions. -// */ -// // case SWT.MouseWheel: { -// // if (event.count is 0) return false; -// // int button = event.count < 0 ? 5 : 4; -// // OS.XTestFakeButtonEvent (xDisplay, button, type is SWT.MouseWheel, 0); -// // } -// } -// return false; -// } -// -// void postEvent (Event event) { -// /* -// * Place the event at the end of the event queue. -// * This code is always called in the Display's -// * thread so it must be re-enterant but does not -// * need to be synchronized. -// */ -// if (eventQueue is null) eventQueue = new Event [4]; -// int index = 0; -// int length = eventQueue.length; -// while (index < length) { -// if (eventQueue [index] is null) break; -// index++; -// } -// if (index is length) { -// Event [] newQueue = new Event [length + 4]; -// System.arraycopy (eventQueue, 0, newQueue, 0, length); -// eventQueue = newQueue; -// } -// eventQueue [index] = event; -// } -// -void putGdkEvents () { -// if (gdkEventCount !is 0) { -// for (int i = 0; i < gdkEventCount; i++) { -// auto event = gdkEvents [i]; -// Widget widget = gdkEventWidgets [i]; -// if (widget is null || !widget.isDisposed ()) { -// OS.gdk_event_put (event); -// } -// OS.gdk_event_free (event); -// gdkEvents [i] = 0; -// gdkEventWidgets [i] = null; -// } -// gdkEventCount = 0; -// } + +/** + * Maps a point from one coordinate system to another. + * When the control is null, coordinates are mapped to + * the display. + *

    + * NOTE: On right-to-left platforms where the coordinate + * systems are mirrored, special care needs to be taken + * when mapping coordinates from one control to another + * to ensure the result is correctly mirrored. + * + * Mapping a point that is the origin of a rectangle and + * then adding the width and height is not equivalent to + * mapping the rectangle. When one control is mirrored + * and the other is not, adding the width and height to a + * point that was mapped causes the rectangle to extend + * in the wrong direction. Mapping the entire rectangle + * instead of just one point causes both the origin and + * the corner of the rectangle to be mapped. + *

    + * + * @param from the source Control or null + * @param to the destination Control or null + * @param point to be mapped + * @return point with mapped coordinates + * + * @exception IllegalArgumentException
      + *
    • ERROR_NULL_ARGUMENT - if the point is null
    • + *
    • ERROR_INVALID_ARGUMENT - if the Control from or the Control to have been disposed
    • + *
    + * @exception SWTException
      + *
    • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • + *
    • ERROR_DEVICE_DISPOSED - if the receiver has been disposed
    • + *
    + * + * @since 2.1.2 + */ +public Point map (Control from, Control to, Point point) { + checkDevice (); + if (point is null) error (SWT.ERROR_NULL_ARGUMENT); + return map (from, to, point.x, point.y); +} + +/** + * Maps a point from one coordinate system to another. + * When the control is null, coordinates are mapped to + * the display. + *

    + * NOTE: On right-to-left platforms where the coordinate + * systems are mirrored, special care needs to be taken + * when mapping coordinates from one control to another + * to ensure the result is correctly mirrored. + * + * Mapping a point that is the origin of a rectangle and + * then adding the width and height is not equivalent to + * mapping the rectangle. When one control is mirrored + * and the other is not, adding the width and height to a + * point that was mapped causes the rectangle to extend + * in the wrong direction. Mapping the entire rectangle + * instead of just one point causes both the origin and + * the corner of the rectangle to be mapped. + *

    + * + * @param from the source Control or null + * @param to the destination Control or null + * @param x coordinates to be mapped + * @param y coordinates to be mapped + * @return point with mapped coordinates + * + * @exception IllegalArgumentException
      + *
    • ERROR_INVALID_ARGUMENT - if the Control from or the Control to have been disposed
    • + *
    + * @exception SWTException
      + *
    • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • + *
    • ERROR_DEVICE_DISPOSED - if the receiver has been disposed
    • + *
    + * + * @since 2.1.2 + */ +public Point map (Control from, Control to, int x, int y) { + checkDevice (); + if (from !is null && from.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT); + if (to !is null && to.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT); + Point point = new Point (x, y); + if (from is to) return point; + if (from !is null) { + auto window = from.eventWindow (); + int origin_x, origin_y; + OS.gdk_window_get_origin (window, &origin_x, &origin_y); + point.x += origin_x; + point.y += origin_y; + } + if (to !is null) { + auto window = to.eventWindow (); + int origin_x, origin_y; + OS.gdk_window_get_origin (window, &origin_x, &origin_y); + point.x -= origin_x; + point.y -= origin_y; + } + return point; +} + +/** + * Maps a point from one coordinate system to another. + * When the control is null, coordinates are mapped to + * the display. + *

    + * NOTE: On right-to-left platforms where the coordinate + * systems are mirrored, special care needs to be taken + * when mapping coordinates from one control to another + * to ensure the result is correctly mirrored. + * + * Mapping a point that is the origin of a rectangle and + * then adding the width and height is not equivalent to + * mapping the rectangle. When one control is mirrored + * and the other is not, adding the width and height to a + * point that was mapped causes the rectangle to extend + * in the wrong direction. Mapping the entire rectangle + * instead of just one point causes both the origin and + * the corner of the rectangle to be mapped. + *

    + * + * @param from the source Control or null + * @param to the destination Control or null + * @param rectangle to be mapped + * @return rectangle with mapped coordinates + * + * @exception IllegalArgumentException
      + *
    • ERROR_NULL_ARGUMENT - if the rectangle is null
    • + *
    • ERROR_INVALID_ARGUMENT - if the Control from or the Control to have been disposed
    • + *
    + * @exception SWTException
      + *
    • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • + *
    • ERROR_DEVICE_DISPOSED - if the receiver has been disposed
    • + *
    + * + * @since 2.1.2 + */ +public Rectangle map (Control from, Control to, Rectangle rectangle) { + checkDevice(); + if (rectangle is null) error (SWT.ERROR_NULL_ARGUMENT); + return map (from, to, rectangle.x, rectangle.y, rectangle.width, rectangle.height); +} + +static wchar mbcsToWcs (wchar ch) { + int key = ch & 0xFFFF; + if (key <= 0x7F) return ch; + char [] buffer; + if (key <= 0xFF) { + buffer = new char [1]; + buffer [0] = cast(char) key; + } else { + buffer = new char [2]; + buffer [0] = cast(char) ((key >> 8) & 0xFF); + buffer [1] = cast(char) (key & 0xFF); + } + wchar [] result = Converter.mbcsToWcs (null, buffer); + if (result.length is 0) return 0; + return result [0]; +} + +int /*long*/ menuPositionProcMeth (GtkWidget * menu, int /*long*/ x, int /*long*/ y, int /*long*/ push_in, int /*long*/ user_data) { + Widget widget = getWidget (menu); + if (widget is null) return 0; + return widget.menuPositionProc (menu, x, y, push_in, user_data); } -// /** -// * Reads an event from the operating system's event queue, -// * dispatches it appropriately, and returns true -// * if there is potentially more work to do, or false -// * if the caller can sleep until another event is placed on -// * the event queue. -// *

    -// * In addition to checking the system event queue, this method also -// * checks if any inter-thread messages (created by syncExec() -// * or asyncExec()) are waiting to be processed, and if -// * so handles them before returning. -// *

    -// * -// * @return false if the caller can sleep upon return from this method -// * -// * @exception SWTException
      -// *
    • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • -// *
    • ERROR_DEVICE_DISPOSED - if the receiver has been disposed
    • -// *
    • ERROR_FAILED_EXEC - if an exception occurred while running an inter-thread message
    • -// *
    -// * -// * @see #sleep -// * @see #wake -// */ -// public bool readAndDispatch () { -// checkDevice (); -// bool events = false; -// events |= runSettings (); -// events |= runPopups (); -// events |= OS.g_main_context_iteration (0, false); -// if (events) { -// runDeferredEvents (); -// return true; -// } -// return runAsyncMessages (false); -// } -// +/** + * Maps a point from one coordinate system to another. + * When the control is null, coordinates are mapped to + * the display. + *

    + * NOTE: On right-to-left platforms where the coordinate + * systems are mirrored, special care needs to be taken + * when mapping coordinates from one control to another + * to ensure the result is correctly mirrored. + * + * Mapping a point that is the origin of a rectangle and + * then adding the width and height is not equivalent to + * mapping the rectangle. When one control is mirrored + * and the other is not, adding the width and height to a + * point that was mapped causes the rectangle to extend + * in the wrong direction. Mapping the entire rectangle + * instead of just one point causes both the origin and + * the corner of the rectangle to be mapped. + *

    + * + * @param from the source Control or null + * @param to the destination Control or null + * @param x coordinates to be mapped + * @param y coordinates to be mapped + * @param width coordinates to be mapped + * @param height coordinates to be mapped + * @return rectangle with mapped coordinates + * + * @exception IllegalArgumentException
      + *
    • ERROR_INVALID_ARGUMENT - if the Control from or the Control to have been disposed
    • + *
    + * @exception SWTException
      + *
    • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • + *
    • ERROR_DEVICE_DISPOSED - if the receiver has been disposed
    • + *
    + * + * @since 2.1.2 + */ +public Rectangle map (Control from, Control to, int x, int y, int width, int height) { + checkDevice(); + if (from !is null && from.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT); + if (to !is null && to.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT); + Rectangle rect = new Rectangle (x, y, width, height); + if (from is to) return rect; + if (from !is null) { + auto window = from.eventWindow (); + int origin_x, origin_y; + OS.gdk_window_get_origin (window, &origin_x, &origin_y); + rect.x += origin_x; + rect.y += origin_y; + } + if (to !is null) { + auto window = to.eventWindow (); + int origin_x, origin_y; + OS.gdk_window_get_origin (window, &origin_x, &origin_y); + rect.x -= origin_x; + rect.y -= origin_y; + } + return rect; +} + +private extern(C) int mouseHoverProcMeth (void* handle) { +//PORTING_TODO + return 0; +} + +int /*long*/ mouseHoverProcMeth (GtkWidget* handle) { + Widget widget = getWidget (handle); + if (widget is null) return 0; + return widget.hoverProc (handle); +} + +/** + * Generate a low level system event. + * + * post is used to generate low level keyboard + * and mouse events. The intent is to enable automated UI + * testing by simulating the input from the user. Most + * SWT applications should never need to call this method. + *

    + * Note that this operation can fail when the operating system + * fails to generate the event for any reason. For example, + * this can happen when there is no such key or mouse button + * or when the system event queue is full. + *

    + *

    + * Event Types: + *

    KeyDown, KeyUp + *

    The following fields in the Event apply: + *

      + *
    • (in) type KeyDown or KeyUp
    • + *

      Either one of: + *

    • (in) character a character that corresponds to a keyboard key
    • + *
    • (in) keyCode the key code of the key that was typed, + * as defined by the key code constants in class SWT
    • + *
    + *

    MouseDown, MouseUp

    + *

    The following fields in the Event apply: + *

      + *
    • (in) type MouseDown or MouseUp + *
    • (in) button the button that is pressed or released + *
    + *

    MouseMove

    + *

    The following fields in the Event apply: + *

      + *
    • (in) type MouseMove + *
    • (in) x the x coordinate to move the mouse pointer to in screen coordinates + *
    • (in) y the y coordinate to move the mouse pointer to in screen coordinates + *
    + * + * + * @param event the event to be generated + * + * @return true if the event was generated or false otherwise + * + * @exception IllegalArgumentException
      + *
    • ERROR_NULL_ARGUMENT - if the event is null
    • + *
    + * @exception SWTException
      + *
    • ERROR_DEVICE_DISPOSED - if the receiver has been disposed
    • + *
    + * + * @since 3.0 + * + */ +public bool post (Event event) { + if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED); + if (event is null) error (SWT.ERROR_NULL_ARGUMENT); + if (!OS.GDK_WINDOWING_X11()) return false; + auto xDisplay = OS.GDK_DISPLAY (); + int type = event.type; + switch (type) { + case SWT.KeyDown: + case SWT.KeyUp: { + int keyCode = 0; + auto keysym = untranslateKey (event.keyCode); + if (keysym !is 0) keyCode = OS.XKeysymToKeycode (xDisplay, keysym); + if (keyCode is 0) { + char key = event.character; + switch (key) { + case SWT.BS: keysym = OS.GDK_BackSpace; break; + case SWT.CR: keysym = OS.GDK_Return; break; + case SWT.DEL: keysym = OS.GDK_Delete; break; + case SWT.ESC: keysym = OS.GDK_Escape; break; + case SWT.TAB: keysym = OS.GDK_Tab; break; + case SWT.LF: keysym = OS.GDK_Linefeed; break; + default: + keysym = wcsToMbcs (key); + } + keyCode = OS.XKeysymToKeycode (xDisplay, keysym); + if (keyCode is 0) return false; + } + OS.XTestFakeKeyEvent (xDisplay, keyCode, type is SWT.KeyDown, 0); + return true; + } + case SWT.MouseDown: + case SWT.MouseMove: + case SWT.MouseUp: { + if (type is SWT.MouseMove) { + OS.XTestFakeMotionEvent (xDisplay, -1, event.x, event.y, 0); + } else { + int button = event.button; + switch (button) { + case 1: + case 2: + case 3: break; + case 4: button = 6; break; + case 5: button = 7; break; + default: return false; + } + OS.XTestFakeButtonEvent (xDisplay, button, type is SWT.MouseDown, 0); + } + return true; + } + /* + * This code is intentionally commented. After posting a + * mouse wheel event the system may respond unpredictably + * to subsequent mouse actions. + */ +// case SWT.MouseWheel: { +// if (event.count is 0) return false; +// int button = event.count < 0 ? 5 : 4; +// OS.XTestFakeButtonEvent (xDisplay, button, type is SWT.MouseWheel, 0); +// } + } + return false; +} + +void postEvent (Event event) { + /* + * Place the event at the end of the event queue. + * This code is always called in the Display's + * thread so it must be re-enterant but does not + * need to be synchronized. + */ + if (eventQueue is null) eventQueue = new Event [4]; + int index = 0; + int length = eventQueue.length; + while (index < length) { + if (eventQueue [index] is null) break; + index++; + } + if (index is length) { + Event [] newQueue = new Event [length + 4]; + System.arraycopy (eventQueue, 0, newQueue, 0, length); + eventQueue = newQueue; + } + eventQueue [index] = event; +} + +void putGdkEvents () { + if (gdkEventCount !is 0) { + for (int i = 0; i < gdkEventCount; i++) { + auto event = gdkEvents [i]; + Widget widget = gdkEventWidgets [i]; + if (widget is null || !widget.isDisposed ()) { + OS.gdk_event_put (event); + } + OS.gdk_event_free (event); + gdkEvents [i] = null; + gdkEventWidgets [i] = null; + } + gdkEventCount = 0; + } +} + +/** + * Reads an event from the operating system's event queue, + * dispatches it appropriately, and returns true + * if there is potentially more work to do, or false + * if the caller can sleep until another event is placed on + * the event queue. + *

    + * In addition to checking the system event queue, this method also + * checks if any inter-thread messages (created by syncExec() + * or asyncExec()) are waiting to be processed, and if + * so handles them before returning. + *

    + * + * @return false if the caller can sleep upon return from this method + * + * @exception SWTException
      + *
    • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • + *
    • ERROR_DEVICE_DISPOSED - if the receiver has been disposed
    • + *
    • ERROR_FAILED_EXEC - if an exception occurred while running an inter-thread message
    • + *
    + * + * @see #sleep + * @see #wake + */ +public bool readAndDispatch () { + checkDevice (); + bool events = false; + events |= runSettings (); + events |= runPopups (); + events |= cast(bool)OS.g_main_context_iteration (null, false); + if (events) { + runDeferredEvents (); + return true; + } + return runAsyncMessages (false); +} + synchronized void register () { for (int i=0; i -// * Disposes all shells which are currently open on the display. -// * After this method has been invoked, all related related shells -// * will answer true when sent the message -// * isDisposed(). -// *

    -// * When a device is destroyed, resources that were acquired -// * on behalf of the programmer need to be returned to the -// * operating system. For example, if the device allocated a -// * font to be used as the system font, this font would be -// * freed in release. Also,to assist the garbage -// * collector and minimize the amount of memory that is not -// * reclaimed when the programmer keeps a reference to a -// * disposed device, all fields except the handle are zero'd. -// * The handle is needed by destroy. -// *

    -// * This method is called before destroy. -// * -// * @see Device#dispose -// * @see #destroy -// */ -// protected void release () { -// sendEvent (SWT.Dispose, new Event ()); -// Shell [] shells = getShells (); -// for (int i=0; i