Mercurial > projects > dwt-linux
diff dwt/widgets/Composite.d @ 240:ce446666f5a2
Update to SWT 3.4M7
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Mon, 12 May 2008 19:13:01 +0200 |
parents | 380bad9f6852 |
children | c0d810de7093 |
line wrap: on
line diff
--- a/dwt/widgets/Composite.d Mon May 12 15:36:37 2008 +0200 +++ b/dwt/widgets/Composite.d Mon May 12 19:13:01 2008 +0200 @@ -27,6 +27,7 @@ import dwt.internal.gtk.OS; import dwt.graphics.GC; import dwt.DWT; +import dwt.graphics.Region; import dwt.internal.cairo.Cairo; import dwt.internal.gtk.OS; import dwt.graphics.Rectangle; @@ -118,7 +119,12 @@ * @see Widget#getStyle */ public this (Composite parent, int style) { - super (parent, style); + super (parent, checkStyle (style)); +} + +static int checkStyle (int style) { + style &= ~DWT.TRANSPARENT; + return style; } Control [] _getChildren () { @@ -296,7 +302,7 @@ OS.gtk_fixed_set_has_window (cast(GtkFixed*)handle, true); OS.GTK_WIDGET_SET_FLAGS(handle, OS.GTK_CAN_FOCUS); if ((style & DWT.EMBEDDED) is 0) { - if ((state & CANVAS) !is 0 && (style & DWT.NO_FOCUS) is 0) { + if ((state & CANVAS) !is 0) { /* Prevent an input method context from being created for the Browser widget */ if (display.getData (NO_INPUT_METHOD) is null) { imHandle_ = OS.gtk_im_multicontext_new (); @@ -328,7 +334,7 @@ if (socketHandle is null) DWT.error (DWT.ERROR_NO_HANDLES); OS.gtk_container_add (cast(GtkContainer*)handle, cast(GtkWidget*)socketHandle); } - if ((style & DWT.NO_REDRAW_RESIZE) !is 0) { + if ((style & DWT.NO_REDRAW_RESIZE) !is 0 && (style & DWT.RIGHT_TO_LEFT) is 0) { OS.gtk_widget_set_redraw_on_allocate (handle, false); } /* @@ -373,6 +379,10 @@ auto pattern = Cairo.cairo_pattern_create_for_surface (surface); if (pattern is null) error (DWT.ERROR_NO_HANDLES); Cairo.cairo_pattern_set_extend (pattern, Cairo.CAIRO_EXTEND_REPEAT); + if ((data.style & DWT.MIRRORED) !is 0) { + double[] matrix = [-1.0, 0, 0, 1, 0, 0 ]; + Cairo.cairo_pattern_set_matrix(pattern, cast(cairo_matrix_t*)matrix.ptr); + } Cairo.cairo_set_source (cairo, pattern); Cairo.cairo_surface_destroy (surface); Cairo.cairo_pattern_destroy (pattern); @@ -442,6 +452,13 @@ } } +void fixModal(GtkWidget* group, GtkWidget* modalGroup) { + Control[] controls = _getChildren (); + for (int i = 0; i < controls.length; i++) { + controls[i].fixModal (group, modalGroup); + } +} + override void fixStyle () { super.fixStyle (); if (scrolledHandle is null) fixStyle (handle); @@ -583,6 +600,10 @@ return super.getClientArea(); } +int getClientWidth() { + return (state & ZERO_WIDTH) !is 0 ? 0 : OS.GTK_WIDGET_WIDTH (clientHandle ()); +} + /** * Returns layout which is associated with the receiver, or * null if one has not been set. @@ -684,6 +705,7 @@ event.y = rectangles[i].y; event.width = rectangles[i].width; event.height = rectangles[i].height; + if ((style & DWT.MIRRORED) !is 0) event.x = getClientWidth () - event.width - event.x; auto damageRgn = OS.gdk_region_new (); OS.gdk_region_union_with_rect (damageRgn, rectangles + i ); GCData data = new GCData (); @@ -1085,6 +1107,41 @@ parentHandle = cast(GtkWidget*)fixed; } +void moveChildren(int oldWidth) { + Control[] children = _getChildren (); + for (int i = 0; i < children.length; i++) { + Control child = children[i]; + auto topHandle = child.topHandle (); + int x = OS.GTK_WIDGET_X (topHandle); + int y = OS.GTK_WIDGET_Y (topHandle); + int controlWidth = (child.state & ZERO_WIDTH) !is 0 ? 0 : OS.GTK_WIDGET_WIDTH (topHandle); + x = oldWidth - controlWidth - x; + int clientWidth = getClientWidth (); + x = clientWidth - controlWidth - x; + if (child.enableWindow !is null) { + OS.gdk_window_move (child.enableWindow, x, y); + } + child.moveHandle (x, y); + /* + * Cause a size allocation this widget's topHandle. Note that + * all calls to gtk_widget_size_allocate() must be preceded by + * a call to gtk_widget_size_request(). + */ + GtkRequisition requisition; + gtk_widget_size_request (topHandle, &requisition); + GtkAllocation allocation; + allocation.x = x; + allocation.y = y; + allocation.width = OS.GTK_WIDGET_WIDTH (topHandle); + allocation.height = OS.GTK_WIDGET_HEIGHT (topHandle); + OS.gtk_widget_size_allocate (topHandle, &allocation); + Control control = child.findBackgroundControl (); + if (control !is null && control.backgroundImage !is null) { + if (child.isVisible ()) child.redrawWidget (0, 0, 0, 0, true, true, true); + } + } +} + Point minimumSize (int wHint, int hHint, bool changed) { Control [] children = _getChildren (); int width = 0, height = 0; @@ -1101,6 +1158,34 @@ return fixedHandle !is null ? fixedHandle : handle; } +override void printWidget (GC gc, GdkDrawable* drawable, int depth, int x, int y) { + Region oldClip = new Region (gc.getDevice ()); + Region newClip = new Region (gc.getDevice ()); + gc.getClipping (oldClip); + Rectangle rect = getBounds (); + newClip.add (oldClip); + newClip.intersect (x, y, rect.width, rect.height); + gc.setClipping (newClip); + super.printWidget (gc, drawable, depth, x, y); + Rectangle clientRect = getClientArea (); + Point pt = display.map (this, parent, clientRect.x, clientRect.y); + clientRect.x = x + pt.x - rect.x; + clientRect.y = y + pt.y - rect.y; + newClip.intersect (clientRect); + gc.setClipping (newClip); + Control [] children = _getChildren (); + for (int i=children.length-1; i>=0; --i) { + Control child = children [i]; + if (child.getVisible ()) { + Point location = child.getLocation (); + child.printWidget (gc, drawable, depth, x + location.x, y + location.y); + } + } + gc.setClipping (oldClip); + oldClip.dispose (); + newClip.dispose (); +} + override void redrawChildren () { super.redrawChildren (); Control [] children = _getChildren ();