diff org.eclipse.draw2d/src/org/eclipse/draw2d/Cursors.d @ 12:bc29606a740c

Added dwt-addons in original directory structure of eclipse.org
author Frank Benoit <benoit@tionex.de>
date Sat, 14 Mar 2009 18:23:29 +0100
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/org.eclipse.draw2d/src/org/eclipse/draw2d/Cursors.d	Sat Mar 14 18:23:29 2009 +0100
@@ -0,0 +1,314 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 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
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ * Port to the D programming language:
+ *     Frank Benoit <benoit@tionex.de>
+ *******************************************************************************/
+module org.eclipse.draw2d.Cursors;
+
+import java.lang.all;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Cursor;
+import org.eclipse.draw2d.PositionConstants;
+
+/**
+ * A collection of cursors.
+ */
+public class Cursors {
+
+/**
+ * Returns the cursor corresponding to the given direction, defined in
+ * {@link PositionConstants}. Note that {@link #getDirectionalCursor(int, bool)} should
+ * be used for applications which want to run properly when running in a mirrored
+ * environment. The behavior is the same as calling {@link #getDirectionalCursor(int,
+ * bool) getDirectionalCursor(direction, false)}.
+ *
+ * @param direction the relative direction of the desired cursor
+ * @return The appropriate directional cursor
+ */
+public static Cursor getDirectionalCursor(int direction) {
+    return getDirectionalCursor(direction, false);
+}
+
+/**
+ * Returns the cursor corresponding to the given direction and mirroring. The direction
+ * must be one of:
+ * <UL>
+ *   <LI>{@link PositionConstants#NORTH}
+ *   <LI>{@link PositionConstants#SOUTH}
+ *   <LI>{@link PositionConstants#EAST}
+ *   <LI>{@link PositionConstants#WEST}
+ *   <LI>{@link PositionConstants#NORTH_EAST}
+ *   <LI>{@link PositionConstants#NORTH_WEST}
+ *   <LI>{@link PositionConstants#SOUTH_EAST}
+ *   <LI>{@link PositionConstants#SOUTH_WEST}
+ * </UL>
+ * <P>The behavior is undefined for other values. If <code>isMirrored</code> is set to
+ * <code>true</code>, EAST and WEST will be inverted.
+ * @param direction the relative direction of the desired cursor
+ * @param isMirrored <code>true</code> if EAST and WEST should be inverted
+ * @return The appropriate directional cursor
+ */
+public static Cursor getDirectionalCursor(int direction, bool isMirrored) {
+    if (isMirrored && (direction & PositionConstants.EAST_WEST) !is 0)
+        direction = direction ^ PositionConstants.EAST_WEST;
+    switch (direction) {
+        case PositionConstants.NORTH :
+            return SIZEN;
+        case PositionConstants.SOUTH:
+            return SIZES;
+        case PositionConstants.EAST :
+            return SIZEE;
+        case PositionConstants.WEST:
+            return SIZEW;
+        case PositionConstants.SOUTH_EAST:
+            return SIZESE;
+        case PositionConstants.SOUTH_WEST:
+            return SIZESW;
+        case PositionConstants.NORTH_EAST:
+            return SIZENE;
+        case PositionConstants.NORTH_WEST:
+            return SIZENW;
+        default:
+            break;
+    }
+    return null;
+}
+
+/**
+ * @see SWT#CURSOR_ARROW
+ */
+private static Cursor ARROW_;
+public static Cursor ARROW(){
+    if( !initStaticCtor_done ) initStaticCtor();
+    return ARROW_;
+}
+
+/**
+ * @see SWT#CURSOR_SIZEN
+ */
+private static Cursor SIZEN_;
+public static Cursor SIZEN(){
+    if( !initStaticCtor_done ) initStaticCtor();
+    return SIZEN_;
+}
+
+/**
+ * @see SWT#CURSOR_SIZENE
+ */
+private static Cursor SIZENE_;
+public static Cursor SIZENE(){
+    if( !initStaticCtor_done ) initStaticCtor();
+    return SIZENE_;
+}
+
+/**
+ * @see SWT#CURSOR_SIZEE
+ */
+private static Cursor SIZEE_;
+public static Cursor SIZEE(){
+    if( !initStaticCtor_done ) initStaticCtor();
+    return SIZEE_;
+}
+
+/**
+ * @see SWT#CURSOR_SIZESE
+ */
+private static Cursor SIZESE_;
+public static Cursor SIZESE(){
+    if( !initStaticCtor_done ) initStaticCtor();
+    return SIZESE_;
+}
+
+/**
+ * @see SWT#CURSOR_SIZES
+ */
+private static Cursor SIZES_;
+public static Cursor SIZES(){
+    if( !initStaticCtor_done ) initStaticCtor();
+    return SIZES_;
+}
+
+/**
+ * @see SWT#CURSOR_SIZESW
+ */
+private static Cursor SIZESW_;
+public static Cursor SIZESW(){
+    if( !initStaticCtor_done ) initStaticCtor();
+    return SIZESW_;
+}
+
+/**
+ * @see SWT#CURSOR_SIZEW
+ */
+private static Cursor SIZEW_;
+public static Cursor SIZEW(){
+    if( !initStaticCtor_done ) initStaticCtor();
+    return SIZEW_;
+}
+
+/**
+ * @see SWT#CURSOR_SIZENW
+ */
+private static Cursor SIZENW_;
+public static Cursor SIZENW(){
+    if( !initStaticCtor_done ) initStaticCtor();
+    return SIZENW_;
+}
+
+/**
+ * @see SWT#CURSOR_APPSTARTING
+ */
+private static Cursor APPSTARTING_;
+public static Cursor APPSTARTING(){
+    if( !initStaticCtor_done ) initStaticCtor();
+    return APPSTARTING_;
+}
+
+/**
+ * @see SWT#CURSOR_CROSS
+ */
+private static Cursor CROSS_;
+public static Cursor CROSS(){
+    if( !initStaticCtor_done ) initStaticCtor();
+    return CROSS_;
+}
+
+/**
+ * @see SWT#CURSOR_HAND
+ */
+private static Cursor HAND_;
+public static Cursor HAND(){
+    if( !initStaticCtor_done ) initStaticCtor();
+    return HAND_;
+}
+
+/**
+ * @see SWT#CURSOR_HELP
+ */
+private static Cursor HELP_;
+public static Cursor HELP(){
+    if( !initStaticCtor_done ) initStaticCtor();
+    return HELP_;
+}
+
+/**
+ * @see SWT#CURSOR_IBEAM
+ */
+private static Cursor IBEAM_;
+public static Cursor IBEAM(){
+    if( !initStaticCtor_done ) initStaticCtor();
+    return IBEAM_;
+}
+
+/**
+ * @see SWT#CURSOR_NO
+ */
+private static Cursor NO_;
+public static Cursor NO(){
+    if( !initStaticCtor_done ) initStaticCtor();
+    return NO_;
+}
+
+/**
+ * @see SWT#CURSOR_SIZEALL
+ */
+private static Cursor SIZEALL_;
+public static Cursor SIZEALL(){
+    if( !initStaticCtor_done ) initStaticCtor();
+    return SIZEALL_;
+}
+
+/**
+ * @see SWT#CURSOR_SIZENESW
+ */
+private static Cursor SIZENESW_;
+public static Cursor SIZENESW(){
+    if( !initStaticCtor_done ) initStaticCtor();
+    return SIZENESW_;
+}
+
+/**
+ * @see SWT#CURSOR_SIZENWSE
+ */
+private static Cursor SIZENWSE_;
+public static Cursor SIZENWSE(){
+    if( !initStaticCtor_done ) initStaticCtor();
+    return SIZENWSE_;
+}
+
+/**
+ * @see SWT#CURSOR_SIZEWE
+ */
+private static Cursor SIZEWE_;
+public static Cursor SIZEWE(){
+    if( !initStaticCtor_done ) initStaticCtor();
+    return SIZEWE_;
+}
+
+/**
+ * @see SWT#CURSOR_SIZENS
+ */
+private static Cursor SIZENS_;
+public static Cursor SIZENS(){
+    if( !initStaticCtor_done ) initStaticCtor();
+    return SIZENS_;
+}
+
+/**
+ * @see SWT#CURSOR_UPARROW
+ */
+private static Cursor UPARROW_;
+public static Cursor UPARROW(){
+    if( !initStaticCtor_done ) initStaticCtor();
+    return UPARROW_;
+}
+
+/**
+ * @see SWT#CURSOR_WAIT
+ */
+private static Cursor WAIT_;
+public static Cursor WAIT(){
+    if( !initStaticCtor_done ) initStaticCtor();
+    return WAIT_;
+}
+
+private static bool initStaticCtor_done = false;
+private static void initStaticCtor() {
+    synchronized(Cursor.classinfo){
+        if(!initStaticCtor_done){
+            ARROW_        = new Cursor(null, SWT.CURSOR_ARROW);
+            SIZEN_        = new Cursor(null, SWT.CURSOR_SIZEN);
+            SIZENE_       = new Cursor(null, SWT.CURSOR_SIZENE);
+            SIZEE_        = new Cursor(null, SWT.CURSOR_SIZEE);
+            SIZESE_       = new Cursor(null, SWT.CURSOR_SIZESE);
+            SIZES_        = new Cursor(null, SWT.CURSOR_SIZES);
+            SIZESW_       = new Cursor(null, SWT.CURSOR_SIZESW);
+            SIZEW_        = new Cursor(null, SWT.CURSOR_SIZEW);
+            SIZENW_       = new Cursor(null, SWT.CURSOR_SIZENW);
+            SIZENS_       = new Cursor(null, SWT.CURSOR_SIZENS);
+            SIZEWE_       = new Cursor(null, SWT.CURSOR_SIZEWE);
+            APPSTARTING_  = new Cursor(null, SWT.CURSOR_APPSTARTING);
+            CROSS_        = new Cursor(null, SWT.CURSOR_CROSS);
+            HAND_         = new Cursor(null, SWT.CURSOR_HAND);
+            HELP_         = new Cursor(null, SWT.CURSOR_HELP);
+            IBEAM_        = new Cursor(null, SWT.CURSOR_IBEAM);
+            NO_           = new Cursor(null, SWT.CURSOR_NO);
+            SIZEALL_      = new Cursor(null, SWT.CURSOR_SIZEALL);
+            SIZENESW_     = new Cursor(null, SWT.CURSOR_SIZENESW);
+            SIZENWSE_     = new Cursor(null, SWT.CURSOR_SIZENWSE);
+            UPARROW_      = new Cursor(null, SWT.CURSOR_UPARROW);
+            WAIT_         = new Cursor(null, SWT.CURSOR_WAIT);
+            initStaticCtor_done = true;
+        }
+    }
+}
+
+}