Mercurial > projects > dwt-linux
diff dwt/widgets/Widget.d @ 71:295b29fc7d13
Renamed SWT to DWT
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Tue, 15 Jan 2008 06:44:34 +0100 |
parents | 15b21862b0ac |
children | 5899e0b43e5d |
line wrap: on
line diff
--- a/dwt/widgets/Widget.d Tue Jan 15 06:38:45 2008 +0100 +++ b/dwt/widgets/Widget.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 @@ -10,12 +10,12 @@ *******************************************************************************/ module dwt.widgets.Widget; -import dwt.SWT; +import dwt.DWT; import dwt.dwthelper.utils; import dwt.events.DisposeListener; import dwt.internal.Converter; -import dwt.internal.SWTEventListener; +import dwt.internal.DWTEventListener; import dwt.internal.gtk.OS; import dwt.widgets.Display; import dwt.widgets.Event; @@ -44,8 +44,8 @@ * </dl> * <p> * IMPORTANT: This class is intended to be subclassed <em>only</em> - * within the SWT implementation. However, it has not been marked - * final to allow those outside of the SWT development team to implement + * within the DWT implementation. However, it has not been marked + * final to allow those outside of the DWT development team to implement * patched versions of the class in order to get around specific * limitations in advance of when those limitations can be addressed * by the team. Any class built using subclassing to access the internals @@ -63,9 +63,9 @@ * the handle to the OS resource * (Warning: This field is platform dependent) * <p> - * <b>IMPORTANT:</b> This field is <em>not</em> part of the SWT + * <b>IMPORTANT:</b> This field is <em>not</em> part of the DWT * public API. It is marked public only so that it can be shared - * within the packages provided by SWT. It is not available on all + * within the packages provided by DWT. It is not available on all * platforms and should never be accessed from application code. * </p> */ @@ -254,10 +254,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> @@ -269,12 +269,12 @@ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li> * <li>ERROR_INVALID_ARGUMENT - if the parent is disposed</li> * </ul> - * @exception SWTException <ul> + * @exception DWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li> * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li> * </ul> * - * @see SWT + * @see DWT * @see #checkSubclass * @see #getStyle */ @@ -295,7 +295,7 @@ * be notified when an event of the given type occurs. When the * event does occur in the widget, the listener is notified by * sending it the <code>handleEvent()</code> message. The event - * type is one of the event constants defined in class <code>SWT</code>. + * type is one of the event constants defined in class <code>DWT</code>. * * @param eventType the type of event to listen for * @param listener the listener which should be notified when the event occurs @@ -303,19 +303,19 @@ * @exception IllegalArgumentException <ul> * <li>ERROR_NULL_ARGUMENT - if the listener is null</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> * * @see Listener - * @see SWT + * @see DWT * @see #removeListener(int, Listener) * @see #notifyListeners */ public void addListener (int eventType, Listener listener) { checkWidget (); - if (listener is null) error (SWT.ERROR_NULL_ARGUMENT); + if (listener is null) error (DWT.ERROR_NULL_ARGUMENT); _addListener (eventType, listener); } @@ -330,7 +330,7 @@ * @exception IllegalArgumentException <ul> * <li>ERROR_NULL_ARGUMENT - if the listener is null</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> @@ -340,9 +340,9 @@ */ public void addDisposeListener (DisposeListener listener) { checkWidget (); - if (listener is null) error (SWT.ERROR_NULL_ARGUMENT); + if (listener is null) error (DWT.ERROR_NULL_ARGUMENT); TypedListener typedListener = new TypedListener (listener); - addListener (SWT.Dispose, typedListener); + addListener (DWT.Dispose, typedListener); } GdkWindow* paintWindow () { @@ -370,14 +370,14 @@ } void checkOrientation (Widget parent) { - style &= ~SWT.MIRRORED; - if ((style & (SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT)) is 0) { + style &= ~DWT.MIRRORED; + if ((style & (DWT.LEFT_TO_RIGHT | DWT.RIGHT_TO_LEFT)) is 0) { if (parent !is null) { - if ((parent.style & SWT.LEFT_TO_RIGHT) !is 0) style |= SWT.LEFT_TO_RIGHT; - if ((parent.style & SWT.RIGHT_TO_LEFT) !is 0) style |= SWT.RIGHT_TO_LEFT; + if ((parent.style & DWT.LEFT_TO_RIGHT) !is 0) style |= DWT.LEFT_TO_RIGHT; + if ((parent.style & DWT.RIGHT_TO_LEFT) !is 0) style |= DWT.RIGHT_TO_LEFT; } } - style = checkBits (style, SWT.LEFT_TO_RIGHT, SWT.RIGHT_TO_LEFT, 0, 0, 0, 0); + style = checkBits (style, DWT.LEFT_TO_RIGHT, DWT.RIGHT_TO_LEFT, 0, 0, 0, 0); } /** @@ -388,13 +388,13 @@ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li> * <li>ERROR_INVALID_ARGUMENT - if the parent is disposed</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> */ void checkParent (Widget parent) { - if (parent is null) error (SWT.ERROR_NULL_ARGUMENT); - if (parent.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT); + if (parent is null) error (DWT.ERROR_NULL_ARGUMENT); + if (parent.isDisposed ()) error (DWT.ERROR_INVALID_ARGUMENT); parent.checkWidget (); parent.checkOpen (); } @@ -402,7 +402,7 @@ /** * Checks that this class can be subclassed. * <p> - * The SWT class library is intended to be subclassed + * The DWT class library is intended to be subclassed * only at specific, controlled points (most notably, * <code>Composite</code> and <code>Canvas</code> when * implementing new widgets). This method enforces this @@ -412,32 +412,32 @@ * method that allows a subclass of a class which does not * normally allow subclassing to be created, the implementer * agrees to be fully responsible for the fact that any such - * subclass will likely fail between SWT releases and will be + * subclass will likely fail between DWT releases and will be * strongly platform specific. No support is provided for * user-written classes which are implemented in this fashion. * </p><p> - * The ability to subclass outside of the allowed SWT classes - * is intended purely to enable those not on the SWT development + * The ability to subclass outside of the allowed DWT classes + * is intended purely to enable those not on the DWT development * team to implement patches in order to get around specific * limitations in advance of when those limitations can be * addressed by the team. Subclassing should not be attempted * without an intimate and detailed understanding of the hierarchy. * </p> * - * @exception SWTException <ul> + * @exception DWTException <ul> * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li> * </ul> */ protected void checkSubclass () { - if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS); + if (!isValidSubclass ()) error (DWT.ERROR_INVALID_SUBCLASS); } /** - * Throws an <code>SWTException</code> if the receiver can not + * Throws an <code>DWTException</code> if the receiver can not * be accessed by the caller. This may include both checks on * the state of the receiver and more generally on the entire * execution context. This method <em>should</em> be called by - * widget implementors to enforce the standard SWT invariants. + * widget implementors to enforce the standard DWT invariants. * <p> * Currently, it is an error to invoke any method (other than * <code>isDisposed()</code>) on a widget that has had its @@ -445,20 +445,20 @@ * to call widget methods from any thread that is different * from the thread that created the widget. * </p><p> - * In future releases of SWT, there may be more or fewer error + * In future releases of DWT, there may be more or fewer error * checks and exceptions may be thrown for different reasons. * </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> */ protected void checkWidget () { Display display = this.display; - if (display is null) error (SWT.ERROR_WIDGET_DISPOSED); - if (display.thread !is Thread.getThis ()) error (SWT.ERROR_THREAD_INVALID_ACCESS); - if ((state & DISPOSED) !is 0) error (SWT.ERROR_WIDGET_DISPOSED); + if (display is null) error (DWT.ERROR_WIDGET_DISPOSED); + if (display.thread !is Thread.getThis ()) error (DWT.ERROR_THREAD_INVALID_ACCESS); + if ((state & DISPOSED) !is 0) error (DWT.ERROR_WIDGET_DISPOSED); } void createHandle (int index) { @@ -499,7 +499,7 @@ * event. * </p> * - * @exception SWTException <ul> + * @exception DWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> * @@ -513,12 +513,12 @@ * more than once. If this happens, fail silently. */ if (isDisposed ()) return; - if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS); + if (!isValidThread ()) error (DWT.ERROR_THREAD_INVALID_ACCESS); release (true); } void error (int code) { - SWT.error (code); + DWT.error (code); } /** @@ -536,7 +536,7 @@ * * @return the widget data * - * @exception SWTException <ul> + * @exception DWTException <ul> * <li>ERROR_WIDGET_DISPOSED - when the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - when called from the wrong thread</li> * </ul> @@ -564,7 +564,7 @@ * @exception IllegalArgumentException <ul> * <li>ERROR_NULL_ARGUMENT - if the key is null</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> @@ -573,7 +573,7 @@ */ public Object getData (char[] key) { checkWidget(); - if (key is null) error (SWT.ERROR_NULL_ARGUMENT); + if (key is null) error (DWT.ERROR_NULL_ARGUMENT); if ((state & KEYED_DATA) !is 0) { char[][] table = (cast(ArrayWrapperString2) data).array; for (int i=1; i<table.length; i+=2) { @@ -594,13 +594,13 @@ * * @return the receiver's display * - * @exception SWTException <ul> + * @exception DWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * </ul> */ public Display getDisplay () { Display display = this.display; - if (display is null) error (SWT.ERROR_WIDGET_DISPOSED); + if (display is null) error (DWT.ERROR_WIDGET_DISPOSED); return display; } @@ -626,14 +626,14 @@ * when the receiver was created. This can occur when the underlying * operating system does not support a particular combination of * requested styles. For example, if the platform widget used to - * implement a particular SWT widget always has scroll bars, the + * implement a particular DWT widget always has scroll bars, the * result of calling this method would always have the - * <code>SWT.H_SCROLL</code> and <code>SWT.V_SCROLL</code> bits set. + * <code>DWT.H_SCROLL</code> and <code>DWT.V_SCROLL</code> bits set. * </p> * * @return the style bits * - * @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> @@ -741,11 +741,11 @@ } int /*long*/ gtk_key_press_event (GtkWidget* widget, GdkEventKey* event) { - return sendKeyEvent (SWT.KeyDown, event) ? 0 : 1; + return sendKeyEvent (DWT.KeyDown, event) ? 0 : 1; } int /*long*/ gtk_key_release_event (GtkWidget* widget, GdkEventKey* event) { - return sendKeyEvent (SWT.KeyUp, event) ? 0 : 1; + return sendKeyEvent (DWT.KeyUp, event) ? 0 : 1; } int /*long*/ gtk_leave_notify_event (GtkWidget* widget, GdkEventCrossing* event) { @@ -938,17 +938,17 @@ * Returns <code>true</code> if there are any listeners * for the specified event type associated with the receiver, * and <code>false</code> otherwise. The event type is one of - * the event constants defined in class <code>SWT</code>. + * the event constants defined in class <code>DWT</code>. * * @param eventType the type of event * @return true if the event is hooked * - * @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 */ public bool isListening (int eventType) { checkWidget (); @@ -969,7 +969,7 @@ /* * Returns <code>true</code> if the specified eventType is * hooked, and <code>false</code> otherwise. Implementations - * of SWT can avoid creating objects and sending events + * of DWT can avoid creating objects and sending events * when an event happens in the operating system but * there are no listeners hooked for the event. * @@ -1010,17 +1010,17 @@ * of the given type that one such event has occurred by * invoking their <code>handleEvent()</code> method. The * event type is one of the event constants defined in class - * <code>SWT</code>. + * <code>DWT</code>. * * @param eventType the type of event which has occurred * @param event the event data * - * @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 * @see #addListener * @see #removeListener(int, Listener) */ @@ -1046,7 +1046,7 @@ void release (bool destroy) { if ((state & DISPOSE_SENT) is 0) { state |= DISPOSE_SENT; - sendEvent (SWT.Dispose); + sendEvent (DWT.Dispose); } if ((state & DISPOSED) is 0) { releaseChildren (destroy); @@ -1086,7 +1086,7 @@ /** * Removes the listener from the collection of listeners who will * be notified when an event of the given type occurs. The event - * type is one of the event constants defined in class <code>SWT</code>. + * type is one of the event constants defined in class <code>DWT</code>. * * @param eventType the type of event to listen for * @param listener the listener which should no longer be notified when the event occurs @@ -1094,19 +1094,19 @@ * @exception IllegalArgumentException <ul> * <li>ERROR_NULL_ARGUMENT - if the listener is null</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> * * @see Listener - * @see SWT + * @see DWT * @see #addListener * @see #notifyListeners */ public void removeListener (int eventType, Listener handler) { checkWidget (); - if (handler is null) error (SWT.ERROR_NULL_ARGUMENT); + if (handler is null) error (DWT.ERROR_NULL_ARGUMENT); if (eventTable is null) return; eventTable.unhook (eventType, handler); } @@ -1115,9 +1115,9 @@ * Removes the listener from the collection of listeners who will * be notified when an event of the given type occurs. * <p> - * <b>IMPORTANT:</b> This method is <em>not</em> part of the SWT + * <b>IMPORTANT:</b> This method is <em>not</em> part of the DWT * public API. It is marked public only so that it can be shared - * within the packages provided by SWT. It should never be + * within the packages provided by DWT. It should never be * referenced from application code. * </p> * @@ -1127,7 +1127,7 @@ * @exception IllegalArgumentException <ul> * <li>ERROR_NULL_ARGUMENT - if the listener is null</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> @@ -1135,9 +1135,9 @@ * @see Listener * @see #addListener */ -protected void removeListener (int eventType, SWTEventListener handler) { +protected void removeListener (int eventType, DWTEventListener handler) { checkWidget (); - if (handler is null) error (SWT.ERROR_NULL_ARGUMENT); + if (handler is null) error (DWT.ERROR_NULL_ARGUMENT); if (eventTable is null) return; eventTable.unhook (eventType, handler); } @@ -1159,7 +1159,7 @@ * @exception IllegalArgumentException <ul> * <li>ERROR_NULL_ARGUMENT - if the listener is null</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> @@ -1169,9 +1169,9 @@ */ public void removeDisposeListener (DisposeListener listener) { checkWidget (); - if (listener is null) error (SWT.ERROR_NULL_ARGUMENT); + if (listener is null) error (DWT.ERROR_NULL_ARGUMENT); if (eventTable is null) return; - eventTable.unhook (SWT.Dispose, listener); + eventTable.unhook (DWT.Dispose, listener); } void sendEvent (Event event) { @@ -1300,7 +1300,7 @@ * * @param data the widget data * - * @exception SWTException <ul> + * @exception DWTException <ul> * <li>ERROR_WIDGET_DISPOSED - when the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - when called from the wrong thread</li> * </ul> @@ -1333,7 +1333,7 @@ * @exception IllegalArgumentException <ul> * <li>ERROR_NULL_ARGUMENT - if the key is null</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> @@ -1342,7 +1342,7 @@ */ public void setData (char[] key, Object value) { checkWidget(); - if (key is null) error (SWT.ERROR_NULL_ARGUMENT); + if (key is null) error (DWT.ERROR_NULL_ARGUMENT); int index = 1; Object [] table = null; if ((state & KEYED_DATA) !is 0) { @@ -1422,12 +1422,12 @@ } bool setInputState (Event event, int state) { - if ((state & OS.GDK_MOD1_MASK) !is 0) event.stateMask |= SWT.ALT; - if ((state & OS.GDK_SHIFT_MASK) !is 0) event.stateMask |= SWT.SHIFT; - if ((state & OS.GDK_CONTROL_MASK) !is 0) event.stateMask |= SWT.CONTROL; - if ((state & OS.GDK_BUTTON1_MASK) !is 0) event.stateMask |= SWT.BUTTON1; - if ((state & OS.GDK_BUTTON2_MASK) !is 0) event.stateMask |= SWT.BUTTON2; - if ((state & OS.GDK_BUTTON3_MASK) !is 0) event.stateMask |= SWT.BUTTON3; + if ((state & OS.GDK_MOD1_MASK) !is 0) event.stateMask |= DWT.ALT; + if ((state & OS.GDK_SHIFT_MASK) !is 0) event.stateMask |= DWT.SHIFT; + if ((state & OS.GDK_CONTROL_MASK) !is 0) event.stateMask |= DWT.CONTROL; + if ((state & OS.GDK_BUTTON1_MASK) !is 0) event.stateMask |= DWT.BUTTON1; + if ((state & OS.GDK_BUTTON2_MASK) !is 0) event.stateMask |= DWT.BUTTON2; + if ((state & OS.GDK_BUTTON3_MASK) !is 0) event.stateMask |= DWT.BUTTON3; return true; } @@ -1436,15 +1436,15 @@ bool isNull = false; event.keyCode = Display.translateKey (keyEvent.keyval); switch (keyEvent.keyval) { - case OS.GDK_BackSpace: event.character = SWT.BS; break; - case OS.GDK_Linefeed: event.character = SWT.LF; break; + case OS.GDK_BackSpace: event.character = DWT.BS; break; + case OS.GDK_Linefeed: event.character = DWT.LF; break; case OS.GDK_KP_Enter: - case OS.GDK_Return: event.character = SWT.CR; break; + case OS.GDK_Return: event.character = DWT.CR; break; case OS.GDK_KP_Delete: - case OS.GDK_Delete: event.character = SWT.DEL; break; - case OS.GDK_Escape: event.character = SWT.ESC; break; + case OS.GDK_Delete: event.character = DWT.DEL; break; + case OS.GDK_Escape: event.character = DWT.ESC; break; case OS.GDK_Tab: - case OS.GDK_ISO_Left_Tab: event.character = SWT.TAB; break; + case OS.GDK_ISO_Left_Tab: event.character = DWT.TAB; break; default: { if (event.keyCode is 0) { uint keyval;