comparison dwt/widgets/Control.d @ 33:27324bbbac70

changed to regenerated BCD bindings
author Frank Benoit <benoit@tionex.de>
date Thu, 10 Jan 2008 02:18:07 +0100
parents 5e5d1c9cffdb
children c86fc3d50cfa
comparison
equal deleted inserted replaced
32:b7c28480e3e0 33:27324bbbac70
8 * Contributors: 8 * Contributors:
9 * IBM Corporation - initial API and implementation 9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/ 10 *******************************************************************************/
11 module dwt.widgets.Control; 11 module dwt.widgets.Control;
12 12
13 import dwt.internal.gtk.c.gtktypes;
14 13
15 import dwt.SWT; 14 import dwt.SWT;
16 //import dwt.accessibility.Accessible; 15 //import dwt.accessibility.Accessible;
17 import dwt.events.ControlListener; 16 import dwt.events.ControlListener;
18 import dwt.events.FocusListener; 17 import dwt.events.FocusListener;
162 auto paintHandle = paintHandle (); 161 auto paintHandle = paintHandle ();
163 auto window = OS.GTK_WIDGET_WINDOW (paintHandle); 162 auto window = OS.GTK_WIDGET_WINDOW (paintHandle);
164 if (window is null) return false; 163 if (window is null) return false;
165 int orientation = vertical ? OS.GTK_ORIENTATION_HORIZONTAL : OS.GTK_ORIENTATION_VERTICAL; 164 int orientation = vertical ? OS.GTK_ORIENTATION_HORIZONTAL : OS.GTK_ORIENTATION_VERTICAL;
166 char dummy; 165 char dummy;
167 OS.gtk_paint_handle (OS.gtk_widget_get_style (paintHandle), window, cast(GtkStateType)OS.GTK_STATE_NORMAL, cast(GtkShadowType)OS.GTK_SHADOW_OUT, null, paintHandle, &dummy, x, y, width, height, cast(GtkOrientation)orientation); 166 OS.gtk_paint_handle (OS.gtk_widget_get_style (paintHandle), window, OS.GTK_STATE_NORMAL, OS.GTK_SHADOW_OUT, null, paintHandle, &dummy, x, y, width, height, orientation);
168 return true; 167 return true;
169 } 168 }
170 169
171 void enableWidget (bool enabled) { 170 void enableWidget (bool enabled) {
172 OS.gtk_widget_set_sensitive (handle, enabled); 171 OS.gtk_widget_set_sensitive (handle, enabled);
218 if ((state & BACKGROUND) !is 0) return; 217 if ((state & BACKGROUND) !is 0) return;
219 auto childStyle = parent.childStyle (); 218 auto childStyle = parent.childStyle ();
220 if (childStyle !is null) { 219 if (childStyle !is null) {
221 GdkColor* color = new GdkColor(); 220 GdkColor* color = new GdkColor();
222 OS.gtk_style_get_bg (childStyle, 0, color); 221 OS.gtk_style_get_bg (childStyle, 0, color);
223 OS.gtk_widget_modify_bg (handle, cast(GtkStateType) 0, color); 222 OS.gtk_widget_modify_bg (handle, 0, color);
224 } 223 }
225 } 224 }
226 225
227 GtkWidget* focusHandle () { 226 GtkWidget* focusHandle () {
228 return handle; 227 return handle;
310 OS.g_signal_connect_closure_by_id (topHandle, display.signalIds [MAP], 0, display.closures [MAP], true); 309 OS.g_signal_connect_closure_by_id (topHandle, display.signalIds [MAP], 0, display.closures [MAP], true);
311 } 310 }
312 311
313 int /*long*/ hoverProc (int /*long*/ widget) { 312 int /*long*/ hoverProc (int /*long*/ widget) {
314 int x, y; 313 int x, y;
315 GdkModifierType mask; 314 int mask;
316 OS.gdk_window_get_pointer (null, &x, &y, &mask); 315 OS.gdk_window_get_pointer (null, &x, &y, &mask);
317 sendMouseEvent (SWT.MouseHover, 0, /*time*/0, x , y , false, mask ); 316 sendMouseEvent (SWT.MouseHover, 0, /*time*/0, x , y , false, mask );
318 /* Always return zero in order to cancel the hover timer */ 317 /* Always return zero in order to cancel the hover timer */
319 return 0; 318 return 0;
320 } 319 }
2643 } 2642 }
2644 double x = gdkEvent.x_root, y = gdkEvent.y_root; 2643 double x = gdkEvent.x_root, y = gdkEvent.y_root;
2645 int state = gdkEvent.state; 2644 int state = gdkEvent.state;
2646 if (gdkEvent.is_hint !is 0) { 2645 if (gdkEvent.is_hint !is 0) {
2647 int pointer_x, pointer_y; 2646 int pointer_x, pointer_y;
2648 GdkModifierType mask; 2647 int mask;
2649 auto window = eventWindow (); 2648 auto window = eventWindow ();
2650 OS.gdk_window_get_pointer (window, &pointer_x, &pointer_y, &mask); 2649 OS.gdk_window_get_pointer (window, &pointer_x, &pointer_y, &mask);
2651 x = pointer_x; 2650 x = pointer_x;
2652 y = pointer_y; 2651 y = pointer_y;
2653 state = mask; 2652 state = mask;
3605 this.menu = menu; 3604 this.menu = menu;
3606 } 3605 }
3607 3606
3608 void setOrientation () { 3607 void setOrientation () {
3609 if ((style & SWT.RIGHT_TO_LEFT) !is 0) { 3608 if ((style & SWT.RIGHT_TO_LEFT) !is 0) {
3610 if (handle !is null) OS.gtk_widget_set_direction (handle, cast(GtkTextDirection)OS.GTK_TEXT_DIR_RTL); 3609 if (handle !is null) OS.gtk_widget_set_direction (handle, OS.GTK_TEXT_DIR_RTL);
3611 if (fixedHandle !is null) OS.gtk_widget_set_direction (fixedHandle, cast(GtkTextDirection)OS.GTK_TEXT_DIR_RTL); 3610 if (fixedHandle !is null) OS.gtk_widget_set_direction (fixedHandle, OS.GTK_TEXT_DIR_RTL);
3612 } 3611 }
3613 } 3612 }
3614 3613
3615 /** 3614 /**
3616 * Changes the parent of the widget to be the one provided if 3615 * Changes the parent of the widget to be the one provided if
3697 if (redrawWindow !is null) { 3696 if (redrawWindow !is null) {
3698 auto window = paintWindow (); 3697 auto window = paintWindow ();
3699 /* Explicitly hiding the window avoids flicker on GTK+ >= 2.6 */ 3698 /* Explicitly hiding the window avoids flicker on GTK+ >= 2.6 */
3700 OS.gdk_window_hide (redrawWindow); 3699 OS.gdk_window_hide (redrawWindow);
3701 OS.gdk_window_destroy (redrawWindow); 3700 OS.gdk_window_destroy (redrawWindow);
3702 OS.gdk_window_set_events (window, cast(GdkEventMask)OS.gtk_widget_get_events (paintHandle ())); 3701 OS.gdk_window_set_events (window, OS.gtk_widget_get_events (paintHandle ()));
3703 redrawWindow = null; 3702 redrawWindow = null;
3704 } 3703 }
3705 } 3704 }
3706 } else { 3705 } else {
3707 if (drawCount++ is 0) { 3706 if (drawCount++ is 0) {
3718 int mouseMask = OS.GDK_BUTTON_PRESS_MASK | OS.GDK_BUTTON_RELEASE_MASK | 3717 int mouseMask = OS.GDK_BUTTON_PRESS_MASK | OS.GDK_BUTTON_RELEASE_MASK |
3719 OS.GDK_ENTER_NOTIFY_MASK | OS.GDK_LEAVE_NOTIFY_MASK | 3718 OS.GDK_ENTER_NOTIFY_MASK | OS.GDK_LEAVE_NOTIFY_MASK |
3720 OS.GDK_POINTER_MOTION_MASK | OS.GDK_POINTER_MOTION_HINT_MASK | 3719 OS.GDK_POINTER_MOTION_MASK | OS.GDK_POINTER_MOTION_HINT_MASK |
3721 OS.GDK_BUTTON_MOTION_MASK | OS.GDK_BUTTON1_MOTION_MASK | 3720 OS.GDK_BUTTON_MOTION_MASK | OS.GDK_BUTTON1_MOTION_MASK |
3722 OS.GDK_BUTTON2_MOTION_MASK | OS.GDK_BUTTON3_MOTION_MASK; 3721 OS.GDK_BUTTON2_MOTION_MASK | OS.GDK_BUTTON3_MOTION_MASK;
3723 OS.gdk_window_set_events (window, cast(GdkEventMask)(OS.gdk_window_get_events (window) & ~mouseMask)); 3722 OS.gdk_window_set_events (window, OS.gdk_window_get_events (window) & ~mouseMask);
3724 OS.gdk_window_set_back_pixmap (redrawWindow, null, false); 3723 OS.gdk_window_set_back_pixmap (redrawWindow, null, false);
3725 OS.gdk_window_show (redrawWindow); 3724 OS.gdk_window_show (redrawWindow);
3726 } 3725 }
3727 } 3726 }
3728 } 3727 }
4278 if (window !is paintWindow) break; 4277 if (window !is paintWindow) break;
4279 auto gdkGC = OS.gdk_gc_new (cast(GdkDrawable*)window); 4278 auto gdkGC = OS.gdk_gc_new (cast(GdkDrawable*)window);
4280 OS.gdk_gc_set_clip_region (gdkGC, gdkEvent.region); 4279 OS.gdk_gc_set_clip_region (gdkGC, gdkEvent.region);
4281 int dest_x, dest_y; 4280 int dest_x, dest_y;
4282 OS.gtk_widget_translate_coordinates (paintHandle (), control.paintHandle (), 0, 0, &dest_x, &dest_y); 4281 OS.gtk_widget_translate_coordinates (paintHandle (), control.paintHandle (), 0, 0, &dest_x, &dest_y);
4283 OS.gdk_gc_set_fill (gdkGC, cast(GdkFill)OS.GDK_TILED); 4282 OS.gdk_gc_set_fill (gdkGC, OS.GDK_TILED);
4284 OS.gdk_gc_set_ts_origin (gdkGC, -dest_x, -dest_y); 4283 OS.gdk_gc_set_ts_origin (gdkGC, -dest_x, -dest_y);
4285 OS.gdk_gc_set_tile (gdkGC, cast(GdkPixmap*)control.backgroundImage.pixmap); 4284 OS.gdk_gc_set_tile (gdkGC, cast(GdkPixmap*)control.backgroundImage.pixmap);
4286 OS.gdk_draw_rectangle (cast(GdkDrawable*)window, gdkGC, 1, gdkEvent.area.x, gdkEvent.area.y, gdkEvent.area.width, gdkEvent.area.height); 4285 OS.gdk_draw_rectangle (cast(GdkDrawable*)window, gdkGC, 1, gdkEvent.area.x, gdkEvent.area.y, gdkEvent.area.width, gdkEvent.area.height);
4287 OS.g_object_unref (gdkGC); 4286 OS.g_object_unref (gdkGC);
4288 } 4287 }