Mercurial > projects > dwt-linux
diff dwt/widgets/Composite.d @ 71:295b29fc7d13
Renamed SWT to DWT
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Tue, 15 Jan 2008 06:44:34 +0100 |
parents | 6537a52fde85 |
children | 5899e0b43e5d |
line wrap: on
line diff
--- a/dwt/widgets/Composite.d Tue Jan 15 06:38:45 2008 +0100 +++ b/dwt/widgets/Composite.d Tue Jan 15 06:44:34 2008 +0100 @@ -1,4 +1,4 @@ -/******************************************************************************* +/******************************************************************************* * Copyright (c) 2000, 2007 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -24,7 +24,7 @@ import dwt.internal.gtk.OS; import dwt.graphics.GC; -import dwt.SWT; +import dwt.DWT; import dwt.internal.cairo.Cairo; import dwt.internal.gtk.OS; import dwt.graphics.Rectangle; @@ -49,7 +49,7 @@ * </p><p> * Note: The <code>CENTER</code> style, although undefined for composites, has the * same value as <code>EMBEDDED</code> (which is used to embed widgets from other - * widget toolkits into SWT). On some operating systems (GTK, Motif), this may cause + * widget toolkits into DWT). On some operating systems (GTK, Motif), this may cause * the children of this composite to be obscured. The <code>EMBEDDED</code> style * is for use by other widget toolkits and should normally never be used. * </p><p> @@ -79,10 +79,10 @@ * and a style value describing its behavior and appearance. * <p> * The style value is either one of the style constants defined in - * class <code>SWT</code> which is applicable to instances of this + * class <code>DWT</code> which is applicable to instances of this * class, or must be built by <em>bitwise OR</em>'ing together * (that is, using the <code>int</code> "|" operator) two or more - * of those <code>SWT</code> style constants. The class description + * of those <code>DWT</code> style constants. The class description * lists the style constants that are applicable to the class. * Style bits are also inherited from superclasses. * </p> @@ -93,15 +93,15 @@ * @exception IllegalArgumentException <ul> * <li>ERROR_NULL_ARGUMENT - if the parent is null</li> * </ul> - * @exception SWTException <ul> + * @exception DWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li> * </ul> * - * @see SWT#NO_BACKGROUND - * @see SWT#NO_FOCUS - * @see SWT#NO_MERGE_PAINTS - * @see SWT#NO_REDRAW_RESIZE - * @see SWT#NO_RADIO_GROUP + * @see DWT#NO_BACKGROUND + * @see DWT#NO_FOCUS + * @see DWT#NO_MERGE_PAINTS + * @see DWT#NO_REDRAW_RESIZE + * @see DWT#NO_RADIO_GROUP * @see Widget#getStyle */ public this (Composite parent, int style) { @@ -164,7 +164,7 @@ * <li>ERROR_INVALID_ARGUMENT - if the changed array is null any of its controls are null or have been disposed</li> * <li>ERROR_INVALID_PARENT - if any control in changed is not in the widget tree of the receiver</li> * </ul> - * @exception SWTException <ul> + * @exception DWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> @@ -173,11 +173,11 @@ */ public void changed (Control[] changed) { checkWidget (); - if (changed is null) error (SWT.ERROR_INVALID_ARGUMENT); + if (changed is null) error (DWT.ERROR_INVALID_ARGUMENT); for (int i=0; i<changed.length; i++) { Control control = changed [i]; - if (control is null) error (SWT.ERROR_INVALID_ARGUMENT); - if (control.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT); + if (control is null) error (DWT.ERROR_INVALID_ARGUMENT); + if (control.isDisposed ()) error (DWT.ERROR_INVALID_ARGUMENT); bool ancestor = false; Composite composite = control.parent; while (composite !is null) { @@ -185,7 +185,7 @@ if (ancestor) break; composite = composite.parent; } - if (!ancestor) error (SWT.ERROR_INVALID_PARENT); + if (!ancestor) error (DWT.ERROR_INVALID_PARENT); } for (int i=0; i<changed.length; i++) { Control child = changed [i]; @@ -201,7 +201,7 @@ } override void checkBuffered () { - if ((style & SWT.DOUBLE_BUFFERED) is 0 && (style & SWT.NO_BACKGROUND) !is 0) { + if ((style & DWT.DOUBLE_BUFFERED) is 0 && (style & DWT.NO_BACKGROUND) !is 0) { return; } super.checkBuffered(); @@ -218,11 +218,11 @@ override public Point computeSize (int wHint, int hHint, bool changed) { checkWidget (); - if (wHint !is SWT.DEFAULT && wHint < 0) wHint = 0; - if (hHint !is SWT.DEFAULT && hHint < 0) hHint = 0; + if (wHint !is DWT.DEFAULT && wHint < 0) wHint = 0; + if (hHint !is DWT.DEFAULT && hHint < 0) hHint = 0; Point size; if (layout_ !is null) { - if (wHint is SWT.DEFAULT || hHint is SWT.DEFAULT) { + if (wHint is DWT.DEFAULT || hHint is DWT.DEFAULT) { changed |= (state & LAYOUT_CHANGED) !is 0; size = layout_.computeSize (this, wHint, hHint, changed); state &= ~LAYOUT_CHANGED; @@ -234,8 +234,8 @@ } if (size.x is 0) size.x = DEFAULT_WIDTH; if (size.y is 0) size.y = DEFAULT_HEIGHT; - if (wHint !is SWT.DEFAULT) size.x = wHint; - if (hHint !is SWT.DEFAULT) size.y = hHint; + if (wHint !is DWT.DEFAULT) size.x = wHint; + if (hHint !is DWT.DEFAULT) size.y = hHint; Rectangle trim = computeTrim (0, 0, size.x, size.y); return new Point (trim.width, trim.height); } @@ -259,35 +259,35 @@ override void createHandle (int index) { state |= HANDLE | CANVAS; - bool scrolled = (style & (SWT.H_SCROLL | SWT.V_SCROLL)) !is 0; + bool scrolled = (style & (DWT.H_SCROLL | DWT.V_SCROLL)) !is 0; if (!scrolled) state |= THEME_BACKGROUND; - createHandle (index, true, scrolled || (style & SWT.BORDER) !is 0); + createHandle (index, true, scrolled || (style & DWT.BORDER) !is 0); } void createHandle (int index, bool fixed, bool scrolled) { if (scrolled) { if (fixed) { fixedHandle = cast(GtkWidget*) OS.g_object_new (display.gtk_fixed_get_type (), null); - if (fixedHandle is null) error (SWT.ERROR_NO_HANDLES); + if (fixedHandle is null) error (DWT.ERROR_NO_HANDLES); OS.gtk_fixed_set_has_window (cast(GtkFixed*)fixedHandle, true); } auto vadj = cast(GtkAdjustment*)OS.gtk_adjustment_new (0, 0, 100, 1, 10, 10); - if (vadj is null) error (SWT.ERROR_NO_HANDLES); + if (vadj is null) error (DWT.ERROR_NO_HANDLES); auto hadj = cast(GtkAdjustment*)OS.gtk_adjustment_new (0, 0, 100, 1, 10, 10); - if (hadj is null) error (SWT.ERROR_NO_HANDLES); + if (hadj is null) error (DWT.ERROR_NO_HANDLES); scrolledHandle = cast(GtkWidget*) OS.gtk_scrolled_window_new (hadj, vadj); - if (scrolledHandle is null) SWT.error (SWT.ERROR_NO_HANDLES); + if (scrolledHandle is null) DWT.error (DWT.ERROR_NO_HANDLES); } handle = cast(GtkWidget*)OS.g_object_new (display.gtk_fixed_get_type (), null); - if (handle is null) SWT.error (SWT.ERROR_NO_HANDLES); + if (handle is null) DWT.error (DWT.ERROR_NO_HANDLES); OS.gtk_fixed_set_has_window (cast(GtkFixed*)handle, true); OS.GTK_WIDGET_SET_FLAGS(handle, OS.GTK_CAN_FOCUS); - if ((style & SWT.EMBEDDED) is 0) { - if ((state & CANVAS) !is 0 && (style & SWT.NO_FOCUS) is 0) { + if ((style & DWT.EMBEDDED) is 0) { + if ((state & CANVAS) !is 0 && (style & DWT.NO_FOCUS) 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 (); - if (imHandle_ is null) error (SWT.ERROR_NO_HANDLES); + if (imHandle_ is null) error (DWT.ERROR_NO_HANDLES); } } } @@ -303,19 +303,19 @@ OS.gtk_container_add (cast(GtkContainer*)scrolledHandle, handle); display.setWarnings (warnings); - int hsp = (style & SWT.H_SCROLL) !is 0 ? OS.GTK_POLICY_ALWAYS : OS.GTK_POLICY_NEVER; - int vsp = (style & SWT.V_SCROLL) !is 0 ? OS.GTK_POLICY_ALWAYS : OS.GTK_POLICY_NEVER; + int hsp = (style & DWT.H_SCROLL) !is 0 ? OS.GTK_POLICY_ALWAYS : OS.GTK_POLICY_NEVER; + int vsp = (style & DWT.V_SCROLL) !is 0 ? OS.GTK_POLICY_ALWAYS : OS.GTK_POLICY_NEVER; OS.gtk_scrolled_window_set_policy (cast(GtkScrolledWindow*)scrolledHandle, hsp, vsp); if (hasBorder ()) { OS.gtk_scrolled_window_set_shadow_type (cast(GtkScrolledWindow*)scrolledHandle, OS.GTK_SHADOW_ETCHED_IN); } } - if ((style & SWT.EMBEDDED) !is 0) { + if ((style & DWT.EMBEDDED) !is 0) { socketHandle = OS.gtk_socket_new (); - if (socketHandle is null) SWT.error (SWT.ERROR_NO_HANDLES); + if (socketHandle is null) DWT.error (DWT.ERROR_NO_HANDLES); OS.gtk_container_add (cast(GtkContainer*)handle, cast(GtkWidget*)socketHandle); } - if ((style & SWT.NO_REDRAW_RESIZE) !is 0) { + if ((style & DWT.NO_REDRAW_RESIZE) !is 0) { OS.gtk_widget_set_redraw_on_allocate (handle, false); } /* @@ -327,7 +327,7 @@ * when NO_BACKGROUND is set and DOUBLE_BUFFERED * is not explicitly set. */ - if ((style & SWT.DOUBLE_BUFFERED) is 0 && (style & SWT.NO_BACKGROUND) !is 0) { + if ((style & DWT.DOUBLE_BUFFERED) is 0 && (style & DWT.NO_BACKGROUND) !is 0) { OS.gtk_widget_set_double_buffered (handle, false); } } @@ -356,9 +356,9 @@ int w, h; OS.gdk_drawable_get_size (cast(GdkDrawable*)drawable, &w, &h); auto surface = Cairo.cairo_xlib_surface_create (xDisplay, xDrawable, xVisual, w, h); - if (surface is null) error (SWT.ERROR_NO_HANDLES); + if (surface is null) error (DWT.ERROR_NO_HANDLES); auto pattern = Cairo.cairo_pattern_create_for_surface (surface); - if (pattern is null) error (SWT.ERROR_NO_HANDLES); + if (pattern is null) error (DWT.ERROR_NO_HANDLES); Cairo.cairo_pattern_set_extend (pattern, Cairo.CAIRO_EXTEND_REPEAT); Cairo.cairo_set_source (cairo, pattern); Cairo.cairo_surface_destroy (surface); @@ -498,18 +498,18 @@ /** * Returns the receiver's background drawing mode. This * will be one of the following constants defined in class - * <code>SWT</code>: + * <code>DWT</code>: * <code>INHERIT_NONE</code>, <code>INHERIT_DEFAULT</code>, * <code>INHERTIT_FORCE</code>. * * @return the background mode * - * @exception SWTException <ul> + * @exception DWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> * - * @see SWT + * @see DWT * * @since 3.2 */ @@ -534,7 +534,7 @@ * @see Control#moveAbove * @see Control#moveBelow * - * @exception SWTException <ul> + * @exception DWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> @@ -577,7 +577,7 @@ * * @return the receiver's layout or null * - * @exception SWTException <ul> + * @exception DWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> @@ -593,7 +593,7 @@ * * @return the receiver's deferred layout state * - * @exception SWTException <ul> + * @exception DWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> @@ -613,7 +613,7 @@ * * @return tabList the ordered list of controls representing the tab order * - * @exception SWTException <ul> + * @exception DWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> @@ -644,7 +644,7 @@ auto result = super.gtk_button_press_event (widget, event); if (result !is 0) return result; if ((state & CANVAS) !is 0) { - if ((style & SWT.NO_FOCUS) is 0 && hooksKeys ()) { + if ((style & DWT.NO_FOCUS) is 0 && hooksKeys ()) { if (event.button is 1) { if (getChildrenCount () is 0) setFocus (); } @@ -658,10 +658,10 @@ if ((state & CANVAS) is 0) { return super.gtk_expose_event (widget, eventPtr); } - if ((style & SWT.NO_MERGE_PAINTS) is 0) { + if ((style & DWT.NO_MERGE_PAINTS) is 0) { return super.gtk_expose_event (widget, eventPtr); } - if (!hooks (SWT.Paint) && !filters (SWT.Paint)) return 0; + if (!hooks (DWT.Paint) && !filters (DWT.Paint)) return 0; GdkEventExpose* gdkEvent = eventPtr; GdkRectangle* rectangles; int n_rectangles; @@ -678,7 +678,7 @@ data.damageRgn = damageRgn; GC gc = event.gc = GC.gtk_new (this, data); OS.gdk_gc_set_clip_region (gc.handle, damageRgn); - sendEvent (SWT.Paint, event); + sendEvent (DWT.Paint, event); gc.dispose (); OS.gdk_region_destroy (damageRgn); event.gc = null; @@ -730,7 +730,7 @@ override int /*long*/ gtk_realize (GtkWidget* widget) { auto result = super.gtk_realize (widget); - if ((style & SWT.NO_BACKGROUND) !is 0) { + if ((style & DWT.NO_BACKGROUND) !is 0) { auto window = OS.GTK_WIDGET_WINDOW (paintHandle ()); if (window !is null) OS.gdk_window_set_back_pixmap (window, null, false); } @@ -748,7 +748,7 @@ override int /*long*/ gtk_style_set (GtkWidget* widget, int /*long*/ previousStyle) { auto result = super.gtk_style_set (widget, previousStyle); - if ((style & SWT.NO_BACKGROUND) !is 0) { + if ((style & DWT.NO_BACKGROUND) !is 0) { auto window = OS.GTK_WIDGET_WINDOW (paintHandle ()); if (window !is null) OS.gdk_window_set_back_pixmap (window, null, false); } @@ -756,7 +756,7 @@ } bool hasBorder () { - return (style & SWT.BORDER) !is 0; + return (style & DWT.BORDER) !is 0; } override void hookEvents () { @@ -770,7 +770,7 @@ } bool hooksKeys () { - return hooks (SWT.KeyDown) || hooks (SWT.KeyUp); + return hooks (DWT.KeyDown) || hooks (DWT.KeyUp); } override GtkIMContext* imHandle () { @@ -785,7 +785,7 @@ * * @return the receiver's deferred layout state * - * @exception SWTException <ul> + * @exception DWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> @@ -819,7 +819,7 @@ * affected, the parent will not paint. * </p> * - * @exception SWTException <ul> + * @exception DWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> @@ -855,7 +855,7 @@ * * @param changed <code>true</code> if the layout must flush its caches, and <code>false</code> otherwise * - * @exception SWTException <ul> + * @exception DWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> @@ -894,7 +894,7 @@ * @param changed <code>true</code> if the layout must flush its caches, and <code>false</code> otherwise * @param all <code>true</code> if all children in the receiver's widget tree should be laid out, and <code>false</code> otherwise * - * @exception SWTException <ul> + * @exception DWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> @@ -929,7 +929,7 @@ * <li>ERROR_INVALID_ARGUMENT - if the changed array is null any of its controls are null or have been disposed</li> * <li>ERROR_INVALID_PARENT - if any control in changed is not in the widget tree of the receiver</li> * </ul> - * @exception SWTException <ul> + * @exception DWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> @@ -938,11 +938,11 @@ */ public void layout (Control [] changed) { checkWidget (); - if (changed is null) error (SWT.ERROR_INVALID_ARGUMENT); + if (changed is null) error (DWT.ERROR_INVALID_ARGUMENT); for (int i=0; i<changed.length; i++) { Control control = changed [i]; - if (control is null) error (SWT.ERROR_INVALID_ARGUMENT); - if (control.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT); + if (control is null) error (DWT.ERROR_INVALID_ARGUMENT); + if (control.isDisposed ()) error (DWT.ERROR_INVALID_ARGUMENT); bool ancestor = false; Composite composite = control.parent; while (composite !is null) { @@ -950,7 +950,7 @@ if (ancestor) break; composite = composite.parent; } - if (!ancestor) error (SWT.ERROR_INVALID_PARENT); + if (!ancestor) error (DWT.ERROR_INVALID_PARENT); } int updateCount = 0; Composite [] update = new Composite [16]; @@ -1143,18 +1143,18 @@ /** * Sets the background drawing mode to the argument which should - * be one of the following constants defined in class <code>SWT</code>: + * be one of the following constants defined in class <code>DWT</code>: * <code>INHERIT_NONE</code>, <code>INHERIT_DEFAULT</code>, * <code>INHERIT_FORCE</code>. * * @param mode the new background mode * - * @exception SWTException <ul> + * @exception DWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> * - * @see SWT + * @see DWT * * @since 3.2 */ @@ -1193,7 +1193,7 @@ * * @param layout the receiver's new layout or null * - * @exception SWTException <ul> + * @exception DWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> @@ -1215,7 +1215,7 @@ * * @param defer the new defer state * - * @exception SWTException <ul> + * @exception DWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> @@ -1248,7 +1248,7 @@ override bool setTabGroupFocus (bool next) { if (isTabItem ()) return setTabItemFocus (next); - bool takeFocus = (style & SWT.NO_FOCUS) is 0; + bool takeFocus = (style & DWT.NO_FOCUS) is 0; if ((state & CANVAS) !is 0) takeFocus = hooksKeys (); if (socketHandle !is null) takeFocus = true; if (takeFocus && setTabItemFocus (next)) return true; @@ -1281,7 +1281,7 @@ * <li>ERROR_INVALID_ARGUMENT - if a widget in the tabList is null or has been disposed</li> * <li>ERROR_INVALID_PARENT - if widget in the tabList is not in the same widget tree</li> * </ul> - * @exception SWTException <ul> + * @exception DWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> @@ -1291,9 +1291,9 @@ if (tabList !is null) { for (int i=0; i<tabList.length; i++) { Control control = tabList [i]; - if (control is null) error (SWT.ERROR_INVALID_ARGUMENT); - if (control.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT); - if (control.parent !is this) error (SWT.ERROR_INVALID_PARENT); + if (control is null) error (DWT.ERROR_INVALID_ARGUMENT); + if (control.isDisposed ()) error (DWT.ERROR_INVALID_ARGUMENT); + if (control.parent !is this) error (DWT.ERROR_INVALID_PARENT); } Control [] newList = new Control [tabList.length]; System.arraycopy (tabList, 0, newList, 0, tabList.length); @@ -1325,7 +1325,7 @@ override int traversalCode(int key, GdkEventKey* event) { if ((state & CANVAS) !is 0) { - if ((style & SWT.NO_FOCUS) !is 0) return 0; + if ((style & DWT.NO_FOCUS) !is 0) return 0; if (hooksKeys ()) return 0; } return super.traversalCode (key, event);