- * IMPORTANT: This method is not part of the public
- * API for Image. It is marked public only so that it
- * can be shared within the packages provided by SWT. It is not
- * available on all platforms, and should never be called from
- * application code.
- *
- * @param device the device on which to create the image
- * @param cgImage the internal image instance
- *
- * @exception IllegalArgumentException
- *
ERROR_NULL_ARGUMENT - if device is null and there is no current device
- *
ERROR_NULL_ARGUMENT - if the iternal image is null
- *
- * @exception SWTException
- *
ERROR_INVALID_IMAGE - if the given internal image is not valid
- *
- * @exception SWTError
- *
ERROR_NO_HANDLES if a handle could not be obtained for image creation
+ * IMPORTANT: This method is not part of the public
+ * API for Image. It is marked public only so that it
+ * can be shared within the packages provided by SWT. It is not
+ * available on all platforms, and should never be called from
+ * application code.
+ *
+ * @param device the device on which to create the image
+ * @param cgImage the internal image instance
+ *
+ * @exception IllegalArgumentException
+ *
ERROR_NULL_ARGUMENT - if device is null and there is no current device
+ *
ERROR_NULL_ARGUMENT - if the iternal image is null
+ *
+ * @exception SWTException
+ *
ERROR_INVALID_IMAGE - if the given internal image is not valid
+ *
+ * @exception SWTError
+ *
ERROR_NO_HANDLES if a handle could not be obtained for image creation
+ *
+ */
+ static Image qt_new(
+ Device device, org.eclipse.swt.internal.qt.graphics.Image cgImage) {
+ Image image = new Image(device);
+ image.init(cgImage);
+ return image;
+ }
}
diff -r abc41079b313 -r 59b3b4473dc8 javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/swt/widgets/Label.java
--- a/javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/swt/widgets/Label.java Fri Jul 23 12:27:20 2010 +0300
+++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/swt/widgets/Label.java Thu Aug 05 16:07:57 2010 +0300
@@ -127,10 +127,11 @@
}
checkWidget();
+
if (changed) {
OS.QWidget_updateGeometry(handle);
}
-
+
/**
* ComputeSize in super class is not able to handle the situation that
* preferred height depends on the width. So ask QLabel for preferred
@@ -167,6 +168,7 @@
else
height = defaultLength;
}
+
return new Point(width, height);
}
@@ -329,6 +331,25 @@
OS.QPixmap_delete(pixmapHandle);
}
}
+
+ void setThemeIcon(String name) {
+ checkWidget();
+ if ((style & SWT.SEPARATOR) != 0)
+ return;
+ int iconHandle = 0;
+ int pixmapHandle = 0;
+ try {
+ iconHandle = OS.HbIcon_new(name);
+ if (iconHandle != 0)
+ pixmapHandle = OS.HbIcon_pixmap(iconHandle);
+ if (pixmapHandle != 0)
+ OS.QLabel_setPixmap(topHandle, pixmapHandle);
+ } finally {
+ OS.HbIcon_delete(iconHandle);
+ OS.QPixmap_delete(pixmapHandle);
+ }
+ }
+
void setStyle(int style) {
int qStyle = 0;
diff -r abc41079b313 -r 59b3b4473dc8 javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/graphics/gfxos.cpp
--- a/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/graphics/gfxos.cpp Fri Jul 23 12:27:20 2010 +0300
+++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/graphics/gfxos.cpp Thu Aug 05 16:07:57 2010 +0300
@@ -967,6 +967,21 @@
return POINTER_TO_HANDLE(img);
}
+jint JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_image_1create__I
+ (JNIEnv* aJniEnv , jclass, jint aPixmapHandle)
+{
+ Image* img = NULL;
+ GFX_TRY
+ {
+ SWT_LOG_JNI_CALL();
+ HANDLE_TO_POINTER(QPixmap*, pixmap, aPixmapHandle);
+ if (pixmap)
+ img = GraphicsFactory::createImage(*pixmap);
+ }
+ GFX_CATCH
+ return POINTER_TO_HANDLE(img);
+}
+
jint JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_image_1getFormat
(JNIEnv* aJniEnv, jclass, jint aImageHandle)
{
diff -r abc41079b313 -r 59b3b4473dc8 javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/graphics/graphics.h
--- a/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/graphics/graphics.h Fri Jul 23 12:27:20 2010 +0300
+++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/graphics/graphics.h Thu Aug 05 16:07:57 2010 +0300
@@ -1675,6 +1675,13 @@
static Image* createImage(const QImage& aImage);
/**
+ * Create image from a QPixmap.
+ *
+ * @param aImage The source QPixmap
+ */
+ static Image* createImage(const QPixmap& aPixmap);
+
+ /**
* Creates an image based on the given ARGB data array.
* @param aRgbData ARGB data array. One pixel is specified as 0xAARRGGBB.
* @param aWidth Image width
diff -r abc41079b313 -r 59b3b4473dc8 javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/graphics/graphicsfactory.cpp
--- a/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/graphics/graphicsfactory.cpp Fri Jul 23 12:27:20 2010 +0300
+++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/graphics/graphicsfactory.cpp Thu Aug 05 16:07:57 2010 +0300
@@ -78,6 +78,14 @@
return static_cast(pixmap);
}
+/*static*/ Image* GraphicsFactory::createImage(const QPixmap& aPixmap)
+{
+ GFX_LOG_FUNC_CALL();
+ Pixmap* pixmap = new Pixmap();
+ pixmap->createFromQPixmap(aPixmap);
+ return static_cast(pixmap);
+}
+
/*static*/ Image* GraphicsFactory::createImage(int* aRgbData, int aWidth, int aHeight, bool aHasAlpha)
{
Pixmap* pixmap = new Pixmap();
diff -r abc41079b313 -r 59b3b4473dc8 javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/graphics/qt/pixmap.cpp
--- a/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/graphics/qt/pixmap.cpp Fri Jul 23 12:27:20 2010 +0300
+++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/graphics/qt/pixmap.cpp Thu Aug 05 16:07:57 2010 +0300
@@ -60,6 +60,19 @@
}
}
+void Pixmap::createFromQPixmap(const QPixmap& aPixmap)
+{
+ GFX_LOG_FUNC_CALL();
+ Q_ASSERT(mPixmap.isNull());
+
+ mPixmap = QPixmap(aPixmap);
+
+ // Validate allocation
+ if(mPixmap.isNull())
+ {
+ throw GfxException(EGfxErrorNoMemory, "Image (Pixmap) creation failed");
+ }
+}
void Pixmap::createFromImage(Image* aImage, int aX, int aY, int aWidth, int aHeight)
{
diff -r abc41079b313 -r 59b3b4473dc8 javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/graphics/qt/pixmap.h
--- a/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/graphics/qt/pixmap.h Fri Jul 23 12:27:20 2010 +0300
+++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/graphics/qt/pixmap.h Thu Aug 05 16:07:57 2010 +0300
@@ -35,6 +35,7 @@
*/
virtual void createBySize(int aWidth, int aHeight, int aFillColor, TImageFormat aFormat);
virtual void createFromQImage(const QImage& aImage);
+ virtual void createFromQPixmap(const QPixmap& aPixmap);
virtual void createFromImage(Image* aImage, int aX, int aY, int aWidth, int aHeight);
virtual void createFromImageData(ImageDataWrapper* aData);
virtual void createFromRGB(int* aRgbdata, int aWidth, int aHeight, bool aHasAlpha);
diff -r abc41079b313 -r 59b3b4473dc8 javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/os.cpp
--- a/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/os.cpp Fri Jul 23 12:27:20 2010 +0300
+++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/os.cpp Thu Aug 05 16:07:57 2010 +0300
@@ -86,6 +86,7 @@
#include
#include
#include
+#include
#endif
#include
@@ -6343,7 +6344,60 @@
return reinterpret_cast< jint >(pixmap);
}
-
+//
+// HbIcon
+//
+
+JNIEXPORT jint JNICALL OS_NATIVE ( HbIcon_1new )
+ (JNIEnv* aJniEnv , jclass, jstring aName)
+ {
+#ifdef __SYMBIAN32__
+ HbIcon* icon = NULL;
+ SWT_TRY
+ {
+ SWT_LOG_JNI_CALL();
+ icon = new HbIcon(swtApp->jniUtils().JavaStringToQString(aJniEnv, aName));
+ }
+ SWT_CATCH
+ return reinterpret_cast< jint >( static_cast< HbIcon* >( icon ) );
+#else
+ return 0;
+#endif
+ }
+
+JNIEXPORT jint JNICALL OS_NATIVE( HbIcon_1pixmap )
+ (JNIEnv* aJniEnv , jclass, jint aHandle)
+ {
+#ifdef __SYMBIAN32__
+ QPixmap* pixmap = NULL;
+ SWT_TRY
+ {
+ SWT_LOG_JNI_CALL();
+ HbIcon* icon = reinterpret_cast< HbIcon* >( aHandle );
+ pixmap = new QPixmap(icon->pixmap());
+ }
+ SWT_CATCH
+ return reinterpret_cast< jint >(pixmap);
+#else
+ return 0;
+#endif
+ }
+
+JNIEXPORT void JNICALL OS_NATIVE( HbIcon_1delete )
+ (JNIEnv* aJniEnv , jclass, jint aHandle)
+ {
+#ifdef __SYMBIAN32__
+ SWT_TRY
+ {
+ SWT_LOG_JNI_CALL();
+ SWT_LOG_DATA_1("handle=%x", aHandle);
+ HbIcon* icon = reinterpret_cast< HbIcon* >( aHandle );
+ delete icon;
+ icon = NULL;
+ }
+ SWT_CATCH
+#endif
+ }
//
// QSlider
diff -r abc41079b313 -r 59b3b4473dc8 javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/org/eclipse/swt/graphics/Internal_GfxPackageSupport.java
--- a/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/org/eclipse/swt/graphics/Internal_GfxPackageSupport.java Fri Jul 23 12:27:20 2010 +0300
+++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/org/eclipse/swt/graphics/Internal_GfxPackageSupport.java Thu Aug 05 16:07:57 2010 +0300
@@ -26,41 +26,28 @@
public static int getNullIconHandle() {
return Image.getNullIconHandle();
}
-public static Image new_Image(Device device, org.eclipse.swt.internal.qt.graphics.Image cgImage) {
- return Image.new_Image(device, cgImage);
+
+public static Image new_Image(Device device,
+ org.eclipse.swt.internal.qt.graphics.Image cgImage) {
+ return Image.qt_new(device, cgImage);
}
+
public static int getIconHandle(Image i) {
return i.getIconHandle();
}
+
public static org.eclipse.swt.internal.qt.graphics.Image getImage(Image i) {
return i.getImage();
}
+
public static int getImageHandle(Image i) {
return i.getImageHandle();
}
+
public static int getPixmapHandle(Image i) {
return i.getPixmapHandle();
}
-/*
- * From the class Device
- */
-public static boolean internal(Device d) {
- return d.internal;
-}
-public static boolean initialized() {
- return Device.initialized;
-}
-public static Color newColor(Device device, int handle) {
- return Color.qt_new(device, handle);
-}
-public static Font newFont(Device device, int handle) {
- return Font.qt_new(device, handle);
-}
-
-/*
- * From the class Image
- */
public static Image createImageWithoutSecurityCheck(Device device,
String filename) {
return Image.createImageWithoutSecurityCheck(device, filename);
@@ -74,4 +61,23 @@
return Image.getImageSize(stream);
}
+/*
+ * From the class Device
+ */
+public static boolean internal(Device d) {
+ return d.internal;
}
+
+public static boolean initialized() {
+ return Device.initialized;
+}
+
+public static Color newColor(Device device, int handle) {
+ return Color.qt_new(device, handle);
+}
+
+public static Font newFont(Device device, int handle) {
+ return Font.qt_new(device, handle);
+}
+
+}
diff -r abc41079b313 -r 59b3b4473dc8 javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/org/eclipse/swt/widgets/Internal_PackageSupport.java
--- a/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/org/eclipse/swt/widgets/Internal_PackageSupport.java Fri Jul 23 12:27:20 2010 +0300
+++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/org/eclipse/swt/widgets/Internal_PackageSupport.java Thu Aug 05 16:07:57 2010 +0300
@@ -385,6 +385,9 @@
public static void setStandardIcon(Label l, int iconType, int iconWidth, int iconHeight) {
l.setStandardIcon(iconType, iconWidth, iconHeight);
}
+public static void setThemeIcon(Label l, String iconName) {
+ l.setThemeIcon(iconName);
+}
public static void setMobileDevice(Display display, MobileDevice mobileDevice){
Display.mobileDevice = mobileDevice;
diff -r abc41079b313 -r 59b3b4473dc8 javauis/lcdui_qt/src/javax/microedition/lcdui/Canvas.java
--- a/javauis/lcdui_qt/src/javax/microedition/lcdui/Canvas.java Fri Jul 23 12:27:20 2010 +0300
+++ b/javauis/lcdui_qt/src/javax/microedition/lcdui/Canvas.java Thu Aug 05 16:07:57 2010 +0300
@@ -28,7 +28,6 @@
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.internal.extension.CompositeExtension;
import org.eclipse.swt.internal.qt.graphics.WindowSurface;
import org.eclipse.swt.internal.extension.MobileShellExtension;
import org.eclipse.swt.internal.qt.SymbianWindowVisibilityListener;
@@ -191,7 +190,6 @@
//private Composite keypadComposite;
private CanvasKeypad onScreenkeypad;
private static CanvasKeypad sharedKeypad;
- private int oskHeight;
// Vector of flags that a certain key was pressed but was not released.
// Used to implement keyRepeated since eSWT does not support
diff -r abc41079b313 -r 59b3b4473dc8 javauis/lcdui_qt/src/javax/microedition/lcdui/CanvasKeypad.java
--- a/javauis/lcdui_qt/src/javax/microedition/lcdui/CanvasKeypad.java Fri Jul 23 12:27:20 2010 +0300
+++ b/javauis/lcdui_qt/src/javax/microedition/lcdui/CanvasKeypad.java Thu Aug 05 16:07:57 2010 +0300
@@ -1,136 +1,129 @@
/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:
-*
-*/
+ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
package javax.microedition.lcdui;
-import java.util.Vector;
import java.util.Timer;
import java.util.TimerTask;
-import org.eclipse.ercp.swt.mobile.MobileShell;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.extension.ImageUtil;
import org.eclipse.swt.internal.qt.*;
-import com.nokia.mj.impl.rt.support.ApplicationInfo;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
-import javax.microedition.lcdui.EventDispatcher.LCDUIEvent;
-
-
/**
- * The CanvasKeypad class is designed to generate the on screen keypad
- * and handle graphical operations as well as low-level pointer events.
- * CanvasKeypad maps the pointer events to key events that are needed by the Canvas.
- *
+ * The CanvasKeypad class is designed to generate the on screen keypad and
+ * handle graphical operations as well as low-level pointer events. CanvasKeypad
+ * maps the pointer events to key events that are needed by the Canvas.
+ *
*/
final class CanvasKeypad implements MouseListener, MouseMoveListener
{
-
/**
- * Constant for UP game action.
- */
+ * Constant for UP game action.
+ */
private static final int UP = -1;
/**
- * Constant for DOWN game action.
- */
+ * Constant for DOWN game action.
+ */
private static final int DOWN = -2;
/**
- * Constant for LEFT game action.
- */
+ * Constant for LEFT game action.
+ */
private static final int LEFT = -3;
/**
- * Constant for RIGHT game action.
- */
+ * Constant for RIGHT game action.
+ */
private static final int RIGHT = -4;
/**
- * Constant for FIRE game action.
- */
+ * Constant for FIRE game action.
+ */
private static final int FIRE = -5;
/**
- * Constant for SLK game action.
- */
+ * Constant for SLK game action.
+ */
private static final int SLK = -6;
/**
- * Constant for SRK game action.
- */
+ * Constant for SRK game action.
+ */
private static final int SRK = -7;
/**
- * Constant for general "A" game action.
- */
+ * Constant for general "A" game action.
+ */
private static final int GAME_A = 55;
/**
- * Constant for general "B" game action.
- */
+ * Constant for general "B" game action.
+ */
private static final int GAME_B = 57;
/**
- * Constant for general "C" game action.
- */
+ * Constant for general "C" game action.
+ */
private static final int GAME_C = 42;
/**
- * Constant for general "D" game action.
- */
+ * Constant for general "D" game action.
+ */
private static final int GAME_D = 35;
/**
- * Constant for general invalid key code.
- */
+ * Constant for general invalid key code.
+ */
private static final int INVALID_CODE = -99;
/**
- * Constant for long keypress timeout.
- */
+ * Constant for long keypress timeout.
+ */
private static final int KEYREPEAT_INTERVAL = 500;
/**
- * alpha value of a transparent pixel.
- */
+ * Alpha value of a transparent pixel.
+ */
private static final int TRANSPARENT = 0;
/**
- * keypad and game keys composites.
- */
+ * Keypad and game keys composites.
+ */
private Composite keypadComposite;
private Composite gameKeysComposite;
private Canvas canvas;
/**
- * CSS engine instance
- */
+ * CSS engine instance
+ */
private BaseCSSEngine cssEngine;
/**
- * Canvas keypad buttons.
- */
-
+ * Canvas keypad buttons.
+ */
private Label center;
private Label up;
private Label down;
@@ -169,30 +162,31 @@
private Label rockerKeyPressed;
/**
- * Timer for handling long key press and mouse move events.
- */
+ * Timer for handling long key press and mouse move events.
+ */
private Timer timer = new Timer();
private CanvasKeypadTimerTask timerTask;
/**
- * Path of the osk graphics
- */
+ * Path of the osk graphics
+ */
private static final String RESOURCE_PATH = "c:/data/images/";
/**
- * offset on the composite in pixels where the osk rocker keys are layed out.
- */
+ * Offset on the composite in pixels where the osk rocker keys are layed
+ * out.
+ */
private int image_offset;
-
/**
- * Constructs a canvas kepad based on the JAD attribute
- *
- * @param canvas - canvas for which the keypad is required.
- * @param canvasComp - Composite corresponding to the canvas.
- * @param mode- the jad attribute as a string.
- */
- CanvasKeypad(Canvas canvas, Composite canvasComp, String mode)
+ * Constructs a canvas kepad based on the JAD attribute
+ *
+ * @param canvas
+ * - canvas for which the keypad is required.
+ * @param mode
+ * - the jad attribute as a string.
+ */
+ CanvasKeypad(Canvas canvas, String mode)
{
this.canvas = canvas;
@@ -200,73 +194,68 @@
cssEngine = new BaseCSSEngine(display);
+ // Load the images
+ center_normal = ImageUtil.createImageFromTheme(display, "qtg_fr_rocker_normal_c");
+ center_pressed = ImageUtil.createImageFromTheme(display, "qtg_fr_rocker_pressed_c");
+ left_normal = ImageUtil.createImageFromTheme(display, "qtg_fr_rocker_normal_l");
+ left_pressed = ImageUtil.createImageFromTheme(display, "qtg_fr_rocker_pressed_l");
+ right_normal = ImageUtil.createImageFromTheme(display, "qtg_fr_rocker_normal_r");
+ right_pressed = ImageUtil.createImageFromTheme(display, "qtg_fr_rocker_pressed_r");
+ up_normal = ImageUtil.createImageFromTheme(display, "qtg_fr_rocker_normal_t");
+ up_pressed = ImageUtil.createImageFromTheme(display, "qtg_fr_rocker_pressed_t");
+ down_normal = ImageUtil.createImageFromTheme(display, "qtg_fr_rocker_normal_b");
+ down_pressed = ImageUtil.createImageFromTheme(display, "qtg_fr_rocker_pressed_b");
- //load the images
- center_normal = new org.eclipse.swt.graphics.Image(display,RESOURCE_PATH + "qtg_fr_rocker_normal_c.svg");
- center_pressed = new org.eclipse.swt.graphics.Image(display,RESOURCE_PATH + "qtg_fr_rocker_pressed_c.svg");
- left_normal = new org.eclipse.swt.graphics.Image(display,RESOURCE_PATH + "qtg_fr_rocker_normal_l.svg");
- left_pressed = new org.eclipse.swt.graphics.Image(display,RESOURCE_PATH + "qtg_fr_rocker_pressed_l.svg");
- right_normal = new org.eclipse.swt.graphics.Image(display,RESOURCE_PATH + "qtg_fr_rocker_normal_r.svg");
- right_pressed = new org.eclipse.swt.graphics.Image(display,RESOURCE_PATH + "qtg_fr_rocker_pressed_r.svg");
- up_normal = new org.eclipse.swt.graphics.Image(display,RESOURCE_PATH + "qtg_fr_rocker_normal_t.svg");
- up_pressed = new org.eclipse.swt.graphics.Image(display,RESOURCE_PATH + "qtg_fr_rocker_pressed_t.svg");
- down_normal = new org.eclipse.swt.graphics.Image(display,RESOURCE_PATH + "qtg_fr_rocker_normal_b.svg");
- down_pressed = new org.eclipse.swt.graphics.Image(display,RESOURCE_PATH + "qtg_fr_rocker_pressed_b.svg");
+ image_offset = (display.getBounds().width / 2) - (center_normal.getBounds().width / 2);
- image_offset = (display.getBounds().width/2) - (center_normal.getBounds().width/2);
-
- //Load image data required to determine the osk button pressed on mouse events
+ // Load image data required to determine the osk button pressed on mouse events
center_data = center_normal.getImageData();
left_data = left_normal.getImageData();
right_data = right_normal.getImageData();
up_data = up_normal.getImageData();
down_data = down_normal.getImageData();
-
- //Set form layout for the shell containing the canvas.
+ // Set form layout for the shell containing the canvas.
canvas.getShell().setLayout(new FormLayout());
- //Create the Navigation keypad
+ // Create the Navigation keypad
createNavKeypad();
- //check if game keys are needed
- if(mode.equalsIgnoreCase("gameactions"))
+ // Check if game keys are needed
+ if (mode.equalsIgnoreCase("gameactions"))
{
- //create the game key pad
createGamePad();
}
-
- //Layout the game keys, navigation keys and the canvas composites on the shell using form layout
-
+ // Layout the game keys, navigation keys and the canvas composites on
+ // the shell using form layout
FormData canvasData = new FormData();
canvasData.right = new FormAttachment(100);
canvasData.left = new FormAttachment(0);
canvasData.top = new FormAttachment(0);
canvasData.bottom = new FormAttachment(keypadComposite);
- canvasComp.setLayoutData(canvasData);
+ canvas.getContentComp().setLayoutData(canvasData);
FormData navKeyData = new FormData();
navKeyData.right = new FormAttachment(100);
navKeyData.left = new FormAttachment(0);
- if(gameKeysComposite != null)
+ if (gameKeysComposite != null)
{
- //game keypad was created above, so layout the game keys.
+ // Game keypad was created above, so layout the game keys.
navKeyData.bottom = new FormAttachment(gameKeysComposite);
}
else
{
- //game keys are not needed
+ // Game keys are not needed
navKeyData.bottom = new FormAttachment(100);
}
keypadComposite.setLayoutData(navKeyData);
-
- if(gameKeysComposite != null)
+ if (gameKeysComposite != null)
{
- //game keys were created, layout the game keys
+ // Game keys were created, layout the game keys
FormData gameKeyData = new FormData();
gameKeyData.right = new FormAttachment(100);
gameKeyData.left = new FormAttachment(0);
@@ -274,19 +263,15 @@
gameKeysComposite.setLayoutData(gameKeyData);
}
- //layout the shell
canvas.getShell().layout();
-
}
/**
- * creates the navigation keypad - the directional keys and selctio key.
- */
+ * creates the navigation keypad - the directional keys and selctio key.
+ */
private void createNavKeypad()
{
-
- //Create the navigation key composite
-
+ // Create the navigation key composite
keypadComposite = new Composite(canvas.getShell(), SWT.NONE);
center = new Label(keypadComposite, SWT.NONE);
@@ -306,39 +291,42 @@
down.setImage(down_normal);
down.pack();
- //layout the navigation keys
+ // layout the navigation keys
keypadComposite.setLayout(new FormLayout());
-
FormData navkeysFormData = new FormData();
- navkeysFormData.top=new FormAttachment(0);
- navkeysFormData.left = new FormAttachment(0,image_offset);
+ navkeysFormData.top = new FormAttachment(0);
+ navkeysFormData.left = new FormAttachment(0, image_offset);
center.setLayoutData(navkeysFormData);
left.setLayoutData(navkeysFormData);
right.setLayoutData(navkeysFormData);
up.setLayoutData(navkeysFormData);
down.setLayoutData(navkeysFormData);
- keypadComposite.pack();
+ keypadComposite.pack(); // will also layout
- keypadComposite.layout();
-
+ // The down Label will catch all mouse down events as it is covering
+ // all other rocker Labels, with the assumption that they all have
+ // the same bounds!
+ down.addMouseListener(this);
+ down.addMouseMoveListener(this);
+
+ // We want to catch all drag events occurring on top of the rocker
+ // including those starting outside.
keypadComposite.addMouseListener(this);
keypadComposite.addMouseMoveListener(this);
-
}
-
/**
- * creates the game keypad - the game action keys A, B, C and D.
- */
+ * creates the game keypad - the game action keys A, B, C and D.
+ */
private void createGamePad()
{
- //create the game pad composite
+ // create the game pad composite
gameKeysComposite = new Composite(canvas.getShell(), SWT.NONE);
gameKeysComposite.setLayout(new FormLayout());
- //Add the game buttons
+ // Add the game buttons
gameA = new Button(gameKeysComposite, SWT.PUSH);
gameA.addMouseListener(this);
@@ -351,114 +339,93 @@
gameD = new Button(gameKeysComposite, SWT.PUSH);
gameD.addMouseListener(this);
- //Set the game key style sheets
- cssEngine.applyCSS(gameA,"QPushButton" +
- "{" +
- "background-color:white;" +
- "border-style: outset;" +
- "border-width: 1px; " +
- "border-color: black;" +
- "border-radius: 2px;" +
- "font: bold 14px;" +
- "min-height: 2em;" +
- "min-width: 5.1em;" +
- "image: url(" + RESOURCE_PATH + "qtg_mono_game_a.svg);" +
- "}" +
- "QPushButton:pressed { image: url(" + RESOURCE_PATH + "qtg_mono_game_a.svg);" +
- " border-style: inset;" +
- "}");
- cssEngine.applyCSS(gameB,"QPushButton" +
- "{" +
- "background-color:white;" +
- "border-style: outset;" +
- "border-width: 1px; " +
- "border-color: black;" +
- "border-radius: 2px;" +
- "font: bold 14px;" +
- "min-height: 2em;" +
- "min-width: 5.1em;" +
- "image: url(" + RESOURCE_PATH + "qtg_mono_game_b.svg);" +
- "}" +
- "QPushButton:pressed { image: url(" + RESOURCE_PATH + "qtg_mono_game_b.svg);" +
- " border-style: inset;" +
- "}");
- cssEngine.applyCSS(gameC,"QPushButton" +
- "{" +
- "background-color:white;" +
- "border-style: outset;" +
- "border-width: 1px; " +
- "border-color: black;" +
- "border-radius: 2px;" +
- "font: bold 14px;" +
- "min-height: 2em;" +
- "min-width: 5.1em;" +
- "image: url(" + RESOURCE_PATH + "qtg_mono_game_c.svg);" +
- "}" +
- "QPushButton:pressed { image: url(" + RESOURCE_PATH + "qtg_mono_game_c.svg);" +
- " border-style: inset;" +
- "}");
- cssEngine.applyCSS(gameD,"QPushButton" +
- "{" +
- "background-color:white;" +
- "border-style: outset;" +
- "border-width: 1px; " +
- "border-color: black;" +
- "border-radius: 2px;" +
- "font: bold 14px;" +
- "min-height: 2em;" +
- "min-width: 5.1em;" +
- "image: url(" + RESOURCE_PATH + "qtg_mono_game_d.svg);" +
- "}" +
- "QPushButton:pressed { image: url(" + RESOURCE_PATH + "qtg_mono_game_d.svg);" +
- " border-style: inset;" +
- "}");
+ // Set the game key style sheets
+ cssEngine.applyCSS(gameA, "QPushButton" + "{" + "background-color:white;"
+ + "border-style: outset;" + "border-width: 1px; " + "border-color: black;"
+ + "border-radius: 2px;" + "font: bold 14px;" + "min-height: 2em;" + "min-width: 5.1em;"
+ + "image: url(" + RESOURCE_PATH + "qtg_mono_game_a.svg);" + "}"
+ + "QPushButton:pressed { image: url(" + RESOURCE_PATH + "qtg_mono_game_a.svg);"
+ + " border-style: inset;" + "}");
+ cssEngine.applyCSS(gameB, "QPushButton" + "{" + "background-color:white;"
+ + "border-style: outset;" + "border-width: 1px; " + "border-color: black;"
+ + "border-radius: 2px;" + "font: bold 14px;" + "min-height: 2em;" + "min-width: 5.1em;"
+ + "image: url(" + RESOURCE_PATH + "qtg_mono_game_b.svg);" + "}"
+ + "QPushButton:pressed { image: url(" + RESOURCE_PATH + "qtg_mono_game_b.svg);"
+ + " border-style: inset;" + "}");
+ cssEngine.applyCSS(gameC, "QPushButton" + "{" + "background-color:white;"
+ + "border-style: outset;" + "border-width: 1px; " + "border-color: black;"
+ + "border-radius: 2px;" + "font: bold 14px;" + "min-height: 2em;" + "min-width: 5.1em;"
+ + "image: url(" + RESOURCE_PATH + "qtg_mono_game_c.svg);" + "}"
+ + "QPushButton:pressed { image: url(" + RESOURCE_PATH + "qtg_mono_game_c.svg);"
+ + " border-style: inset;" + "}");
+ cssEngine.applyCSS(gameD, "QPushButton" + "{" + "background-color:white;"
+ + "border-style: outset;" + "border-width: 1px; " + "border-color: black;"
+ + "border-radius: 2px;" + "font: bold 14px;" + "min-height: 2em;" + "min-width: 5.1em;"
+ + "image: url(" + RESOURCE_PATH + "qtg_mono_game_d.svg);" + "}"
+ + "QPushButton:pressed { image: url(" + RESOURCE_PATH + "qtg_mono_game_d.svg);"
+ + " border-style: inset;" + "}");
-
- //layout the game Keys
+ // layout the game Keys
FormData gameAFormData = new FormData();
- gameAFormData.bottom=new FormAttachment(100,0);
- gameAFormData.left=new FormAttachment(0,0);
+ gameAFormData.bottom = new FormAttachment(100, 0);
+ gameAFormData.left = new FormAttachment(0, 0);
gameA.setLayoutData(gameAFormData);
FormData gameBFormData = new FormData();
- gameBFormData.bottom=new FormAttachment(100,0);
- gameBFormData.left=new FormAttachment(gameA,0);
+ gameBFormData.bottom = new FormAttachment(100, 0);
+ gameBFormData.left = new FormAttachment(gameA, 0);
gameB.setLayoutData(gameBFormData);
FormData gameCFormData = new FormData();
- gameCFormData.bottom=new FormAttachment(100,0);
- gameCFormData.left=new FormAttachment(gameB,0);
+ gameCFormData.bottom = new FormAttachment(100, 0);
+ gameCFormData.left = new FormAttachment(gameB, 0);
gameC.setLayoutData(gameCFormData);
FormData gameDFormData = new FormData();
- gameDFormData.bottom=new FormAttachment(100,0);
- gameDFormData.left=new FormAttachment(gameC,0);
+ gameDFormData.bottom = new FormAttachment(100, 0);
+ gameDFormData.left = new FormAttachment(gameC, 0);
gameD.setLayoutData(gameDFormData);
gameKeysComposite.layout();
}
/**
- * Handles orientation changes.
- */
+ * Handles orientation changes.
+ */
void handleOrientationChange(int mode)
{
- //change the layout as per orientation mode
+ // change the layout as per orientation mode
}
+ /**
+ * Sets the currect Canvas for Key events.
+ *
+ * @param canvas
+ * - Current Canvas to which the key events needs to be
+ * delivered.
+ */
+ void setCurrentCanvas(Canvas canvas)
+ {
+ this.canvas = canvas;
+ }
/**
- * Adds LSk and RSK keys to navigation keypad if the canvas is set to full screen mode.
- * @param mode- Indicates if the canvas is in fullscreen mode or not. True if fullscreen, False otherwise.
- */
+ * Adds LSk and RSK keys to navigation keypad if the canvas is set to full
+ * screen mode.
+ *
+ * @param mode
+ * - Indicates if the canvas is in fullscreen mode or not. True
+ * if fullscreen, False otherwise.
+ */
void setFullScreenMode(boolean mode)
{
- //add the soft keys if the canvas is set to full screen mode/remove otherwise
- if(mode == true)
+ // add the soft keys if the canvas is set to full screen mode/remove
+ // otherwise
+ if (mode == true)
{
- if(keypadComposite != null)
+ if (keypadComposite != null)
{
Color black = display.getSystemColor(SWT.COLOR_BLACK);
@@ -470,48 +437,31 @@
skleft = new Button(keypadComposite, SWT.PUSH);
skleft.addMouseListener(this);
- //Set the style sheet
- cssEngine.applyCSS(skright,"QPushButton" +
- "{" +
- "background-color:white;" +
- "border-style: outset;" +
- "border-width: 1px; " +
- "border-bottom-left-radius: 22px;"+
- "border-color: black;" +
- "font: bold 14px;" +
- "min-width: 3em;" +
- "min-height: 2em;" +
- "image: url(" + RESOURCE_PATH + "qtg_mono_rsk_horizontal.svg);" +
- "}" +
- "QPushButton:pressed { image: url(" + RESOURCE_PATH + "qtg_mono_rsk_horizontal.svg);" +
- " border-style: inset;" +
- "}");
+ // Set the style sheet
+ cssEngine.applyCSS(skright, "QPushButton" + "{" + "background-color:white;"
+ + "border-style: outset;" + "border-width: 1px; "
+ + "border-bottom-left-radius: 22px;" + "border-color: black;"
+ + "font: bold 14px;" + "min-width: 3em;" + "min-height: 2em;" + "image: url("
+ + RESOURCE_PATH + "qtg_mono_rsk_horizontal.svg);" + "}"
+ + "QPushButton:pressed { image: url(" + RESOURCE_PATH
+ + "qtg_mono_rsk_horizontal.svg);" + " border-style: inset;" + "}");
- cssEngine.applyCSS(skleft,"QPushButton" +
- "{" +
- "background-color:white;" +
- "border-style: outset;" +
- "border-width: 1px; " +
- "border-bottom-right-radius: 22px;"+
- "border-color: black;" +
- "font: bold 14px;" +
- "min-width: 3em;" +
- "min-height: 2em;" +
- "image: url(" + RESOURCE_PATH + "qtg_mono_lsk_horizontal.svg);" +
- "}" +
- "QPushButton:pressed { image: url(" + RESOURCE_PATH + "qtg_mono_lsk_horizontal.svg);" +
- " border-style: inset;" +
- "}");
-
+ cssEngine.applyCSS(skleft, "QPushButton" + "{" + "background-color:white;"
+ + "border-style: outset;" + "border-width: 1px; "
+ + "border-bottom-right-radius: 22px;" + "border-color: black;"
+ + "font: bold 14px;" + "min-width: 3em;" + "min-height: 2em;" + "image: url("
+ + RESOURCE_PATH + "qtg_mono_lsk_horizontal.svg);" + "}"
+ + "QPushButton:pressed { image: url(" + RESOURCE_PATH
+ + "qtg_mono_lsk_horizontal.svg);" + " border-style: inset;" + "}");
FormData sklFormData = new FormData();
- sklFormData.top=new FormAttachment(0, 0);
- sklFormData.left=new FormAttachment(0, 0);
+ sklFormData.top = new FormAttachment(0, 0);
+ sklFormData.left = new FormAttachment(0, 0);
skleft.setLayoutData(sklFormData);
FormData skrFormData = new FormData();
- skrFormData.top=new FormAttachment(0, 0);
- skrFormData.right=new FormAttachment(100, 0);
+ skrFormData.top = new FormAttachment(0, 0);
+ skrFormData.right = new FormAttachment(100, 0);
skright.setLayoutData(skrFormData);
keypadComposite.layout();
@@ -519,10 +469,11 @@
}
else
{
- //LSK and RSK buttons are not needed, remove the buttons from navigation keypad
- if(skright != null)
+ // LSK and RSK buttons are not needed, remove the buttons from
+ // navigation keypad
+ if (skright != null)
skright.dispose();
- if(skleft != null)
+ if (skleft != null)
skleft.dispose();
keypadComposite.setBackground(null);
@@ -531,384 +482,332 @@
}
/**
- * returns the height of the canvas keypad in pixels.
- * @return Height of the canvas keypad in pixels.
- */
+ * returns the height of the canvas keypad in pixels.
+ *
+ * @return Height of the canvas keypad in pixels.
+ */
int getHeight()
{
int navKeyPadHeight = 0;
int gameKeyPadHeight = 0;
- if(keypadComposite != null)
+ if (keypadComposite != null)
{
- //calculate the navigation keypad height
+ // calculate the navigation keypad height
navKeyPadHeight = keypadComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
}
- if(gameKeysComposite != null)
+ if (gameKeysComposite != null)
{
- //calculate the game keypad height
+ // calculate the game keypad height
gameKeyPadHeight = gameKeysComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
}
- //return the total height
+ // return the total height
return (navKeyPadHeight + gameKeyPadHeight);
}
/**
- * returns the keycode corresponding to the canvas keypad button.
- * @return keycode.
- */
+ * returns the keycode corresponding to the canvas keypad button.
+ *
+ * @return keycode.
+ */
private int getKeyCode(Widget w)
{
-
int keyCode = INVALID_CODE;
// Find out which osk button was pressed
- if(w == up)
+ if (w == up)
{
keyCode = UP;
}
- else if(w == down)
+ else if (w == down)
{
keyCode = DOWN;
}
- else if(w == left)
+ else if (w == left)
{
keyCode = LEFT;
}
- else if(w == right)
+ else if (w == right)
{
keyCode = RIGHT;
}
- else if(w == center)
+ else if (w == center)
{
keyCode = FIRE;
}
- else if(w == skleft)
+ else if (w == skleft)
{
keyCode = SLK;
}
- else if(w == skright)
+ else if (w == skright)
{
keyCode = SRK;
}
- else if(w == gameA)
+ else if (w == gameA)
{
keyCode = GAME_A;
}
- else if(w == gameB)
+ else if (w == gameB)
{
keyCode = GAME_B;
}
- else if(w == gameC)
+ else if (w == gameC)
{
keyCode = GAME_C;
}
- else if(w == gameD)
+ else if (w == gameD)
{
keyCode = GAME_D;
}
else
{
- keyCode = INVALID_CODE;;
+ keyCode = INVALID_CODE;
}
return keyCode;
}
-
/**
- * Mouse listeners.
- */
-
+ * Mouse listeners.
+ */
public void mouseDown(MouseEvent e)
{
-
- //handle the mouse down event
handleMouseDown(e);
-
}
public void mouseUp(MouseEvent e)
{
-
- //handle the mouse up event
handleMouseUp(e);
-
}
public void mouseMove(MouseEvent e)
{
-
- //handle the mouse move event
handleMouseMove(e);
-
}
public void mouseDoubleClick(MouseEvent event)
{
- //do nothing
+ // Do nothing
}
-
-
-
-
/**
- * Handles the mouse down event
- *
- */
+ * Handles the mouse down event
+ * Note that e.x and e.y are relative to the widget that was pressed.
+ */
private void handleMouseDown(MouseEvent e)
{
-
- if(e.widget == keypadComposite)
+ if (e.widget == down) // highest in the z-order
{
- //the mouse down was grabbed by the keypad composite, map the key code based on the on rocker images.
keyPressed = handleRockerPressed(e);
-
}
else
{
- //get the keycode of the game or soft keys based on the button that was clicked
keyPressed = getKeyCode(e.widget);
}
- if(keyPressed != INVALID_CODE)
+ if (keyPressed != INVALID_CODE)
{
-
- //notify the canvas
canvas.doKeyPressed(keyPressed);
- // Create and Schedule the long keypress timer
timerTask = new CanvasKeypadTimerTask();
timer.schedule(timerTask, KEYREPEAT_INTERVAL);
}
}
/**
- * Handles the mouse up event
- *
- */
+ * Handles the mouse up event
+ * Note that e.x and e.y are relative to the widget that was pressed.
+ */
private void handleMouseUp(MouseEvent e)
{
int keyReleased;
- if(timerTask != null)
- {
- //cancel the long keypress timer if it is running
- timerTask.cancel();
- timerTask = null;
- }
-
- if(e.widget == keypadComposite)
- {
- //the mouse up was grabbed by the keypad composite, map the key code based on the on rocker images.
- keyReleased = handleRockerReleased(e);
-
- }
- else
+ if (timerTask != null)
{
- //get the keycode of the game or soft keys based on the button that was clicked
- keyReleased = getKeyCode(e.widget);
- }
-
- if(keyReleased != INVALID_CODE)
- {
-
- //notify the canvas
- canvas.doKeyReleased(keyReleased);
- }
- }
-
-
- /**
- * Handles the mouse move event
- *
- */
- private void handleMouseMove(MouseEvent e)
- {
-
- if(timerTask != null)
- {
- //cancel the long keypress timer if it is running
timerTask.cancel();
timerTask = null;
}
- if(e.widget == keypadComposite)
+ if (e.widget == down || e.widget == keypadComposite)
{
- //the mouse move was grabbed by the keypad composite, handle the rocker key swipe
- handleRockerMoved(e);
-
+ keyReleased = handleRockerReleased(e);
}
else
{
- //get the keycode of the game or soft keys based on the button that was clicked
- keyPressed = getKeyCode(e.widget);
+ keyReleased = getKeyCode(e.widget);
+ }
+
+ if (keyReleased != INVALID_CODE)
+ {
+ canvas.doKeyReleased(keyReleased);
+ }
+ }
- //notify the canvas
+ /**
+ * Handles the mouse move event
+ * Note that e.x and e.y are relative to the widget that was pressed.
+ */
+ private void handleMouseMove(MouseEvent e)
+ {
+ if (timerTask != null)
+ {
+ timerTask.cancel();
+ timerTask = null;
+ }
+
+ if (e.widget == down || e.widget == keypadComposite)
+ {
+ handleRockerMoved(e);
+ }
+ else
+ {
+ keyPressed = getKeyCode(e.widget);
canvas.doKeyPressed(keyPressed);
-
- // Create and Schedule Timer
timerTask = new CanvasKeypadTimerTask();
timer.schedule(timerTask, KEYREPEAT_INTERVAL);
}
-
-
}
-
/**
- * Handles the rocker key press
- *
- */
+ * Handles the rocker key press
+ */
private int handleRockerPressed(MouseEvent e)
{
-
keyPressed = INVALID_CODE;
-
- Rectangle image_bounds = center.getBounds();
-
- // Find out which rocker button was pressed
- if(image_bounds.contains(e.x,e.y) == true)
+
+ Point rockerSize = center.getSize();
+ if (e.x >= 0 && e.x <= rockerSize.x && e.y >= 0 && e.y <= rockerSize.y)
{
- //check each of the button images to check which osk navkey button was pressed
- if(center_data.getAlpha(e.x-image_offset,e.y)!=TRANSPARENT)
+ if (center_data.getAlpha(e.x, e.y) != TRANSPARENT)
{
- //center button was pressed
keyPressed = FIRE;
rockerKeyPressed = center;
center.setImage(center_pressed);
}
- else if(left_data.getAlpha(e.x-image_offset,e.y)!=TRANSPARENT)
+ else if (left_data.getAlpha(e.x, e.y) != TRANSPARENT)
{
- //left button was pressed
keyPressed = LEFT;
rockerKeyPressed = left;
left.setImage(left_pressed);
}
- else if(right_data.getAlpha(e.x-image_offset,e.y)!=TRANSPARENT)
+ else if (right_data.getAlpha(e.x, e.y) != TRANSPARENT)
{
- //right button was pressed
keyPressed = RIGHT;
rockerKeyPressed = right;
right.setImage(right_pressed);
}
- else if(up_data.getAlpha(e.x-image_offset,e.y)!=TRANSPARENT)
+ else if (up_data.getAlpha(e.x, e.y) != TRANSPARENT)
{
- //up button was pressed
keyPressed = UP;
rockerKeyPressed = up;
up.setImage(up_pressed);
}
- else if(down_data.getAlpha(e.x-image_offset,e.y)!=TRANSPARENT)
+ else if (down_data.getAlpha(e.x, e.y) != TRANSPARENT)
{
- //down button was pressed
keyPressed = DOWN;
rockerKeyPressed = down;
down.setImage(down_pressed);
}
else
{
- keyPressed = INVALID_CODE;;
+ keyPressed = INVALID_CODE;
}
-
}
return keyPressed;
-
}
-
/**
- * Handles the mouse released on the rocker keys
- *
- */
+ * Handles the mouse released on the rocker keys
+ */
private int handleRockerReleased(MouseEvent e)
{
-
int keyReleased = INVALID_CODE;
- Rectangle image_bounds = center.getBounds();
-
- // Find out which rocker button was released
- if(image_bounds.contains(e.x,e.y) == true)
+ Point rockerSize = center.getSize();
+ Point rockerLoc = center.getLocation();
+
+ if (e.widget == keypadComposite)
{
- //check each of the button images to check which osk navkey button was released
- if((rockerKeyPressed == center) &&
- (center_data.getAlpha(e.x-image_offset,e.y)!=TRANSPARENT))
+ // Drag started outside rocker
+ e.x -= rockerLoc.x;
+ e.y -= rockerLoc.y;
+ }
+
+ if (e.x >= 0 && e.x <= rockerSize.x && e.y >= 0 && e.y <= rockerSize.y)
+ {
+ if ((rockerKeyPressed == center)
+ && (center_data.getAlpha(e.x, e.y) != TRANSPARENT))
{
- //center button was released
keyReleased = FIRE;
center.setImage(center_normal);
}
- else if((rockerKeyPressed == left) &&
- (left_data.getAlpha(e.x-image_offset,e.y)!=TRANSPARENT))
+ else if ((rockerKeyPressed == left)
+ && (left_data.getAlpha(e.x, e.y) != TRANSPARENT))
{
- //left button was released
keyReleased = LEFT;
left.setImage(left_normal);
}
- else if((rockerKeyPressed == right) &&
- (right_data.getAlpha(e.x-image_offset,e.y)!=TRANSPARENT))
+ else if ((rockerKeyPressed == right)
+ && (right_data.getAlpha(e.x, e.y) != TRANSPARENT))
{
- //right button was released
keyReleased = RIGHT;
right.setImage(right_normal);
}
- else if((rockerKeyPressed == up) &&
- (up_data.getAlpha(e.x-image_offset,e.y)!=TRANSPARENT))
+ else if ((rockerKeyPressed == up)
+ && (up_data.getAlpha(e.x, e.y) != TRANSPARENT))
{
- //up button was released
keyReleased = UP;
up.setImage(up_normal);
}
- else if((rockerKeyPressed == down) &&
- (down_data.getAlpha(e.x-image_offset,e.y)!=TRANSPARENT))
+ else if ((rockerKeyPressed == down)
+ && (down_data.getAlpha(e.x, e.y) != TRANSPARENT))
{
- //down button was released
keyReleased = DOWN;
down.setImage(down_normal);
}
else
{
- keyReleased = INVALID_CODE;;
+ keyReleased = INVALID_CODE;
}
-
}
return keyReleased;
-
}
-
/**
- * Handles the mouse move on the rocker keys
- *
- */
+ * Handles the mouse move on the rocker keys
+ */
private void handleRockerMoved(MouseEvent e)
{
-
keyPressed = INVALID_CODE;
-
- Rectangle image_bounds = center.getBounds();
+ Point size = center.getSize();
+ Point rockerLoc = center.getLocation();
+
+ if (e.widget == keypadComposite)
+ {
+ // Drag started outside rocker
+ e.x -= rockerLoc.x;
+ e.y -= rockerLoc.y;
+ }
- // Find out which rocker button was traversed to
- if(image_bounds.contains(e.x,e.y) == true)
+ if (e.x >= 0 && e.x <= size.x && e.y >= 0 && e.y <= size.y)
{
- //check each of the button images to check which osk navkey button was traversed to
- if((center_data.getAlpha(e.x-image_offset,e.y)!=TRANSPARENT) &&
- (rockerKeyPressed != center))
+ if ((center_data.getAlpha(e.x, e.y) != TRANSPARENT)
+ && (rockerKeyPressed != center))
{
- //Mouse moved to center rocker key from another rocker key, release the other(source) rocker key
+ // Mouse moved to center rocker key from another rocker key,
+ // release the other(source) rocker key
releaseRockerKey(rockerKeyPressed);
}
- else if((left_data.getAlpha(e.x-image_offset,e.y)!=TRANSPARENT) &&
- (rockerKeyPressed != left))
+ else if ((left_data.getAlpha(e.x, e.y) != TRANSPARENT)
+ && (rockerKeyPressed != left))
{
- //Mouse moved to left rocker key from another rocker key, release the other(source) rocker key
+ // Mouse moved to left rocker key from another rocker key,
+ // release the other(source) rocker key
// and press the left key
releaseRockerKey(rockerKeyPressed);
keyPressed = LEFT;
@@ -917,10 +816,11 @@
canvas.doKeyPressed(keyPressed);
pressedKeyData = left_data;
}
- else if((right_data.getAlpha(e.x-image_offset,e.y)!=TRANSPARENT) &&
- (rockerKeyPressed != right))
+ else if ((right_data.getAlpha(e.x, e.y) != TRANSPARENT)
+ && (rockerKeyPressed != right))
{
- //Mouse moved to right rocker key from another rocker key, release the other(source) rocker key
+ // Mouse moved to right rocker key from another rocker key,
+ // release the other(source) rocker key
// and press the right key
releaseRockerKey(rockerKeyPressed);
keyPressed = RIGHT;
@@ -929,10 +829,11 @@
canvas.doKeyPressed(keyPressed);
pressedKeyData = right_data;
}
- else if((up_data.getAlpha(e.x-image_offset,e.y)!=TRANSPARENT) &&
- (rockerKeyPressed != up))
+ else if ((up_data.getAlpha(e.x, e.y) != TRANSPARENT)
+ && (rockerKeyPressed != up))
{
- //Mouse moved to up rocker key from another rocker key, release the other(source) rocker key
+ // Mouse moved to up rocker key from another rocker key, release
+ // the other(source) rocker key
// and press the up key
releaseRockerKey(rockerKeyPressed);
keyPressed = UP;
@@ -941,10 +842,11 @@
rockerKeyPressed = up;
pressedKeyData = up_data;
}
- else if((down_data.getAlpha(e.x-image_offset,e.y)!=TRANSPARENT) &&
- (rockerKeyPressed != down))
+ else if ((down_data.getAlpha(e.x, e.y) != TRANSPARENT)
+ && (rockerKeyPressed != down))
{
- //Mouse moved to down rocker key from another rocker key, release the other(source) rocker key
+ // Mouse moved to down rocker key from another rocker key,
+ // release the other(source) rocker key
// and press the down key
releaseRockerKey(rockerKeyPressed);
keyPressed = DOWN;
@@ -955,76 +857,65 @@
}
else
{
- if((pressedKeyData != null) &&
- (pressedKeyData.getAlpha(e.x-image_offset,e.y) == TRANSPARENT))
+ if ((pressedKeyData != null)
+ && (pressedKeyData.getAlpha(e.x, e.y) == TRANSPARENT))
{
- //Mouse moved to out of all rocker keys from another rocker key, release the other(source) rocker key
+ // Mouse moved to out of all rocker keys from another rocker
+ // key, release the other(source) rocker key
releaseRockerKey(rockerKeyPressed);
pressedKeyData = null;
rockerKeyPressed = null;
}
}
-
}
else
{
- //Mouse moved to out of all rocker keys, release the other(source) rocker key
+ // Mouse moved to out of all rocker keys, release the other(source)
+ // rocker key
releaseRockerKey(rockerKeyPressed);
}
-
-
}
-
-
/**
- * Releases a rocker key
- *
- */
+ * Releases a rocker key
+ */
private void releaseRockerKey(Label rockerKeyPressed)
{
-
- if(rockerKeyPressed == center)
+ if (rockerKeyPressed == center)
{
center.setImage(center_normal);
canvas.doKeyReleased(FIRE);
}
- else if(rockerKeyPressed == left)
+ else if (rockerKeyPressed == left)
{
left.setImage(left_normal);
canvas.doKeyReleased(LEFT);
}
- else if(rockerKeyPressed == right)
+ else if (rockerKeyPressed == right)
{
right.setImage(right_normal);
canvas.doKeyReleased(RIGHT);
}
- else if(rockerKeyPressed == up)
+ else if (rockerKeyPressed == up)
{
up.setImage(up_normal);
canvas.doKeyReleased(UP);
}
- else if(rockerKeyPressed == down)
+ else if (rockerKeyPressed == down)
{
down.setImage(down_normal);
canvas.doKeyReleased(DOWN);
}
-
}
-
-
/**
- * Canvas Keypad timer task
- *
- */
+ * Canvas Keypad timer task
+ */
class CanvasKeypadTimerTask extends TimerTask
{
-
public void run()
{
-
ESWTUIThreadRunner.syncExec(new Runnable()
{
public void run()
@@ -1032,11 +923,6 @@
canvas.doKeyPressed(keyPressed);
}
});
-
-
}
}
-
-
-
}
diff -r abc41079b313 -r 59b3b4473dc8 javauis/lcdui_qt/src/javax/microedition/lcdui/ChoiceGroup.java
--- a/javauis/lcdui_qt/src/javax/microedition/lcdui/ChoiceGroup.java Fri Jul 23 12:27:20 2010 +0300
+++ b/javauis/lcdui_qt/src/javax/microedition/lcdui/ChoiceGroup.java Thu Aug 05 16:07:57 2010 +0300
@@ -23,6 +23,18 @@
*/
public class ChoiceGroup extends Item implements Choice
{
+ /**
+ * If ChoiceGroup is changed, reasons for Re-layouting.
+ */
+ static final int UPDATE_REASON_APPEND = UPDATE_ITEM_MAX << 1;
+ static final int UPDATE_REASON_DELETE = UPDATE_ITEM_MAX << 2;
+ static final int UPDATE_REASON_DELETEALL = UPDATE_ITEM_MAX << 3;
+ static final int UPDATE_REASON_INSERT = UPDATE_ITEM_MAX << 4;
+ static final int UPDATE_REASON_SET = UPDATE_ITEM_MAX << 5;
+ static final int UPDATE_FITPOLICY = UPDATE_ITEM_MAX << 6;
+ static final int UPDATE_FONT = UPDATE_ITEM_MAX << 7;
+ static final int UPDATE_SELECTEDFLAGS = UPDATE_ITEM_MAX << 8;
+ static final int UPDATE_SELECTEDINDEX = UPDATE_ITEM_MAX << 9;
private ChoiceImpl choiceImpl;
private int type;
@@ -90,7 +102,7 @@
public int append(String text, Image img)
{
int ret = choiceImpl.append(text, img);
- updateParent(UPDATE_SIZE_CHANGED);
+ updateParent(UPDATE_REASON_APPEND);
return ret;
}
@@ -104,7 +116,7 @@
public void insert(int position, String text, Image img)
{
choiceImpl.insert(position, text, img);
- updateParent(UPDATE_SIZE_CHANGED);
+ updateParent(UPDATE_REASON_INSERT);
}
/**
@@ -117,7 +129,7 @@
public void set(int position, String text, Image img)
{
choiceImpl.set(position, text, img);
- updateParent(UPDATE_CONTENT);
+ updateParent(UPDATE_REASON_SET);
}
/**
@@ -128,7 +140,7 @@
public void delete(int position)
{
choiceImpl.delete(position);
- updateParent(UPDATE_SIZE_CHANGED);
+ updateParent(UPDATE_REASON_DELETE);
}
/**
@@ -137,7 +149,7 @@
public void deleteAll()
{
choiceImpl.deleteAll();
- updateParent(UPDATE_SIZE_CHANGED);
+ updateParent(UPDATE_REASON_DELETEALL);
}
/**
@@ -223,7 +235,7 @@
public void setFitPolicy(int newFitPolicy)
{
choiceImpl.setFitPolicy(newFitPolicy);
- updateParent(UPDATE_SIZE_CHANGED);
+ updateParent(UPDATE_FITPOLICY);
}
/**
@@ -235,7 +247,7 @@
public void setFont(int position, Font font)
{
choiceImpl.setFont(position, font);
- updateParent(UPDATE_SIZE_CHANGED);
+ updateParent(UPDATE_FONT);
}
/**
@@ -246,7 +258,7 @@
public void setSelectedFlags(boolean[] selectedArray)
{
choiceImpl.setSelectedFlags(selectedArray);
- updateParent(UPDATE_CONTENT);
+ updateParent(UPDATE_SELECTEDFLAGS);
}
/**
@@ -258,7 +270,7 @@
public void setSelectedIndex(int position, boolean select)
{
choiceImpl.setSelected(position, select);
- updateParent(UPDATE_CONTENT);
+ updateParent(UPDATE_SELECTEDINDEX);
}
/**
diff -r abc41079b313 -r 59b3b4473dc8 javauis/lcdui_qt/src/javax/microedition/lcdui/ChoiceGroupLayouter.java
--- a/javauis/lcdui_qt/src/javax/microedition/lcdui/ChoiceGroupLayouter.java Fri Jul 23 12:27:20 2010 +0300
+++ b/javauis/lcdui_qt/src/javax/microedition/lcdui/ChoiceGroupLayouter.java Thu Aug 05 16:07:57 2010 +0300
@@ -45,9 +45,9 @@
/**
* Constructor.
*/
- ChoiceGroupLayouter(DefaultFormLayoutPolicy dflp)
+ ChoiceGroupLayouter(FormLayouter aFormLayouter)
{
- super(dflp);
+ super(aFormLayouter);
}
/**
@@ -259,7 +259,7 @@
*/
boolean eswtOfferKeyPressed(Item item, int key)
{
- LayoutObject lo = dfi.getFirstLayoutObjectOfItem(item);
+ LayoutObject lo = formLayouter.getFirstLayoutObjectOfItem(item);
TableExtension tempExt;
ChoiceGroup chgr = (ChoiceGroup) item;
tempExt = (TableExtension) eswtFindSpecificControl(item,
@@ -478,7 +478,7 @@
private void update(SelectionEvent se)
{
- //int vPosition = dfi.vPosition;
+ //int vPosition = formLayouter.vPosition;
int index = ((Table) se.widget).indexOf((TableItem) se.item);
choiceGroup.internalSetSelectedIndex(index,
!choiceGroup.isSelected(index));
@@ -546,20 +546,20 @@
int topOfTable = table.getLocation().y;
if(choicegroup.hasLabel())
{
- LayoutObject lo = dfi.getFirstLayoutObjectOfItem(choicegroup);
+ LayoutObject lo = formLayouter.getFirstLayoutObjectOfItem(choicegroup);
topOfTable += lo.getY();
}
int topYOfSelectedItem = topOfTable + (focusedIndex * itemHeight);
if(te.keyCode == SWT.ARROW_DOWN)
{
topYOfSelectedItem += itemHeight;
- dfi.eswtScrollIfNeeded(topYOfSelectedItem,
+ formLayouter.eswtScrollIfNeeded(topYOfSelectedItem,
topYOfSelectedItem + itemHeight);
}
else if(te.keyCode == SWT.ARROW_UP)
{
topYOfSelectedItem -= itemHeight;
- dfi.eswtScrollIfNeeded(topYOfSelectedItem,
+ formLayouter.eswtScrollIfNeeded(topYOfSelectedItem,
topYOfSelectedItem + itemHeight);
}
}
@@ -582,7 +582,7 @@
public void focusGained(FocusEvent focusEvent)
{
TableExtension te = (TableExtension) focusEvent.widget;
- int direction = dfi.getDirection();
+ int direction = formLayouter.getDirection();
if(choicegroup.getType() != ChoiceGroup.POPUP)
{
if(direction == -1)
@@ -608,7 +608,7 @@
int topOfTable = te.getLocation().y;
if(choicegroup.hasLabel())
{
- LayoutObject lo = dfi.getFirstLayoutObjectOfItem(choicegroup);
+ LayoutObject lo = formLayouter.getFirstLayoutObjectOfItem(choicegroup);
topOfTable += lo.getY();
}
@@ -616,13 +616,13 @@
if(direction == SWT.ARROW_DOWN || direction == SWT.ARROW_RIGHT)
{
topYOfSelectedItem += itemHeight;
- dfi.eswtScrollIfNeeded(topYOfSelectedItem,
+ formLayouter.eswtScrollIfNeeded(topYOfSelectedItem,
topYOfSelectedItem + itemHeight);
}
else if(direction == SWT.ARROW_UP || direction == SWT.ARROW_LEFT)
{
topYOfSelectedItem -= itemHeight;
- dfi.eswtScrollIfNeeded(topYOfSelectedItem,
+ formLayouter.eswtScrollIfNeeded(topYOfSelectedItem,
topYOfSelectedItem + itemHeight);
}
}
diff -r abc41079b313 -r 59b3b4473dc8 javauis/lcdui_qt/src/javax/microedition/lcdui/Command.java
--- a/javauis/lcdui_qt/src/javax/microedition/lcdui/Command.java Fri Jul 23 12:27:20 2010 +0300
+++ b/javauis/lcdui_qt/src/javax/microedition/lcdui/Command.java Thu Aug 05 16:07:57 2010 +0300
@@ -132,11 +132,7 @@
this.shortLabel = shortLabel;
this.longLabel = longLabel;
this.priority = priority;
-
- if(EMPTY_STRING.equals(this.shortLabel))
- {
- this.shortLabel = getDefaultLabel(this.type);
- }
+
}
/**
diff -r abc41079b313 -r 59b3b4473dc8 javauis/lcdui_qt/src/javax/microedition/lcdui/CustomItem.java
--- a/javauis/lcdui_qt/src/javax/microedition/lcdui/CustomItem.java Fri Jul 23 12:27:20 2010 +0300
+++ b/javauis/lcdui_qt/src/javax/microedition/lcdui/CustomItem.java Thu Aug 05 16:07:57 2010 +0300
@@ -20,16 +20,13 @@
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.internal.extension.CanvasExtension;
import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Scrollable;
/**
* Implementation of LCDUI abstract CustomItem class.
*/
public abstract class CustomItem extends Item
{
-
protected static final int NONE = 0;
protected static final int TRAVERSE_HORIZONTAL = 1;
protected static final int TRAVERSE_VERTICAL = 2;
@@ -43,9 +40,10 @@
protected static final int POINTER_DRAG = 0x80;
/**
- * Constant used by layouter to repaint CustomItem's rectangle section.
+ * If CustomItem is changed, reasons for Re-layouting.
*/
- static final int UPDATE_REPAINT_RECT = 4;
+ static final int UPDATE_REASON_REPAINT = UPDATE_ITEM_MAX << 1;
+
private boolean cleanupNeeded;
private int contentWidth;
@@ -68,7 +66,7 @@
// Graphics command buffer for this instance
Buffer graphicsBuffer;
- Graphics CustomItemGraphics;
+ Graphics customItemGraphics;
CustomItemLayouter layouter;
@@ -154,7 +152,7 @@
{
Rectangle rect = new Rectangle(aX, aY, aWidth, aHeight);
// From here it goes to updateItem()
- updateParent(UPDATE_REPAINT_RECT, rect);
+ updateParent(UPDATE_REASON_REPAINT, rect);
}
/**
@@ -308,7 +306,7 @@
contentHeight = newHeight;
}
EventDispatcher eventDispatcher = EventDispatcher.instance();
- LCDUIEvent event = eventDispatcher.newEvent(LCDUIEvent.CUSTOMITEM_SIZECHANGED, layouter.dfi.getForm());
+ LCDUIEvent event = eventDispatcher.newEvent(LCDUIEvent.CUSTOMITEM_SIZECHANGED, layouter.formLayouter.getForm());
event.item = this;
eventDispatcher.postEvent(event);
synchronized(cleanupLock)
@@ -356,7 +354,7 @@
else
{
// Item was added to a Form
- layouter = ((CustomItemLayouter)((Form)parent).getLayoutPolicy().getLayouter(this));
+ layouter = ((CustomItemLayouter)((Form)parent).getFormLayouter().getItemLayouter(this));
}
}
@@ -432,7 +430,7 @@
{
EventDispatcher eventDispatcher = EventDispatcher.instance();
LCDUIEvent event = eventDispatcher.newEvent(
- LCDUIEvent.CUSTOMITEM_PAINT_MIDLET_REQUEST, layouter.dfi.getForm());
+ LCDUIEvent.CUSTOMITEM_PAINT_MIDLET_REQUEST, layouter.formLayouter.getForm());
event.widget = control;
event.item = this;
eventDispatcher.postEvent(event);
@@ -550,11 +548,11 @@
widgetDisposed = true;
return;
}
- if(CustomItemGraphics == null)
+ if(customItemGraphics == null)
{
graphicsBuffer = Buffer.createInstance(self, (Control)event.widget);
- CustomItemGraphics = graphicsBuffer.getGraphics();
- CustomItemGraphics.setSyncStrategy(Graphics.SYNC_LEAVE_SURFACE_SESSION_OPEN);
+ customItemGraphics = graphicsBuffer.getGraphics();
+ customItemGraphics.setSyncStrategy(Graphics.SYNC_LEAVE_SURFACE_SESSION_OPEN);
}
else
{
@@ -583,17 +581,18 @@
contentHeight = this.contentHeight;
}
- CustomItemGraphics.setClip(0, 0, contentWidth, contentHeight);
- CustomItemGraphics.cleanBackground(new Rectangle(0, 0, contentWidth, contentHeight));
+ customItemGraphics.setClip(0, 0, contentWidth, contentHeight);
+ customItemGraphics.cleanBackground(new Rectangle(0, 0, contentWidth, contentHeight));
cleanupNeeded = false;
}
}
// Clip must define the invalid area
- CustomItemGraphics.setClip(redrawNowX, redrawNowY, redrawNowW, redrawNowH);
+ customItemGraphics.reset();
+ customItemGraphics.setClip(redrawNowX, redrawNowY, redrawNowW, redrawNowH);
// The callback
- paint(CustomItemGraphics, contentWidth, contentHeight);
+ paint(customItemGraphics, contentWidth, contentHeight);
// Wait until the UI thread is available. Then in the UI thread
// synchronously send a paint event.
diff -r abc41079b313 -r 59b3b4473dc8 javauis/lcdui_qt/src/javax/microedition/lcdui/CustomItemBufferLinux.java
--- a/javauis/lcdui_qt/src/javax/microedition/lcdui/CustomItemBufferLinux.java Fri Jul 23 12:27:20 2010 +0300
+++ b/javauis/lcdui_qt/src/javax/microedition/lcdui/CustomItemBufferLinux.java Thu Aug 05 16:07:57 2010 +0300
@@ -43,7 +43,7 @@
protected void init()
{
super.init();
- surface = Internal_PackageSupport.getWindowsurface(host.layouter.dfi.getForm().getContentComp().getShell());
+ surface = Internal_PackageSupport.getWindowsurface(host.layouter.formLayouter.getForm().getContentComp().getShell());
}
void bindToHost(GraphicsContext gc) {
diff -r abc41079b313 -r 59b3b4473dc8 javauis/lcdui_qt/src/javax/microedition/lcdui/CustomItemBufferSymbian.java
--- a/javauis/lcdui_qt/src/javax/microedition/lcdui/CustomItemBufferSymbian.java Fri Jul 23 12:27:20 2010 +0300
+++ b/javauis/lcdui_qt/src/javax/microedition/lcdui/CustomItemBufferSymbian.java Thu Aug 05 16:07:57 2010 +0300
@@ -39,7 +39,7 @@
protected void init()
{
super.init();
- surface = Internal_PackageSupport.getWindowsurface(host.layouter.dfi.getForm().getContentComp().getShell());
+ surface = Internal_PackageSupport.getWindowsurface(host.layouter.formLayouter.getForm().getContentComp().getShell());
}
int getHostType()
diff -r abc41079b313 -r 59b3b4473dc8 javauis/lcdui_qt/src/javax/microedition/lcdui/CustomItemLayouter.java
--- a/javauis/lcdui_qt/src/javax/microedition/lcdui/CustomItemLayouter.java Fri Jul 23 12:27:20 2010 +0300
+++ b/javauis/lcdui_qt/src/javax/microedition/lcdui/CustomItemLayouter.java Thu Aug 05 16:07:57 2010 +0300
@@ -64,11 +64,11 @@
/**
* Constructor.
*
- * @param dflp DefaultFormLayoutPolicy used for layouting.
+ * @param aFormLayouter FormLayouter used for layouting.
*/
- public CustomItemLayouter(DefaultFormLayoutPolicy dflp)
+ public CustomItemLayouter(FormLayouter aFormLayouter)
{
- super(dflp);
+ super(aFormLayouter);
noBackground = JadAttributeUtil.isValue(JadAttributeUtil.ATTRIB_NOKIA_UI_ENHANCEMENT,
JadAttributeUtil.VALUE_CANVAS_HAS_BACKGROUND);
@@ -205,7 +205,7 @@
*/
void eswtUpdateItem(Item item, Control control, int reason, Object param)
{
- if(reason == CustomItem.UPDATE_REPAINT_RECT)
+ if(reason == CustomItem.UPDATE_REASON_REPAINT)
{
Rectangle rect = (Rectangle) param;
((CustomItem)item).updateItem(rect, control);
@@ -267,7 +267,7 @@
if(!((selectionKeyCompatibility == true) && (key == -5)))
{
EventDispatcher eventDispatcher = EventDispatcher.instance();
- LCDUIEvent e = eventDispatcher.newEvent(LCDUIEvent.CUSTOMITEM_KEYPRESSED, dfi.getForm());
+ LCDUIEvent e = eventDispatcher.newEvent(LCDUIEvent.CUSTOMITEM_KEYPRESSED, formLayouter.getForm());
e.item = customItem;
e.keyCode = key;
eventDispatcher.postEvent(e);
@@ -282,13 +282,13 @@
int[] visRect = getVisRect(ctrl);
// Offer event for inner traversal
consumed = customItem.traverse(direction,
- dfi.getFormWidth(), dfi.getFormHeight(), visRect);
+ formLayouter.getFormWidth(), formLayouter.getFormHeight(), visRect);
if(consumed)
{
// if inner focus is on - scroll to inner focus
Point loc = new Point(0, 0);
- dfi.getControlPositionOnComposite(ctrl, loc);
- dfi.eswtScrolltoRegion(loc.y + visRect[1],
+ formLayouter.getControlPositionOnComposite(ctrl, loc);
+ formLayouter.eswtScrolltoRegion(loc.y + visRect[1],
loc.y + visRect[1] + visRect[3], key);
}
control.redraw();
@@ -306,7 +306,7 @@
if(!((selectionKeyCompatibility == true) && (key == -5)))
{
EventDispatcher eventDispatcher = EventDispatcher.instance();
- LCDUIEvent e = eventDispatcher.newEvent(LCDUIEvent.CUSTOMITEM_KEYRELEASED, dfi.getForm());
+ LCDUIEvent e = eventDispatcher.newEvent(LCDUIEvent.CUSTOMITEM_KEYRELEASED, formLayouter.getForm());
e.item = customItem;
e.keyCode = key;
eventDispatcher.postEvent(e);
@@ -332,12 +332,12 @@
Control ctrl = eswtFindSpecificControl(item, control);
int[] visRect = getVisRect(ctrl);
if(customItem.traverse(getCanvasDirection(swtDir),
- dfi.getFormWidth(), dfi.getFormHeight(), visRect))
+ formLayouter.getFormWidth(), formLayouter.getFormHeight(), visRect))
{
// if inner focus is on - scroll to inner focus
Point loc = new Point(0, 0);
- dfi.getControlPositionOnComposite(ctrl, loc);
- dfi.eswtScrolltoRegion(loc.y + visRect[1],
+ formLayouter.getControlPositionOnComposite(ctrl, loc);
+ formLayouter.eswtScrolltoRegion(loc.y + visRect[1],
loc.y + visRect[1] + visRect[3], swtDir);
}
control.redraw();
@@ -360,7 +360,7 @@
void eswtHandleShow(Item item)
{
EventDispatcher eventDispatcher = EventDispatcher.instance();
- LCDUIEvent event = eventDispatcher.newEvent(LCDUIEvent.CUSTOMITEM_SHOWNOTIFY, dfi.getForm());
+ LCDUIEvent event = eventDispatcher.newEvent(LCDUIEvent.CUSTOMITEM_SHOWNOTIFY, formLayouter.getForm());
event.item = item;
eventDispatcher.postEvent(event);
CustomItem customItem = (CustomItem) item;
@@ -373,7 +373,7 @@
void eswtHandleHide(Item item)
{
EventDispatcher eventDispatcher = EventDispatcher.instance();
- LCDUIEvent event = eventDispatcher.newEvent(LCDUIEvent.CUSTOMITEM_HIDENOTIFY, dfi.getForm());
+ LCDUIEvent event = eventDispatcher.newEvent(LCDUIEvent.CUSTOMITEM_HIDENOTIFY, formLayouter.getForm());
event.item = item;
eventDispatcher.postEvent(event);
}
@@ -445,7 +445,7 @@
// the paint callback has been executed.
EventDispatcher eventDispatcher = EventDispatcher.instance();
LCDUIEvent event = eventDispatcher.newEvent(
- LCDUIEvent.CUSTOMITEM_PAINT_NATIVE_REQUEST, dfi.getForm());
+ LCDUIEvent.CUSTOMITEM_PAINT_NATIVE_REQUEST, formLayouter.getForm());
event.x = pe.x;
event.y = pe.y;
event.width = pe.width;
@@ -473,7 +473,7 @@
public void mouseDown(MouseEvent event)
{
EventDispatcher eventDispatcher = EventDispatcher.instance();
- LCDUIEvent e = eventDispatcher.newEvent(LCDUIEvent.CUSTOMITEM_POINTERPRESSED, dfi.getForm());
+ LCDUIEvent e = eventDispatcher.newEvent(LCDUIEvent.CUSTOMITEM_POINTERPRESSED, formLayouter.getForm());
e.item = customItem;
e.x = event.x;
e.y = event.y;
@@ -513,7 +513,7 @@
}
}
EventDispatcher eventDispatcher = EventDispatcher.instance();
- LCDUIEvent e = eventDispatcher.newEvent(LCDUIEvent.CUSTOMITEM_POINTERRELEASED, dfi.getForm());
+ LCDUIEvent e = eventDispatcher.newEvent(LCDUIEvent.CUSTOMITEM_POINTERRELEASED, formLayouter.getForm());
e.item = customItem;
e.x = pointerUpX;
e.y = pointerUpY;
@@ -526,7 +526,7 @@
if(disableTapDetection || (!suppressDragEvent) || !checkWithinRect(event.x, event.y))
{
EventDispatcher eventDispatcher = EventDispatcher.instance();
- LCDUIEvent e = eventDispatcher.newEvent(LCDUIEvent.CUSTOMITEM_POINTERDRAGGED, dfi.getForm());
+ LCDUIEvent e = eventDispatcher.newEvent(LCDUIEvent.CUSTOMITEM_POINTERDRAGGED, formLayouter.getForm());
e.item = customItem;
e.x = event.x;
e.y = event.y;
diff -r abc41079b313 -r 59b3b4473dc8 javauis/lcdui_qt/src/javax/microedition/lcdui/DateField.java
--- a/javauis/lcdui_qt/src/javax/microedition/lcdui/DateField.java Fri Jul 23 12:27:20 2010 +0300
+++ b/javauis/lcdui_qt/src/javax/microedition/lcdui/DateField.java Thu Aug 05 16:07:57 2010 +0300
@@ -25,7 +25,6 @@
*/
public class DateField extends Item
{
-
/**
* Input mode that displays only date.
*/
@@ -41,6 +40,13 @@
*/
public static final int DATE_TIME = 3;
+ /**
+ * If DateField is changed, reasons for Re-layouting.
+ */
+ static final int UPDATE_DATE = UPDATE_ITEM_MAX << 1;
+ static final int UPDATE_INPUTMODE = UPDATE_ITEM_MAX << 2;
+
+
private Date date;
private int mode;
@@ -102,7 +108,7 @@
calendar.set(Calendar.SECOND,0);
calendar.set(Calendar.MILLISECOND,0);
}
- return calendar.getTime();//date;
+ return calendar.getTime();
}
/**
@@ -113,7 +119,7 @@
public void setDate(Date newDate)
{
internalSetDate(newDate);
- updateParent(UPDATE_CONTENT);
+ updateParent((newDate == null ? UPDATE_DATE | UPDATE_SIZE_CHANGED : UPDATE_DATE));
}
/**
@@ -143,8 +149,12 @@
throw new IllegalArgumentException(
MsgRepository.DATEFIELD_EXCEPTION_INVALID_MODE);
}
- mode = inputMode;
- updateParent(UPDATE_SIZE_CHANGED);
+
+ if(getInputMode() != inputMode)
+ {
+ mode = inputMode;
+ updateParent(UPDATE_INPUTMODE | UPDATE_SIZE_CHANGED);
+ }
}
/**
@@ -208,12 +218,16 @@
}
else
{
+ calendar.set(Calendar.SECOND,0);
+ calendar.set(Calendar.MILLISECOND,0);
date = calendar.getTime();
}
break;
case DATE:
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
+ calendar.set(Calendar.SECOND,0);
+ calendar.set(Calendar.MILLISECOND,0);
date = calendar.getTime();
break;
case DATE_TIME:
diff -r abc41079b313 -r 59b3b4473dc8 javauis/lcdui_qt/src/javax/microedition/lcdui/DateFieldLayouter.java
--- a/javauis/lcdui_qt/src/javax/microedition/lcdui/DateFieldLayouter.java Fri Jul 23 12:27:20 2010 +0300
+++ b/javauis/lcdui_qt/src/javax/microedition/lcdui/DateFieldLayouter.java Thu Aug 05 16:07:57 2010 +0300
@@ -16,15 +16,18 @@
*/
package javax.microedition.lcdui;
+import java.util.Date;
import java.util.Calendar;
-import org.eclipse.ercp.swt.mobile.DateEditor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
+import org.eclipse.ercp.swt.mobile.DateEditor;
+import org.eclipse.ercp.swt.mobile.CaptionedControl;
+
/**
* Super class for all DateField Layouters. Contains their common
@@ -36,41 +39,38 @@
/**
* Key name for modify listener.
*/
- private static final String MODIFY_LISTENER = "modify";
-
- private static DateEditor staticDate;
+ private static final String MODIFY_LISTENER = "ModifyListener";
/**
* Constructor.
*
- * @param dflp DefaultFormLayoutPolicy used for layouting.
+ * @param aFormLayouter FormLayouter used for layouting.
*/
- DateFieldLayouter(DefaultFormLayoutPolicy dflp)
+ DateFieldLayouter(FormLayouter aFormLayouter)
{
- super(dflp);
+ super(aFormLayouter);
}
/**
- * Get static eSWT DateEditor widget for size calculations.
+ * Creates the eSWT Control for this item.
+ *
+ * @param parent where to create.
+ * @param item DateField Item.
+ * @return Control.
*/
- static DateEditor eswtGetStaticDate()
+ Control eswtGetControl(Composite parent, Item item)
{
- if(staticDate == null)
- {
- staticDate = new DateEditor(eswtGetStaticShell(), SWT.NONE,
- DateEditor.DATE_TIME | DateEditor.COMPACT);
- }
- return staticDate;
+ return eswtCreateControl(parent, item);
}
/**
- * Creates the eSWT control.
+ * Creates the eSWT Control for this item.
*
* @param parent where to create.
- * @param item on which it is based. Must be DateField.
+ * @param item DateField Item.
* @return Control.
*/
- Control eswtGetControl(Composite parent, Item item)
+ static Control eswtCreateControl(Composite parent, Item item)
{
DateField dateField = (DateField) item;
DateEditor dateEditor = null;
@@ -101,7 +101,8 @@
{
dateEditor.setDate(dateField.getDate());
}
- return dateEditor;
+ parent.pack();
+ return parent;
}
/**
@@ -109,12 +110,16 @@
*/
void eswtAddSpecificListeners(Item item, Control control)
{
- super.eswtAddSpecificListeners(item, control);
- DateField dateField = (DateField) item;
- DateEditor de = (DateEditor) control;
- ModifyListener listener = new DateEditorModifyListener(dateField);
- de.addModifyListener(listener);
- de.setData(MODIFY_LISTENER, listener);
+ DateEditor dateEditor = (DateEditor) control;
+ ModifyListener listener = (ModifyListener)dateEditor.getData(MODIFY_LISTENER);
+ if(listener == null)
+ {
+ super.eswtAddSpecificListeners(item, control);
+ DateField dateField = (DateField) item;
+ listener = new DateEditorModifyListener(dateField);
+ dateEditor.addModifyListener(listener);
+ dateEditor.setData(MODIFY_LISTENER, listener);
+ }
}
/**
@@ -122,13 +127,13 @@
*/
void eswtRemoveSpecificListeners(Item item, Control control)
{
- super.eswtRemoveSpecificListeners(item, control);
- DateEditor de = (DateEditor) control;
- ModifyListener listener = (ModifyListener) de.getData(MODIFY_LISTENER);
+ DateEditor dateEditor = (DateEditor) control;
+ ModifyListener listener = (ModifyListener)dateEditor.getData(MODIFY_LISTENER);
if(listener != null)
{
- de.removeModifyListener(listener);
- de.setData(MODIFY_LISTENER, null);
+ super.eswtRemoveSpecificListeners(item, control);
+ dateEditor.removeModifyListener(listener);
+ dateEditor.setData(MODIFY_LISTENER, null);
}
}
@@ -143,20 +148,80 @@
/**
* Updates the values of DateField.
*/
- void eswtUpdateItem(Item item, Control control, int reason, Object param)
+ void eswtUpdateItem(Item item, Control control, int aReason, Object param)
{
- DateField dateField = (DateField) item;
- DateEditor dateEditor = (DateEditor) control;
+ if(!(control instanceof CaptionedControl))
+ {
+ return;
+ }
+
+ DateField dateField = (DateField)item;
+ int reason = aReason & Item.UPDATE_SIZE_MASK;
+
+ switch(reason)
+ {
+ case Item.UPDATE_NONE:
+ break;
+
+ case Item.UPDATE_LABEL:
+ {
+ String label = dateField.getLabel();
+ if(label == null)
+ {
+ label = "";
+ }
+
+ ((CaptionedControl)control).setText(label);
+ control.pack();
+ break;
+ }
+
+ case DateField.UPDATE_DATE:
+ {
+ Control ctrl = eswtFindSpecificControl(dateField, control);
+
+ if(ctrl instanceof DateEditor)
+ {
+ DateEditor dateEditor = (DateEditor)ctrl;
+ Date date = dateField.getDate();
- if(dateField.getDate() != null)
- {
- dateEditor.setDate(dateField.getDate());
- }
+ if(date != null)
+ {
+ if(dateField.getTimeZone() != null)
+ {
+ dateEditor.setTimeZone(dateField.getTimeZone());
+ }
+ dateEditor.setDate(date);
+ }
+ else
+ {
+ //It is expected that on dispose of DateEditor it will remove ModifyListener.
+ dateEditor.dispose();
+ eswtGetControl((CaptionedControl)control, item);
+ }
+ }
+ break;
+ }
- if(dateField.getTimeZone() != null)
- {
- dateEditor.setTimeZone(dateField.getTimeZone());
- }
+ case DateField.UPDATE_INPUTMODE:
+ {
+ Control ctrl = eswtFindSpecificControl(dateField, control);
+
+ if(ctrl instanceof DateEditor)
+ {
+ DateEditor dateEditor = (DateEditor)ctrl;
+ //It is expected that on dispose of DateEditor it will remove ModifyListener.
+ dateEditor.dispose();
+ eswtGetControl((CaptionedControl)control, item);
+ }
+ break;
+ }
+
+ default:
+ {
+ break;
+ }
+ }
}
/**
@@ -169,7 +234,7 @@
{
if(key == SWT.ARROW_LEFT || key == SWT.ARROW_RIGHT)
{
- return true;
+ //return true;
}
return false;
}
@@ -182,18 +247,25 @@
*/
static Point calculateMinimumBounds(final DateField datefield)
{
- final Point minSize = new Point(0, 0);
+ final Point minSize = new Point(0, 0);
ESWTUIThreadRunner.syncExec(new Runnable()
{
public void run()
{
- DateEditor tempEditor = eswtGetStaticDate();
- minSize.x = getMaximumItemWidth(datefield);
- minSize.y = tempEditor.computeSize(minSize.x, SWT.DEFAULT).y;
- applyMinMargins(datefield, minSize);
+ CaptionedControl captioned = new CaptionedControl(eswtGetStaticShell(), SWT.VERTICAL);
+ if(datefield.hasLabel())
+ {
+ captioned.setText(MIN_TEXT);
+ }
+ eswtCreateControl(captioned, datefield);
+ int maxWidth = getMaximumItemWidth(datefield);
+ Point size = captioned.computeSize(maxWidth, SWT.DEFAULT);
+ captioned.dispose();
+ minSize.x = size.x;
+ minSize.y = size.y;
}
});
- return minSize;
+ return minSize;
}
/**
@@ -203,22 +275,27 @@
* @return Preferred area needed to display Item. x is width and y is
* height.
*/
- static Point calculatePreferredBounds(Item item)
+ static Point calculatePreferredBounds(final DateField datefield)
{
- final Point prefSize = new Point(0, 0);
- final DateField datefield = (DateField) item;
+ final Point prefSize = new Point(0, 0);
ESWTUIThreadRunner.syncExec(new Runnable()
{
public void run()
{
- DateEditor tempEditor = eswtGetStaticDate();
- prefSize.x = getMaximumItemWidth(datefield);
- prefSize.y = tempEditor.computeSize(prefSize.x, SWT.DEFAULT).y;
- applyPrefMargins(datefield, prefSize);
+ CaptionedControl captioned = new CaptionedControl(eswtGetStaticShell(), SWT.VERTICAL);
+ if(datefield.hasLabel())
+ {
+ captioned.setText(datefield.getLabel());
+ }
+ eswtCreateControl(captioned, datefield);
+ int maxWidth = getMaximumItemWidth(datefield);
+ Point size = captioned.computeSize(maxWidth, SWT.DEFAULT);
+ captioned.dispose();
+ prefSize.x = size.x;
+ prefSize.y = size.y;
}
});
- return prefSize;
- // return calculateMinimumBounds((DateField) item);
+ return prefSize;
}
/**
@@ -226,30 +303,29 @@
*/
class DateEditorModifyListener implements ModifyListener
{
-
private DateField dateField;
/**
- * Constructor.
- * @param dateField DateField to be updated.
- */
+ * Constructor.
+ * @param dateField DateField to be updated.
+ */
public DateEditorModifyListener(DateField dateField)
{
this.dateField = dateField;
}
/**
- * Called by eSWT when DateEditor's value is modified.
- *
- * @param e Event.
- */
+ * Called by eSWT when DateEditor's value is modified.
+ *
+ * @param e Event.
+ */
public void modifyText(ModifyEvent e)
{
// Actions needed only if value is adjusted. Compare values
// depending of dateField's type and exit if values are same.
if(!isEqualDate(dateField, (DateEditor) e.getSource()))
{
- Logger.method(dateField, "modify", e);
+ Logger.method(dateField, MODIFY_LISTENER, e);
dateField.internalSetDate(((DateEditor) e.getSource()).getDate());
// notify item state listener
dateField.notifyStateChanged();
diff -r abc41079b313 -r 59b3b4473dc8 javauis/lcdui_qt/src/javax/microedition/lcdui/DefaultFormInteraction.java
--- a/javauis/lcdui_qt/src/javax/microedition/lcdui/DefaultFormInteraction.java Fri Jul 23 12:27:20 2010 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,652 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:
-*
-*/
-package javax.microedition.lcdui;
-
-import java.util.Timer;
-import java.util.TimerTask;
-
-import org.eclipse.swt.SWT;
-
-/**
- * Responsible for implementing interaction in DefaultFormLayoutPolicy.
- */
-class DefaultFormInteraction extends DefaultFormLayoutPolicy
-{
-
- private static final int NO_DIRECTION = -1;
-
- private Item currentSelectedItem;
-
- private int direction = NO_DIRECTION;
-
- private boolean mousePressed;
-
- private LayoutObject currentlyUnderMouse;
-
- /**
- * Constructor.
- *
- * @param form where DFLP is applied.
- */
- DefaultFormInteraction(Form form)
- {
- super(form);
- }
-
- final void handleShowCurrentEvent()
- {
- super.handleShowCurrentEvent();
- eswtApplyCurrentFocus();
- }
-
- final void handleHideCurrentEvent()
- {
- super.handleHideCurrentEvent();
- direction = NO_DIRECTION;
- }
-
- /* (non-Javadoc)
- * @see DefaultFormLayoutPolicy#eswtLayoutForm(int)
- */
- final void eswtLayoutForm(int startIndex)
- {
- super.eswtLayoutForm(startIndex);
-
- // clear invalid selected item
- eswtCheckCurrentSelectedItem();
-
- if(currentSelectedItem != null
- && (currentSelectedItem.isFocusable()))
- {
- eswtApplyCurrentFocus();
- }
- else
- {
- // If there's no item currently selected try to find first
- // focusable item and set it current (if found):
- Item found = eswtGetNextFocusableItem(
- getItem(startIndex - 1), SWT.ARROW_RIGHT);
- if(found != null)
- {
- eswtSetCurrentSelectedItem(found, NO_DIRECTION);
- }
- else
- {
- eswtApplyCurrentFocus();
- }
- }
- }
-
- /* (non-Javadoc)
- * @see DefaultFormLayoutPolicy#eswtSetCurrentItem(Item)
- */
- boolean eswtSetCurrentItem(Item item)
- {
- boolean ret = super.eswtSetCurrentItem(item);
- if(ret && item != null && item.isFocusable())
- {
- eswtSetCurrentSelectedItem(item, NO_DIRECTION);
- Logger.info("eswtSetCurrentItem" + item);
- }
- return ret;
- }
-
- /**
- * DefaultFormInteraction handler for key events.
- * The DefaultFormInteraction is responsible to react to key presses
- * accordingly. The implementation moves focus and/or scrolls the form when
- * needed. The method is called by the Form.
- *
- * @param keyCode eSWT key code.
- * @param keyType eSWT key type.
- */
- final void handleKeyEvent(int keyCode, int keyType)
- {
- Logger.method(this, "handleKeyEvent", currentSelectedItem,
- String.valueOf(keyCode), String.valueOf(keyType));
-
- boolean isDirectionalKey = isDirectionKey(keyCode);
- if(keyType == SWT.KeyDown && isDirectionalKey)
- {
- eswtCheckCurrentSelectedItem();
- }
-
- if(currentSelectedItem != null)
- {
- if(getLayouter(currentSelectedItem).eswtOfferKeyEvent(
- currentSelectedItem, keyCode, keyType))
- {
- // if the key has been consumed
- return;
- }
- }
-
- // scrolling/focus traverse only happens on directional key's down event
- if(keyType == SWT.KeyDown && isDirectionalKey)
- {
- // try to find next focusable item
- Item next = eswtGetNextFocusableItem(currentSelectedItem, keyCode);
-
- // if no visible & focusable item was found to transfer focus
- if(next == currentSelectedItem)
- {
- // try to scroll a bit
- eswtSetScrollingPosition(getNextScrollingPosition(keyCode),
- true);
- // find next focusable after scrolling
- next = eswtGetNextFocusableItem(currentSelectedItem, keyCode);
- }
-
- if(next != currentSelectedItem)
- {
- //textfield always have to be fully visible when focused.
- if(next instanceof TextField)
- {
- eswtScrollToItem(next);
- }
- eswtSetCurrentSelectedItem(next, keyCode);
- }
- }
- }
-
- /**
- * Returns if the parameter is a eSWT directional key code.
- *
- * @param keyCode key code
- */
- private boolean isDirectionKey(int keyCode)
- {
- return (keyCode == SWT.ARROW_DOWN || keyCode == SWT.ARROW_UP
- || keyCode == SWT.ARROW_LEFT || keyCode == SWT.ARROW_RIGHT);
- }
-
- /**
- * DefaultFormInteraction handler for pointer events.
- * The method is called by the Form.
- *
- * @param x coordinate relative to scrolledComposite
- * @param y coordinate relative to scrolledComposite
- * @param type event type: SWT.MouseDown, SWT.MouseMove, SWT.MouseUp
- */
- final void handlePointerEvent(int x, int y, int type)
- {
- Logger.method(this, "handlePointerEvent", String.valueOf(x),
- String.valueOf(y), String.valueOf(type));
-
- // TODO: change when DirectUI style arrives.
- /*
- Item item;
- if (type == SWT.MouseMove) {
- if (currentlyUnderMouse == null
- || !currentlyUnderMouse.contains(x, y)) {
- if (currentlyUnderMouse != null) {
- //currentlyUnderMouse.getControl().setCapture(false);
- }
- item = eswtFindItemUnderMouse(x, y);
- if (item != null && item != currentSelectedItem
- && item.isFocusable()) {
- setCurrentItem(item);
- item.internalSetFocused(true);
- eswtSetCurrentSelectedItem(item);
- //following method causes all mouse events delivered to it
-
- currentlyUnderMouse.getControl().setCapture(true);
- Logger.warning("seting capture to:" + item);
- }
- }
- int currentVPosition = getVPosition();
- boolean isMouseDirectionUp = false;
- boolean doScrolling = false;
- int localY = y;
-
- if (y <= currentVPosition) {
- localY = Math.max(0, y);
- eswtSetScrollingPosition(localY, true);
- isMouseDirectionUp = true;
- doScrolling = true;
- }
- else if (y > (currentVPosition + getFormHeight())) {
- //check for maxVPosition
- if (y > (eswtGetMaxVPosition() + getFormHeight())) {
- localY = eswtGetMaxVPosition() + getFormHeight();
- }
- else {
- localY = y;
- }
- currentVPosition = localY - getFormHeight();
- eswtSetScrollingPosition(currentVPosition, true);
-
- isMouseDirectionUp = false;
- doScrolling = true;
- }
- if (mousePressed && doScrolling) {
- resetEventTimer(isMouseDirectionUp, localY);
- }
- }
- else
- if (type == SWT.MouseDown) {
- mousePressed = true;
- item = eswtFindItemUnderMouse(x, y);
- if (item != null && item != currentSelectedItem
- && item.isFocusable() && getForm().getShell() ==
- getForm().getShell().getDisplay().getActiveShell()) {
- //eswtScrollToItem(item);
- //following method causes all mouse events delivered to it
-
- //currentlyUnderMouse.getControl().setCapture(true);
- }
- }
- else if (type == SWT.MouseUp) {
- mousePressed = false;
- if (currentlyUnderMouse != null) {
- //currentlyUnderMouse.getControl().setCapture(false);
- }
- }*/
- }
-
- /**
- * Find item at the specified point.
- *
- * @param x coordinate.
- * @param y coordinate.
- * @return Item.
- */
- Item eswtFindItemUnderMouse(int x, int y)
- {
- Row itemRow;
- for(int i = 0; i < getRowCount(); i++)
- {
- itemRow = getRow(i);
- if(itemRow.getYShift() <= y && y <= itemRow.getBottomPosition())
- {
- LayoutObject lo;
- for(int j = 0; j < itemRow.size(); j++)
- {
- lo = itemRow.getLayoutObject(j);
- if(lo.contains(x, y))
- {
- Logger.info("Item under mouse: "
- + lo.getOwningItem());
- currentlyUnderMouse = lo;
- return lo.getOwningItem();
- }
- }
- break;
- }
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see DefaultFormLayoutPolicy#eswtHandleVisibilityChanges()
- */
- protected void eswtHandleVisibilityChanges()
- {
- super.eswtHandleVisibilityChanges();
- eswtCheckCurrentSelectedItem();
- }
-
- /**
- * Gets next (or nearest) focusable item.
- *
- * @param fromItem Item where to start to search the next focusable item.
- * @param dir Search direction, one of the arrow key constants defined
- * in class SWT.
- *
- * @return Nearest focusable item or null if no item found.
- */
- final Item eswtGetNextFocusableItem(Item fromItem, int dir)
- {
- Item nextItem = fromItem;
-
- switch(dir)
- {
- case SWT.ARROW_RIGHT:
- {
- LayoutObject obj = getLastLayoutObjectOfItem(fromItem);
- while((obj = getNextLayoutObjectOfItem(obj, null)) != null)
- {
- Item owner = obj.getOwningItem();
- if(owner != null && owner != fromItem
- && owner.isFocusable()
- && isPartiallyVisible(obj, Config.DFI_VISIBILITY_PERCENT))
- {
- nextItem = owner;
- break;
- }
- }
- break;
- }
-
- case SWT.ARROW_LEFT:
- {
- LayoutObject obj = getFirstLayoutObjectOfItem(fromItem);
- while((obj = getPrevLayoutObjectOfItem(obj, null)) != null)
- {
- Item owner = obj.getOwningItem();
- if(owner != null && owner != fromItem
- && owner.isFocusable()
- && isPartiallyVisible(obj, Config.DFI_VISIBILITY_PERCENT))
- {
- nextItem = owner;
- break;
- }
- }
- break;
- }
-
- case SWT.ARROW_DOWN:
- {
- int minDist = Integer.MAX_VALUE;
- LayoutObject start = getLastLayoutObjectOfItem(fromItem);
- LayoutObject obj = start;
- while((obj = getNextLayoutObjectOfItem(obj, null)) != null)
- {
- Item owner = obj.getOwningItem();
- if(owner != null && owner != fromItem
- && owner.isFocusable() && obj.isBelow(start)
- && isPartiallyVisible(obj, Config.DFI_VISIBILITY_PERCENT))
- {
- int dist = obj.distanceTo(start);
- if(dist < minDist)
- {
- minDist = dist;
- nextItem = owner;
- }
- }
- }
- break;
- }
-
- case SWT.ARROW_UP:
- {
- int minDist = Integer.MAX_VALUE;
- LayoutObject start = getFirstLayoutObjectOfItem(fromItem);
- LayoutObject obj = start;
- while((obj = getPrevLayoutObjectOfItem(obj, null)) != null)
- {
- Item owner = obj.getOwningItem();
- if(owner != null && owner != fromItem
- && owner.isFocusable() && obj.isAbove(start)
- && isPartiallyVisible(obj, Config.DFI_VISIBILITY_PERCENT))
- {
- int dist = obj.distanceTo(start);
- if(dist < minDist)
- {
- minDist = dist;
- nextItem = owner;
- }
- }
- }
- break;
- }
-
- default:
- }
-
- return nextItem;
- }
-
- /**
- * Check if the currentSelectedItem is valid and visible. If not then it
- * sets it to null.
- */
- final void eswtCheckCurrentSelectedItem()
- {
- if(currentSelectedItem != null)
- {
- if(currentSelectedItem.getParent() != getForm()
- || !currentSelectedItem.isVisible())
- {
- // we need to find another
- Logger.method(this, "eswtCheckCurrentSelectedItem");
- eswtSetCurrentSelectedItem(null, NO_DIRECTION);
- }
- }
- }
-
- /**
- * Sets currentSelectedItem and sets focus to it.
- * If one of form's items is already selected when this method is called,
- * removes focus from old item and then moves focus to new one.
- *
- * @param item Item to set as current selected. If null, nothing happens.
- * @param dir Direction which is delivered to layouter.
- */
- void eswtSetCurrentSelectedItem(Item item, int dir)
- {
- if(currentSelectedItem != item)
- {
- Logger.info(this + "::SelectedItem: "
- + currentSelectedItem + " --(" + dir + ")--> " + item);
-
- // Save direction
- direction = dir;
- // Remove focus from currentSelectedItem and notify its Layouter.
- if(currentSelectedItem != null)
- {
- getLayouter(currentSelectedItem).eswtFocusLost(
- currentSelectedItem);
- }
-
- // Set new currentSelectedItem, must be focusable or null
- currentSelectedItem = item;
-
- // Set focus to currentSelectedItem and notify its Layouter.
- if(currentSelectedItem != null)
- {
- getLayouter(currentSelectedItem).eswtFocusGained(
- currentSelectedItem, dir);
- }
-
- // Apply eSWT focus to currentSelectedItem's control
- eswtApplyCurrentFocus();
- }
- }
-
- /**
- * Sets currentSelectedItem and sets focus to it.
- * If one of form's items is already selected when this method is called,
- * removes focus from old item and then moves focus to new one.
- *
- * @param item Item to set as current selected. If null, nothing happens.
- * @param dir Direction which is delivered to layouter.
- */
- void eswtSetCurrentSelectedItem(Item item)
- {
- if(currentSelectedItem != item)
- {
- Logger.info(this + "::SelectedItem: "
- + currentSelectedItem + " ---> " + item);
-
- // Remove focus from currentSelectedItem and notify its Layouter.
- if(currentSelectedItem != null)
- {
- getLayouter(currentSelectedItem).eswtFocusLost(
- currentSelectedItem);
- }
-
- // Set new currentSelectedItem, must be focusable or null
- currentSelectedItem = item;
-
- // Set focus to currentSelectedItem and notify its Layouter.
- if(currentSelectedItem != null)
- {
- getLayouter(currentSelectedItem).eswtFocusGained(
- currentSelectedItem, NO_DIRECTION);
- }
-
- // Apply eSWT focus to currentSelectedItem's control
- //eswtApplyCurrentFocus();
- }
- }
-
- /**
- * Sets focus to currentSelectedItem's control if its partially visible.
- * Otherwise it sets dummy focus to form's composite.
- *
- * Note that this method applies focus only to eSWT control. Item focus
- * update and layouter notifications are handled in method
- * eswtSetCurrentSelectedItem().
- * If currentSelectedItem is null or form is not shown, this method has no
- * effect.
- */
- void eswtApplyCurrentFocus()
- {
- if(isFormCurrent())
- {
- // if any of the Item's LayoutObjects is visible
- if(isItemPartiallyVisible(currentSelectedItem))
- {
- Logger.method(this, "ApplyFocus", currentSelectedItem);
- eswtSetFocusToFirstControl(currentSelectedItem);
- }
- else
- {
- Logger.method(this, "ApplyFocus", "dummy");
- formComposite.forceFocus();
- }
- }
- }
-
- /**
- * If the Item is valid and it is layouted, then sets the Item's first
- * LayoutObject focused.
- *
- * @param item an item which first LayoutObject is set focused.
- */
- void eswtSetFocusToFirstControl(Item item)
- {
- if(item != null && item.isFocusable())
- {
- LayoutObject lo = getFirstLayoutObjectOfItem(item);
- if(lo != null)
- {
- lo.getControl().forceFocus();
- }
- }
- }
-
- /**
- * Gets Current selected item.
- *
- * @return Current selected item. May also return null.
- */
- Item getCurrentSelectedItem()
- {
- return currentSelectedItem;
- }
-
- /**
- * Get the direction of scrolling.
- *
- * @return direction of scrolling.
- */
- int getDirection()
- {
- return direction;
- }
-
- /* (non-Javadoc)
- * @see DefaultFormLayoutPolicy#eswtResizeItemAndShift(Item)
- */
- int eswtResizeItemAndShift(Item item)
- {
- // save the state of the last row before resizing and Shifting.
- boolean itemWasVisible = isItemPartiallyVisible(item);
-
- int newVPosition = super.eswtResizeItemAndShift(item);
-
- if(item == currentSelectedItem)
- {
- if(itemWasVisible)
- {
- int itemTop = getItemTopPosition(item);
- int itemBottom = getItemBottomPosition(item);
- // currentSelectedItem has to be focused if it was focused
- // before resizing e.g TextField when it is resized by adding a
- // new row and it was in the bottom of the Screen.
- if(newVPosition <= itemTop
- && (newVPosition + getFormHeight()) >= itemBottom)
- {
- // do not change vPosition;
- }
- else if(newVPosition > itemTop)
- {
- newVPosition = itemTop;
- }
- else if((newVPosition + getFormHeight()) < itemBottom)
- {
- newVPosition = itemBottom - getFormHeight();
- }
- }
- }
- return newVPosition;
- }
-
- private Timer eventTimer = new Timer();
- private EventGeneratorTask eventTask;
-
- /**
- * Reset timer for do layout with a given start index.
- */
- private void resetEventTimer(boolean directionUp, int y)
- {
- if(eventTimer != null)
- {
- if(eventTask != null)
- {
- eventTask.cancel();
- eventTask = null;
- }
- // schedule new timer
- eventTask = new EventGeneratorTask(directionUp, y);
- eventTimer.schedule(eventTask, Config.DFI_EVENT_TIMER_DELAY);
- }
- }
-
- /**
- * Form Timer task. Triggers the formComposite to Layout.
- */
- class EventGeneratorTask extends TimerTask
- {
-
- private boolean isUpDirection;
- private int localY;
-
- public EventGeneratorTask(boolean direction, int y)
- {
- isUpDirection = direction;
- localY = y;
- Logger.info("y is " + localY);
- }
-
- public void run()
- {
- if(isUpDirection)
- {
- localY -= Config.DFI_EVENT_MOVE_DELTA;
- }
- else
- {
- localY += Config.DFI_EVENT_MOVE_DELTA;
- }
- handlePointerEvent(0, localY, SWT.MouseMove);
- }
- }
-
-}
diff -r abc41079b313 -r 59b3b4473dc8 javauis/lcdui_qt/src/javax/microedition/lcdui/DefaultFormLayoutPolicy.java
--- a/javauis/lcdui_qt/src/javax/microedition/lcdui/DefaultFormLayoutPolicy.java Fri Jul 23 12:27:20 2010 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1433 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:
-*
-*/
-package javax.microedition.lcdui;
-
-import java.util.NoSuchElementException;
-import java.util.Vector;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-
-/**
- * DefaultFormLayoutPolciy implements form layout algorithm.
- */
-class DefaultFormLayoutPolicy extends FormLayoutPolicy
-{
-
- /**
- * Form instance (not owned).
- */
- private Form form;
-
- /**
- * Form's scrolled composite (not owned).
- */
- protected ScrolledComposite formComposite;
-
- /**
- * Rows vector.
- */
- private Vector rows = new Vector();
-
- /**
- * Form's current horizontal alignment
- */
- private int currentHLayoutDirective;
-
- private ImageItemLayouter imIL;
-
- private StringItemLayouter sIL;
-
- private GaugeLayouter gL;
-
- private TextFieldLayouter tfL;
-
- private DateFieldLayouter dfL;
-
- private ChoiceGroupLayouter cgL;
-
- private CustomItemLayouter ciL;
-
- private SpacerLayouter sL;
-
- private int vPosition;
-
- private Item deferredScrollToItem;
-
- private boolean isCurrent;
-
- // Used by getItemControl() method to return Item's main conrol.
- private Control itemMainControl;
-
- /**
- * Constructor.
- *
- * @param form Form to perform layout on.
- */
- DefaultFormLayoutPolicy(Form form)
- {
- this.form = form;
- formComposite = form.getFormComposite();
- imIL = new ImageItemLayouter(this);
- sIL = new StringItemLayouter(this);
- gL = new GaugeLayouter(this);
- dfL = new DateFieldLayouter(this);
- tfL = new TextFieldLayouter(this);
- cgL = new ChoiceGroupLayouter(this);
- ciL = new CustomItemLayouter(this);
- sL = new SpacerLayouter(this);
- }
-
- /**
- * Dispose and cleanup layouted items.
- */
- void dispose()
- {
- ESWTUIThreadRunner.syncExec(new Runnable()
- {
- public void run()
- {
- eswtClearRows(0, null);
- }
- });
- }
-
- /**
- * Log out a control with all its children at the given indentation level.
- */
- void logControl(int level, Control control)
- {
- if(control != null)
- {
- String s2 = control.toString();
- s2 = s2.substring(0, s2.indexOf('}') - 1);
- String s3 = control.getBounds().toString();
- s3 = s3.substring(s3.indexOf('{'));
- Logger.verbose(Logger.indent(s2 + s3, level * 2));
- if(control instanceof Composite)
- {
- Control[] arr = ((Composite) control).getChildren();
- for(int i = 0; i < arr.length; i++)
- {
- logControl(level + 1, arr[i]);
- }
- }
- }
- }
-
- /**
- * Log out all layoutobjects for each item.
- */
- void logFormLayout()
- {
- Logger.verbose(form + " ---------------------------------------------");
- LayoutObject lo = null;
- Item item = null;
- int line = -1;
- while((lo = getNextLayoutObjectOfItem(lo, null)) != null)
- {
- if(lo.getOwningItem() != item)
- {
- item = lo.getOwningItem();
- Logger.verbose(item.toString());
- }
- if(lo.getRowIdx() != line)
- {
- line = lo.getRowIdx();
- }
- Logger.verbose(Logger.indent("Row:" + lo.getRowIdx(), 2));
- logControl(2, lo.getControl());
- }
- Logger.verbose(form + " ---------------------------------------------");
- }
-
- /**
- * Called when Form is about to be shown.
- * NOTE: this is called from eSWT UI-thread
- */
- void handleShowCurrentEvent()
- {
- Logger.method(this, "handleShowCurrentEvent");
- isCurrent = true;
-
- // restore our scrolling position (eSWT resets it to 0 by default)
- eswtSetScrollingPosition(vPosition, true);
-
- Item item = null;
- LayoutObject lo = null;
- while((lo = getNextLayoutObjectOfItem(lo, null)) != null)
- {
- if(lo.getOwningItem() != item)
- {
- // item border
- item = lo.getOwningItem();
- getLayouter(item).eswtAddListeners(item, lo);
- }
- }
- }
-
- /**
- * Called when Form is about to be hidden.
- * NOTE: this is called from eSWT UI-thread
- */
- void handleHideCurrentEvent()
- {
- Logger.method(this, "handleHideCurrentEvent");
- isCurrent = false;
-
- Item item = null;
- LayoutObject lo = null;
- while((lo = getNextLayoutObjectOfItem(lo, null)) != null)
- {
- if(lo.getOwningItem() != item)
- {
- // item border
- item = lo.getOwningItem();
- getLayouter(item).eswtRemoveListeners(item, lo);
- getLayouter(item).eswtHandleVisibilityChange(item, false);
- }
- }
- }
-
- /**
- * Called when Form is beeing resized.
- * NOTE: this is called from eSWT UI-thread
- */
- void handleResizeEvent(int width, int height)
- {
- // Logger.method(this, "handleResizeEvent");
- int numitems = getItemCount();
- for(int i = 0; i < numitems; i++)
- {
- getItem(i).invalidateCachedSizes();
- }
- ItemLayouter.eswtUpdateStaticShellSize(width, height);
- }
-
- /**
- * Do form layout according to startIndex.
- *
- * @param startItem - index of item which need to be layouted.
- */
- void layoutForm(final int startItem)
- {
- ESWTUIThreadRunner.syncExec(new Runnable()
- {
- public void run()
- {
- eswtLayoutForm(startItem);
- }
- });
- }
-
- /**
- * eSWT callback for doLayout().
- */
- void eswtLayoutForm(int startItem)
- {
- int numItems = getItemCount();
- Logger.method(this, "eswtLayoutForm", startItem + " / " + numItems);
-
- eswtUpdateFormComposite(false);
- if(numItems > 0)
- {
- Item previousItem = null;
- int startRowIndex = 0;
-
- if(startItem > 0)
- {
- // Find row with previous item.
- previousItem = getItem(startItem - 1);
- Row prevItemRow = getLastRowOfItem(previousItem);
- if(prevItemRow != null)
- {
- startRowIndex = rows.indexOf(prevItemRow);
- }
- }
-
- // Clear rows starting from item - partial re-layouting
- eswtClearRows(startRowIndex, previousItem);
-
- // Layout items
- for(int i = startItem; i < numItems; i++)
- {
- eswtLayoutItem(getItem(i));
- }
-
- // Update last row
- eswtUpdateRow(getLastRow());
- }
- else
- {
- eswtClearRows(0, null);
- }
- // check if we need to scroll to a particular item
- if(deferredScrollToItem != null)
- {
- eswtSetCurrentItem(deferredScrollToItem);
- deferredScrollToItem = null;
- }
- eswtUpdateFormComposite(true);
- eswtHandleVisibilityChanges();
-
- if(Logger.isLogVerbose())
- {
- logFormLayout();
- }
- }
-
- void handleKeyEvent(int keyCode, int keyType)
- {
- // Implemented in sub-class DefaultFormInteraction
- }
-
- void handlePointerEvent(int x, int y, int type)
- {
- // Implemented in sub-class DefaultFormInteraction
- }
-
- /**
- * Set focus to an item if it is focusable and scroll form to make it
- * visible if it is not.
- *
- * @param item Item to set as current item.
- */
- void setCurrentItem(final Item item)
- {
- Logger.method(this, "setCurrentItem", item);
- ESWTUIThreadRunner.syncExec(new Runnable()
- {
- public void run()
- {
- eswtSetCurrentItem(item);
- }
- });
- }
-
- /**
- * eSWT callback for setCurrentItem.
- */
- boolean eswtSetCurrentItem(Item item)
- {
- if(item != null)
- {
- if(isItemLayouted(item))
- {
- eswtScrollToItem(item);
- deferredScrollToItem = null;
- return true;
- }
- else
- {
- deferredScrollToItem = item;
- }
- }
- return false;
- }
-
- void eswtScrollToItem(Item item)
- {
- if(item != null)
- {
- int pos = getItemBottomPosition(item) - getFormHeight();
- if(!isItemPartiallyVisible(item))
- {
- eswtSetScrollingPosition(pos, true);
- }
- else if(item instanceof TextField && !isItemFullyVisible(item))
- {
- eswtSetScrollingPosition(pos, true);
- }
- }
- }
-
- void eswtScrolltoRegion(int yTop, int yBottom, int swtDir)
- {
- if(yTop < vPosition || yBottom > vPosition + getFormHeight())
- {
- // if the region is somewhat outside the screen
- if(swtDir == SWT.ARROW_DOWN || swtDir == SWT.ARROW_RIGHT)
- {
- // align to top
- eswtSetScrollingPosition(yTop, true);
- }
- else
- {
- // align to bottom
- eswtSetScrollingPosition(yBottom - getFormHeight(), true);
- }
- }
- }
-
- void eswtScrollIfNeeded(final int top, final int bottom)
- {
- if(bottom > vPosition + getFormHeight())
- {
- eswtSetScrollingPosition(bottom - (getFormHeight() / 2), true);
- }
- else if(top < vPosition)
- {
- eswtSetScrollingPosition(bottom - (getFormHeight() / 2), true);
- }
- }
-
- /**
- * Get control's position relative to composite.
- */
- void getControlPositionOnComposite(Control control, Point location)
- {
- if(control != formComposite)
- {
- Point rel = control.getLocation();
- location.x += rel.x;
- location.y += rel.y;
- getControlPositionOnComposite(control.getParent(), location);
- }
- }
-
- /**
- * eSWT specific calls to do update ScrolledComposite.
- */
- private void eswtUpdateFormComposite(boolean show)
- {
- if(getRowCount() > 0)
- {
- if(show)
- {
- formComposite.updateScrollbar(getLastRow().getBottomPosition());
- formComposite.pack();
- }
- }
- // Could happen if changing item from very tall to very short.
- // so we have to update VPosition
- if(getVPosition() > eswtGetMaxVPosition())
- {
- eswtSetScrollingPosition(eswtGetMaxVPosition(), false);
- }
-
- formComposite.setRedraw(show);
- formComposite.setVisible(show);
- }
-
- /**
- * Clean all form rows starting from startIndex.
- *
- * @param startIndex Start row from which to clean.
- * @param keepItem - item in a startRow which shouldn't be recreated.
- */
- private void eswtClearRows(int startIndex, Item keepItem)
- {
- Logger.method(this, "clearRows", String.valueOf(startIndex), keepItem);
- Row row = null;
- for(int i = (getRowCount() - 1); i >= startIndex; i--)
- {
- row = getRow(i);
- if(row.cleanRow(keepItem))
- {
- break;
- }
- else
- {
- rows.removeElement(row);
- }
- }
-
- // one row always should be available.
- if((getRowCount() == 0))
- {
- // rows.addElement(tempRow);
- currentHLayoutDirective = Item.LAYOUT_DEFAULT;
- Row newRow = new Row(ItemLayouter.getMaximumItemWidth(null),
- getCurrentHLayoutDirective());
- rows.addElement(newRow);
- }
- }
-
- /**
- * Update Row's internal layout. Handles LAYOUT_2 related post-processing.
- *
- * @param row Row
- */
- private void eswtUpdateRow(Row row)
- {
- if(row != null)
- {
- //Logger.verbose("updateRow start: " + row);
- int numShrink = row.getNumLayoutObjects(Item.LAYOUT_SHRINK);
- int numExpand = row.getNumLayoutObjects(Item.LAYOUT_EXPAND);
- //Logger.verbose("shrink: " + numShrink + " expand: " + numExpand);
-
- int vMask = Item.LAYOUT_VSHRINK | Item.LAYOUT_VEXPAND;
- // Expand items vertically with VSHRINK or VEXPAND layout directive
- LayoutObject lo = null;
- int maxHeight = row.getRowHeight(vMask);
- while((lo = row.getNextLayoutObject(lo, vMask)) != null)
- {
- if(lo.getOwningItem().hasLayout(Item.LAYOUT_VSHRINK))
- {
- int pref = lo.getOwningItem().getPreferredHeight();
- getLayouter(lo.getOwningItem()).eswtResizeObject(lo,
- lo.getWidth(), Math.min(pref, maxHeight));
- }
- else if(lo.getOwningItem().hasLayout(Item.LAYOUT_VEXPAND))
- {
- getLayouter(lo.getOwningItem()).eswtResizeObject(lo,
- lo.getWidth(), maxHeight);
- }
- }
-
- // Expand items with SHRINK layout directive
- if(numShrink > 0)
- {
- // Get extra space before shrink and expand
- int offset = row.getFreeSpace() / numShrink;
- // Logger.verbose("shrinkOffset: " + offset);
- if(offset >= 0)
- {
- while((lo = row.getNextLayoutObject(lo, Item.LAYOUT_SHRINK)) != null)
- {
- int pref = lo.getOwningItem().getPreferredWidth();
- int min = lo.getOwningItem().getMinimumWidth();
- int itemWidth = Math.min(pref, min + offset);
- getLayouter(lo.getOwningItem()).eswtResizeObject(lo,
- itemWidth, lo.getHeight());
- }
- }
- }
-
- // Expand items with EXPAND layout directive
- if(numExpand > 0)
- {
- // Get extra space after shrink but before expand
- int offset = row.getFreeSpace(Item.LAYOUT_EXPAND) / numExpand;
- if(offset >= 0)
- {
- // Logger.verbose("expandOffset: " + offset);
- while((lo = row.getNextLayoutObject(lo, Item.LAYOUT_EXPAND)) != null)
- {
- int pref = lo.getOwningItem().getPreferredWidth();
- getLayouter(lo.getOwningItem()).eswtResizeObject(lo,
- pref + offset, lo.getHeight());
- }
- }
- }
-
- //if (numShrink > 0 || numExpand > 0) {
- row.updateRowInternals();
- //}
-
- row.updateRowLayout(form.getLeftRightLanguage());
- // Logger.verbose("updateRow: " + row);
- }
- }
-
- /**
- * Add a new Row.
- */
- private Row eswtAddNewRow()
- {
- Row lastRow = getLastRow();
- eswtUpdateRow(lastRow);
- int yShift = (lastRow == null ? 0 : lastRow.getBottomPosition());
- // create new Row
- Row newRow = new Row(ItemLayouter.getMaximumItemWidth(null),
- getCurrentHLayoutDirective());
- newRow.setYShift(yShift);
- rows.addElement(newRow);
- return newRow;
- }
-
- /**
- * Add a LayoutObject to the last Row.
- *
- * @param layoutObject the layout object
- */
- void eswtAddNewLayoutObject(LayoutObject layoutObject)
- {
- Row lastRow = getLastRow();
- // check if the current Row is full
- if(!lastRow.isEmpty()
- && lastRow.getFreeSpace() < layoutObject.getWidth())
- {
- lastRow = eswtAddNewRow();
- }
- lastRow.eswtAddLayoutObject(layoutObject);
- layoutObject.setRowIdx(getRowCount() - 1);
- }
-
- /**
- * Optionally add a new Row and adds a LayoutObject.
- *
- * @param layoutObject the layout object
- * @param newRow adds a new row if true. If false, adds new row only if
- * there's no space for layoutObject in current row.
- */
- void eswtAddNewLayoutObject(LayoutObject layoutObject, boolean newRow)
- {
- if(newRow)
- {
- eswtAddNewRow();
- }
- eswtAddNewLayoutObject(layoutObject);
- }
-
- /**
- * Layout item in a row, if needed new row is added.
- *
- * @param row - where to startLayout.
- * @param item - Item to Layout
- */
- private void eswtLayoutItem(Item item)
- {
- Row lastRow = getLastRow();
- boolean hlChange = setCurrentHLayoutDirective(item.internalGetLayout());
- if(hlChange || getItemNewLineBefore(item))
- {
- // newline directive or horizontal layout changed
- if(lastRow.isEmpty())
- {
- // if the current/last row is empty - use that
- lastRow.setRowHLayout(getCurrentHLayoutDirective());
- }
- else
- {
- eswtAddNewRow();
- }
- }
-
- // Use the specific layouter to layout item in the last row
- getLayouter(item).eswtLayoutItem(getLastRow(), item);
-
- if(form.eswtIsShown())
- {
- LayoutObject lo = getFirstLayoutObjectOfItem(item);
- if(lo != null)
- {
- getLayouter(item).eswtAddListeners(item, lo);
- }
- }
-
- if(getItemNewLineAfter(item))
- {
- eswtAddNewRow();
- }
- }
-
- /**
- * Set Form's Layout directive. if it differ from current set flag
- * startFromNewLine = true;
- *
- * @param newLayoutDirective
- * @return true if a layout change has occured
- */
- private boolean setCurrentHLayoutDirective(int newLayoutDirective)
- {
- int newHLayoutDirective = Item.getHorizontalLayout(newLayoutDirective);
- if((newHLayoutDirective != currentHLayoutDirective)
- && (newHLayoutDirective != Item.LAYOUT_DEFAULT))
- {
- currentHLayoutDirective = newHLayoutDirective;
- return true;
- }
- return false;
- }
-
- /**
- * Get Form current Layout directive.
- *
- * @return current Layout directive for Form.
- */
- private int getCurrentHLayoutDirective()
- {
- if(currentHLayoutDirective == Item.LAYOUT_DEFAULT)
- {
- return getLanguageSpecificLayoutDirective();
- }
- return currentHLayoutDirective;
- }
-
- /**
- * Returns language specific layout directive.
- *
- * @return LAYOUT_LEFT or LAYOUT_RIGHT.
- */
- int getLanguageSpecificLayoutDirective()
- {
- if(form.getLeftRightLanguage())
- {
- return Item.LAYOUT_LEFT;
- }
- else
- {
- return Item.LAYOUT_RIGHT;
- }
- }
-
- private boolean getItemNewLineBefore(Item item)
- {
- return ((item.internalGetLayout() & Item.LAYOUT_NEWLINE_BEFORE) != 0);
- }
-
- private boolean getItemNewLineAfter(Item item)
- {
- return ((item.internalGetLayout() & Item.LAYOUT_NEWLINE_AFTER) != 0);
- }
-
- boolean isItemLayouted(Item item)
- {
- return (getFirstLayoutObjectOfItem(item) != null);
- }
-
- /**
- * Returns if the form is shown.
- */
- boolean isFormCurrent()
- {
- return isCurrent;
- }
-
- /**
- * Returns if the region is partially visible.
- *
- * @param viewTop viewPort's top position
- * @param viewBottom viewPort's bottom position
- * @return true if visible
- */
- boolean isPartiallyVisible(int yTop, int yBottom)
- {
- int vBottomPosition = vPosition + getFormHeight();
- if((vPosition <= yTop && vBottomPosition <= yTop)
- || (vPosition >= yBottom && vBottomPosition >= yBottom))
- {
- return false;
- }
- return true;
- }
-
- /**
- * Returns if at least the region's given percentage is visible.
- */
- boolean isPartiallyVisible(int yTop, int yBottom, int minPercent)
- {
- int visPercent = getVisibilityPercent(yTop, yBottom);
- if(visPercent > minPercent)
- {
- return true;
- }
- return false;
- }
-
- /**
- * Returns the region's visibility percentage.
- */
- int getVisibilityPercent(int yTop, int yBottom)
- {
- if(yTop >= yBottom)
- {
- return 0;
- }
- int vBottomPosition = vPosition + getFormHeight();
- int r1 = Math.max(vPosition, Math.min(yTop, vBottomPosition));
- int r2 = Math.min(vBottomPosition, Math.max(yBottom, vPosition));
- return ((r2 - r1) * 100) / (yBottom - yTop);
- }
-
- /**
- * Returns if the LayoutObject is partially visible.
- */
- boolean isPartiallyVisible(LayoutObject lo)
- {
- if(lo != null)
- {
- return isPartiallyVisible(lo.getY(), lo.getY() + lo.getHeight());
- }
- return false;
- }
-
- /**
- * Returns if at least the LayoutObject's given percentage is visible.
- */
- boolean isPartiallyVisible(LayoutObject lo, int minPercent)
- {
- if(lo != null)
- {
- return isPartiallyVisible(lo.getY(), lo.getY() + lo.getHeight(),
- minPercent);
- }
- return false;
- }
-
- /**
- * Returns if the Item is partially visible (if one of its LayoutObjects is
- * partially visible).
- *
- * @param item the Item
- * @return true if partially visible
- */
- boolean isItemPartiallyVisible(Item item)
- {
- if(item != null)
- {
- LayoutObject lo = null;
- while((lo = getNextLayoutObjectOfItem(lo, item)) != null)
- {
- if(isPartiallyVisible(lo))
- {
- return true;
- }
- }
- }
- return false;
- }
-
-
-
- /**
- * Returns true if item is fully visible.
- *
- * @param item the Item.
- * @return true if fully visible.
- */
- boolean isItemFullyVisible(Item item)
- {
- if(item != null)
- {
- LayoutObject lo = null;
- while((lo = getNextLayoutObjectOfItem(lo, item)) != null)
- {
- if(!isLOFullyVisible(lo))
- {
- return false;
- }
- }
- }
- return true;
- }
-
- /**
- * Returns if the LayoutObject is fully visible.
- */
- boolean isLOFullyVisible(LayoutObject lo)
- {
- if(lo != null)
- {
- return isFullyVisible(lo.getY(), lo.getY() + lo.getHeight());
- }
- return false;
- }
-
- /**
- * Returns if the region is fully visible.
- *
- * @param viewTop viewPort's top position
- * @param viewBottom viewPort's bottom position
- * @return true if visible
- */
- boolean isFullyVisible(int yTop, int yBottom)
- {
- int vBottomPosition = vPosition + getFormHeight();
- if((vPosition <= yTop && vBottomPosition >= yBottom))
- {
- return true;
- }
- return false;
- }
-
- int getItemTopPosition(Item item)
- {
- LayoutObject lo = getFirstLayoutObjectOfItem(item);
- if(lo != null)
- {
- return lo.getY();
- }
- return 0;
- }
-
- int getItemBottomPosition(Item item)
- {
- LayoutObject lo = getLastLayoutObjectOfItem(item);
- if(lo != null)
- {
- return lo.getY() + lo.getHeight();
- }
- return 0;
- }
-
- int getItemCount()
- {
- return form.size();
- }
-
- Item getItem(int index)
- {
- try
- {
- return (Item) form.getItems().elementAt(index);
- }
- catch(ArrayIndexOutOfBoundsException e)
- {
- // Logger.exception(e);
- return null;
- }
- }
-
- int getItemIndex(Item item)
- {
- return form.getItems().indexOf(item);
- }
-
- int getRowCount()
- {
- return rows.size();
- }
-
- /**
- * Return the Row with the given index.
- *
- * @param index Row's index
- * @return a Row
- */
- Row getRow(int index)
- {
- try
- {
- return (Row) rows.elementAt(index);
- }
- catch(ArrayIndexOutOfBoundsException e)
- {
- Logger.exception("getRow", e);
- return null;
- }
- }
-
- /**
- * Return the Row to which the given LayoutObject belongs.
- *
- * @param lo LayoutObject
- * @return the owning Row
- */
- Row getRow(LayoutObject lo)
- {
- try
- {
- return getRow(lo.getRowIdx());
- }
- catch(NullPointerException e)
- {
- // Logger.exception("getRow", e);
- return null;
- }
- }
-
- /**
- * Returns the last row of the form.
- */
- Row getLastRow()
- {
- try
- {
- return (Row) rows.lastElement();
- }
- catch(NoSuchElementException nse)
- {
- // Logger.exception("getLastRow", nse);
- return null;
- }
- }
-
- /**
- * Find last row which contains corresponding Item.
- *
- * @param item Item in a Row.
- * @return Last Row with that item.
- */
- Row getLastRowOfItem(Item item)
- {
- return getRow(getLastLayoutObjectOfItem(item));
- }
-
- /**
- * Get Form which requires layout.
- *
- * @return form.
- */
- Form getForm()
- {
- return form;
- }
-
- /**
- * Form's content height.
- */
- int getFormHeight()
- {
- return form.getHeight();
- }
-
- /**
- * Form's content width.
- */
- int getFormWidth()
- {
- return form.getWidth();
- }
-
- /**
- * Returns the next LayoutObject belonging to this Item.
- *
- * @param lo starting LayoutObject; if null then it start from first.
- * @param item specifies the parent Item; null means any Item
- * @return the next LayoutObject in the layout.
- */
- LayoutObject getNextLayoutObjectOfItem(LayoutObject lo, Item item)
- {
- int startRow = (lo == null ? 0 : lo.getRowIdx());
- LayoutObject temp = null;
- for(int i = startRow; i < getRowCount(); i++)
- {
- temp = getRow(i).getNextLayoutObject(lo, item);
- if(temp != null && temp != lo)
- {
- return temp;
- }
- }
- return null;
- }
-
- /**
- * Returns the previous LayoutObject belonging to this Item.
- *
- * @param lo starting LayoutObject; if null then it start from last.
- * @param item specifies the parent Item; null means any Item
- * @return the previous LayoutObject in the layout.
- */
- LayoutObject getPrevLayoutObjectOfItem(LayoutObject lo, Item item)
- {
- int startRow = (lo == null ? rows.size() - 1 : lo.getRowIdx());
- LayoutObject temp = null;
- for(int i = startRow; i >= 0; i--)
- {
- temp = getRow(i).getPrevLayoutObject(lo, item);
- if(temp != null && temp != lo)
- {
- return temp;
- }
- }
- return null;
- }
-
- /**
- * Returns the first LayoutObject of a layouted item.
- *
- * @param item
- * @return the LO, or NULL if the item is not layouted
- */
- LayoutObject getFirstLayoutObjectOfItem(Item item)
- {
- if(item != null)
- {
- return getNextLayoutObjectOfItem(null, item);
- }
- return null;
- }
-
- /**
- * Returns the last LayoutObject of a layouted item.
- *
- * @param item
- * @return the LO, or NULL if the item is not layouted
- */
- LayoutObject getLastLayoutObjectOfItem(Item item)
- {
- if(item != null)
- {
- return getPrevLayoutObjectOfItem(null, item);
- }
- return null;
- }
-
- /**
- * Update item state in form.
- *
- * @param item
- * @param updateReason
- * @param param additional parameter
- */
- void updateItemState(Item item, int updateReason, Object param)
- {
- Logger.method(this, "updateItemState", item,
- String.valueOf(updateReason), param);
-
- // Clean reason - without resizing flags
- int reason = updateReason & Item.UPDATE_REASON_MASK;
- switch(reason)
- {
- case Item.UPDATE_NONE:
- break;
- case Item.UPDATE_ADDCOMMAND:
- {
- if(isFormCurrent() && param != null)
- {
- LayoutObject lo = getFirstLayoutObjectOfItem(item);
- if(lo != null && param instanceof Command)
- {
- lo.addCommand((Command) param);
- }
- }
- break;
- }
- case Item.UPDATE_REMOVECOMMAND:
- {
- if(isFormCurrent() && param != null)
- {
- LayoutObject lo = getFirstLayoutObjectOfItem(item);
- if(lo != null && param instanceof Command)
- {
- lo.removeCommand((Command) param);
- }
- }
- break;
- }
- default:
- {
- LayoutObject lo = getFirstLayoutObjectOfItem(item);
- if(lo != null)
- {
- getLayouter(item).updateItem(item, lo.getControl(), reason,
- param);
- }
- break;
- }
- }
-
- // Check this always - because this is a flag
- if((updateReason & Item.UPDATE_HEIGHT_CHANGED)
- == Item.UPDATE_HEIGHT_CHANGED)
- {
- resizeItemAndShift(item);
- }
- }
-
- int eswtGetMaxVPosition()
- {
- return formComposite.getSize().y - getFormHeight();
- }
-
- /**
- * Called by key Form to compute new vertical coordinate to position form's
- * content.
- *
- * @param swtDir scrolling direction.
- * @return New vertical position of Form's content.
- */
- protected int getNextScrollingPosition(int swtDir)
- {
- boolean scrollDown = (swtDir == SWT.ARROW_DOWN
- || swtDir == SWT.ARROW_RIGHT);
- int formHeight = getFormHeight();
- int refPoint;
- int ret = vPosition;
- if(scrollDown)
- {
- ret += formHeight / 5;
- refPoint = (vPosition + 1) + formHeight;
- }
- else
- {
- ret -= formHeight / 5;
- refPoint = (vPosition - 1);
- }
-
- Row row = null;
- for(int i = 0; i < getRowCount(); i++)
- {
- row = getRow(i);
- if(row.isInsideRow(refPoint)
- && (row.getRowHeight() < formHeight))
- {
- if(scrollDown)
- {
- ret = row.getBottomPosition() - formHeight;
- }
- else
- {
- ret = row.getYShift();
- }
- break;
- }
- }
-
- return ret;
- }
-
- /**
- * Set the scrolling to the specified position.
- * This method also updates the Form's scrollbars.
- *
- * @param position new position
- */
- void eswtSetScrollingPosition(int position, boolean keyNav)
- {
- // check constraints
- int newVPosition = position;
- int maxVPos = eswtGetMaxVPosition();
- newVPosition = Math.min(newVPosition, maxVPos);
- newVPosition = Math.max(newVPosition, 0);
-
- vPosition = newVPosition;
- formComposite.setRedraw(false);
- formComposite.setOrigin(0, vPosition, keyNav);
- formComposite.pack();
- formComposite.setRedraw(true);
-
- eswtHandleVisibilityChanges();
- }
-
- /**
- * Returns the scrolling position.
- */
- protected int getScrollingPosition()
- {
- return vPosition;
- }
-
- /**
- * Updates visibility status of all items.
- */
- protected void eswtHandleVisibilityChanges()
- {
- // Logger.method(this, "eswtHandleVisibilityChanges");
- boolean shown = false;
- Item item = null;
- LayoutObject lo = null;
- // Go through all LayoutObjects and check/update visibilities
- while((lo = getNextLayoutObjectOfItem(lo, null)) != null)
- {
- // check if owning item is changing
- if(lo.getOwningItem() != item)
- {
- if(item != null)
- {
- // set current item's visibility
- getLayouter(item).eswtHandleVisibilityChange(item, shown);
- }
- // new item
- item = lo.getOwningItem();
- shown = false;
- }
-
- // track current item's visibility
- if(!shown && isFormCurrent() && isPartiallyVisible(lo))
- {
- shown = true;
- }
- }
-
- // call it for last item
- if(item != null)
- {
- getLayouter(item).eswtHandleVisibilityChange(item, shown);
- }
- }
-
- /**
- * Changes item size and does shift of all Rows.
- *
- * @param item - item to changeSize.
- */
- void resizeItemAndShift(final Item item)
- {
- ESWTUIThreadRunner.syncExec(new Runnable()
- {
- public void run()
- {
- int newVPosition = eswtResizeItemAndShift(item);
- if(newVPosition != vPosition)
- {
- eswtSetScrollingPosition(newVPosition, true);
- }
- else
- {
- eswtHandleVisibilityChanges();
- }
- }
- });
- }
-
- /**
- * eSWT callback for resizeItemAndShift.
- *
- * @param item Item to be resized.
- * @return new scrolling vPosition
- */
- int eswtResizeItemAndShift(Item item)
- {
- Row row = getLastRowOfItem(item);
- int deltaYShift = row.getRowHeight();
- // if we un-comment this then when we set true,
- // focus will jump to first item.
- // eswtUpdateFormComposite(false);
- LayoutObject lo = getFirstLayoutObjectOfItem(item);
- if(lo != null)
- {
- getLayouter(item).eswtResizeObject(lo);
- }
-
- eswtUpdateRow(row);
-
- /*
- // to avoid double call of updateRowInternals
- if (row.getNumLayoutObjects(Item.LAYOUT_SHRINK) > 0
- || row.getNumLayoutObjects(Item.LAYOUT_EXPAND) > 0) {
- eswtUpdateRow(row);
- }
- else {
- row.updateRowInternals();
- }
- */
- deltaYShift = row.getRowHeight() - deltaYShift;
- // row's height change - all remaining rows are shifted with this.
-
- Row lastRow = getLastRow();
- if(row != lastRow)
- {
- for(int i = rows.indexOf(row) + 1; i < getRowCount(); i++)
- {
- row = getRow(i);
- row.setYShift(row.getYShift() + deltaYShift);
- eswtUpdateRow(row);
- }
- }
-
- // following code updates scrolling if needed.
- // need to check where in the form resize happeneed.
-
- int itemRowYShift = getLastRowOfItem(item).getYShift();
- // vPosition should be changed in syncexec
- int newVPosition = vPosition;
-
- // we need to scroll only if changes happened above the screen.
- if(newVPosition >= itemRowYShift)
- {
- newVPosition = Math.max(0, newVPosition + deltaYShift);
- }
- // check to avoid gap in the bottom of the form
- if(newVPosition + getFormHeight() > lastRow.getBottomPosition())
- {
- newVPosition = Math.max(0,
- lastRow.getBottomPosition() - getFormHeight());
- }
-
- eswtUpdateFormComposite(true);
-
- // formComposite.pack();
- // formComposite.updateScrollbarSize(lastRow.getBottomPosition());
-
- return newVPosition;
- }
-
- /**
- * Gets layouter that can layout the specified item.
- *
- * @param item Item to be layouted.
- * @return ItemLayouter or null if no Layouter found.
- */
- protected final ItemLayouter getLayouter(Item item)
- {
- if(item instanceof StringItem)
- {
- return sIL;
- }
- else if(item instanceof ImageItem)
- {
- return imIL;
- }
- else if(item instanceof Gauge)
- {
- return gL;
- }
- else if(item instanceof TextField)
- {
- return tfL;
- }
- else if(item instanceof DateField)
- {
- return dfL;
- }
- else if(item instanceof ChoiceGroup)
- {
- return cgL;
- }
- else if(item instanceof CustomItem)
- {
- return ciL;
- }
- else if(item instanceof Spacer)
- {
- return sL;
- }
- return null;
- }
-
- /**
- * Returns eSWT Control that represents the item specified.
- */
- Control getItemControl(final Item item)
- {
- final LayoutObject lo = getFirstLayoutObjectOfItem(item);
- if(lo != null)
- {
- ESWTUIThreadRunner.syncExec(new Runnable()
- {
- public void run()
- {
- itemMainControl = getLayouter(item)
- .eswtFindSpecificControl(item, lo.getControl());
- }
- });
- return itemMainControl;
- }
- return null;
- }
-
- void updateScrolling(final int value, final boolean keyNav)
- {
- Logger.method("updateScrolling", String.valueOf(value));
- ESWTUIThreadRunner.syncExec(new Runnable()
- {
- public void run()
- {
-
- eswtSetScrollingPosition(value, keyNav);
-
- }
- });
- }
-
- /**
- * Get current scrolling value.
- *
- * @return vPosition.
- */
- int getVPosition()
- {
- return vPosition;
- }
-
-}
diff -r abc41079b313 -r 59b3b4473dc8 javauis/lcdui_qt/src/javax/microedition/lcdui/Displayable.java
--- a/javauis/lcdui_qt/src/javax/microedition/lcdui/Displayable.java Fri Jul 23 12:27:20 2010 +0300
+++ b/javauis/lcdui_qt/src/javax/microedition/lcdui/Displayable.java Thu Aug 05 16:07:57 2010 +0300
@@ -28,7 +28,6 @@
import org.eclipse.swt.internal.extension.MobileShellExtension;
import org.eclipse.swt.widgets.*;
import com.nokia.mj.impl.rt.support.ApplicationUtils;
-import com.nokia.mj.impl.rt.support.ApplicationInfo;
/**
* Implementation of LCDUI Displayable class.
diff -r abc41079b313 -r 59b3b4473dc8 javauis/lcdui_qt/src/javax/microedition/lcdui/Form.java
--- a/javauis/lcdui_qt/src/javax/microedition/lcdui/Form.java Fri Jul 23 12:27:20 2010 +0300
+++ b/javauis/lcdui_qt/src/javax/microedition/lcdui/Form.java Thu Aug 05 16:07:57 2010 +0300
@@ -34,7 +34,7 @@
/**
* Abstract layouting policy.
*/
- private FormLayoutPolicy layoutPolicy;
+ private FormLayouter formLayouter;
/**
* Item vector.
@@ -69,7 +69,7 @@
{
super(title);
construct();
- layoutPolicy = new DefaultFormInteraction(this);
+ formLayouter = new FormLayouter(this);
}
/**
@@ -117,7 +117,7 @@
{
vBar.addSelectionListener(fsbl);
}
- layoutPolicy.handleShowCurrentEvent();
+ formLayouter.handleShowCurrentEvent();
}
/* (non-Javadoc)
@@ -132,7 +132,7 @@
{
vBar.removeSelectionListener(fsbl);
}
- layoutPolicy.handleHideCurrentEvent();
+ formLayouter.handleHideCurrentEvent();
}
/* (non-Javadoc)
@@ -147,7 +147,7 @@
formComposite.setOrigin(0, 0, true);
formComposite.setSize(width, height);
formComposite.setRedraw(true);
- layoutPolicy.handleResizeEvent(width, height);
+ formLayouter.handleResizeEvent(width, height);
resetLayoutTimer(0);
}
}
@@ -166,7 +166,7 @@
}
else
{
- layoutPolicy.handleKeyEvent(e.keyCode, e.type);
+ formLayouter.handleKeyEvent(e.keyCode, e.type);
}
}
@@ -189,7 +189,7 @@
MsgRepository.FORM_EXCEPTION_ITEM_OWNED_BY_CONTAINER);
}
int returnValue = -1;
- synchronized(layoutPolicy)
+ synchronized(formLayouter)
{
item.setParent(this);
items.addElement(item);
@@ -255,7 +255,7 @@
throw new IndexOutOfBoundsException(
MsgRepository.FORM_EXCEPTION_INVALID_ITEM_INDEX);
}
- synchronized(layoutPolicy)
+ synchronized(formLayouter)
{
item.setParent(this);
items.insertElementAt(item, position);
@@ -276,9 +276,11 @@
throw new IndexOutOfBoundsException(
MsgRepository.FORM_EXCEPTION_INVALID_ITEM_INDEX);
}
- synchronized(layoutPolicy)
+ synchronized(formLayouter)
{
- ((Item) items.elementAt(position)).setParent(null);
+ Item item = ((Item) items.elementAt(position));
+ item.clearParent();
+ formLayouter.removeLayoutObject(item);
items.removeElementAt(position);
resetLayoutTimer(position - 1);
}
@@ -289,11 +291,13 @@
*/
public void deleteAll()
{
- synchronized(layoutPolicy)
+ synchronized(formLayouter)
{
for(int i = 0; i < items.size(); i++)
{
- ((Item) items.elementAt(i)).setParent(null);
+ Item item = ((Item) items.elementAt(i));
+ item.clearParent();
+ formLayouter.removeLayoutObject(item);
}
items.removeAllElements();
resetLayoutTimer(0);
@@ -324,11 +328,13 @@
throw new IndexOutOfBoundsException(
MsgRepository.FORM_EXCEPTION_INVALID_ITEM_INDEX);
}
- synchronized(layoutPolicy)
+ synchronized(formLayouter)
{
newItem.setParent(this);
// clear reference to a form for "old" item.
- get(position).setParent(null);
+ Item oldItem = get(position);
+ oldItem.clearParent();
+ formLayouter.removeLayoutObject(oldItem);
items.setElementAt(newItem, position);
resetLayoutTimer(position);
}
@@ -344,7 +350,7 @@
public Item get(int position)
{
Item returnItem = null;
- synchronized(layoutPolicy)
+ synchronized(formLayouter)
{
try
{
@@ -386,7 +392,7 @@
*/
void setCurrentItem(Item item)
{
- layoutPolicy.setCurrentItem(item);
+ formLayouter.setCurrentItem(item);
}
/**
@@ -419,30 +425,24 @@
* @param updateReason
* @param param additional parameter
*/
- void updateItemState(Item item, int updateReason, Object param)
- {
- if(item != null && item.getParent() == this)
- {
- if((updateReason & Item.UPDATE_WIDTH_CHANGED) != 0)
- {
- synchronized(layoutPolicy)
- {
- resetLayoutTimer(items.indexOf(item));
- }
- }
- else
- {
- if(layoutPolicy instanceof DefaultFormInteraction)
- {
- if(layoutTimer != null)
- {
- ((DefaultFormInteraction) layoutPolicy)
- .updateItemState(item, updateReason, param);
- }
- }
- }
- }
- }
+ void updateItemState(Item item, int updateReason, Object param)
+ {
+ if(item != null && item.getParent() == this)
+ {
+ if(layoutTimer != null)
+ {
+ formLayouter.updateItemState(item, updateReason, param);
+ }
+
+ if((updateReason & Item.UPDATE_SIZE_CHANGED) != 0)
+ {
+ synchronized(formLayouter)
+ {
+ resetLayoutTimer(items.indexOf(item));
+ }
+ }
+ }
+ }
/**
* Get Vector of items.
@@ -464,13 +464,13 @@
/**
- * Returns form layout policy.
+ * Returns form Form Layouter.
* @return Reference to layout policy.
*
*/
- FormLayoutPolicy getLayoutPolicy()
+ FormLayouter getFormLayouter()
{
- return layoutPolicy;
+ return formLayouter;
}
// =========================================================================
@@ -483,7 +483,7 @@
super(title);
construct();
layoutLR = leftRightLanguage;
- layoutPolicy = new DefaultFormInteraction(this);
+ formLayouter = new FormLayouter(this);
}
// =========================================================================
@@ -510,13 +510,30 @@
}
// schedule new timer
startIndex = Math.max(0, Math.min(newStartIndex, startIndex));
- // layoutPolicy.layoutForm(startIndex);
+ // formLayouter.layoutForm(startIndex);
formTimerTask = new FormTimerTask(startIndex);
layoutTimer.schedule(formTimerTask, Config.FORM_LAYOUT_TIMER_DELAY);
}
}
/**
+ * Cancel Layout Timer.
+ */
+ private void cancelLayoutTimer()
+ {
+ if(layoutTimer != null)
+ {
+ if(formTimerTask != null)
+ {
+ formTimerTask.cancel();
+ formTimerTask = null;
+ }
+ layoutTimer.cancel();
+ layoutTimer = null;
+ }
+ }
+
+ /**
* Form Timer task. Triggers the formComposite to Layout.
*/
class FormTimerTask extends TimerTask
@@ -532,7 +549,7 @@
public void run()
{
Logger.method(Form.this, "layout");
- layoutPolicy.layoutForm(index);
+ formLayouter.layoutForm(index);
startIndex = items.size();
}
@@ -550,7 +567,7 @@
Point p = ((Control) e.widget).toDisplay(new Point(e.x, e.y));
// translate display coordinates to composite coordinates
p = formComposite.toControl(p);
- layoutPolicy.handlePointerEvent(p.x, p.y, e.type);
+ formLayouter.handlePointerEvent(p.x, p.y, e.type);
}
}
}*/
@@ -568,7 +585,7 @@
public void widgetSelected(SelectionEvent se)
{
ScrollBar sb = (ScrollBar) se.widget;
- layoutPolicy.updateScrolling(sb.getSelection(), false);
+ formLayouter.updateScrolling(sb.getSelection(), false);
}
}
@@ -577,12 +594,12 @@
*/
void dispose()
{
+ cancelLayoutTimer();
super.dispose();
- layoutTimer.cancel();
- layoutTimer = null;
deleteAll();
- ((DefaultFormInteraction) layoutPolicy).dispose();
- layoutPolicy = null;
+ formLayouter.dispose();
+ items = null;
+ formLayouter = null;
}
/*
@@ -593,7 +610,7 @@
if((event.type & LCDUIEvent.CUSTOMITEMBIT) != 0)
{
// Synchronize with Form content modification operations.
- synchronized(layoutPolicy)
+ synchronized(formLayouter)
{
// If the eSWT widget has been explicitly disposed while the event
// was in the queue then ignore the event.
diff -r abc41079b313 -r 59b3b4473dc8 javauis/lcdui_qt/src/javax/microedition/lcdui/FormLayoutPolicy.java
--- a/javauis/lcdui_qt/src/javax/microedition/lcdui/FormLayoutPolicy.java Fri Jul 23 12:27:20 2010 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,89 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:
-*
-*/
-package javax.microedition.lcdui;
-
-abstract class FormLayoutPolicy
-{
-
- /**
- * Layouts the Form.
- *
- * @param startItem item from which to start Layout;
- */
- abstract void layoutForm(int startItem);
-
- /**
- * Set focus to an item.
- */
- abstract void setCurrentItem(Item item);
-
- /**
- * Called when Form becomes current Displayable.
- */
- abstract void handleShowCurrentEvent();
-
- /**
- * Called when Form stops being current Displayable.
- */
- abstract void handleHideCurrentEvent();
-
- /**
- * Called when Form is being resized.
- *
- * @param width new width
- * @param height new height
- */
- abstract void handleResizeEvent(int width, int height);
-
- /**
- * Handle key event.
- *
- * @param keyCode key
- * @param keyType type
- */
- abstract void handleKeyEvent(int keyCode, int keyType);
-
- /**
- * Handle pointer event.
- *
- * @param x coordinate relative to scrolledComposite
- * @param y coordinate relative to scrolledComposite
- * @param type event type: SWT.MouseDown, SWT.MouseMove, SWT.MouseUp
- */
- abstract void handlePointerEvent(int x, int y, int type);
-
- /**
- * Set scrolling of form composite.
- */
- abstract void updateScrolling(int value, boolean keyNavi);
-
- /**
- * Get the layouted conrol of an item.
- *
- * @param item item
- * @return layouted control
- */
- abstract org.eclipse.swt.widgets.Control getItemControl(Item item);
-
- /**
- * Gets layouter that can layout the specified item.
- *
- * @param item Item to be layouted.
- * @return ItemLayouter or null if no Layouter found.
- */
- abstract ItemLayouter getLayouter(Item item);
-}
diff -r abc41079b313 -r 59b3b4473dc8 javauis/lcdui_qt/src/javax/microedition/lcdui/FormLayouter.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/javauis/lcdui_qt/src/javax/microedition/lcdui/FormLayouter.java Thu Aug 05 16:07:57 2010 +0300
@@ -0,0 +1,2060 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+package javax.microedition.lcdui;
+
+import java.util.NoSuchElementException;
+import java.util.Vector;
+import java.util.Enumeration;
+import java.util.Timer;
+import java.util.TimerTask;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+
+/**
+ * FormLayouter implements form layout algorithm.
+ */
+class FormLayouter
+{
+
+ /**
+ * Form instance (not owned).
+ */
+ private Form form;
+
+ /**
+ * Form's scrolled composite (not owned).
+ */
+ protected ScrolledComposite formComposite;
+
+ /**
+ * Controls vector.
+ */
+ private Vector layoutObjects = new Vector();
+
+ /**
+ * Rows vector.
+ */
+ private Vector rows = new Vector();
+
+ /**
+ * Form's current horizontal alignment
+ */
+ private int currentHLayoutDirective;
+
+ private ImageItemLayouter imIL;
+
+ private StringItemLayouter sIL;
+
+ private GaugeLayouter gL;
+
+ private TextFieldLayouter tfL;
+
+ private DateFieldLayouter dfL;
+
+ private ChoiceGroupLayouter cgL;
+
+ private CustomItemLayouter ciL;
+
+ private SpacerLayouter sL;
+
+ private int vPosition;
+
+ private Item deferredScrollToItem;
+
+ private boolean isCurrent;
+
+ private Control itemMainControl;
+
+ private static final int NO_DIRECTION = -1;
+
+ private Item currentSelectedItem;
+
+ private int direction = NO_DIRECTION;
+
+ private boolean mousePressed;
+
+ private LayoutObject currentlyUnderMouse;
+
+
+ /**
+ * Constructor.
+ *
+ * @param form Form to perform layout on.
+ */
+ FormLayouter(Form form)
+ {
+ this.form = form;
+ formComposite = form.getFormComposite();
+ imIL = new ImageItemLayouter(this);
+ sIL = new StringItemLayouter(this);
+ gL = new GaugeLayouter(this);
+ dfL = new DateFieldLayouter(this);
+ tfL = new TextFieldLayouter(this);
+ cgL = new ChoiceGroupLayouter(this);
+ ciL = new CustomItemLayouter(this);
+ sL = new SpacerLayouter(this);
+ }
+
+ /**
+ * Dispose and cleanup layouted items.
+ */
+ void dispose()
+ {
+ ESWTUIThreadRunner.syncExec(new Runnable()
+ {
+ public void run()
+ {
+ eswtClearRows(0, null);
+ removeAllLayoutObjects();
+ rows = null;
+ layoutObjects = null;
+ }
+ });
+ }
+
+ /**
+ * Log out a control with all its children at the given indentation level.
+ */
+ void logControl(int level, Control control)
+ {
+ if(control != null)
+ {
+ String s2 = control.toString();
+ s2 = s2.substring(0, s2.indexOf('}') - 1);
+ String s3 = control.getBounds().toString();
+ s3 = s3.substring(s3.indexOf('{'));
+ Logger.verbose(Logger.indent(s2 + s3, level * 2));
+ if(control instanceof Composite)
+ {
+ Control[] arr = ((Composite) control).getChildren();
+ for(int i = 0; i < arr.length; i++)
+ {
+ logControl(level + 1, arr[i]);
+ }
+ }
+ }
+ }
+
+ /**
+ * Log out all layoutobjects for each item.
+ */
+ void logFormLayout()
+ {
+ Logger.verbose(form + " ---------------------------------------------");
+ LayoutObject lo = null;
+ Item item = null;
+ int line = -1;
+ while((lo = getNextLayoutObjectOfItem(lo, null)) != null)
+ {
+ if(lo.getOwningItem() != item)
+ {
+ item = lo.getOwningItem();
+ Logger.verbose(item.toString());
+ }
+ if(lo.getRowIdx() != line)
+ {
+ line = lo.getRowIdx();
+ }
+ Logger.verbose(Logger.indent("Row:" + lo.getRowIdx(), 2));
+ logControl(2, lo.getControl());
+ }
+ Logger.verbose(form + " ---------------------------------------------");
+ }
+
+ /**
+ * Called when Form is about to be shown.
+ * NOTE: this is called from eSWT UI-thread
+ */
+ void handleShowCurrentEvent()
+ {
+ Logger.method(this, "handleShowCurrentEvent");
+ isCurrent = true;
+
+ // restore our scrolling position (eSWT resets it to 0 by default)
+ eswtSetScrollingPosition(vPosition, true);
+
+ Item item = null;
+ LayoutObject lo = null;
+ while((lo = getNextLayoutObjectOfItem(lo, null)) != null)
+ {
+ if(lo.getOwningItem() != item)
+ {
+ // item border
+ item = lo.getOwningItem();
+ getItemLayouter(item).eswtAddListeners(item, lo);
+ }
+ }
+
+ eswtApplyCurrentFocus();
+ }
+
+ /**
+ * Called when Form is about to be hidden.
+ * NOTE: this is called from eSWT UI-thread
+ */
+ void handleHideCurrentEvent()
+ {
+ Logger.method(this, "handleHideCurrentEvent");
+ isCurrent = false;
+
+ Item item = null;
+ LayoutObject lo = null;
+ while((lo = getNextLayoutObjectOfItem(lo, null)) != null)
+ {
+ if(lo.getOwningItem() != item)
+ {
+ // item border
+ item = lo.getOwningItem();
+ getItemLayouter(item).eswtRemoveListeners(item, lo);
+ getItemLayouter(item).eswtHandleVisibilityChange(item, false);
+ }
+ }
+
+ direction = NO_DIRECTION;
+ }
+
+ /**
+ * Called when Form is beeing resized.
+ * NOTE: this is called from eSWT UI-thread
+ */
+ void handleResizeEvent(int width, int height)
+ {
+ // Logger.method(this, "handleResizeEvent");
+ int numitems = getItemCount();
+ for(int i = 0; i < numitems; i++)
+ {
+ getItem(i).invalidateCachedSizes();
+ }
+ ItemLayouter.eswtUpdateStaticShellSize(width, height);
+ }
+
+ /**
+ * Do form layout according to startIndex.
+ *
+ * @param startItem - index of item which need to be layouted.
+ */
+ void layoutForm(final int startIndex)
+ {
+ ESWTUIThreadRunner.syncExec(new Runnable()
+ {
+ public void run()
+ {
+ eswtLayoutForm(startIndex);
+ }
+ });
+ }
+
+ /**
+ * eSWT callback for doLayout().
+ */
+ void eswtLayoutForm(int startIndex)
+ {
+ int numItems = getItemCount();
+ Logger.method(this, "eswtLayoutForm", startIndex + " / " + numItems);
+
+ eswtUpdateFormComposite(false);
+ if(numItems > 0)
+ {
+ Item previousItem = null;
+ int startRowIndex = 0;
+
+ if(startIndex > 0)
+ {
+ // Find row with previous item.
+ previousItem = getItem(startIndex - 1);
+ Row prevItemRow = getLastRowOfItem(previousItem);
+ if(prevItemRow != null)
+ {
+ startRowIndex = rows.indexOf(prevItemRow);
+ }
+ }
+
+ // Clear rows starting from item - partial re-layouting
+ eswtClearRows(startRowIndex, previousItem);
+ // Layout items
+ for(int i = startIndex; i < numItems; i++)
+ {
+ eswtLayoutItem(getItem(i));
+ }
+ // Update last row
+ eswtUpdateRow(getLastRow());
+ }
+ else
+ {
+ eswtClearRows(0, null);
+ }
+ // check if we need to scroll to a particular item
+ if(deferredScrollToItem != null)
+ {
+ eswtSetCurrentItem(deferredScrollToItem);
+ deferredScrollToItem = null;
+ }
+ eswtUpdateFormComposite(true);
+ eswtHandleVisibilityChanges();
+
+ if(Logger.isLogVerbose())
+ {
+ logFormLayout();
+ }
+
+ // clear invalid selected item
+ eswtCheckCurrentSelectedItem();
+
+ if(currentSelectedItem != null
+ && (currentSelectedItem.isFocusable()))
+ {
+ eswtApplyCurrentFocus();
+ }
+ else
+ {
+ // If there's no item currently selected try to find first
+ // focusable item and set it current (if found):
+ Item found = eswtGetNextFocusableItem(
+ getItem(startIndex - 1), SWT.ARROW_RIGHT);
+ if(found != null)
+ {
+ eswtSetCurrentSelectedItem(found, NO_DIRECTION);
+ }
+ else
+ {
+ eswtApplyCurrentFocus();
+ }
+ }
+ }
+
+ /**
+ * Returns if the parameter is a eSWT directional key code.
+ *
+ * @param keyCode key code
+ */
+ private boolean isDirectionKey(int keyCode)
+ {
+ return (keyCode == SWT.ARROW_DOWN || keyCode == SWT.ARROW_UP
+ || keyCode == SWT.ARROW_LEFT || keyCode == SWT.ARROW_RIGHT);
+ }
+
+ /**
+ * Handler for key events.
+ * The implementation moves focus and/or scrolls the form when
+ * needed. The method is called by the Form.
+ *
+ * @param keyCode eSWT key code.
+ * @param keyType eSWT key type.
+ */
+ final void handleKeyEvent(int keyCode, int keyType)
+ {
+ Logger.method(this, "handleKeyEvent", currentSelectedItem,
+ String.valueOf(keyCode), String.valueOf(keyType));
+
+ boolean isDirectionalKey = isDirectionKey(keyCode);
+ if(keyType == SWT.KeyDown && isDirectionalKey)
+ {
+ eswtCheckCurrentSelectedItem();
+ }
+
+ if(currentSelectedItem != null)
+ {
+ if(getItemLayouter(currentSelectedItem).eswtOfferKeyEvent(
+ currentSelectedItem, keyCode, keyType))
+ {
+ // if the key has been consumed
+ return;
+ }
+ }
+
+ // scrolling/focus traverse only happens on directional key's down event
+ if(keyType == SWT.KeyDown && isDirectionalKey)
+ {
+ // try to find next focusable item
+ Item next = eswtGetNextFocusableItem(currentSelectedItem, keyCode);
+
+ // if no visible & focusable item was found to transfer focus
+ if(next == currentSelectedItem)
+ {
+ // try to scroll a bit
+ eswtSetScrollingPosition(getNextScrollingPosition(keyCode),
+ true);
+ // find next focusable after scrolling
+ next = eswtGetNextFocusableItem(currentSelectedItem, keyCode);
+ }
+
+ if(next != currentSelectedItem)
+ {
+ //textfield always have to be fully visible when focused.
+ if(next instanceof TextField)
+ {
+ eswtScrollToItem(next);
+ }
+ eswtSetCurrentSelectedItem(next, keyCode);
+ }
+ }
+ }
+
+ /**
+ * Handler for pointer events.
+ * The method is called by the Form.
+ *
+ * @param x coordinate relative to scrolledComposite
+ * @param y coordinate relative to scrolledComposite
+ * @param type event type: SWT.MouseDown, SWT.MouseMove, SWT.MouseUp
+ */
+ final void handlePointerEvent(int x, int y, int type)
+ {
+ Logger.method(this, "handlePointerEvent", String.valueOf(x),
+ String.valueOf(y), String.valueOf(type));
+
+ // TODO: change when DirectUI style arrives.
+ /*
+ Item item;
+ if (type == SWT.MouseMove) {
+ if (currentlyUnderMouse == null
+ || !currentlyUnderMouse.contains(x, y)) {
+ if (currentlyUnderMouse != null) {
+ //currentlyUnderMouse.getControl().setCapture(false);
+ }
+ item = eswtFindItemUnderMouse(x, y);
+ if (item != null && item != currentSelectedItem
+ && item.isFocusable()) {
+ setCurrentItem(item);
+ item.internalSetFocused(true);
+ eswtSetCurrentSelectedItem(item);
+ //following method causes all mouse events delivered to it
+
+ currentlyUnderMouse.getControl().setCapture(true);
+ Logger.warning("seting capture to:" + item);
+ }
+ }
+ int currentVPosition = getVPosition();
+ boolean isMouseDirectionUp = false;
+ boolean doScrolling = false;
+ int localY = y;
+
+ if (y <= currentVPosition) {
+ localY = Math.max(0, y);
+ eswtSetScrollingPosition(localY, true);
+ isMouseDirectionUp = true;
+ doScrolling = true;
+ }
+ else if (y > (currentVPosition + getFormHeight())) {
+ //check for maxVPosition
+ if (y > (eswtGetMaxVPosition() + getFormHeight())) {
+ localY = eswtGetMaxVPosition() + getFormHeight();
+ }
+ else {
+ localY = y;
+ }
+ currentVPosition = localY - getFormHeight();
+ eswtSetScrollingPosition(currentVPosition, true);
+
+ isMouseDirectionUp = false;
+ doScrolling = true;
+ }
+ if (mousePressed && doScrolling) {
+ resetEventTimer(isMouseDirectionUp, localY);
+ }
+ }
+ else
+ if (type == SWT.MouseDown) {
+ mousePressed = true;
+ item = eswtFindItemUnderMouse(x, y);
+ if (item != null && item != currentSelectedItem
+ && item.isFocusable() && getForm().getShell() ==
+ getForm().getShell().getDisplay().getActiveShell()) {
+ //eswtScrollToItem(item);
+ //following method causes all mouse events delivered to it
+
+ //currentlyUnderMouse.getControl().setCapture(true);
+ }
+ }
+ else if (type == SWT.MouseUp) {
+ mousePressed = false;
+ if (currentlyUnderMouse != null) {
+ //currentlyUnderMouse.getControl().setCapture(false);
+ }
+ }*/
+ }
+
+ /**
+ * Find item at the specified point.
+ *
+ * @param x coordinate.
+ * @param y coordinate.
+ * @return Item.
+ */
+ Item eswtFindItemUnderMouse(int x, int y)
+ {
+ Row itemRow;
+ for(int i = 0; i < getRowCount(); i++)
+ {
+ itemRow = getRow(i);
+ if(itemRow.getYShift() <= y && y <= itemRow.getBottomPosition())
+ {
+ LayoutObject lo;
+ for(int j = 0; j < itemRow.size(); j++)
+ {
+ lo = itemRow.getLayoutObject(j);
+ if(lo.contains(x, y))
+ {
+ Logger.info("Item under mouse: "
+ + lo.getOwningItem());
+ currentlyUnderMouse = lo;
+ return lo.getOwningItem();
+ }
+ }
+ break;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Gets next (or nearest) focusable item.
+ *
+ * @param fromItem Item where to start to search the next focusable item.
+ * @param dir Search direction, one of the arrow key constants defined
+ * in class SWT.
+ *
+ * @return Nearest focusable item or null if no item found.
+ */
+ final Item eswtGetNextFocusableItem(Item fromItem, int dir)
+ {
+ Item nextItem = fromItem;
+
+ switch(dir)
+ {
+ case SWT.ARROW_RIGHT:
+ {
+ LayoutObject obj = getLastLayoutObjectOfItem(fromItem);
+ while((obj = getNextLayoutObjectOfItem(obj, null)) != null)
+ {
+ Item owner = obj.getOwningItem();
+ if(owner != null && owner != fromItem
+ && owner.isFocusable()
+ && isPartiallyVisible(obj, Config.DFI_VISIBILITY_PERCENT))
+ {
+ nextItem = owner;
+ break;
+ }
+ }
+ break;
+ }
+
+ case SWT.ARROW_LEFT:
+ {
+ LayoutObject obj = getFirstLayoutObjectOfItem(fromItem);
+ while((obj = getPrevLayoutObjectOfItem(obj, null)) != null)
+ {
+ Item owner = obj.getOwningItem();
+ if(owner != null && owner != fromItem
+ && owner.isFocusable()
+ && isPartiallyVisible(obj, Config.DFI_VISIBILITY_PERCENT))
+ {
+ nextItem = owner;
+ break;
+ }
+ }
+ break;
+ }
+
+ case SWT.ARROW_DOWN:
+ {
+ int minDist = Integer.MAX_VALUE;
+ LayoutObject start = getLastLayoutObjectOfItem(fromItem);
+ LayoutObject obj = start;
+ while((obj = getNextLayoutObjectOfItem(obj, null)) != null)
+ {
+ Item owner = obj.getOwningItem();
+ if(owner != null && owner != fromItem
+ && owner.isFocusable() && obj.isBelow(start)
+ && isPartiallyVisible(obj, Config.DFI_VISIBILITY_PERCENT))
+ {
+ int dist = obj.distanceTo(start);
+ if(dist < minDist)
+ {
+ minDist = dist;
+ nextItem = owner;
+ }
+ }
+ }
+ break;
+ }
+
+ case SWT.ARROW_UP:
+ {
+ int minDist = Integer.MAX_VALUE;
+ LayoutObject start = getFirstLayoutObjectOfItem(fromItem);
+ LayoutObject obj = start;
+ while((obj = getPrevLayoutObjectOfItem(obj, null)) != null)
+ {
+ Item owner = obj.getOwningItem();
+ if(owner != null && owner != fromItem
+ && owner.isFocusable() && obj.isAbove(start)
+ && isPartiallyVisible(obj, Config.DFI_VISIBILITY_PERCENT))
+ {
+ int dist = obj.distanceTo(start);
+ if(dist < minDist)
+ {
+ minDist = dist;
+ nextItem = owner;
+ }
+ }
+ }
+ break;
+ }
+
+ default:
+ }
+
+ return nextItem;
+ }
+
+ /**
+ * Check if the currentSelectedItem is valid and visible. If not then it
+ * sets it to null.
+ */
+ final void eswtCheckCurrentSelectedItem()
+ {
+ if(currentSelectedItem != null)
+ {
+ if(currentSelectedItem.getParent() != getForm()
+ || !currentSelectedItem.isVisible())
+ {
+ // we need to find another
+ Logger.method(this, "eswtCheckCurrentSelectedItem");
+ eswtSetCurrentSelectedItem(null, NO_DIRECTION);
+ }
+ }
+ }
+
+ /**
+ * Sets currentSelectedItem and sets focus to it.
+ * If one of form's items is already selected when this method is called,
+ * removes focus from old item and then moves focus to new one.
+ *
+ * @param item Item to set as current selected. If null, nothing happens.
+ * @param dir Direction which is delivered to layouter.
+ */
+ void eswtSetCurrentSelectedItem(Item item, int dir)
+ {
+ if(currentSelectedItem != item)
+ {
+ Logger.info(this + "::SelectedItem: "
+ + currentSelectedItem + " --(" + dir + ")--> " + item);
+
+ // Save direction
+ direction = dir;
+ // Remove focus from currentSelectedItem and notify its Layouter.
+ if(currentSelectedItem != null)
+ {
+ getItemLayouter(currentSelectedItem).eswtFocusLost(
+ currentSelectedItem);
+ }
+
+ // Set new currentSelectedItem, must be focusable or null
+ currentSelectedItem = item;
+
+ // Set focus to currentSelectedItem and notify its Layouter.
+ if(currentSelectedItem != null)
+ {
+ getItemLayouter(currentSelectedItem).eswtFocusGained(
+ currentSelectedItem, dir);
+ }
+
+ // Apply eSWT focus to currentSelectedItem's control
+ eswtApplyCurrentFocus();
+ }
+ }
+
+ /**
+ * Sets currentSelectedItem and sets focus to it.
+ * If one of form's items is already selected when this method is called,
+ * removes focus from old item and then moves focus to new one.
+ *
+ * @param item Item to set as current selected. If null, nothing happens.
+ * @param dir Direction which is delivered to layouter.
+ */
+ void eswtSetCurrentSelectedItem(Item item)
+ {
+ if(currentSelectedItem != item)
+ {
+ Logger.info(this + "::SelectedItem: "
+ + currentSelectedItem + " ---> " + item);
+
+ // Remove focus from currentSelectedItem and notify its Layouter.
+ if(currentSelectedItem != null)
+ {
+ getItemLayouter(currentSelectedItem).eswtFocusLost(
+ currentSelectedItem);
+ }
+
+ // Set new currentSelectedItem, must be focusable or null
+ currentSelectedItem = item;
+
+ // Set focus to currentSelectedItem and notify its Layouter.
+ if(currentSelectedItem != null)
+ {
+ getItemLayouter(currentSelectedItem).eswtFocusGained(
+ currentSelectedItem, NO_DIRECTION);
+ }
+
+ // Apply eSWT focus to currentSelectedItem's control
+ //eswtApplyCurrentFocus();
+ }
+ }
+
+ /**
+ * Sets focus to currentSelectedItem's control if its partially visible.
+ * Otherwise it sets dummy focus to form's composite.
+ *
+ * Note that this method applies focus only to eSWT control. Item focus
+ * update and layouter notifications are handled in method
+ * eswtSetCurrentSelectedItem().
+ * If currentSelectedItem is null or form is not shown, this method has no
+ * effect.
+ */
+ void eswtApplyCurrentFocus()
+ {
+ if(isFormCurrent())
+ {
+ // if any of the Item's LayoutObjects is visible
+ if(isItemPartiallyVisible(currentSelectedItem))
+ {
+ Logger.method(this, "ApplyFocus", currentSelectedItem);
+ eswtSetFocusToFirstControl(currentSelectedItem);
+ }
+ else
+ {
+ Logger.method(this, "ApplyFocus", "dummy");
+ formComposite.forceFocus();
+ }
+ }
+ }
+
+ /**
+ * If the Item is valid and it is layouted, then sets the Item's first
+ * LayoutObject focused.
+ *
+ * @param item an item which first LayoutObject is set focused.
+ */
+ void eswtSetFocusToFirstControl(Item item)
+ {
+ if(item != null && item.isFocusable())
+ {
+ LayoutObject lo = getFirstLayoutObjectOfItem(item);
+ if(lo != null)
+ {
+ lo.getControl().forceFocus();
+ }
+ }
+ }
+
+ /**
+ * Gets Current selected item.
+ *
+ * @return Current selected item. May also return null.
+ */
+ Item getCurrentSelectedItem()
+ {
+ return currentSelectedItem;
+ }
+
+ /**
+ * Get the direction of scrolling.
+ *
+ * @return direction of scrolling.
+ */
+ int getDirection()
+ {
+ return direction;
+ }
+
+ /**
+ * Set focus to an item if it is focusable and scroll form to make it
+ * visible if it is not.
+ *
+ * @param item Item to set as current item.
+ */
+ void setCurrentItem(final Item item)
+ {
+ Logger.method(this, "setCurrentItem", item);
+ ESWTUIThreadRunner.syncExec(new Runnable()
+ {
+ public void run()
+ {
+ eswtSetCurrentItem(item);
+ }
+ });
+ }
+
+ /**
+ * eSWT callback for setCurrentItem.
+ */
+ boolean eswtSetCurrentItem(Item item)
+ {
+ if(item != null)
+ {
+ if(isItemLayouted(item))
+ {
+ eswtScrollToItem(item);
+ deferredScrollToItem = null;
+
+ if(item.isFocusable())
+ {
+ eswtSetCurrentSelectedItem(item, NO_DIRECTION);
+ Logger.info("eswtSetCurrentItem" + item);
+ }
+ return true;
+ }
+ else
+ {
+ deferredScrollToItem = item;
+ }
+ }
+ return false;
+ }
+
+ void eswtScrollToItem(Item item)
+ {
+ if(item != null)
+ {
+ int pos = getItemBottomPosition(item) - getFormHeight();
+ if(!isItemPartiallyVisible(item))
+ {
+ eswtSetScrollingPosition(pos, true);
+ }
+ else if(item instanceof TextField && !isItemFullyVisible(item))
+ {
+ eswtSetScrollingPosition(pos, true);
+ }
+ }
+ }
+
+ void eswtScrolltoRegion(int yTop, int yBottom, int swtDir)
+ {
+ if(yTop < vPosition || yBottom > vPosition + getFormHeight())
+ {
+ // if the region is somewhat outside the screen
+ if(swtDir == SWT.ARROW_DOWN || swtDir == SWT.ARROW_RIGHT)
+ {
+ // align to top
+ eswtSetScrollingPosition(yTop, true);
+ }
+ else
+ {
+ // align to bottom
+ eswtSetScrollingPosition(yBottom - getFormHeight(), true);
+ }
+ }
+ }
+
+ void eswtScrollIfNeeded(final int top, final int bottom)
+ {
+ if(bottom > vPosition + getFormHeight())
+ {
+ eswtSetScrollingPosition(bottom - (getFormHeight() / 2), true);
+ }
+ else if(top < vPosition)
+ {
+ eswtSetScrollingPosition(bottom - (getFormHeight() / 2), true);
+ }
+ }
+
+ /**
+ * Get control's position relative to composite.
+ */
+ void getControlPositionOnComposite(Control control, Point location)
+ {
+ if(control != formComposite)
+ {
+ Point rel = control.getLocation();
+ location.x += rel.x;
+ location.y += rel.y;
+ getControlPositionOnComposite(control.getParent(), location);
+ }
+ }
+
+ /**
+ * eSWT specific calls to do update ScrolledComposite.
+ */
+ private void eswtUpdateFormComposite(boolean show)
+ {
+ if(getRowCount() > 0)
+ {
+ if(show)
+ {
+ formComposite.updateScrollbar(getLastRow().getBottomPosition());
+ formComposite.pack();
+ }
+ }
+ // Could happen if changing item from very tall to very short.
+ // so we have to update VPosition
+ if(getVPosition() > eswtGetMaxVPosition())
+ {
+ eswtSetScrollingPosition(eswtGetMaxVPosition(), false);
+ }
+
+ formComposite.setRedraw(show);
+ formComposite.setVisible(show);
+ }
+
+ /**
+ * Clean all form rows starting from startIndex.
+ *
+ * @param startIndex Start row from which to clean.
+ * @param keepItem - item in a startRow which shouldn't be recreated.
+ */
+ private void eswtClearRows(int startIndex, Item keepItem)
+ {
+ Logger.method(this, "clearRows", String.valueOf(startIndex), keepItem);
+ Row row = null;
+ for(int i = (getRowCount() - 1); i >= startIndex; i--)
+ {
+ row = getRow(i);
+ if(row.cleanRow(keepItem))
+ {
+ break;
+ }
+ else
+ {
+ rows.removeElement(row);
+ }
+ }
+
+ // one row always should be available.
+ if((getRowCount() == 0))
+ {
+ // rows.addElement(tempRow);
+ currentHLayoutDirective = Item.LAYOUT_DEFAULT;
+ Row newRow = new Row(ItemLayouter.getMaximumItemWidth(null),
+ getCurrentHLayoutDirective());
+ rows.addElement(newRow);
+ }
+ }
+
+ /**
+ * Update Row's internal layout. Handles LAYOUT_2 related post-processing.
+ *
+ * @param row Row
+ */
+ private void eswtUpdateRow(Row row)
+ {
+ if(row != null)
+ {
+ //Logger.verbose("updateRow start: " + row);
+ int numShrink = row.getNumLayoutObjects(Item.LAYOUT_SHRINK);
+ int numExpand = row.getNumLayoutObjects(Item.LAYOUT_EXPAND);
+ //Logger.verbose("shrink: " + numShrink + " expand: " + numExpand);
+
+ int vMask = Item.LAYOUT_VSHRINK | Item.LAYOUT_VEXPAND;
+ // Expand items vertically with VSHRINK or VEXPAND layout directive
+ LayoutObject lo = null;
+ int maxHeight = row.getRowHeight(vMask);
+ while((lo = row.getNextLayoutObject(lo, vMask)) != null)
+ {
+ if(lo.getOwningItem().hasLayout(Item.LAYOUT_VSHRINK))
+ {
+ int pref = lo.getOwningItem().getPreferredHeight();
+ getItemLayouter(lo.getOwningItem()).eswtResizeObject(lo,
+ lo.getWidth(), Math.min(pref, maxHeight));
+ }
+ else if(lo.getOwningItem().hasLayout(Item.LAYOUT_VEXPAND))
+ {
+ getItemLayouter(lo.getOwningItem()).eswtResizeObject(lo,
+ lo.getWidth(), maxHeight);
+ }
+ }
+
+ // Expand items with SHRINK layout directive
+ if(numShrink > 0)
+ {
+ // Get extra space before shrink and expand
+ int offset = row.getFreeSpace() / numShrink;
+ // Logger.verbose("shrinkOffset: " + offset);
+ if(offset >= 0)
+ {
+ while((lo = row.getNextLayoutObject(lo, Item.LAYOUT_SHRINK)) != null)
+ {
+ int pref = lo.getOwningItem().getPreferredWidth();
+ int min = lo.getOwningItem().getMinimumWidth();
+ int itemWidth = Math.min(pref, min + offset);
+ getItemLayouter(lo.getOwningItem()).eswtResizeObject(lo,
+ itemWidth, lo.getHeight());
+ }
+ }
+ }
+
+ // Expand items with EXPAND layout directive
+ if(numExpand > 0)
+ {
+ // Get extra space after shrink but before expand
+ int offset = row.getFreeSpace(Item.LAYOUT_EXPAND) / numExpand;
+ if(offset >= 0)
+ {
+ // Logger.verbose("expandOffset: " + offset);
+ while((lo = row.getNextLayoutObject(lo, Item.LAYOUT_EXPAND)) != null)
+ {
+ int pref = lo.getOwningItem().getPreferredWidth();
+ getItemLayouter(lo.getOwningItem()).eswtResizeObject(lo,
+ pref + offset, lo.getHeight());
+ }
+ }
+ }
+
+ //if (numShrink > 0 || numExpand > 0) {
+ row.updateRowInternals();
+ //}
+
+ row.updateRowLayout(form.getLeftRightLanguage());
+ // Logger.verbose("updateRow: " + row);
+ }
+ }
+
+ /**
+ * Add a new Row.
+ */
+ private Row eswtAddNewRow()
+ {
+ Row lastRow = getLastRow();
+ eswtUpdateRow(lastRow);
+ int yShift = (lastRow == null ? 0 : lastRow.getBottomPosition());
+ // create new Row
+ Row newRow = new Row(ItemLayouter.getMaximumItemWidth(null),
+ getCurrentHLayoutDirective());
+ newRow.setYShift(yShift);
+ rows.addElement(newRow);
+ return newRow;
+ }
+
+ /**
+ * Add a LayoutObject to the last Row.
+ *
+ * @param layoutObject the layout object
+ */
+ void eswtAddNewLayoutObject(LayoutObject layoutObject)
+ {
+ if(!layoutObjects.contains(layoutObject))
+ {
+ layoutObjects.addElement(layoutObject);
+ }
+ Row lastRow = getLastRow();
+ // check if the current Row is full
+ if(!lastRow.isEmpty()
+ && lastRow.getFreeSpace() < layoutObject.getWidth())
+ {
+ lastRow = eswtAddNewRow();
+ }
+ lastRow.eswtAddLayoutObject(layoutObject);
+ layoutObject.setRowIdx(getRowCount() - 1);
+ }
+
+ /**
+ * Optionally add a new Row and adds a LayoutObject.
+ *
+ * @param layoutObject the layout object
+ * @param newRow adds a new row if true. If false, adds new row only if
+ * there's no space for layoutObject in current row.
+ */
+ void eswtAddNewLayoutObject(LayoutObject layoutObject, boolean newRow)
+ {
+ if(newRow)
+ {
+ eswtAddNewRow();
+ }
+ eswtAddNewLayoutObject(layoutObject);
+ }
+
+ /**
+ * Layout item in a row, if needed new row is added.
+ *
+ * @param row - where to startLayout.
+ * @param item - Item to Layout
+ */
+ private void eswtLayoutItem(Item item)
+ {
+ Row lastRow = getLastRow();
+ boolean hlChange = setCurrentHLayoutDirective(item.internalGetLayout());
+ if(hlChange || getItemNewLineBefore(item))
+ {
+ // newline directive or horizontal layout changed
+ if(lastRow.isEmpty())
+ {
+ // if the current/last row is empty - use that
+ lastRow.setRowHLayout(getCurrentHLayoutDirective());
+ }
+ else
+ {
+ eswtAddNewRow();
+ }
+ }
+
+ // Use the specific layouter to layout item in the last row
+ getItemLayouter(item).eswtLayoutItem(getLastRow(), item);
+
+ if(form.eswtIsShown())
+ {
+ LayoutObject lo = getFirstLayoutObjectOfItem(item);
+ if(lo != null)
+ {
+ getItemLayouter(item).eswtAddListeners(item, lo);
+ }
+ }
+
+ if(getItemNewLineAfter(item))
+ {
+ eswtAddNewRow();
+ }
+ }
+
+ /**
+ * Set Form's Layout directive. if it differ from current set flag
+ * startFromNewLine = true;
+ *
+ * @param newLayoutDirective
+ * @return true if a layout change has occured
+ */
+ private boolean setCurrentHLayoutDirective(int newLayoutDirective)
+ {
+ int newHLayoutDirective = Item.getHorizontalLayout(newLayoutDirective);
+ if((newHLayoutDirective != currentHLayoutDirective)
+ && (newHLayoutDirective != Item.LAYOUT_DEFAULT))
+ {
+ currentHLayoutDirective = newHLayoutDirective;
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Get Form current Layout directive.
+ *
+ * @return current Layout directive for Form.
+ */
+ private int getCurrentHLayoutDirective()
+ {
+ if(currentHLayoutDirective == Item.LAYOUT_DEFAULT)
+ {
+ return getLanguageSpecificLayoutDirective();
+ }
+ return currentHLayoutDirective;
+ }
+
+ /**
+ * Returns language specific layout directive.
+ *
+ * @return LAYOUT_LEFT or LAYOUT_RIGHT.
+ */
+ int getLanguageSpecificLayoutDirective()
+ {
+ if(form.getLeftRightLanguage())
+ {
+ return Item.LAYOUT_LEFT;
+ }
+ else
+ {
+ return Item.LAYOUT_RIGHT;
+ }
+ }
+
+ private boolean getItemNewLineBefore(Item item)
+ {
+ return ((item.internalGetLayout() & Item.LAYOUT_NEWLINE_BEFORE) != 0);
+ }
+
+ private boolean getItemNewLineAfter(Item item)
+ {
+ return ((item.internalGetLayout() & Item.LAYOUT_NEWLINE_AFTER) != 0);
+ }
+
+ boolean isItemLayouted(Item item)
+ {
+ return (getFirstLayoutObjectOfItem(item) != null);
+ }
+
+ /**
+ * Returns if the form is shown.
+ */
+ boolean isFormCurrent()
+ {
+ return isCurrent;
+ }
+
+ /**
+ * Returns if the region is partially visible.
+ *
+ * @param viewTop viewPort's top position
+ * @param viewBottom viewPort's bottom position
+ * @return true if visible
+ */
+ boolean isPartiallyVisible(int yTop, int yBottom)
+ {
+ int vBottomPosition = vPosition + getFormHeight();
+ if((vPosition <= yTop && vBottomPosition <= yTop)
+ || (vPosition >= yBottom && vBottomPosition >= yBottom))
+ {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Returns if at least the region's given percentage is visible.
+ */
+ boolean isPartiallyVisible(int yTop, int yBottom, int minPercent)
+ {
+ int visPercent = getVisibilityPercent(yTop, yBottom);
+ if(visPercent > minPercent)
+ {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Returns the region's visibility percentage.
+ */
+ int getVisibilityPercent(int yTop, int yBottom)
+ {
+ if(yTop >= yBottom)
+ {
+ return 0;
+ }
+ int vBottomPosition = vPosition + getFormHeight();
+ int r1 = Math.max(vPosition, Math.min(yTop, vBottomPosition));
+ int r2 = Math.min(vBottomPosition, Math.max(yBottom, vPosition));
+ return ((r2 - r1) * 100) / (yBottom - yTop);
+ }
+
+ /**
+ * Returns if the LayoutObject is partially visible.
+ */
+ boolean isPartiallyVisible(LayoutObject lo)
+ {
+ if(lo != null)
+ {
+ return isPartiallyVisible(lo.getY(), lo.getY() + lo.getHeight());
+ }
+ return false;
+ }
+
+ /**
+ * Returns if at least the LayoutObject's given percentage is visible.
+ */
+ boolean isPartiallyVisible(LayoutObject lo, int minPercent)
+ {
+ if(lo != null)
+ {
+ return isPartiallyVisible(lo.getY(), lo.getY() + lo.getHeight(),
+ minPercent);
+ }
+ return false;
+ }
+
+ /**
+ * Returns if the Item is partially visible (if one of its LayoutObjects is
+ * partially visible).
+ *
+ * @param item the Item
+ * @return true if partially visible
+ */
+ boolean isItemPartiallyVisible(Item item)
+ {
+ if(item != null)
+ {
+ LayoutObject lo = null;
+ while((lo = getNextLayoutObjectOfItem(lo, item)) != null)
+ {
+ if(isPartiallyVisible(lo))
+ {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+
+
+ /**
+ * Returns true if item is fully visible.
+ *
+ * @param item the Item.
+ * @return true if fully visible.
+ */
+ boolean isItemFullyVisible(Item item)
+ {
+ if(item != null)
+ {
+ LayoutObject lo = null;
+ while((lo = getNextLayoutObjectOfItem(lo, item)) != null)
+ {
+ if(!isLOFullyVisible(lo))
+ {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Returns if the LayoutObject is fully visible.
+ */
+ boolean isLOFullyVisible(LayoutObject lo)
+ {
+ if(lo != null)
+ {
+ return isFullyVisible(lo.getY(), lo.getY() + lo.getHeight());
+ }
+ return false;
+ }
+
+ /**
+ * Returns if the region is fully visible.
+ *
+ * @param viewTop viewPort's top position
+ * @param viewBottom viewPort's bottom position
+ * @return true if visible
+ */
+ boolean isFullyVisible(int yTop, int yBottom)
+ {
+ int vBottomPosition = vPosition + getFormHeight();
+ if((vPosition <= yTop && vBottomPosition >= yBottom))
+ {
+ return true;
+ }
+ return false;
+ }
+
+ int getItemTopPosition(Item item)
+ {
+ LayoutObject lo = getFirstLayoutObjectOfItem(item);
+ if(lo != null)
+ {
+ return lo.getY();
+ }
+ return 0;
+ }
+
+ int getItemBottomPosition(Item item)
+ {
+ LayoutObject lo = getLastLayoutObjectOfItem(item);
+ if(lo != null)
+ {
+ return lo.getY() + lo.getHeight();
+ }
+ return 0;
+ }
+
+ int getItemCount()
+ {
+ return form.size();
+ }
+
+ Item getItem(int index)
+ {
+ try
+ {
+ return (Item) form.getItems().elementAt(index);
+ }
+ catch(ArrayIndexOutOfBoundsException e)
+ {
+ // Logger.exception(e);
+ return null;
+ }
+ }
+
+ int getItemIndex(Item item)
+ {
+ return form.getItems().indexOf(item);
+ }
+
+ int getRowCount()
+ {
+ return rows.size();
+ }
+
+ /**
+ * Return the Row with the given index.
+ *
+ * @param index Row's index
+ * @return a Row
+ */
+ Row getRow(int index)
+ {
+ try
+ {
+ return (Row) rows.elementAt(index);
+ }
+ catch(ArrayIndexOutOfBoundsException e)
+ {
+ Logger.exception("getRow", e);
+ return null;
+ }
+ }
+
+ /**
+ * Return the Row to which the given LayoutObject belongs.
+ *
+ * @param lo LayoutObject
+ * @return the owning Row
+ */
+ Row getRow(LayoutObject lo)
+ {
+ try
+ {
+ return getRow(lo.getRowIdx());
+ }
+ catch(NullPointerException e)
+ {
+ // Logger.exception("getRow", e);
+ return null;
+ }
+ }
+
+ /**
+ * Returns the last row of the form.
+ */
+ Row getLastRow()
+ {
+ try
+ {
+ return (Row) rows.lastElement();
+ }
+ catch(NoSuchElementException nse)
+ {
+ // Logger.exception("getLastRow", nse);
+ return null;
+ }
+ }
+
+ /**
+ * Find last row which contains corresponding Item.
+ *
+ * @param item Item in a Row.
+ * @return Last Row with that item.
+ */
+ Row getLastRowOfItem(Item item)
+ {
+ return getRow(getLastLayoutObjectOfItem(item));
+ }
+
+ /**
+ * Get Form which requires layout.
+ *
+ * @return form.
+ */
+ Form getForm()
+ {
+ return form;
+ }
+
+ /**
+ * Form's content height.
+ */
+ int getFormHeight()
+ {
+ return form.getHeight();
+ }
+
+ /**
+ * Form's content width.
+ */
+ int getFormWidth()
+ {
+ return form.getWidth();
+ }
+
+ /**
+ * Returns LayoutObject for the given Item.
+ *
+ * @param item Item to layout
+ * @return LayoutObject
+ */
+ LayoutObject getLayoutObject(Item item)
+ {
+ int num = layoutObjects.size();
+
+ for(int i = 0; i < num; i++)
+ {
+ if(((LayoutObject)layoutObjects.elementAt(i)).getOwningItem() == item)
+ {
+ LayoutObject lo = (LayoutObject)(layoutObjects.elementAt(i));
+ lo.setRowIdx(-1);
+ return lo;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Removes Layout Object for the given Item.
+ *
+ * @param item Item to remove LayoutObject
+ */
+ void removeLayoutObject(Item item)
+ {
+
+ int num = layoutObjects.size();
+
+ for(int i = 0; i < num; i++)
+ {
+ if(((LayoutObject)layoutObjects.elementAt(i)).getOwningItem() == item)
+ {
+ LayoutObject lo = (LayoutObject)(layoutObjects.elementAt(i));
+ layoutObjects.removeElement(lo);
+ lo.dispose();
+ break;
+ }
+ }
+ }
+
+ /**
+ * Removes all Layout Objects from the FormLayouter.
+ */
+ void removeAllLayoutObjects()
+ {
+ Enumeration e = layoutObjects.elements();
+
+ while(e.hasMoreElements())
+ {
+ LayoutObject lo = (LayoutObject)e.nextElement();
+ layoutObjects.removeElement(lo);
+ lo.dispose();
+ }
+ }
+
+ /**
+ * Returns the next LayoutObject belonging to this Item.
+ *
+ * @param lo starting LayoutObject; if null then it start from first.
+ * @param item specifies the parent Item; null means any Item
+ * @return the next LayoutObject in the layout.
+ */
+ LayoutObject getNextLayoutObjectOfItem(LayoutObject lo, Item item)
+ {
+ int startRow = (lo == null ? 0 : lo.getRowIdx());
+ LayoutObject temp = null;
+ for(int i = startRow; i < getRowCount(); i++)
+ {
+ temp = getRow(i).getNextLayoutObject(lo, item);
+ if(temp != null && temp != lo)
+ {
+ return temp;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns the previous LayoutObject belonging to this Item.
+ *
+ * @param lo starting LayoutObject; if null then it start from last.
+ * @param item specifies the parent Item; null means any Item
+ * @return the previous LayoutObject in the layout.
+ */
+ LayoutObject getPrevLayoutObjectOfItem(LayoutObject lo, Item item)
+ {
+ int startRow = (lo == null ? rows.size() - 1 : lo.getRowIdx());
+ LayoutObject temp = null;
+ for(int i = startRow; i >= 0; i--)
+ {
+ temp = getRow(i).getPrevLayoutObject(lo, item);
+ if(temp != null && temp != lo)
+ {
+ return temp;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns the first LayoutObject of a layouted item.
+ *
+ * @param item
+ * @return the LO, or NULL if the item is not layouted
+ */
+ LayoutObject getFirstLayoutObjectOfItem(Item item)
+ {
+ if(item != null)
+ {
+ return getNextLayoutObjectOfItem(null, item);
+ }
+ return null;
+ }
+
+ /**
+ * Returns the last LayoutObject of a layouted item.
+ *
+ * @param item
+ * @return the LO, or NULL if the item is not layouted
+ */
+ LayoutObject getLastLayoutObjectOfItem(Item item)
+ {
+ if(item != null)
+ {
+ return getPrevLayoutObjectOfItem(null, item);
+ }
+ return null;
+ }
+
+ /**
+ * Update item state in form.
+ *
+ * @param item
+ * @param updateReason
+ * @param param additional parameter
+ */
+ void updateItemState(Item item, int updateReason, Object param)
+ {
+ Logger.method(this, "updateItemState", item,
+ String.valueOf(updateReason), param);
+
+ LayoutObject lo = getFirstLayoutObjectOfItem(item);
+
+ if(lo != null)
+ {
+ getItemLayouter(item).updateItem(item, lo.getControl(), updateReason,
+ param);
+ }
+
+ // Clean reason - without resizing flags
+ int reason = updateReason & Item.UPDATE_SIZE_MASK;
+ switch(reason)
+ {
+ case Item.UPDATE_ADDCOMMAND:
+ {
+ if(isFormCurrent() && param != null)
+ {
+ if(lo != null && param instanceof Command)
+ {
+ lo.addCommand((Command) param);
+ }
+ }
+ break;
+ }
+ case Item.UPDATE_REMOVECOMMAND:
+ {
+ if(isFormCurrent() && param != null)
+ {
+ if(lo != null && param instanceof Command)
+ {
+ lo.removeCommand((Command) param);
+ }
+ }
+ break;
+ }
+ }
+
+ // Check this always - because this is a flag
+ if((updateReason & Item.UPDATE_HEIGHT_CHANGED)
+ == Item.UPDATE_HEIGHT_CHANGED)
+ {
+ resizeItemAndShift(item);
+ }
+ }
+
+ int eswtGetMaxVPosition()
+ {
+ return formComposite.getSize().y - getFormHeight();
+ }
+
+ /**
+ * Called by key Form to compute new vertical coordinate to position form's
+ * content.
+ *
+ * @param swtDir scrolling direction.
+ * @return New vertical position of Form's content.
+ */
+ protected int getNextScrollingPosition(int swtDir)
+ {
+ boolean scrollDown = (swtDir == SWT.ARROW_DOWN
+ || swtDir == SWT.ARROW_RIGHT);
+ int formHeight = getFormHeight();
+ int refPoint;
+ int ret = vPosition;
+ if(scrollDown)
+ {
+ ret += formHeight / 5;
+ refPoint = (vPosition + 1) + formHeight;
+ }
+ else
+ {
+ ret -= formHeight / 5;
+ refPoint = (vPosition - 1);
+ }
+
+ Row row = null;
+ for(int i = 0; i < getRowCount(); i++)
+ {
+ row = getRow(i);
+ if(row.isInsideRow(refPoint)
+ && (row.getRowHeight() < formHeight))
+ {
+ if(scrollDown)
+ {
+ ret = row.getBottomPosition() - formHeight;
+ }
+ else
+ {
+ ret = row.getYShift();
+ }
+ break;
+ }
+ }
+
+ return ret;
+ }
+
+ /**
+ * Set the scrolling to the specified position.
+ * This method also updates the Form's scrollbars.
+ *
+ * @param position new position
+ */
+ void eswtSetScrollingPosition(int position, boolean keyNav)
+ {
+ // check constraints
+ int newVPosition = position;
+ int maxVPos = eswtGetMaxVPosition();
+ newVPosition = Math.min(newVPosition, maxVPos);
+ newVPosition = Math.max(newVPosition, 0);
+
+ vPosition = newVPosition;
+ formComposite.setRedraw(false);
+ formComposite.setOrigin(0, vPosition, keyNav);
+ formComposite.pack();
+ formComposite.setRedraw(true);
+
+ eswtHandleVisibilityChanges();
+ }
+
+ /**
+ * Returns the scrolling position.
+ */
+ protected int getScrollingPosition()
+ {
+ return vPosition;
+ }
+
+ /**
+ * Updates visibility status of all items.
+ */
+ protected void eswtHandleVisibilityChanges()
+ {
+ // Logger.method(this, "eswtHandleVisibilityChanges");
+ boolean shown = false;
+ Item item = null;
+ LayoutObject lo = null;
+ // Go through all LayoutObjects and check/update visibilities
+ while((lo = getNextLayoutObjectOfItem(lo, null)) != null)
+ {
+ // check if owning item is changing
+ if(lo.getOwningItem() != item)
+ {
+ if(item != null)
+ {
+ // set current item's visibility
+ getItemLayouter(item).eswtHandleVisibilityChange(item, shown);
+ }
+ // new item
+ item = lo.getOwningItem();
+ shown = false;
+ }
+
+ // track current item's visibility
+ if(!shown && isFormCurrent() && isPartiallyVisible(lo))
+ {
+ shown = true;
+ }
+ }
+
+ // call it for last item
+ if(item != null)
+ {
+ getItemLayouter(item).eswtHandleVisibilityChange(item, shown);
+ }
+
+ eswtCheckCurrentSelectedItem();
+ }
+
+ /**
+ * Changes item size and does shift of all Rows.
+ *
+ * @param item - item to changeSize.
+ */
+ void resizeItemAndShift(final Item item)
+ {
+ ESWTUIThreadRunner.syncExec(new Runnable()
+ {
+ public void run()
+ {
+ int newVPosition = eswtResizeItemAndShift(item);
+ if(newVPosition != vPosition)
+ {
+ eswtSetScrollingPosition(newVPosition, true);
+ }
+ else
+ {
+ eswtHandleVisibilityChanges();
+ }
+ }
+ });
+ }
+
+ /**
+ * eSWT callback for resizeItemAndShift.
+ *
+ * @param item Item to be resized.
+ * @return new scrolling vPosition
+ */
+ int eswtResizeItemAndShift(Item item)
+ {
+ // save the state of the last row before resizing and Shifting.
+ boolean itemWasVisible = isItemPartiallyVisible(item);
+ Row row = getLastRowOfItem(item);
+ int deltaYShift = row.getRowHeight();
+ // if we un-comment this then when we set true,
+ // focus will jump to first item.
+ // eswtUpdateFormComposite(false);
+ LayoutObject lo = getFirstLayoutObjectOfItem(item);
+ if(lo != null)
+ {
+ getItemLayouter(item).eswtResizeObject(lo);
+ }
+
+ eswtUpdateRow(row);
+
+ /*
+ // to avoid double call of updateRowInternals
+ if (row.getNumLayoutObjects(Item.LAYOUT_SHRINK) > 0
+ || row.getNumLayoutObjects(Item.LAYOUT_EXPAND) > 0) {
+ eswtUpdateRow(row);
+ }
+ else {
+ row.updateRowInternals();
+ }
+ */
+ deltaYShift = row.getRowHeight() - deltaYShift;
+ // row's height change - all remaining rows are shifted with this.
+
+ Row lastRow = getLastRow();
+ if(row != lastRow)
+ {
+ for(int i = rows.indexOf(row) + 1; i < getRowCount(); i++)
+ {
+ row = getRow(i);
+ row.setYShift(row.getYShift() + deltaYShift);
+ eswtUpdateRow(row);
+ }
+ }
+
+ // following code updates scrolling if needed.
+ // need to check where in the form resize happeneed.
+
+ int itemRowYShift = getLastRowOfItem(item).getYShift();
+ // vPosition should be changed in syncexec
+ int newVPosition = vPosition;
+
+ // we need to scroll only if changes happened above the screen.
+ if(newVPosition >= itemRowYShift)
+ {
+ newVPosition = Math.max(0, newVPosition + deltaYShift);
+ }
+ // check to avoid gap in the bottom of the form
+ if(newVPosition + getFormHeight() > lastRow.getBottomPosition())
+ {
+ newVPosition = Math.max(0,
+ lastRow.getBottomPosition() - getFormHeight());
+ }
+
+ eswtUpdateFormComposite(true);
+
+ // formComposite.pack();
+ // formComposite.updateScrollbarSize(lastRow.getBottomPosition());
+
+ if(item == currentSelectedItem)
+ {
+ if(itemWasVisible)
+ {
+ int itemTop = getItemTopPosition(item);
+ int itemBottom = getItemBottomPosition(item);
+ // currentSelectedItem has to be focused if it was focused
+ // before resizing e.g TextField when it is resized by adding a
+ // new row and it was in the bottom of the Screen.
+ if(newVPosition <= itemTop
+ && (newVPosition + getFormHeight()) >= itemBottom)
+ {
+ // do not change vPosition;
+ }
+ else if(newVPosition > itemTop)
+ {
+ newVPosition = itemTop;
+ }
+ else if((newVPosition + getFormHeight()) < itemBottom)
+ {
+ newVPosition = itemBottom - getFormHeight();
+ }
+ }
+ }
+ return newVPosition;
+ }
+
+ /**
+ * Gets layouter that can layout the specified item.
+ *
+ * @param item Item to be layouted.
+ * @return ItemLayouter or null if no Layouter found.
+ */
+ protected final ItemLayouter getItemLayouter(Item item)
+ {
+ if(item instanceof StringItem)
+ {
+ return sIL;
+ }
+ else if(item instanceof ImageItem)
+ {
+ return imIL;
+ }
+ else if(item instanceof Gauge)
+ {
+ return gL;
+ }
+ else if(item instanceof TextField)
+ {
+ return tfL;
+ }
+ else if(item instanceof DateField)
+ {
+ return dfL;
+ }
+ else if(item instanceof ChoiceGroup)
+ {
+ return cgL;
+ }
+ else if(item instanceof CustomItem)
+ {
+ return ciL;
+ }
+ else if(item instanceof Spacer)
+ {
+ return sL;
+ }
+ return null;
+ }
+
+ /**
+ * Returns eSWT Control that represents the item specified.
+ */
+ Control getItemControl(final Item item)
+ {
+ final LayoutObject lo = getFirstLayoutObjectOfItem(item);
+ if(lo != null)
+ {
+ ESWTUIThreadRunner.syncExec(new Runnable()
+ {
+ public void run()
+ {
+ itemMainControl = getItemLayouter(item)
+ .eswtFindSpecificControl(item, lo.getControl());
+ }
+ });
+ return itemMainControl;
+ }
+ return null;
+ }
+
+ void updateScrolling(final int value, final boolean keyNav)
+ {
+ Logger.method("updateScrolling", String.valueOf(value));
+ ESWTUIThreadRunner.syncExec(new Runnable()
+ {
+ public void run()
+ {
+
+ eswtSetScrollingPosition(value, keyNav);
+
+ }
+ });
+ }
+
+ /**
+ * Get current scrolling value.
+ *
+ * @return vPosition.
+ */
+ int getVPosition()
+ {
+ return vPosition;
+ }
+
+
+ private Timer eventTimer = new Timer();
+ private EventGeneratorTask eventTask;
+
+ /**
+ * Reset timer for do layout with a given start index.
+ */
+ private void resetEventTimer(boolean directionUp, int y)
+ {
+ if(eventTimer != null)
+ {
+ if(eventTask != null)
+ {
+ eventTask.cancel();
+ eventTask = null;
+ }
+ // schedule new timer
+ eventTask = new EventGeneratorTask(directionUp, y);
+ eventTimer.schedule(eventTask, Config.DFI_EVENT_TIMER_DELAY);
+ }
+ }
+
+ /**
+ * Form Timer task. Triggers the formComposite to Layout.
+ */
+ class EventGeneratorTask extends TimerTask
+ {
+
+ private boolean isUpDirection;
+ private int localY;
+
+ public EventGeneratorTask(boolean direction, int y)
+ {
+ isUpDirection = direction;
+ localY = y;
+ Logger.info("y is " + localY);
+ }
+
+ public void run()
+ {
+ if(isUpDirection)
+ {
+ localY -= Config.DFI_EVENT_MOVE_DELTA;
+ }
+ else
+ {
+ localY += Config.DFI_EVENT_MOVE_DELTA;
+ }
+ handlePointerEvent(0, localY, SWT.MouseMove);
+ }
+ }
+
+}
diff -r abc41079b313 -r 59b3b4473dc8 javauis/lcdui_qt/src/javax/microedition/lcdui/Gauge.java
--- a/javauis/lcdui_qt/src/javax/microedition/lcdui/Gauge.java Fri Jul 23 12:27:20 2010 +0300
+++ b/javauis/lcdui_qt/src/javax/microedition/lcdui/Gauge.java Thu Aug 05 16:07:57 2010 +0300
@@ -23,7 +23,6 @@
*/
public class Gauge extends Item
{
-
/**
* Indefinite constant.
*/
@@ -49,6 +48,13 @@
*/
public static final int INCREMENTAL_UPDATING = 3;
+ /**
+ * If Gauge is changed, reasons for Re-layouting.
+ */
+ static final int UPDATE_MAXVALUE = UPDATE_ITEM_MAX << 1;
+ static final int UPDATE_VALUE = UPDATE_ITEM_MAX << 2;
+
+
private int maxValue;
private int value;
private boolean interactive;
@@ -147,7 +153,7 @@
* that requires eSWT extension.
*/
this.value = checkValue(value, this.maxValue);
- updateParent(UPDATE_CONTENT);
+ updateParent(UPDATE_VALUE);
}
/**
@@ -169,7 +175,7 @@
{
this.maxValue = checkMaxValue(maxValue, interactive);
this.value = checkValue(getValue(), this.maxValue);
- updateParent(UPDATE_CONTENT);
+ updateParent(UPDATE_MAXVALUE);
}
/**
diff -r abc41079b313 -r 59b3b4473dc8 javauis/lcdui_qt/src/javax/microedition/lcdui/GaugeLayouter.java
--- a/javauis/lcdui_qt/src/javax/microedition/lcdui/GaugeLayouter.java Fri Jul 23 12:27:20 2010 +0300
+++ b/javauis/lcdui_qt/src/javax/microedition/lcdui/GaugeLayouter.java Thu Aug 05 16:07:57 2010 +0300
@@ -38,11 +38,11 @@
/**
* Constructor.
*
- * @param dflp DefaultFormLayoutPolicy
+ * @param aFormLayouter FormLayouter used for layouting.
*/
- GaugeLayouter(DefaultFormLayoutPolicy dflp)
+ GaugeLayouter(FormLayouter aFormLayouter)
{
- super(dflp);
+ super(aFormLayouter);
}
/**
diff -r abc41079b313 -r 59b3b4473dc8 javauis/lcdui_qt/src/javax/microedition/lcdui/ImageItem.java
--- a/javauis/lcdui_qt/src/javax/microedition/lcdui/ImageItem.java Fri Jul 23 12:27:20 2010 +0300
+++ b/javauis/lcdui_qt/src/javax/microedition/lcdui/ImageItem.java Thu Aug 05 16:07:57 2010 +0300
@@ -26,7 +26,6 @@
*/
public class ImageItem extends Item
{
-
/**
* Left here for source compatibility purposes. Use layout directives from
* Item class instead.
@@ -63,6 +62,13 @@
*/
public static final int LAYOUT_NEWLINE_AFTER = Item.LAYOUT_NEWLINE_AFTER;
+ /**
+ * If ImageItem is changed, reasons for Re-layouting.
+ */
+ static final int UPDATE_ALTTEXT = UPDATE_ITEM_MAX << 1;
+ static final int UPDATE_IMAGE = UPDATE_ITEM_MAX << 2;
+
+
private Image image;
private int appearanceMode;
private String alternateText;
@@ -129,8 +135,12 @@
*/
public void setImage(Image image)
{
+ if((image == null) && (this.image == null))
+ {
+ return;
+ }
this.image = image;
- updateParent(UPDATE_SIZE_CHANGED);
+ updateParent(UPDATE_IMAGE | UPDATE_SIZE_CHANGED);
}
/**
@@ -151,7 +161,7 @@
public void setAltText(String newAltText)
{
alternateText = newAltText;
- updateParent(UPDATE_SIZE_CHANGED);
+ updateParent(UPDATE_ALTTEXT);
}
/**
@@ -173,6 +183,44 @@
}
/**
+ * Adds command to this ImageItem. If same command is already added to this item,
+ * nothing happens.
+ *
+ * @param command A command to be added.
+ * @throws NullPointerException if cmd is null.
+ */
+ public void addCommand(Command command)
+ {
+ int numCmds = getNumCommands();
+
+ super.addCommand(command);
+
+ if((getNumCommands() != numCmds) && (getNumCommands() == 1))
+ {
+ updateParent(UPDATE_SIZE_CHANGED);
+ }
+ }
+
+ /**
+ * Removes command from the ImageItem. If command doesn't exists in this item,
+ * nothing happens.
+ *
+ * @param command The command to be removed.
+ */
+ public void removeCommand(Command command)
+ {
+ int numCmds = getNumCommands();
+
+ super.removeCommand(command);
+
+ if((getNumCommands() != numCmds) && (getNumCommands() == 0))
+
+ {
+ updateParent(UPDATE_SIZE_CHANGED);
+ }
+ }
+
+ /**
* Calculates minimum size of this item.
*
* @return Minimum size.
diff -r abc41079b313 -r 59b3b4473dc8 javauis/lcdui_qt/src/javax/microedition/lcdui/ImageItemLayouter.java
--- a/javauis/lcdui_qt/src/javax/microedition/lcdui/ImageItemLayouter.java Fri Jul 23 12:27:20 2010 +0300
+++ b/javauis/lcdui_qt/src/javax/microedition/lcdui/ImageItemLayouter.java Thu Aug 05 16:07:57 2010 +0300
@@ -18,7 +18,6 @@
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.*;
import org.eclipse.ercp.swt.mobile.CaptionedControl;
@@ -31,29 +30,28 @@
/**
* Constructor.
*
- * @param dflp - DefaultFormLayoutPolicy used for layouting.
+ * @param aFormLayouter FormLayouter used for layouting.
*/
- ImageItemLayouter(DefaultFormLayoutPolicy dflp)
+ ImageItemLayouter(FormLayouter aFormLayouter)
{
- super(dflp);
- }
-
- int eswtGetLabelAlignmentDirective()
- {
- return Item.LAYOUT_BOTTOM;
+ super(aFormLayouter);
}
/**
- * Layout Item in a row.
+ * Creates LayoutObject for the given Item.
*
- * @param row current Row
* @param item Item to layout
+ * @return LayoutObject
*/
- void eswtLayoutItem(Row row, Item item)
+ LayoutObject getLayoutObject(Item item)
{
- LayoutObject lo = new LayoutObject(item, eswtGetControl(formComposite, item));
- dfi.eswtAddNewLayoutObject(lo);
- }
+ LayoutObject lo = formLayouter.getLayoutObject(item);
+ if(lo == null)
+ {
+ lo = new LayoutObject(item, eswtGetControl(formComposite, item));
+ }
+ return lo;
+ }
/**
* Creates the eSWT CaptionedControl or Composite for this item.
@@ -61,10 +59,7 @@
Control eswtGetControl(Composite parent, Item item)
{
Control ret = eswtCreateControl(parent, item);
- Point size = new Point(0,0);
- size.x = item.getLayoutWidth();
- size.y = item.getLayoutHeight();
- eswtCaptionedResize(item, ret, size.x, size.y);
+ eswtCaptionedResize(item, ret, item.getLayoutWidth(), item.getLayoutHeight());
return ret;
}
@@ -73,18 +68,22 @@
*/
static Control eswtCreateControl(Composite parent, Item item)
{
- if(item.hasLabel())
- {
- CaptionedControl captioned = new CaptionedControl(parent, SWT.VERTICAL);
- captioned.setText(item.getLabel());
- eswtSpecificControl(captioned, item);
- return captioned;
- }
- else
- {
- Control ret = eswtSpecificControl(parent, item);
- return ret;
- }
+ CaptionedControl captioned = new CaptionedControl(parent, SWT.VERTICAL);
+ if(item.hasLabel())
+ {
+ captioned.setText(item.getLabel());
+ }
+
+ if(((ImageItem)item).getImage() != null)
+ {
+ eswtSpecificControl(captioned, item);
+ }
+ else
+ {
+ updateControlSize(null, captioned, (ImageItem)item);
+ }
+
+ return captioned;
}
/**
@@ -94,38 +93,10 @@
{
ImageItem imgItem = (ImageItem) item;
- if(item.getNumCommands() == 0)
+ if(imgItem.getNumCommands() == 0)
{
Label imageLabel = new Label(parent, SWT.CENTER);
- imageLabel.setImage(Image.getESWTImage(imgItem.getImage()));
- imageLabel.pack();
- int imageWidth = imageLabel.getBounds().width;
- int imageHeight = imageLabel.getBounds().height;
- int maxWidth = getMaximumItemWidth(item);
- if(imageWidth > maxWidth)
- {
- Point size = imageLabel.computeSize(maxWidth, SWT.DEFAULT);
- //Image Resize has to be done.
- imageLabel.setSize(size.x, size.y);
- imageWidth = size.x;
- imageHeight = size.y;
- }
-
- if(imgItem.hasLabel())
- {
- int labelWidth = Font.getDefaultFont().stringWidth(imgItem.getLabel());
-
- if(labelWidth > imageWidth)
- {
- Point size = parent.computeSize(Math.min(labelWidth, maxWidth), SWT.DEFAULT);
- parent.setSize(size.x, size.y);
- }
- else
- {
- parent.pack();
- }
- }
-
+ constructLabel(imageLabel, parent, imgItem);
return imageLabel;
}
else
@@ -143,54 +114,176 @@
button = new Button(parent, SWT.FLAT | SWT.NONE);
break;
}
- button.setImage(Image.getESWTImage(imgItem.getImage()));
- button.pack();
- int buttonWidth = button.getBounds().width;
- int buttonHeight = button.getBounds().height;
- int maxWidth = getMaximumItemWidth(item);
- if(buttonWidth > maxWidth)
- {
- Point size = button.computeSize(maxWidth, SWT.DEFAULT);
- //Image Resize has to be done.
- button.setSize(size.x, size.y);
- buttonWidth = size.x;
- buttonHeight = size.y;
- }
-
- if(imgItem.hasLabel())
- {
- int labelWidth = Font.getDefaultFont().stringWidth(imgItem.getLabel());
-
- if(labelWidth > buttonWidth)
- {
- Point size = parent.computeSize(Math.min(labelWidth, maxWidth), SWT.DEFAULT);
- parent.setSize(size.x, size.y);
- }
- else
- {
- parent.pack();
- }
- }
-
+ constructButton(button, parent, imgItem);
return button;
}
}
+ static private void constructLabel(Label imageLabel, Composite parent, ImageItem imgItem)
+ {
+ imageLabel.setImage(Image.getESWTImage(imgItem.getImage()));
+ imageLabel.pack();
+ updateControlSize(imageLabel, parent, imgItem);
+ }
+
+ static private void constructButton(Button button, Composite parent, ImageItem imgItem)
+ {
+ button.setImage(Image.getESWTImage(imgItem.getImage()));
+ button.pack();
+ updateControlSize(button, parent, imgItem);
+ }
+
+ static private void updateControlSize(Control control, Composite parent, ImageItem imgItem)
+ {
+ int controlWidth;
+ int controlHeight;
+ int maxWidth = getMaximumItemWidth(imgItem);
+
+ if(control != null)
+ {
+ controlWidth = control.getBounds().width;
+ controlHeight = control.getBounds().height;
+
+ if(controlWidth > maxWidth)
+ {
+ //Image Resize has to be done.
+ Point size = control.computeSize(maxWidth, SWT.DEFAULT);
+ control.setSize(size.x, size.y);
+ controlWidth = size.x;
+ controlHeight = size.y;
+ }
+ }
+ else
+ {
+ controlWidth = maxWidth;
+ }
+
+ if(imgItem.hasLabel())
+ {
+ int labelWidth = Font.getDefaultFont().stringWidth(imgItem.getLabel());
+
+ if(labelWidth > controlWidth)
+ {
+ Point size = parent.computeSize(Math.min(labelWidth, maxWidth), SWT.DEFAULT);
+ parent.setSize(size.x, size.y);
+ return;
+ }
+ }
+ else if(control == null)
+ {
+ parent.setSize(0, 0);
+ return;
+ }
+
+ parent.pack();
+ }
+
/**
* Returns if this eSWT control is Layouter specific.
*/
boolean eswtIsSpecificControl(Item item, Control control)
{
- // No implementation needed
return ((control instanceof Label) || (control instanceof Button));
}
/**
* Updates the values of ImageItem.
*/
- void eswtUpdateItem(Item item, Control control, int reason, Object param)
+ void eswtUpdateItem(Item item, Control control, int aReason, Object param)
{
- // No implementation needed
+ if(!(control instanceof CaptionedControl))
+ {
+ return;
+ }
+
+ ImageItem imgItem = (ImageItem)item;
+ int reason = aReason & Item.UPDATE_SIZE_MASK;
+
+ switch(reason)
+ {
+ case Item.UPDATE_NONE:
+ case ImageItem.UPDATE_ALTTEXT:
+ break;
+
+ case Item.UPDATE_LABEL:
+ {
+ String label = imgItem.getLabel();
+ if(label == null)
+ {
+ label = "";
+ }
+
+ ((CaptionedControl)control).setText(label);
+ Control sCtrl = eswtFindSpecificControl(imgItem, control);
+ updateControlSize(sCtrl, (Composite)control, imgItem);
+ break;
+ }
+
+ case ImageItem.UPDATE_IMAGE:
+ {
+ Control sCtrl = eswtFindSpecificControl(imgItem, control);
+ if(sCtrl != null)
+ {
+ if(imgItem.getImage() != null)
+ {
+ if(sCtrl instanceof Label)
+ {
+ constructLabel((Label)sCtrl, (Composite)control, imgItem);
+ }
+ else if(sCtrl instanceof Button)
+ {
+ constructButton((Button)sCtrl, (Composite)control, imgItem);
+ }
+ }
+ else
+ {
+ sCtrl.dispose();
+ updateControlSize(null, (Composite)control, imgItem);
+ }
+ }
+ else
+ {
+ if(imgItem.getImage() != null)
+ {
+ eswtSpecificControl((Composite)control, imgItem);
+ }
+ }
+ break;
+ }
+
+ case Item.UPDATE_ADDCOMMAND:
+ {
+ Control sCtrl = eswtFindSpecificControl(imgItem, control);
+ if(sCtrl != null)
+ {
+ if((sCtrl instanceof Label) && (imgItem.getNumCommands()==1))
+ {
+ sCtrl.dispose();
+ eswtSpecificControl((Composite)control, imgItem);
+ }
+ }
+ }
+ break;
+
+ case Item.UPDATE_REMOVECOMMAND:
+ {
+ Control sCtrl = eswtFindSpecificControl(imgItem, control);
+ if(sCtrl != null)
+ {
+ if((sCtrl instanceof Button) && (imgItem.getNumCommands()==0))
+ {
+ sCtrl.dispose();
+ eswtSpecificControl((Composite)control, imgItem);
+ }
+ }
+ }
+ break;
+
+ default:
+ {
+ break;
+ }
+ }
}
/**
diff -r abc41079b313 -r 59b3b4473dc8 javauis/lcdui_qt/src/javax/microedition/lcdui/Item.java
--- a/javauis/lcdui_qt/src/javax/microedition/lcdui/Item.java Fri Jul 23 12:27:20 2010 +0300
+++ b/javauis/lcdui_qt/src/javax/microedition/lcdui/Item.java Thu Aug 05 16:07:57 2010 +0300
@@ -17,6 +17,7 @@
package javax.microedition.lcdui;
import java.util.Vector;
+import java.lang.ref.WeakReference;
import javax.microedition.lcdui.EventDispatcher.LCDUIEvent;
import com.nokia.mj.impl.nokialcdui.ItemControlStateChangeListener;
@@ -136,35 +137,27 @@
static final int LAYOUT_VERTICAL_MASK = LAYOUT_VCENTER; // 48;
-
- static final int UPDATE_NONE = 0;
-
- static final int UPDATE_ADDCOMMAND = 1;
-
- static final int UPDATE_REMOVECOMMAND = 2;
-
/**
- * Item content has changed. Re-layouting not needed.
+ * If Item is changed, reasons for Re-layouting.
*/
- static final int UPDATE_CONTENT = 3; // general update value
-
- static final int UPDATE_REASON_MASK = 255;
+ static final int UPDATE_NONE = 0;
- /**
- * Item height has changed. Re-layouting not needed.
- */
- static final int UPDATE_HEIGHT_CHANGED = 256;
+ static final int UPDATE_ADDCOMMAND = 1;
+ static final int UPDATE_REMOVECOMMAND = 1 << 1;
+ static final int UPDATE_DEFAULTCOMMAND = 1 << 2;
+ static final int UPDATE_ITEMCOMMANDLISTENER = 1 << 3;
+ static final int UPDATE_LABEL = 1 << 4;
+ static final int UPDATE_LAYOUT = 1 << 5;
+ static final int UPDATE_PREFERREDSIZE = 1 << 6;
- /**
- * Item width is changed. Re-layouting asap.
- */
- static final int UPDATE_WIDTH_CHANGED = 512;
-
- /**
- * Item width and height changed. Re-layouting asap.
- */
+ static final int UPDATE_HEIGHT_CHANGED = 1 << 7;
+ static final int UPDATE_WIDTH_CHANGED = 1 << 8;
static final int UPDATE_SIZE_CHANGED =
UPDATE_HEIGHT_CHANGED | UPDATE_WIDTH_CHANGED;
+ static final int UPDATE_SIZE_MASK = ~UPDATE_SIZE_CHANGED;
+
+ static final int UPDATE_ITEM_MAX = 1 << 15;
+
private String label;
@@ -177,7 +170,7 @@
private ItemControlStateChangeListener controlListener;
private Command defaultCommand;
- private Screen parent;
+ private WeakReference wParent;
private int layout;
private int lockedPrefWidth = -1;
@@ -191,11 +184,18 @@
/**
* Sets the parent of this Item.
- * @param parent new Parent. If null, current parent is removed.
+ * @param parent new Parent. If null, current parent is to be removed.
*/
void setParent(Screen parent)
{
- this.parent = parent;
+ if(parent != null)
+ {
+ wParent = new WeakReference(parent);
+ }
+ else
+ {
+ clearParent();
+ }
}
/**
@@ -205,7 +205,27 @@
*/
Screen getParent()
{
- return parent;
+ if(wParent != null)
+ {
+ return (Screen)wParent.get();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ /**
+ * Clears the Item's parent.
+ *
+ */
+ void clearParent()
+ {
+ if(wParent != null)
+ {
+ wParent.clear();
+ wParent = null;
+ }
}
/**
@@ -221,8 +241,12 @@
throw new IllegalStateException(
MsgRepository.ITEM_EXCEPTION_OWNED_BY_ALERT);
}
+ if((newLabel == null) && (label == null))
+ {
+ return;
+ }
label = newLabel;
- updateParent(UPDATE_SIZE_CHANGED);
+ updateParent(UPDATE_LABEL | UPDATE_SIZE_CHANGED);
}
/**
@@ -276,7 +300,7 @@
}
layout = newLayout;
Logger.method(this, "setLayout", String.valueOf(layout));
- updateParent(UPDATE_SIZE_CHANGED);
+ updateParent(UPDATE_LAYOUT | UPDATE_SIZE_CHANGED);
}
/**
@@ -302,19 +326,7 @@
if(!commands.contains(command))
{
commands.addElement(command);
-
- int reason = UPDATE_ADDCOMMAND;
-
- if(this instanceof StringItem && commands.size() == 1)
- {
- reason |= UPDATE_SIZE_CHANGED;
- }
- if(this instanceof ImageItem && commands.size() == 1)
- {
- reason |= UPDATE_SIZE_CHANGED;
- }
-
- updateParent(reason, command);
+ updateParent(UPDATE_ADDCOMMAND, command);
}
}
@@ -332,21 +344,11 @@
{
// Remove command from commands-vector
commands.removeElement(command);
-
- defaultCommand = null;
-
- int reason = UPDATE_REMOVECOMMAND;
-
- if(this instanceof StringItem && commands.size() == 0)
- {
- reason |= UPDATE_SIZE_CHANGED;
- }
- if(this instanceof ImageItem && commands.size() == 0)
- {
- reason |= UPDATE_SIZE_CHANGED;
- }
-
- updateParent(reason, command);
+ if(defaultCommand == command)
+ {
+ defaultCommand = null;
+ }
+ updateParent(UPDATE_REMOVECOMMAND, command);
}
}
@@ -519,7 +521,7 @@
Logger.method(this, "setPrefSize",
String.valueOf(lockedPrefWidth),
String.valueOf(lockedPrefHeight));
- updateParent(UPDATE_SIZE_CHANGED);
+ updateParent(UPDATE_PREFERREDSIZE | UPDATE_SIZE_CHANGED);
}
/**
@@ -568,7 +570,7 @@
MsgRepository.ITEM_EXCEPTION_NOT_OWNED_BY_FORM);
}
// Notify item state listener
- ((Form) parent).notifyItemStateChanged(this);
+ ((Form) getParent()).notifyItemStateChanged(this);
}
/**
@@ -628,7 +630,7 @@
*/
boolean isContainedInAlert()
{
- return (parent != null && parent instanceof Alert);
+ return ((wParent != null) && (getParent() instanceof Alert));
}
/**
@@ -636,7 +638,7 @@
*/
boolean isContainedInForm()
{
- return (parent != null && parent instanceof Form);
+ return ((wParent != null) && (getParent() instanceof Form));
}
/**
@@ -670,7 +672,7 @@
}
if(isContainedInForm())
{
- ((Form) parent).updateItemState(this, updateReason, param);
+ ((Form) getParent()).updateItemState(this, updateReason, param);
}
}
diff -r abc41079b313 -r 59b3b4473dc8 javauis/lcdui_qt/src/javax/microedition/lcdui/ItemLayouter.java
--- a/javauis/lcdui_qt/src/javax/microedition/lcdui/ItemLayouter.java Fri Jul 23 12:27:20 2010 +0300
+++ b/javauis/lcdui_qt/src/javax/microedition/lcdui/ItemLayouter.java Thu Aug 05 16:07:57 2010 +0300
@@ -36,11 +36,11 @@
/**
* Key name for paint listener.
*/
- private static final String FOCUS_LISTENER = "itemfocus";
+ private static final String FOCUS_LISTENER = "FocusListener";
protected static final String MIN_TEXT = "...";
- protected DefaultFormInteraction dfi;
+ protected FormLayouter formLayouter;
protected Composite formComposite;
@@ -112,12 +112,12 @@
/**
* Constructor.
*
- * @param dflp - DefaultFormLayoutPolicy used for layouting.
+ * @param aFormLayouter FormLayouter used for layouting.
*/
- ItemLayouter(DefaultFormLayoutPolicy dflp)
+ ItemLayouter(FormLayouter aFormLayouter)
{
- this.dfi = (DefaultFormInteraction) dflp;
- formComposite = dflp.getForm().getFormComposite();
+ formLayouter = aFormLayouter;
+ formComposite = formLayouter.getForm().getFormComposite();
ESWTUIThreadRunner.syncExec(new Runnable()
{
public void run()
@@ -132,7 +132,7 @@
*/
int eswtGetLabelAlignmentDirective()
{
- return dfi.getLanguageSpecificLayoutDirective();
+ return formLayouter.getLanguageSpecificLayoutDirective();
}
/**
@@ -143,8 +143,8 @@
*/
void eswtLayoutItem(Row row, Item item)
{
- LayoutObject lo = new LayoutObject(item, eswtGetCaptionedControl(item));
- dfi.eswtAddNewLayoutObject(lo);
+ LayoutObject lo = getLayoutObject(item);
+ formLayouter.eswtAddNewLayoutObject(lo);
if(item instanceof CustomItem)
{
ItemControlStateChangeListener listener = item.getItemControlStateChangeListener();
@@ -157,6 +157,22 @@
}
/**
+ * Creates LayoutObject for the given Item.
+ *
+ * @param item Item to layout
+ * @return LayoutObject
+ */
+ LayoutObject getLayoutObject(Item item)
+ {
+ LayoutObject lo = formLayouter.getLayoutObject(item);
+ if(lo == null)
+ {
+ lo = new LayoutObject(item, eswtGetCaptionedControl(item));
+ }
+ return lo;
+ }
+
+ /**
* Wraps this item's control in the necessary composites.
* Based on the item, the result of this method can be:
*
render the document on an internal SVG buffer (iSvg)
- *
alpha-blend it with the bound graphics target (iGraphicsBitmap)
- *
- * @note if transparency factor is not set, iSvg is simply blitted onto iGraphicsTarget
- *
- * @param aSvgDocumentHandle handle to SVG document
- * @param aCurrentTime the current time of the animation
- * @param aSvgW Svg image viewport width
- * @param aSvgH Svg image viewport height
- * @param aRect contains position about the rendered area
- * @since S60 3.1
- */
-
-
- virtual void RenderLCDUIL(
- TM2GSvgDocumentHandle& aSvgDocHandle,
- const TReal32 aCurrentTime,
- TInt aSvgW,
- TInt aSvgH,
- TM2GRenderRect& aRect) = 0 ;
-
- virtual void RenderESWTL(
- TM2GSvgDocumentHandle& aSvgDocHandle,
- const TReal32 aCurrentTime,
- TInt aSvgW,
- TInt aSvgH,
- TM2GRenderRect& aRect,
- TBool aUseNativeClear,
- TInt* aReturnData) = 0;
-
- /**
- * Sets render quality
- * @since Series S60 3.1
- * @param aMode Mode
- * @throws exception if not ok
- */
- virtual void SetRenderingQualityL(TInt aMode) = 0;
-
- /**
- * Sets transparency
- * @since Series S60 3.1
- * @param aAlpha Alpha factor
- * @throws exception if not ok
- */
- virtual void SetTransparency(TReal32 aAlpha) = 0;
-
-};
-
-M2G_NS_END
-#endif // MM2GRENDERCONTEXT_H
diff -r abc41079b313 -r 59b3b4473dc8 javauis/m2g_qt/inc/MM2GSVGProxy.h
--- a/javauis/m2g_qt/inc/MM2GSVGProxy.h Fri Jul 23 12:27:20 2010 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,854 +0,0 @@
-/*
-* Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: SVGTopt proxy interface
-*
-*/
-
-#ifndef MM2GSVGPROXY_H
-#define MM2GSVGPROXY_H
-
-// INCLUDES
-#include "M2GUtils.h"
-
-M2G_NS_START
-
-// CONSTANTS
-
-// MACROS
-
-// DATA TYPES
-
-// FUNCTION PROTOTYPES
-
-// FORWARD DECLARATIONS
-
-// CLASS DECLARATION
-/**
- * Interface class
- */
-class MM2GSVGProxy
-{
-public: // METHODS
-
- /**
- * Dtor
- */
- virtual ~MM2GSVGProxy() {};
-
- /**
- * Add close to the given path.
- * @since Series S60 3.1
- * @param aPathHandle Path handle.
- * @throws exception if not ok
- */
- virtual void AddCloseL(const TM2GSvgPathHandle& aPathHandle) = 0;
-
- /**
- * Add curve to the given path.
- * @since Series S60 3.1
- * @param aPathHandle Path handle.
- * @param aPathCurveData Curve data
- * @throws exception if not ok
- */
- virtual void AddCurveToL(
- const TM2GSvgPathHandle& aPathHandle,
- const TM2GPathCurveData& aPathCurveData) = 0;
-
- /**
- * Add line to the given path.
- * @since Series S60 3.1
- * @param aPathHandle Path handle.
- * @param aX -
- * @param aY -
- * @throws exception if not ok
- */
- virtual void AddLineToL(
- const TM2GSvgPathHandle& aPathHandle,
- const TReal32& aX, const TReal32& aY) = 0;
- /**
- * Add move to the given path.
- * @since Series S60 3.1
- * @param aPathHandle Path handle.
- * @param aX -
- * @param aY -
- * @throws exception if not ok
- */
- virtual void AddMoveToL(
- const TM2GSvgPathHandle& aPathHandle,
- const TReal32& aX, const TReal32& aY) = 0;
-
- /**
- * Add quad to the given path.
- * @since Series S60 3.1
- * @param aPathHandle Path handle.
- * @param aX1 -
- * @param aY1 -
- * @param aX2 -
- * @param aY2 -
- * @throws exception if not ok
- */
- virtual void AddQuadToL(
- const TM2GSvgPathHandle& aPathHandle,
- const TReal32& aX1, const TReal32& aY1,
- const TReal32& aX2, const TReal32& aY2) = 0;
-
- /**
- * Append child
- * @since Series S60 3.1
- * @param aElementHandle
- * @param aChildElementHandle
- * @throws exception if not ok
- */
- virtual void AppendChildL(
- const TM2GSvgElementHandle& aElementHandle,
- const TM2GSvgElementHandle& aChildElementHandle) = 0;
-
- /**
- * Set the begin animation time for the given element.
- * @since Series S60 3.1
- * @param aDocumentHandle
- * @param aElementHandle
- * @param aOffset
- * @throws exception if not ok
- */
- virtual void BeginElementAtL(
- const TM2GSvgDocumentHandle& aDocumentHandle,
- const TM2GSvgElementHandle& aElementHandle,
- const TReal32& aOffset) = 0;
-
- /**
- * Check if element is removable
- * @since Series S60 3.1
- * @param aSurfaceHandle
- * @param aRemoveable Result
- * @throws exception if not ok
- */
- virtual void CheckRemoveableL(
- const TM2GSvgElementHandle& aElementHandle,
- TInt& aRemoveable) = 0;
-
-
- /**
- * Clear svg surface
- * @since Series S60 3.1
- * @param aSurfaceHandle Surface handle
- * @throws exception if not ok
- */
- virtual void ClearSvgSurfaceL(const TM2GSvgDocumentHandle& aSurfaceHandle) = 0;
-
- /**
- * Create document
- * @since Series S60 3.1
- * @param aData Document content
- * @param aDocumentHandle Document handle to be returned
- * @throws exception if not ok
- */
- virtual void CreateDocumentL(
- const TPtrC16& aData,
- TM2GSvgDocumentHandle& aDocumentHandle) = 0;
-
- /**
- * Create svg engine
- * @since Series S60 3.1
- * @param aEngineHandle Svg engine handle
- * @throws exception if not ok
- */
- virtual void CreateSvgEngineL(TM2GSvgEngineHandle& aEngineHandle) = 0;
-
- /**
- * Create path
- * @since Series S60 3.1
- * @param aPathHandle Path handle to be returned
- * @throws exception if not ok
- */
- virtual void CreatePathL(TM2GSvgPathHandle& aPathHandle) = 0;
-
- /**
- * Create svg surface
- * @since Series S60 3.1
- * @param aWidth Surface width
- * @param aHeight Surface height
- * @return Svg surface
- * @throws exception if not ok
- */
- virtual TM2GBitmapHandle CreateSvgSurfaceL(TInt aWidth, TInt aHeight) = 0;
-
- /**
- * Create new element
- * @since Series S60 3.1
- * @param aType Element type id
- * @param aParentHandle Parent of the new element.
- * Note: Can be '0' if element is not added to DOM.
- * @param aDocumentHandle Document handle.
- * @param aRootHandle Root element handle.
- * @param aEngineHandle Element handle to be returned
- * @throws exception if not ok
- */
- virtual void CreateElementNsL(
- const TM2GSvgAttrType& aType,
- const TM2GSvgDocumentHandle& aDocumentHandle,
- TM2GSvgElementHandle& aEngineHandle) = 0;
-
- /**
- * Delete document
- * @since Series S60 3.1
- * @param aDocumentHandle Document handle
- * @throws exception if not ok
- */
- virtual void DeleteDocumentL(const TM2GSvgDocumentHandle& aDocumentHandle) = 0;
-
- /**
- * Delete svg engine
- * @since Series S60 3.1
- * @param aEngineHandle Engine handle
- * @throws exception if not ok
- */
- virtual void DeleteSvgEngineL(const TM2GSvgEngineHandle& aEngineHandle) = 0;
-
- /**
- * Deletes svg surface
- * @since Series S60 3.1
- * @param aSurfaceHandle Surface handle
- * @throws exception if not ok
- */
- virtual void DeleteSvgSurfaceL(const TM2GSvgDocumentHandle& aSurfaceHandle) = 0;
-
- /**
- * Delete path
- * @since Series S60 3.1
- * @param aPathHandle Path handle
- * @throws exception if not ok
- */
- virtual void DestroyPathL(const TM2GSvgPathHandle& aPathHandle) = 0;
-
- /**
- * Dispatches a mouse event
- * @since Series S60 3.1
- * @param aDocumentHandle Document handle.
- * @param aX X coordinate.
- * @param aY Y coordinate
- * @param aElementHandle Target element handle
- * @throws exception if not ok
- */
- virtual void DispatchMouseEventL(
- const TM2GSvgDocumentHandle& aDocumentHandle,
- TInt aX, TInt aY, TM2GSvgElementHandle& aElementHandle) = 0;
-
- /**
- * Set the end animation time for the given element.
- * @since Series S60 3.1
- * @param aDocumentHandle
- * @param aElementHandle
- * @param aOffset
- * @throws exception if not ok
- */
- virtual void EndElementAtL(
- const TM2GSvgDocumentHandle& aDocumentHandle,
- const TM2GSvgElementHandle& aElementHandle,
- const TReal32& aOffset) = 0;
-
-
- /**
- * Set focus on.
- * @since Series S60 3.1
- * @param aDocumentHandle
- * @param aElementHandle
- * @throws exception if not ok
- */
- virtual void FocusOnL(
- const TM2GSvgDocumentHandle& aDocumentHandle,
- const TM2GSvgElementHandle& aElementHandle) = 0;
-
- /**
- * Set focus out.
- * @since Series S60 3.1
- * @param aDocumentHandle
- * @param aElementHandle
- * @throws exception if not ok
- */
- virtual void FocusOutL(
- const TM2GSvgDocumentHandle& aDocumentHandle,
- const TM2GSvgElementHandle& aElementHandle) = 0;
-
- /**
- * Get a bounding box
- * @since Series S60 3.1
- * @param aElementHandle Element handle.
- * @param aAttributeType Attribute type
- * @param aRectData Rect components are saved to this parameter
- * @param aResult Result
- * @throws exception if not ok
- */
- virtual void GetBBoxL(
- const TM2GSvgElementHandle& aElementHandle,
- const TM2GSvgAttrType& aAttributeType,
- TM2GRectData& aRectData, TInt& aResult) = 0;
-
- /**
- * Get colors
- * @since Series S60 3.1
- * @param aElementHandle Element handle
- * @param aAttributeType Attribute type
- * @param aColor Result
- * @param aResult Extra result info
- * @throws exception if not ok
- */
- virtual void GetColorTraitL(
- const TM2GSvgElementHandle& aElementHandle,
- const TM2GSvgAttrType& aAttributeType,
- TM2GColorData& aColor,
- TInt& aResult) = 0;
-
- /**
- * Get element by id
- * @since Series S60 3.1
- * @param aDocumentHandle Document handle.
- * @param aId Element id
- * @param aElementHandle Element handle to be returned
- * @throws exception if not ok
- */
- virtual void GetElementByIdL(
- const TM2GSvgDocumentHandle& aDocumentHandle,
- const TPtrC16& aId,
- TM2GSvgElementHandle& aElementHandle) = 0;
-
- /**
- * Get element by id
- * @since Series S60 3.1
- * @param aElementHandle Element handle.
- * @param aId Result element type id.
- * @throws exception if not ok
- */
- virtual void GetElementTypeIdL(const TM2GSvgElementHandle& aElementHandle, TInt16& aId) = 0;
-
- /**
- * Get an enumeration value of the specified attribute.
- * @since Series S60 3.1
- * @param aElementHandle Element handle.
- * @param aAttributeType Attribute type
- * @param aEnumTraiT Enum attribute.
- * @throws exception if not ok
- */
- virtual void GetEnumTraitL(
- const TM2GSvgElementHandle& aElementHandle,
- const TM2GSvgAttrType& aAttributeType,
- TInt16& aEnumTrait) = 0;
-
- /**
- * Get external list item
- * @since Series S60 3.1
- * @param aDocumentHandle Document handle.
- * @param aIndex Index.
- * @param aItem Returns external item according to a given index
- * @return KErrNone if no error
- * @throws Exception if not ok
- */
- virtual TInt GetExternalListItemL(
- const TM2GSvgDocumentHandle& aDocumentHandle,
- TInt aIndex,
- TPtrC16& aItem) = 0;
-
- /**
- * Get external list size
- * @since Series S60 3.1
- * @param aDocumentHandle Document handle.
- * @param aListSz Size.
- * @throws exception if not ok
- */
- virtual void GetExternalListSizeL(
- const TM2GSvgDocumentHandle& aDocumentHandle,
- TInt& aListSz) = 0;
-
- /**
- * Get a first chlid element
- * @since Series S60 3.1
- * @param aElementHandle Element handle.
- * @param aChildHandle Returns child element handle.
- * @throws exception if not ok
- */
- virtual void GetFirstElementChildL(
- const TM2GSvgElementHandle& aElementHandle,
- TM2GSvgElementHandle& aChildHandle) = 0;
-
- /**
- * Get a float trait
- * @since Series S60 3.1
- * @param aElementHandle Element handle.
- * @param aAttributeType Attribute type
- * @param Float trait
- * @throws exception if not ok
- */
- virtual void GetFloatTraitL(
- const TM2GSvgElementHandle& aElementHandle,
- const TM2GSvgAttrType& aAttributeType,
- TReal32& aFloatTrait) = 0;
-
- /**
- * Get a matrix trait
- * @since Series S60 3.1
- * @param aElementHandle Element handle.
- * @param aAttributeType Attribute type
- * @param aMatrix Matrix trait
- * @param aResult
- * @throws exception if not ok
- */
- virtual void GetMatrixTraitL(
- const TM2GSvgElementHandle& aElementHandle,
- const TM2GSvgAttrType& aAttributeType,
- TM2GMatrixData& aMatrix, TInt& aResult) = 0;
-
- /**
- * Get a media time
- * @since Series S60 3.1
- * @param aDocumentHandle Document handle.
- * @param aSeconds Media time to be returned
- * @throws exception if not ok
- */
- virtual void GetMediaTimeL(
- const TM2GSvgDocumentHandle& aDocumentHandle,
- TReal32& aSeconds) = 0;
-
- /**
- * Get a next element sibling
- * @since Series S60 3.1
- * @param aElementHandle Element handle.
- * @param aSiblingElementHandle Sibling handle
- * @throws exception if not ok
- */
- virtual void GetNextElementSiblingL(
- const TM2GSvgElementHandle& aElementHandle,
- TM2GSvgElementHandle& aSiblingElementHandle) = 0;
-
- /**
- * Get the segment count for the given path.
- * @since Series S60 3.1
- * @param aPathHandle Path handle.
- * @param aNumberOfSegments Segment count
- * @throws exception if not ok
- */
- virtual void GetNumberOfSegmentsL(
- const TM2GSvgPathHandle& aPathHandle,
- TInt& aNumberOfSegments) = 0;
-
- /**
- * Get a parent
- * @since Series S60 3.1
- * @param aElementHandle Element handle.
- * @param aParentElementHandle Parent Element handle
- * @throws exception if not ok
- */
- virtual void GetParentL(
- const TM2GSvgElementHandle& aElementHandle,
- TM2GSvgElementHandle& aParentElementHandle) = 0;
-
- /**
- * Get a path trait
- * @since Series S60 3.1
- * @param aElementHandle Element handle.
- * @param aAttributeType Attribute type
- * @param aPathTrait Path trait
- * @throws exception if not ok
- */
- virtual void GetPathTraitL(
- const TM2GSvgElementHandle& aElementHandle,
- const TM2GSvgAttrType& aAttributeType,
- TInt& aPathTrait) = 0;
-
- /**
- * Get a rect trait
- * @since Series S60 3.1
- * @param aElementHandle Element handle.
- * @param aAttributeType Attribute type
- * @param aRectData Rect components are saved to this parameter
- * @param aResult Result
- * @throws exception if not ok
- */
- virtual void GetRectTraitL(
- const TM2GSvgElementHandle& aElementHandle,
- const TM2GSvgAttrType& aAttributeType,
- TM2GRectData& aRectData, TInt& aResult) = 0;
-
- /**
- * Get a root element
- * @since Series S60 3.1
- * @param aDocumentHandle Document handle.
- * @param aRootElementHandle Root element handle
- * @throws exception if not ok
- */
- virtual void GetRootElementL(
- const TM2GSvgDocumentHandle& aDocumentHandle,
- TM2GSvgElementHandle& aRootElementHandle) = 0;
-
- /**
- * Get screen b box
- * @since Series S60 3.1
- * @param aElementHandle Element handle
- * @param aScreenBBoxData Screen box data out
- * @throws exception if not ok
- */
- virtual void GetScreenBBoxL(
- const TM2GSvgElementHandle& aElementHandle,
- TM2GScreenBBoxData& aScreenBBoxData) = 0;
-
- /**
- * Get the segment parameter for the given path.
- * @since Series S60 3.1
- * @param aPathHandle Path handle.
- * @param aSegmentIndex -
- * @param aParamIndex -
- * @param aSegmentParam Segment parameter to be returned.
- * @throws exception if not ok
- */
- virtual void GetSegmentParameterL(
- const TM2GSvgPathHandle& aPathHandle,
- TInt aSegmentIndex, TInt aParamIndex,
- TReal32& aSegmentParam) = 0;
-
- /**
- * Get the segment type for the given path.
- * @since Series S60 3.1
- * @param aPathHandle Path handle.
- * @param aSegmentIndex -
- * @param aSegmentType Segment type
- * @throws exception if not ok
- */
- virtual void GetSegmentTypeL(
- const TM2GSvgPathHandle& aPathHandle,
- TInt aSegmentIndex,
- TInt16& aSegmentType) = 0;
-
- /**
- * Get a string trait
- * @since Series S60 3.1
- * @param aElementHandle Element handle.
- * @param aAttributeType Attribute type.
- * @param aStr Returns a string attribute
-
- * @throws exception if not ok
- */
- virtual TInt GetStringTraitL(
- const TM2GSvgElementHandle& aElementHandle,
- const TM2GSvgAttrType& aAttributeType,
- TPtrC16& aStr) = 0;
- /**
- * Get a svg surface height
- * @since Series S60 3.1
- * @param aSurfaceHandle Surface handle.
- * @return Svg surface height
- * @throws exception if not ok
- */
- virtual TInt GetSvgSurfaceHeightL(const TM2GBitmapHandle& aSurfaceHandle) = 0;
-
- /**
- * Get a svg surface width
- * @since Series S60 3.1
- * @param aSurfaceHandle Surface handle.
- * @return Svg surface width
- * @throws exception if not ok
- */
- virtual TInt GetSvgSurfaceWidthL(const TM2GBitmapHandle& aSurfaceHandle) = 0;
-
- /**
- * Finds handle to the actual cloned element
- * @since Series S60 3.1
- * @param aElementHandle Element handle.
- * @param aHandle Element handle to be returned
- * @throws exception if not ok
- */
- virtual void GetUsedFromElementL(
- const TM2GSvgElementHandle& aElementHandle,
- TM2GSvgElementHandle& aHandle) = 0;
-
- /**
- * Viewport height.
- * @since Series S60 3.1
- * @param aDocumentHandle Document handle.
- * @param aHeight Wieport height to be returned.
- * @throws exception if not ok
- */
- virtual void GetViewportHeightL(
- const TM2GSvgDocumentHandle& aDocumentHandle,
- TInt& aHeight) = 0;
-
- /**
- * Viewport width.
- * @since Series S60 3.1
- * @param aDocumentHandle Document handle.
- * @param aWidth Viewport width.
- * @throws exception if not ok
- */
- virtual void GetViewportWidthL(
- const TM2GSvgDocumentHandle& aDocumentHandle,
- TInt& aWidth) = 0;
-
- /**
- * Init native engine & document
- * @since Series S60 3.1
- * @param aDocumentHandle Document handle
- * @throws exception if not ok
- */
- virtual void InitViewportL(
- const TM2GSvgDocumentHandle& aDocumentHandle) = 0;
-
- /**
- * Add given child element to the given element before
- * the given reference element.
- * @since Series S60 3.1
- * @param aElementHandle Element handle.
- * @param aNewChildElementHandle Child element handle.
- * @param aReferenceElementHandle Child element handle.
- * @throws exception if not ok
- */
- virtual void InsertBeforeL(
- const TM2GSvgElementHandle& aElementHandle,
- const TM2GSvgElementHandle& aNewChildElementHandle,
- const TM2GSvgElementHandle& aReferenceElementHandle) = 0;
-
- /**
- * Check if element is active.
- * @since Series S60 3.1
- * @param aElementHandle Element handle.
- * @param aActive Return "1" if active
- * @throws exception if not ok
- */
- virtual void IsActiveL(
- const TM2GSvgElementHandle& aElementHandle,
- TInt& aActive) = 0;
-
- /**
- * Checks if an element in DOM.
- * @since Series S60 3.1
- * @param aDocumentHandle Document handle.
- * @param aElementHandle Element handle.
- * @param aIsElementInDom Result.
- * @throws exception if not ok
- */
- virtual void IsElementInDomL(
- const TM2GSvgDocumentHandle& aDocumentHandle,
- const TM2GSvgElementHandle& aElementHandle,
- TInt& aIsElementInDom) = 0;
-
- /**
- * Checks whether this element is child of a use element
- * @since Series S60 3.1
- * @param aElementHandle Element handle.
- * @param aResult Return "1" if used otherwise returns "0"
- * @throws exception if not ok
- */
- virtual void IsUsedL(
- const TM2GSvgElementHandle& aElementHandle,
- TInt& aResult) = 0;
-
- /**
- * Remove child
- * @since Series S60 3.1
- * @param aDocumentHandle Document handle.
- * @param aURI Uri
- * @param aResourceData Resource
- * @param aHandle Removed element handle
- * @throws exception if not ok
- */
- virtual void RemoveChildL(
- const TM2GSvgElementHandle& aElementHandle,
- const TM2GSvgElementHandle& aChildElementHandle,
- TM2GSvgElementHandle& aHandle) = 0;
- /**
- * Render document
- * @since Series S60 3.1
- * @param aEngineHandle Engine handle.
- * @param aDocumentHandle Document handle.
- * @param aSurfaceHandle Surface.
- * @param aSurfaceMaskHandle Mask.
- * @throws exception if not ok
- */
- virtual void RenderDocumentL(
- const TM2GSvgEngineHandle& aEngineHandle,
- const TM2GSvgDocumentHandle& aDocumentHandle,
- const TM2GBitmapHandle& aSurfaceHandle,
- TM2GBitmapHandle aSurfaceMaskHandle,
- TReal32 aCurrentTime) = 0;
-
-// pankaj Qimage related changes TODO following Changes done
- virtual void RenderDocumentL(
- const TM2GSvgEngineHandle& aEngineHandle,
- const TM2GSvgDocumentHandle& aDocumentHandle,
- const TM2GSvgBitmapHandle& aSurfaceHandle,
- TM2GSvgBitmapHandle aSurfaceMaskHandle,
- TReal32 aCurrentTime)=0;
-
- /**
- * Sets render quality
- * @since Series S60 3.1
- * @param aEngineHandle Engine handle.
- * @param aQuality Quality.
- * @throws exception if not ok
- */
- virtual void RenderQualityL(
- const TM2GSvgEngineHandle& aEngineHandle,
- TInt aQuality) = 0;
-
- /**
- * Request completed
- * @since Series S60 3.1
- * @param aDocumentHandle Document handle.
- * @param aURI -
- * @param aResourceData -
- * @param aCompeleted Result
- * @throws exception if not ok
- */
- virtual void RequestCompletedL(
- const TM2GSvgDocumentHandle& aDocumentHandle,
- const TPtrC16& aURI,
- const TPtrC8& aResourceData,
- TInt& aCompleted) = 0;
-
- /**
- * Set color trait
- * @since Series S60 3.1
- * @param aElementHandle Element handle.
- * @param aAttributeType Attribute type
- * @param aColor Color components: RGB
- * @throws exception if not ok
- */
- virtual void SetColorTraitL(
- const TM2GSvgElementHandle& aElementHandle,
- const TM2GSvgAttrType& aAttributeType,
- const TM2GColorData& aColor) = 0;
-
- /**
- * Set enum trait
- * @since Series S60 3.1
- * @param aElementHandle Element handle.
- * @param aAttributeType Attribute type
- * @param aValue Value
- * @throws exception if not ok
- */
- virtual void SetEnumTraitL(
- const TM2GSvgElementHandle& aElementHandle,
- const TM2GSvgAttrType& aAttributeType,
- TInt16 aValue) = 0;
-
- /**
- * Set float attribute
- * @since Series S60 3.1
- * @param aElementHandle Element handle.
- * @param aAttributeType Attribute type
- * @param aValue Value
- * @throws exception if not ok
- */
- virtual void SetFloatTraitL(
- const TM2GSvgElementHandle& aElementHandle,
- const TM2GSvgAttrType& aAttributeType,
- const TReal32& aValue) = 0;
-
- /**
- * Set matrix attribute
- * @since Series S60 3.1
- * @param aElementHandle Element handle.
- * @param aAttributeType Attribute type
- * @param aMatrix -
- * @throws exception if not ok
- */
- virtual void SetMatrixTraitL(
- const TM2GSvgElementHandle& aElementHandle,
- const TM2GSvgAttrType& aAttributeType,
- const TM2GMatrixData& aMatrix) = 0;
-
- /**
- * Set media time
- * @since Series S60 3.1
- * @param aDocumentHandle Document handle.
- * @param aSeconds Media time
- * @throws exception if not ok
- */
- virtual void SetMediaTimeL(
- const TM2GSvgDocumentHandle& aDocumentHandle,
- const TReal32& aSeconds) = 0;
-
- /**
- * Set path attribute
- * @since Series S60 3.1
- * @param aElementHandle Element handle.
- * @param aAttributeType Attribute type
- * @param aPathHandle -
- * @throws exception if not ok
- */
- virtual void SetPathTraitL(
- const TM2GSvgElementHandle& aElementHandle,
- const TM2GSvgAttrType& aAttributeType,
- const TM2GSvgPathHandle& aPathHandle) = 0;
-
- /**
- * Set rect attribute
- * @since Series S60 3.1
- * @param aElementHandle Element handle.
- * @param aAttributeType Attribute type
- * @param aRect Rect trait to be set
- * @throws exception if not ok
- */
- virtual void SetRectTraitL(
- const TM2GSvgElementHandle& aElementHandle,
- const TM2GSvgAttrType& aAttributeType,
- const TM2GRectData& aRect) = 0;
-
- /**
- * Set render quality
- * @since Series S60 3.1
- * @param aEngineHandle Engine handle.
- * @param aMode
- * @throws exception if not ok
- */
- virtual void SetRenderingQualityL(
- const TM2GSvgEngineHandle& aEngineHandle,
- TInt aMode) = 0;
-
- /**
- * Set string attribute
- * @since Series S60 3.1
- * @param aElementHandle Element handle.
- * @param aAttributeType Attribute type
- * @param aStr String trait to be set
- * @throws exception if not ok
- */
- virtual void SetStringTraitL(
- const TM2GSvgElementHandle& aElementHandle,
- const TM2GSvgAttrType& aAttributeTypeId,
- const TPtrC16& aStr) = 0;
-
- /**
- * Set viewport height
- * @since Series S60 3.1
- * @param aDocumentHandle Document
- * @param aWidth Width
- * @throws exception if not ok
- */
- virtual void SetViewportHeightL(
- const TM2GSvgDocumentHandle& aDocumentHandle,
- TInt aHeight) = 0;
-
- /**
- * Set viewport width
- * @since Series S60 3.1
- * @param aDocumentHandle Document
- * @param aWidth Width
- * @throws exception if not ok
- */
- virtual void SetViewportWidthL(
- const TM2GSvgDocumentHandle& aDocumentHandle,
- TInt aWidth) = 0;
-};
-
-M2G_NS_END
-
-#endif // MM2GSVGPROXY_H
diff -r abc41079b313 -r 59b3b4473dc8 javauis/m2g_qt/javasrc/com/nokia/microedition/m2g/ESWTScalableGraphics.java
--- a/javauis/m2g_qt/javasrc/com/nokia/microedition/m2g/ESWTScalableGraphics.java Fri Jul 23 12:27:20 2010 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,95 +0,0 @@
-/*
-* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:
-*
-*/
-
-package com.nokia.microedition.m2g;
-
-import javax.microedition.m2g.ScalableGraphics;
-import javax.microedition.m2g.ScalableImage;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.*;
-
-public class ESWTScalableGraphics
-{
- Display iDisplay = null;
- Rectangle iCanvasBounds = null;
- ScalableGraphics iSg = null;
- GC iBufferGC = null;
- GC iRealGC = null;
- Image iBufferedImage = null;
-
- public ESWTScalableGraphics(Display display)
- {
- System.out.println("P+ ESWTScalableGraphics(Display display)");
-
- iSg = ScalableGraphics.createInstance();
- iDisplay = display;
- }
-
- public ESWTScalableGraphics(Display display, Rectangle canvasBounds)
- {
- System.out.println(" P+ ESWTScalableGraphics(Display display, Rectangle canvasBounds)");
- iSg = ScalableGraphics.createInstance();
- iDisplay = display;
- iCanvasBounds = canvasBounds;
- }
-
- public void setBounds(Rectangle canvasBounds)
- {
- iCanvasBounds = canvasBounds;
- }
-
- public void bindTarget(GC gc)
- {
- System.out.println(" bindTarget(GC gc)");
- iRealGC = gc;
- iBufferedImage = new Image(iDisplay, iCanvasBounds);
- iBufferGC = new GC(iBufferedImage);
- iSg.bindTarget(iBufferGC);
- }
-
- public void releaseTarget()
- {
- System.out.println(" releaseTarget");
-
- iSg.releaseTarget();
- iBufferedImage.dispose();
- iBufferGC.dispose();
- /* iRealGC is disposed in paintControl */
- iRealGC = null;
- }
-
- public void render(int x, int y, ScalableImage image)
- {
- System.out.println(" render(int x, int y, ScalableImage image)");
- iSg.render(x,y, image);
- iRealGC.drawImage(iBufferedImage, x, y);
- }
-
- public void setRenderingQuality(int mode)
- {
- System.out.println("setRenderingQuality(int mode)");
- iSg.setRenderingQuality(mode);
- }
-
- public void setTransparency(float alpha)
- {
- System.out.println("setTransparency(float alpha)");
- iSg.setTransparency(alpha);
- }
-}
diff -r abc41079b313 -r 59b3b4473dc8 javauis/m2g_qt/javasrc/com/nokia/microedition/m2g/M2GDOMChangeObserver.java
--- a/javauis/m2g_qt/javasrc/com/nokia/microedition/m2g/M2GDOMChangeObserver.java Fri Jul 23 12:27:20 2010 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
-* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:
-*
-*/
-
-
-package com.nokia.microedition.m2g;
-
-/**
- * Anyone implementing this interface will receive notifications
- * about changes in DOM.
- *
- * Subject = M2GDocument
- * Observer/listener = M2GSVGCanvas
- *
- * M2GSVGCanvas from M2GSVGAnimator implements this in order to be notified
- * about changes in DOM, so that SVGImage updates
- * (via the API, e.g. setTrait(), insertBefore()) will be rendered
- * while Animator is in pause state.
- *
- * M2GSVGElement informs M2GDocument about changes in DOM
- * (e.g. adding/removing nodes, changing traits),
- * and then M2GDocument informs M2GSVGCanvas.
- *
- * @since S60 3.2
- */
-public interface M2GDOMChangeObserver
-{
- /**
- * Notifies about any change in DOM
- */
- public void notifyDOMChange();
-}
diff -r abc41079b313 -r 59b3b4473dc8 javauis/m2g_qt/javasrc/com/nokia/microedition/m2g/M2GDestroyable.java
--- a/javauis/m2g_qt/javasrc/com/nokia/microedition/m2g/M2GDestroyable.java Fri Jul 23 12:27:20 2010 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,57 +0,0 @@
-/*
-* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:
-*
-*/
-
-package com.nokia.microedition.m2g;
-
-//import com.nokia.mj.impl.rt.legacy.ToolkitInvoker;
-//import com.nokia.mj.impl.rt.legacy.ToolkitObserver;
-
-/**
- * Interface
- */
-public interface M2GDestroyable
-{
- /**
- * Finalization
- */
- void doDestroy();
-}
-
-//--------------------------------------------------
-// OTHER CLASSES
-//--------------------------------------------------
-/**
- * M2GDestroyer implements the ToolkitObserver interface.
- */
-class M2GDestroyer
-{
- private M2GDestroyable iDestroyable;
-
- /**
- * Ctor
- * @param aDestroyable Destroy target
- */
- M2GDestroyer(M2GDestroyable aDestroyable)
- {
- if (aDestroyable != null)
- {
- iDestroyable = aDestroyable;
- }
- }
-}
-
-
diff -r abc41079b313 -r 59b3b4473dc8 javauis/m2g_qt/javasrc/com/nokia/microedition/m2g/M2GDocument.java
--- a/javauis/m2g_qt/javasrc/com/nokia/microedition/m2g/M2GDocument.java Fri Jul 23 12:27:20 2010 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1339 +0,0 @@
-/*
-* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:
-*
-*/
-
-
-package com.nokia.microedition.m2g;
-
-import org.w3c.dom.*;
-import org.w3c.dom.events.*;
-import org.w3c.dom.svg.SVGElement;
-import java.io.IOException;
-import java.util.Hashtable;
-import java.lang.ref.WeakReference;
-import java.util.Vector;
-import java.util.Enumeration;
-import javax.microedition.m2g.*;
-import com.nokia.microedition.m2g.connection.*;
-import com.nokia.mj.impl.utils.Logger;
-
-public class M2GDocument extends M2GObject
- implements Document, M2GConnectionPolicyHandler
-{
- //--------------------------------------------------
- // STATIC CONSTANTS
- //--------------------------------------------------
- // Error constants
- /* Optimization: static finals changed to local variables
- public static final String UNSUPORTED_ELEMENT_TYPE_ESTR =
- "The type of element is not supported by the implementation.";
- public static final String UNSUPORTED_NAMESPACE_ESTR =
- "The URI is not the SVG namespace URI.";
- public static final String ID_IS_NULL_ESTR =
- "The ID is null.";
- public static final String NAMESPACE_URI_IS_NULL_ESTR =
- "The namespace URI is null.";
- public static final String QUALIFIED_NAME_IS_NULL_ESTR =
- "The qualifiedName is null.";
- public static final String CANNOT_APPEND_CHILD_ESTR =
- "Cannot appendChild to a Document node.";
- public static final String CANNOT_INSERT_BEFORE_ESTR =
- "Cannot insertBefore a Document node.";
- public static final String CANNOT_REMOVE_CHILD_ESTR =
- "Cannot removeChild from a Document node.";
- public static final String DOCUMENT_IS_ILLEGAL_ESTR =
- "The SVG document does not conform to the XML 1.0 specification.";
- public static final String HEIGHT_IS_ILLEGAL_ESTR =
- "The height is negative.";
- public static final String WIDTH_IS_ILLEGAL_ESTR =
- "The width is negative.";
- */
-
- //--------------------------------------------------
- // VARIABLES
- //--------------------------------------------------
- private M2GEventDispatcher iEventDispatcher = null;
- private ExternalResourceHandler iResourceHandler = null;
- private M2GSVGImage iImage = null;
- private M2GSVGSVGElement iRootElement = null;
- private final M2GLiveElements iLiveElements = new M2GLiveElements(true);
- private M2GConnectionPolicy iConnectionPolicy =
- M2GConnectionFactory.getDefaultPolicy();
- boolean iConnectionRight = true;
- Vector iExternalResources = new Vector();
-
- /** A base url from where a document was downloaded */
- String iBaseUrl;
-
- /** The suffix of the url from where the document was open*/
- String iSuffixUrl;
-
- /**
- * Observer to be notified about changes in DOM
- * @see M2GDOMChangeObserver.notifyDOMChange()
- */
- private M2GDOMChangeObserver iDOMChangeObserver = null;
-
- //--------------------------------------------------
- // METHODS
- //--------------------------------------------------
- /**
- * Creates new document object. If aData is null or empty then
- * an empty document is create.
- * @param aImage Svg image
- * @param aBaseUrl A base url from where a document is downloaded.
- * @param aSuffixUrl A suffix url from where a document is downloaded
- * @param aData Plain text svg data
- */
- public M2GDocument(M2GSVGImage aImage, String aBaseUrl, String aSuffixUrl,
- String aData)
- {
- super();
-
- System.out.println("P-M2GDocument Constructor getting Called.");
- iImage = aImage;
- iBaseUrl = aBaseUrl;
- iSuffixUrl = aSuffixUrl;
-
- setHandle(_createDocument(
- getNativeSVGProxyHandle(),
- aData)
- );
-
- doConstruct();
- }
-
- /**
- * @see org.w3c.dom.Node#appendChild()
- */
- public Node appendChild(Node newChild) throws DOMException
- {
- // Optimization: if(!getConnectionPolicy().getAccessRight())
- if (!iConnectionRight)
- {
- Logger.ELOG(Logger.EJavaUI, "appendChild() - access rights failure");
- throw new SecurityException(M2GSVGConstants.ACCESS_RIGHTS_ESTR);
- }
- Logger.ELOG(Logger.EJavaUI, "appendChild() - exception: "
- + /*SF*/"Cannot appendChild to a Document node."/*SF*/);
- throw new DOMException(
- DOMException.HIERARCHY_REQUEST_ERR,
- /*SF*/"Cannot appendChild to a Document node."/*SF*/);
- }
-
- /**
- * Appends external resource uri to internal container
- * @param aUri External resource uri
- * @return true if succeeds
- */
- boolean appendExternalResourceURI(String aUri)
- {
- boolean result = false;
- if (aUri != null && !aUri.equals(""))
- {
- synchronized (iExternalResources)
- {
- if (!iExternalResources.contains(aUri))
- {
- iExternalResources.addElement(aUri);
- result = true;
- }
- }
- }
- Logger.LOG(Logger.EJavaUI, Logger.EInfo, "appendExternalResourceURI() uri=" +
- ((aUri != null) ? aUri : "null") + ", result=" + result + " - end");
- return result;
- }
-
- /**
- * Checks if document contains the element
- * @param id
- * @return true if document contains the element
- */
- public boolean containsElement(String id)
- {
- if (id == null || id.equals(""))
- {
- return false;
- }
- int handle = _getElementById(
- getNativeSVGProxyHandle(),
- getHandle(), id);
- return M2GObject.checkHandle(handle);
- }
-
- /**
- * Check if external resource uri exists in internal container
- * @param aUri External resource uri
- * @return true if uri exists in container
- */
- boolean containsExternalResourceURI(String aUri)
- {
- boolean result = false;
- if (aUri != null && !aUri.equals(""))
- {
- synchronized (iExternalResources)
- {
- result = iExternalResources.contains(aUri);
- }
- }
- Logger.LOG(Logger.EJavaUI, Logger.EInfo, "containsExternalResourceURI() uri=" +
- ((aUri != null) ? aUri : "null") + ", result=" + result + " - end");
- return result;
- }
-
-
- /**
- * @see org.w3c.dom.Document#createElementNS()
- */
- public Element createElementNS(String namespaceURI, String qualifiedName)
- {
- if (namespaceURI == null || namespaceURI.equals(""))
- {
- Logger.ELOG(Logger.EJavaUI,
- "createElementNS() exception because namespace is null. qualifiedName="
- + qualifiedName);
- throw new NullPointerException(/*SF*/"The namespace URI is null."/*SF*/);
- }
- if (qualifiedName == null || qualifiedName.equals(""))
- {
- Logger.ELOG(Logger.EJavaUI,
- "createElementNS() exception - " + namespaceURI + ", "
- + qualifiedName);
- throw new NullPointerException(/*SF*/"The qualifiedName is null."/*SF*/);
- }
- // Checks element validity
- if (!M2GSVGConstants.isQualifiedElement(qualifiedName))
- {
- Logger.ELOG(Logger.EJavaUI, "createElementNS() exception - "
- + namespaceURI + ", " + qualifiedName);
- throw new DOMException(
- DOMException.NOT_SUPPORTED_ERR,
- /*SF*/"The type of element is not supported by the implementation."/*SF*/);
- }
- // Checks namespace validity
- if (!namespaceURI.equals(M2GSVGConstants.SVG_NAMESPACE_URI))
- {
- Logger.ELOG(Logger.EJavaUI, "createElementNS() exception - "
- + namespaceURI + ", " + qualifiedName);
- throw new DOMException(
- DOMException.NOT_SUPPORTED_ERR,
- /*SF*/"The URI is not the SVG namespace URI."/*SF*/);
- }
- // Creates native element. A native document owns the new element.
- // NOTE: The element is NOT located in the DOM tree yet.
- int elementHandle = _createElementNS(
- getNativeSVGProxyHandle(),
- M2GSVGConstants.parseElementTypeId(qualifiedName),
- getHandle());
- M2GSVGLocatableElement element = null;
- // Checks native handle validity
- if (M2GObject.checkHandle(elementHandle))
- {
- // Creates java element object
- element = new M2GSVGLocatableElement(elementHandle, this);
- registerLiveElement(element, new Integer(elementHandle));
- }
- else
- {
- Logger.LOG(Logger.EJavaUI, Logger.EInfo,
- "createElementNS(): " + qualifiedName + " - end, NOK!!!");
- }
- return element;
- }
-
- /**
- * Checks document validity.
- * @return true if valid
- */
- public boolean doCheckValidity() throws IOException
- {
- boolean result = false;
- if (isHandleValid())
- {
- M2GSVGSVGElement root = getRootElement();
- if (root != null)
- {
- // Check svg version and base profile
- root.checkVersionAndProfile();
- result = true;
- }
- }
- return result;
- }
-
- /**
- * Cleanup
- * @see com.nokia.microedition.m2g.M2GObject#doCleanup()
- */
- public void doCleanup()
- {
- if (isHandleValid())
- {
- _deleteDocument(
- getNativeSVGProxyHandle(),
- getHandle());
- }
- iImage = null;
- if (iEventDispatcher != null)
- {
- iEventDispatcher.clear();
- iEventDispatcher = null;
- }
- resetHandles();
- }
-
- /**
- * @see com.nokia.microedition.m2g.M2GObject#doConstruct()
- */
- protected void doConstruct()
- {
- super.doConstruct();
- iEventDispatcher = new M2GEventDispatcher();
- }
-
- /**
- * Find an element from the handle-to-element map.
- * @see M2GLiveElements#findElement()
- */
- public SVGElement findLiveElement(Integer aElementHandle)
- {
- return iLiveElements.findElement(aElementHandle);
- }
-
- /**
- * Get connection policy
- * @see M2GConnectionListener#getConnectionPolicy()
- */
- public M2GConnectionPolicy getConnectionPolicy()
- {
- return iConnectionPolicy;
- }
-
- /**
- * @see org.w3c.dom.Document#getDocumentElement()
- */
- public Element getDocumentElement()
- {
- // Optimization: if(!getConnectionPolicy().getAccessRight())
- if (!iConnectionRight)
- {
- Logger.ELOG(Logger.EJavaUI,
- "getDocumentElement() - access rights failure");
- throw new SecurityException(M2GSVGConstants.ACCESS_RIGHTS_ESTR);
- }
- return getRootElement();
- }
-
- /**
- * @see org.w3c.dom.Document#getElementById()
- */
- public Element getElementById(String id)
- {
- // Optimization: if(!getConnectionPolicy().getAccessRight())
- if (!iConnectionRight)
- {
- Logger.ELOG(Logger.EJavaUI, "getElementById() - access rights failure");
- throw new SecurityException(M2GSVGConstants.ACCESS_RIGHTS_ESTR);
- }
- if (id == null || id.equals(""))
- {
- Logger.ELOG(Logger.EJavaUI, "getElementById() - exception");
- throw new NullPointerException(/*SF*/"The ID is null."/*SF*/);
- }
- int elementHandle = _getElementById(
- getNativeSVGProxyHandle(),
- getHandle(),
- id );
- return M2GSVGElement.buildElement(elementHandle, this);
- }
-
- /**
- * Returns the image
- */
- public M2GSVGImage getImage()
- {
- return iImage;
- }
-
- /**
- * @see org.w3c.dom.Node#getLocalName()
- */
- public String getLocalName()
- {
- // Optimization: if(!getConnectionPolicy().getAccessRight())
- if (!iConnectionRight)
- {
- Logger.ELOG(Logger.EJavaUI, "getLocalName() - access rights failure");
- throw new SecurityException(M2GSVGConstants.ACCESS_RIGHTS_ESTR);
- }
- return null;
- }
-
- /**
- * @see org.w3c.dom.Node#getNamespaceURI()
- */
- public String getNamespaceURI()
- {
- // Optimization: if(!getConnectionPolicy().getAccessRight())
- if (!iConnectionRight)
- {
- Logger.ELOG(Logger.EJavaUI, "getNamespaceURI() - access rights failure");
- throw new SecurityException(M2GSVGConstants.ACCESS_RIGHTS_ESTR);
- }
- return null;
- }
-
- /**
- * @see org.w3c.dom.Node#getParentNode()
- */
- public Node getParentNode()
- {
- // Optimization: if(!getConnectionPolicy().getAccessRight())
- if (!iConnectionRight)
- {
- Logger.ELOG(Logger.EJavaUI,
- "getParentNode() - access rights failure");
- throw new SecurityException(M2GSVGConstants.ACCESS_RIGHTS_ESTR);
- }
- return null;
- }
-
- /**
- * Get root element
- * @return M2GSVGSVGElement
- */
- public M2GSVGSVGElement getRootElement()
- {
- if (iRootElement == null)
- {
- iRootElement = M2GSVGSVGElement.buildRootElement(this);
- }
- return iRootElement;
- }
-
- /**
- * @see javax.microedition.m2g.ScalableImage#getViewportHeight()
- */
- public int getViewportHeight()
- {
- return _getViewportHeight(
- getNativeSVGProxyHandle(),
- getHandle());
- }
-
- /**
- * @see javax.microedition.m2g.ScalableImage#getViewportWidth()
- */
- public int getViewportWidth()
- {
- return _getViewportWidth(
- getNativeSVGProxyHandle(),
- getHandle() );
- }
-
-
- /**
- * Called by SVGImage upon creating an Event instance
- * Calls the handleEvent() of all the listeners of the event
- */
- public void handleEvent(Event aEvent)
- {
- iEventDispatcher.handleEvent(aEvent);
- }
-
- /**
- * @see org.w3c.dom.Node#insertBefore()
- */
- public Node insertBefore(Node newChild, Node refChild)
- {
- // Optimization: if(!getConnectionPolicy().getAccessRight())
- if (!iConnectionRight)
- {
- Logger.ELOG(Logger.EJavaUI, "insertBefore() - access rights failure");
- throw new SecurityException(M2GSVGConstants.ACCESS_RIGHTS_ESTR);
- }
-
- Logger.ELOG(Logger.EJavaUI, "insertBefore() DOMException");
- throw new DOMException(
- DOMException.HIERARCHY_REQUEST_ERR,
- /*SF*/"Cannot insertBefore a Document node."/*SF*/);
- }
-
- /**
- * Checks if element is in DOM
- * @param aElementHandle -
- * @return true if element is in DOM
- */
- public boolean isElementInDOM(int aElementHandle)
- {
- if (!M2GObject.checkHandle(aElementHandle))
- {
- return false;
- }
- return (_isElementInDOM(
- getNativeSVGProxyHandle(),
- getHandle(),
- aElementHandle) > 0 ? true : false);
- }
-
- /**
- * The external resource handler is invoked
- * for any external resource referenced in the document.
- * @param aUri External resource referenced in the document
- */
- public void invokeResourceHandler(String aUri)
- {
- Logger.LOG(Logger.EJavaUI, Logger.EInfo, "invokeResourceHandler() - URI="
- + aUri + " - begin");
-
- if ((iImage != null) && (iResourceHandler != null) &&
- (aUri != null) && (aUri.length() > 4))
- {
- StringBuffer urlBuf = new StringBuffer();
- // The uri format for external resource must include the base url
- // from which the document was loaded. It's also checked that the
- // url read from svg doesn't contain already the base part.
- if ((iBaseUrl != null) &&
- !iBaseUrl.equals("") &&
- (aUri.indexOf(iBaseUrl) == -1))
- {
- Logger.LOG(Logger.EJavaUI, Logger.EInfo,
- "invokeResourceHandler() append base url=" + iBaseUrl);
- urlBuf.append(iBaseUrl);
- }
-
- urlBuf.append(aUri);
-
- // append the url suffix in case of drm open mode
- if (iSuffixUrl != null && !iSuffixUrl.equals(""))
- {
- Logger.LOG(Logger.EJavaUI, Logger.EInfo,
- "invokeResourceHandler() append suffix url=" + iSuffixUrl);
- urlBuf.append(iSuffixUrl);
- }
-
- Logger.LOG(Logger.EJavaUI, Logger.EInfo,
- "invokeResourceHandler() handler uri=" + urlBuf.toString());
-
- iResourceHandler.requestResource(iImage, urlBuf.toString());
- appendExternalResourceURI(aUri);
- }
-
- Logger.LOG(Logger.EJavaUI, Logger.EInfo,
- "invokeResourceHandler() - URI:" + aUri + " - end");
- }
-
- /**
- * Registers an event target and an event listener.
- * @param aTarget Target element
- * @param aType Event type
- * @param aListener Event listener
- */
- void register(EventTarget aTarget, String aType, EventListener aListener)
- {
- iEventDispatcher.register(aTarget, aType, aListener);
- }
-
- /**
- * Register element
- * @see M2GLiveElements#registerElement()
- */
- public void registerLiveElement(SVGElement aElement, Integer aElementHandle)
- {
- iLiveElements.registerElement(aElement, aElementHandle);
- }
-
- /**
- * @see org.w3c.dom.Node#removeChild()
- */
- public Node removeChild(Node oldChild) throws DOMException
- {
- // Optimization: if(!getConnectionPolicy().getAccessRight())
- if (!iConnectionRight)
- {
- Logger.ELOG(Logger.EJavaUI, "removeChild() - access rights failure");
- throw new SecurityException(M2GSVGConstants.ACCESS_RIGHTS_ESTR);
- }
- Logger.ELOG(Logger.EJavaUI, "removeChild() DOMException");
- throw new DOMException(
- DOMException.NOT_SUPPORTED_ERR,
- /*SF*/"Cannot removeChild from a Document node."/*SF*/);
- }
-
- /**
- * Removes external resource uri from internal container
- * @param aUri External resource uri
- * @return true if succeeds
- */
- boolean removeExternalResourceURI(String aUri)
- {
- boolean result = false;
- if (aUri != null && !aUri.equals(""))
- {
- synchronized (iExternalResources)
- {
- result = iExternalResources.removeElement(aUri);
- }
- }
- Logger.LOG(Logger.EJavaUI, Logger.EInfo,
- "removeExternalResourceURI() uri="
- + ((aUri != null) ? aUri : "null") + ", result=" + result + " - end");
- return result;
- }
-
- /*
- * @see com.nokia.microedition.m2g.M2GSVGImage#requestCompleted()
- */
- public int requestCompleted(String aUri, byte[] aResourceData)
- {
- Logger.LOG(Logger.EJavaUI, Logger.EInfo,
- "requestCompleted() uri=" + aUri + " - begin");
- // If the aUri contains a base part it will be cut off
- if (!aUri.equals("") &&
- (iBaseUrl != null) &&
- !containsExternalResourceURI(aUri) &&
- (aUri.indexOf(iBaseUrl, 0) != -1))
- {
- aUri = aUri.substring(iBaseUrl.length(), aUri.length());
- Logger.LOG(Logger.EJavaUI, Logger.EInfo,
- "requestCompleted() uri when base part is cut off=" + aUri);
- }
-
- // Execute tha request command.
- int status = _requestCompleted(
- getNativeSVGProxyHandle(),
- getHandle(), aUri, aResourceData);
- if ((status == 0) || aUri.equals(""))
- {
- Logger.LOG(Logger.EJavaUI, Logger.EInfo,
- "requestCompleted() remove URI=" + aUri);
- removeExternalResourceURI(aUri);
- }
- return status;
- }
-
- /**
- * Set connection policy
- * @see M2GConnectionListener#setConnectionPolicy()
- */
- public void setConnectionPolicy(M2GConnectionPolicy aConnectionPolicy)
- {
- iConnectionPolicy = aConnectionPolicy;
- if (iConnectionPolicy != null)
- {
- iConnectionRight = iConnectionPolicy.getAccessRight();
- }
- else
- {
- iConnectionRight = true;
- }
- }
-
- /**
- * Set image
- * @param aImage Image
- */
- public void setImage(M2GSVGImage aImage)
- {
- iImage = aImage;
- }
-
- /**
- * Set external resource handler
- * @param aHandler External resource handler
- */
- public void setResourceHandler(ExternalResourceHandler aHandler)
- {
- iResourceHandler = aHandler;
- }
-
- /**
- * @see javax.microedition.m2g.ScalableImage#setViewportHeight()
- */
- public void setViewportHeight(int height)
- {
- Logger.LOG(Logger.EJavaUI, Logger.EInfo,
- "setViewportHeight():" + height + " - begin");
- if (height < 0)
- {
- Logger.ELOG(Logger.EJavaUI, "setViewportHeight():"
- + height + " - IllegalArgumentException is thrown");
- throw new IllegalArgumentException(/*SF*/"The height is negative."/*SF*/);
- }
- _setViewportHeight(
- getNativeSVGProxyHandle(),
- getHandle(),
- height);
- Logger.LOG(Logger.EJavaUI, Logger.EInfo,
- "setViewportHeight():" + height + " - end");
- }
-
- /**
- * @see javax.microedition.m2g.ScalableImage#setViewportWidth()
- */
- public void setViewportWidth(int width)
- {
- Logger.LOG(Logger.EJavaUI, Logger.EInfo, "setViewportWidth:" + width + " - begin");
- if (width < 0)
- {
- Logger.ELOG(Logger.EJavaUI, "setViewportWidth():"
- + width + " - IllegalArgumentException is thrown");
- throw new IllegalArgumentException(/*SF*/"The width is negative."/*SF*/);
- }
- _setViewportWidth(
- getNativeSVGProxyHandle(),
- getHandle(),
- width );
- Logger.LOG(Logger.EJavaUI, Logger.EInfo,
- "setViewportWidth:" + width + " - end");
- }
-
- /**
- * Unregister event listener
- * @param aTarget Target element
- * @param aType Event type
- * @param aListener Event listener
- */
- void unregister(EventTarget aTarget, String aType, EventListener aListener)
- {
- iEventDispatcher.unregister(aTarget, aType, aListener);
- }
-
- /**
- * Unregister an element from the handle-to-element map
- * @see M2GLiveElements#unregisterElement()
- */
- public void unregisterLiveElement(Integer aElementHandle)
- {
- iLiveElements.unregisterElement(aElementHandle);
- }
-
- //--------------------------------------------------
- // INNER CLASSES
- //--------------------------------------------------
- /**
- * M2GLiveElements
- */
- class M2GLiveElements
- {
- private Hashtable iLiveElements = new Hashtable();
- private boolean iUseWeakReference;
-
- /**
- * Constructor
- */
- public M2GLiveElements(boolean aUseWeakReference)
- {
- iUseWeakReference = aUseWeakReference;
- }
-
- /**
- * Find an element from the handle-to-element map.
- * @param aElementHandle Handle
- * @return SVGElement. Null if not found
- */
- public SVGElement findElement(Integer aElementHandle)
- {
- SVGElement element = null;
- Object weakObject = null;
- Object object = null;
-
- synchronized (this)
- {
- Logger.LOG(Logger.EJavaUI, Logger.EInfo,
- "** findElement() handle: " + aElementHandle + " - begin **");
- object = iLiveElements.get(aElementHandle);
- if (object != null)
- {
- if (iUseWeakReference)
- {
- weakObject = ((WeakReference)object).get();
- if (weakObject == null)
- {
- Logger.LOG(Logger.EJavaUI, Logger.EInfo,
- "** findElement() handle: " + aElementHandle
- + " is garbage collected. **");
- iLiveElements.remove(aElementHandle);
- }
- else
- {
- element = (SVGElement)weakObject;
- }
- }
- else
- {
- element = (SVGElement)object;
- }
- }
- Logger.LOG(Logger.EJavaUI, Logger.EInfo,"** findElement() handle: " + aElementHandle
- + ((element != null) ? " FOUND" : " NOT FOUND") + " - end **");
- }
- return element;
- }
-
- /**
- * Register element
- * @param aElement Element
- * @param aElementHandle Handle
- */
- public void registerElement(SVGElement aElement, Integer aElementHandle)
- {
- if (aElement == null)
- {
- return;
- }
- synchronized (this)
- {
- if (iUseWeakReference)
- {
- iLiveElements.put(aElementHandle, new WeakReference(aElement));
- }
- else
- {
- iLiveElements.put(aElementHandle, aElement);
- }
- }
- }
-
- /**
- * Unregister an element from the handle-to-element map
- * @param aElementHandle Handle
- */
- public void unregisterElement(Integer aElementHandle)
- {
- synchronized (this)
- {
- iLiveElements.remove(aElementHandle);
- }
- }
- }
-
-
- /**
- * M2GEventDispatcher
- */
- protected class M2GEventDispatcher
- {
- static public final int INDEX_UNDEFINED = -1;
- static public final int INDEX_CLICK = 0;
- static public final int INDEX_ACTIVATE = 1;
- static public final int INDEX_FOCUS_IN = 2;
- static public final int INDEX_FOCUS_OUT = 3;
-
- Hashtable[] iEventTypes;
- int iCurrentIndex;
- Hashtable iDelayedRegistrations = new Hashtable();
- M2GEventData iCurrentEventData = new M2GEventData();
-
- /**
- * Constructor
- */
- public M2GEventDispatcher()
- {
- iEventTypes = new Hashtable[4];
- iCurrentIndex = INDEX_UNDEFINED;
- }
-
- /**
- * Clear all
- */
- public void clear()
- {
- synchronized (this)
- {
- for (int index = 0; index < iEventTypes.length; index++)
- {
- if (iEventTypes[index] != null)
- {
- iEventTypes[index].clear();
- iEventTypes[index] = null;
- }
- }
- }
- }
-
- /**
- * Execute delayed registration
- * If an EventListener is added to an EventTarget while it is
- * processing an event, it will not be triggered by the current actions.
- */
- private void doDelayedRegistration()
- {
- try
- {
- Enumeration registrations = iDelayedRegistrations.elements();
- while (registrations.hasMoreElements())
- {
- M2GEventData eventData =
- (M2GEventData)registrations.nextElement();
- register(
- eventData.iTarget, eventData.iType, eventData.iListener);
- }
- }
- catch (NullPointerException e)
- {
- }
- iDelayedRegistrations.clear();
- }
-
-
- /**
- * Handle event
- * @param aEvent Event
- */
- public void handleEvent(Event aEvent)
- {
- synchronized (this)
- {
- if ((aEvent == null) || !prepare(aEvent.getType()))
- {
- Logger.LOG(Logger.EJavaUI, Logger.EInfo,
- "handleEvent() FAILED - event invalid");
- return;
- }
- Logger.LOG(Logger.EJavaUI, Logger.EInfo,
- "handleEvent(): " + aEvent.getType() + " - begin");
- EventTarget target = aEvent.getCurrentTarget();
- if (target == null)
- {
- Logger.LOG(Logger.EJavaUI, Logger.EInfo,
- "handleEvent() FAILED - event's target is null");
- return;
- }
- // Check if wrapped event target
- if (target instanceof M2GSVGElementWrapper)
- {
- target = ((M2GSVGElementWrapper)target).getWrappedTarget();
- if (target == null)
- {
- Logger.LOG(Logger.EJavaUI, Logger.EInfo,
- "handleEvent() FAILED - wrapped event's target is null");
- return;
- }
- }
- if (iEventTypes[iCurrentIndex].containsKey(target))
- {
- Logger.LOG(Logger.EJavaUI, Logger.EInfo,
- "handleEvent() - target handling begin");
- iCurrentEventData.set(target, aEvent.getType(), null);
- Vector listeners =
- (Vector)iEventTypes[iCurrentIndex].get(iCurrentEventData.iTarget);
-
- if (listeners != null)
- {
- Enumeration index = listeners.elements();
- while (index.hasMoreElements())
- {
- Object listener = index.nextElement();
- if ((listener != null) && (listener instanceof EventListener))
- {
- ((EventListener)listener).handleEvent(aEvent);
- }
- else
- {
- Logger.LOG(Logger.EJavaUI, Logger.EInfo,
- "handleEvent(): listener is null!");
- }
- }
- }
- else
- {
- Logger.LOG(Logger.EJavaUI, Logger.EInfo,
- "handleEvent(): listeners is null!");
- }
- iCurrentEventData.clear();
- }
- else
- {
- Logger.LOG(Logger.EJavaUI, Logger.EInfo,
- "handleEvent(): target not found");
- }
- // Execute the delayed registration.
- doDelayedRegistration();
- }
- }
-
- /**
- * Check is event targets are equal
- * @param aLhs Left hand side
- * @param aRhs Right hand side
- * @return True if equal
- */
- private boolean isEquals(EventTarget aLhs, EventTarget aRhs)
- {
- int lhsHandle = M2GObject.INVALID_NATIVE_HANDLE;
- int rhsHandle = M2GObject.INVALID_NATIVE_HANDLE;
- if (aLhs instanceof M2GSVGElement)
- {
- lhsHandle = ((M2GSVGElement)aLhs).getHandle();
- }
- if (aRhs instanceof M2GSVGElement)
- {
- rhsHandle = ((M2GSVGElement)aRhs).getHandle();
- }
- if ((lhsHandle == rhsHandle) && (lhsHandle != M2GObject.INVALID_NATIVE_HANDLE))
- {
- return true;
- }
- return false;
- }
-
- /**
- * Set an index that points to an event type hash table.
- * The hash table is created if needed.
- * @param aType Type
- */
- private boolean prepare(String aType)
- {
- if (!setIndex(aType))
- {
- return false;
- }
- if (iEventTypes[iCurrentIndex] == null)
- {
- iEventTypes[iCurrentIndex] = new Hashtable();
- }
- return true;
- }
-
- /**
- * Register an event target and an event listener pair
- * @param aTarget Target
- * @param aType Type
- * @param aListener Listener
- */
- public void register(EventTarget aTarget,
- String aType,
- EventListener aListener)
- {
- // NOTE: no need to check validity of aTarget & aListener. It's
- // already done.
- synchronized (this)
- {
- if (!prepare(aType))
- {
- Logger.LOG(Logger.EJavaUI, Logger.EInfo,
- "register() - failed: " + aType);
- return;
- }
- // Check if delayed registration is needed
- // If an EventListener is added to an EventTarget while it is
- // processing an event, it will not be triggered by
- // the current actions.
- if ((iCurrentEventData.iType == aType) &&
- isEquals(iCurrentEventData.iTarget, aTarget))
- {
- try
- {
- iDelayedRegistrations.put(
- aListener,
- new M2GEventData(aTarget, aType, aListener));
- }
- catch (NullPointerException e)
- {
- }
- return;
- }
- Vector listeners = null;
- if (iEventTypes[iCurrentIndex].containsKey(aTarget))
- {
- listeners = (Vector)iEventTypes[iCurrentIndex].get(aTarget);
- }
- else
- {
- listeners = new Vector();
- iEventTypes[iCurrentIndex].put(aTarget, listeners);
- }
- // Don't add if the event target already contains the same listener
- // for the same event.
- if (!listeners.contains(aListener))
- {
- listeners.addElement(aListener);
- }
- }
- }
-
- /**
- * Set an event type container index
- * @param aType Type
- * @return False if the type is invalid
- */
- private boolean setIndex(String aType)
- {
- if (aType.equals(M2GSVGConstants.EVENT_ACTIVATE))
- {
- iCurrentIndex = INDEX_ACTIVATE;
- }
- else if (aType.equals(M2GSVGConstants.EVENT_CLICK))
- {
- iCurrentIndex = INDEX_CLICK;
- }
- else if (aType.equals(M2GSVGConstants.EVENT_FOCUS_IN))
- {
- iCurrentIndex = INDEX_FOCUS_IN;
- }
- else if (aType.equals(M2GSVGConstants.EVENT_FOCUS_OUT))
- {
- iCurrentIndex = INDEX_FOCUS_OUT;
- }
- else
- {
- Logger.LOG(Logger.EJavaUI, Logger.EInfo,
- "setIndex() type:" + aType + " FALSE - end");
- // Wrong event type
- iCurrentIndex = INDEX_UNDEFINED;
- return false;
- }
- return true;
- }
-
- /**
- * Unregister an event target and an event listener pair
- * @param aTarget Target
- * @param aType Type
- * @param aListener Listener
- */
- public void unregister(EventTarget aTarget,
- String aType,
- EventListener aListener)
- {
- synchronized (this)
- {
- if (!prepare(aType))
- {
- return;
- }
- // Remove delayed registration
- iDelayedRegistrations.remove(aListener);
- // Remove real registration
- Vector listeners = (Vector)iEventTypes[iCurrentIndex].get(aTarget);
- boolean removed = false;
- if (listeners != null)
- {
- removed = listeners.removeElement(aListener);
- if (listeners.isEmpty())
- {
- iEventTypes[iCurrentIndex].remove(aTarget);
- }
- }
- if (removed)
- {
- Logger.LOG(Logger.EJavaUI, Logger.EInfo,
- "unregister() ok - end");
- }
- else
- {
- Logger.LOG(Logger.EJavaUI, Logger.EInfo,
- "unregister() failed - end");
- }
- }
- }
-
- /**
- * Helper class for handling delayed registration
- */
- class M2GEventData
- {
- public EventTarget iTarget = null;
- public String iType = null;
- public EventListener iListener = null;
-
- /**
- * Ctor
- */
- public M2GEventData()
- {
- }
-
- /**
- * Ctor
- * @param aTarget Target
- * @param aType Event type
- * @param aListener Event listener
- */
- public M2GEventData(
- EventTarget aTarget,
- String aType,
- EventListener aListener)
- {
- set(aTarget, aType, aListener);
- }
-
- /**
- * Clearing
- */
- public void clear()
- {
- iTarget = null;
- iType = null;
- iListener = null;
- }
-
- /**
- * Setter
- * @param aTarget Target
- * @param aType Event type
- * @param aListener Event listener
- */
- public void set(EventTarget aTarget,
- String aType,
- EventListener aListener)
- {
- iTarget = aTarget;
- iType = aType;
- iListener = aListener;
- }
- }
- }
-
- //--------------------------------------------------
- // STATIC METHODS
- //--------------------------------------------------
-
- /**
- * Creates an empty SVG document. The document contains a
- * root
- *
- * @param handler implementation of the ExternalResourceHandler interface
- * @see javax.microedition.m2g.ExternalResourceHandler
- *
- * @return an empty SVGImage
- */
- public static SVGImage createEmptyImage(ExternalResourceHandler handler)
- {
- M2GSVGImage image = M2GSVGImage.buildEmptyImage(handler);
- if (image == null)
- {
- throw new NullPointerException();
- }
- SVGImage proxy = new SVGImage();
- proxy.iImg = image;
- return proxy;
- }
-
- /**
- * @see javax.microedition.m2g.ScalableImage
- */
- public static ScalableImage createImage(
- InputStream stream, ExternalResourceHandler handler) throws IOException
- {
- M2GSVGImage image = M2GSVGImage.buildImage(stream, handler, null, null);
- if (image == null)
- {
- throw new NullPointerException();
- }
- SVGImage proxy = new SVGImage();
- proxy.iImg = image;
- return proxy;
- }
-
- /**
- * @see javax.microedition.m2g.ScalableImage
- */
- public static ScalableImage createImage(
- String url, ExternalResourceHandler handler) throws IOException
- {
- M2GSVGImage image = M2GSVGImage.buildImage(url, handler);
- if (image == null)
- {
- throw new NullPointerException();
- }
- SVGImage proxy = new SVGImage();
- proxy.iImg = image;
- return proxy;
- }
-
- /**
- * This method is used to dispatch a mouse event of the specified type to the
- * document. The mouse position is given as screen coordinates x, y. If the
- * x, y values are outside the viewport area or no target is available for the x, y
- * coordinates, the event is not dispatched. Note that when a "click" event is dispatched,
- * a "DOMActivate" is automatically dispatched by the underlying implementation. The only
- * required mouse event type is "click". Therefore, if an unsupported type is specified,
- * a DOMException with error code NOT_SUPPORTED_ERR is thrown.
- *
- *
- * @param type the type of mouse event.
- * @param x the x location of the mouse/pointer in viewport coordinate
- * system.
- * @param y the y location of the mouse/pointer in viewport coordinate
- * system.
- * @throws DOMException with error code NOT_SUPPORTED_ERR: if the event type is not supported.
- * @throws NullPointerException if type is null.
- * @throws IllegalArgumentException if the x or y values are negative.
- *
- */
- public void dispatchMouseEvent(String type, int x, int y) throws DOMException
- {
- iImg.dispatchMouseEvent(type, x, y);
- }
-
- /**
- * Returns the associated Document.
- * @return the associated Document.
- */
- public Document getDocument()
- {
- return iImg.getDocument();
- }
-
- /**
- * @see javax.microedition.m2g.ScalableImage
- */
- public int getViewportHeight()
- {
- return iImg.getViewportHeight();
- }
-
- /**
- * @see javax.microedition.m2g.ScalableImage
- */
- public int getViewportWidth()
- {
- return iImg.getViewportWidth();
- }
-
- /**
- * This method triggers a "DOMFocusIn" event with the specified element as
- * the event target. That element becomes the element with focus. This
- * method also triggers a "DOMFocusOut" event with the element which
- * previous had focus as target. When the activate method is called, a
- * "DOMActivate" event is triggered with the currently focused element as
- * the target. The initial focus is always null and setting
- * null will remove the current focus.
- *
- * @param element the element to set the focus on.
- * @throws DOMException with error code WRONG_DOCUMENT_ERR: if invalid element is passed (for
- * ex: an element that does not belong to this document).
- */
- public void focusOn(SVGElement element) throws DOMException
- {
- iImg.focusOn(element);
- }
-
- /**
- * Increments the animation or media timeline for this SVGImage (in seconds). As the name
- * implies, this method is intended to move only forward in the timeline and typically should be used
- * to animate SVG content when the SVGAnimator class in not used. Setting negative values will throw
- * an Exception. It is important to note that setting large increments of time would result in
- * skipping parts of the animation as per the SVG animation model.
- *
- * @param seconds the value of time to increment in seconds.
- * @throws IllegalArgumentException if the specified time is negative.
- */
- public void incrementTime(float seconds)
- {
- iImg.incrementTime(seconds);
- }
-
- /**
- * @see javax.microedition.m2g.ScalableImage
- */
- public void requestCompleted(
- String URI, InputStream resourceData) throws IOException
- {
- iImg.requestCompleted(URI, resourceData);
- }
-
- /**
- * @see javax.microedition.m2g.ScalableImage
- */
- public void setViewportHeight(int height)
- {
- iImg.setViewportHeight(height);
- }
-
- /**
- * @see javax.microedition.m2g.ScalableImage
- */
- public void setViewportWidth(int width)
- {
- iImg.setViewportWidth(width);
- }
-}
-
diff -r abc41079b313 -r 59b3b4473dc8 javauis/m2g_qt/javasrc/javax/microedition/m2g/ScalableGraphics.java
--- a/javauis/m2g_qt/javasrc/javax/microedition/m2g/ScalableGraphics.java Fri Jul 23 12:27:20 2010 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,146 +0,0 @@
-/*
-* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:
-*
-*/
-
-
-package javax.microedition.m2g;
-
-import com.nokia.microedition.m2g.M2GScalableGraphics;
-
-/**
- * This is the fundamental class for 2D rendering. The ScalableGraphics context class
- * provides and handles all the rendering capability within this package. In other
- * words, the rendering can only be achieved through the render method provided
- * in this class. Note that the ScalableGraphics instance must be bound to the rendering
- * target prior to calling the render method. The implementation must clip to the
- * viewport boundaries.
-*/
-public class ScalableGraphics
-{
- // Defines a low rendering quality level.
- public static final int RENDERING_QUALITY_LOW = 1;
- // Defines a high rendering quality level.
- public static final int RENDERING_QUALITY_HIGH = 2;
-
- private M2GScalableGraphics iSg;
-
- /**
- * Constructor
- */
- private ScalableGraphics()
- {
- System.out.println("P-In ScalableGraphics() Creating iSg" );
- iSg = new M2GScalableGraphics();
- System.out.println("P-OUT ScalableGraphics() Creating iSg" );
- }
-
- /**
- * Binds the given Graphics as the rendering target of this ScalableGraphics context. The
- * type of the Graphics object depends on the Java profile that this specification is
- * implemented on, as follows:
- *
- *
javax.microedition.lcdui.Graphics on profiles supporting LCDUI;
- *
java.awt.Graphics on profiles supporting AWT;
- *
either of the above on profiles supporting both AWT and LCDUI.
- *
- * @param target the object (Graphics) to receive the rendered image.
- * @throws NullPointerException if target is null.
- * @throws IllegalArgumentException if target is invalid.
- * @throws IllegalStateException if target is already bound.
- */
- public void bindTarget(java.lang.Object target)
- {
- System.out.println("P-In Bind Target of ScalableGraphics.java" );
- iSg.bindTarget(target);
- System.out.println("P-Out Bind Target of ScalableGraphics.java" );
- }
-
- /**
- * Retrieve a new instance of ScalableGraphics that can be associated to
- * an application.
- *
- * @return the newly created ScalableGraphics instance.
- */
- public static ScalableGraphics createInstance()
- {
- return new ScalableGraphics();
- }
-
- /**
- * Flushes the rendered ScalableImage to the currently bound target and then releases
- * the target. This ensures that the ScalableImage is actually made visible on the target
- * that was set in bindTarget. Otherwise, the image may or may not become visible.
- * @throws IllegalStateException if target is not bound.
- */
- public void releaseTarget()
- {
- System.out.println("P-In Release Target of ScalableGraphics.java" );
- iSg.releaseTarget();
- System.out.println("P-Out Release Target of ScalableGraphics.java" );
- }
-
- /**
- * Renders the specified ScalableImage using the supplied anchor point. The anchor point given
- * is relative to the upper left corner of the rendering surface. It is important to note that
- * the content is made visible or flushed to the display only after a call is made to
- * releaseTarget.
- * @param x the X coordinate of the anchor point, in pixels.
- * @param y the Y coordinate of the anchor point, in pixels.
- * @param image the ScalableImage to be rendered.
- * @throws NullPointerException if image is null.
- * @throws IllegalStateException if target is not bound.
- * @see #releaseTarget
- */
- public void render(int x, int y, ScalableImage image)
- {
- System.out.println("P-In Render Target of ScalableGraphics.java" );
- iSg.render(x,y, image);
- System.out.println("P-Out Render Target of ScalableGraphics.java" );
- }
-
- /**
- * Set the quality of rendering in the ScalableGraphics context. It can take one of the values,
- * RENDERING_QUALITY_LOW or RENDERING_QUALITY_HIGH. Default=RENDERING_QUALITY_HIGH. The
- * implementation of these quality levels is implementation dependent and should be mapped
- * to definitions in SVG spec (shape, text, image and color rendering).
- * @param mode this value indicates the quality of rendering required.
- * @throws IllegalArgumentException if the mode is invalid.
- */
-
- public void setRenderingQuality(int mode)
- {
- iSg.setRenderingQuality(mode);
- }
-
- /**
- * Set the transparency in the ScalableGraphics context with the supplied alpha value.
- * Alpha value must be a floating point number in the range [0.0, 1.0]. The source pixels
- * are always combined with destination pixels using the Source Over Destination
- * rule [Porter-Duff]. In this context, the Source Over Destination rule has the following
- * properties: a fully opaque pixel in the source must replace the destination pixel, a
- * fully transparent pixel in the source must leave the destination pixel unchanged, and
- * a semitransparent pixel in the source must be alpha blended with the destination pixel using
- * the supplied value. The default alpha value is 1.0 (fully opaque), when not specified.
- *
- * @param alpha the constant alpha value to be used for rendering.
- *
- * @throws IllegalArgumentException if alpha is out of range.
- */
- public void setTransparency(float alpha)
- {
- iSg.setTransparency(alpha);
- }
-}
diff -r abc41079b313 -r 59b3b4473dc8 javauis/m2g_qt/javasrc/javax/microedition/m2g/ScalableImage.java
--- a/javauis/m2g_qt/javasrc/javax/microedition/m2g/ScalableImage.java Fri Jul 23 12:27:20 2010 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,225 +0,0 @@
-/*
-* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:
-*
-*/
-
-
-package javax.microedition.m2g;
-
-import java.io.IOException;
-
-/**
- * This class models images in vector format, such as the Scalable Vector
- * Graphics (SVG) image format. Therefore, it is required that all classes
- * representing "scalable" images extend this class.
- * @see javax.microedition.m2g.SVGImage
- */
-public abstract class ScalableImage
-{
- /**
- * Constructor
- */
- protected ScalableImage()
- {
- }
-
- /**
- * This method creates and loads a ScalableImage (e.g. SVG) from the specified stream.
- * A ScalableImage can only be rendered using the render() method in the ScalableGraphics
- * context.The image size is determined by the content specification
- * (eg: width/height attributes on root SVG element). The default viewport size
- * of 100-by-100 pixels is used when the size is unspecified. This method will throw an exception
- * when the image is in error. For SVG document, the document is in error when:
- *
- *
the SVG document does not conform to the XML 1.0 specification
- *
an element has an attribute or property value which is not permissible according to the SVG specification
- *
the required or mandatory attributes according to the SVG specification are missing
- *
the document contains circular references on the <use> element
- *
the document contains <image> element(s) with local references
- *
the document contains elements with duplicate Id's
- *
the document contains animation(s) in error
- *
- *
- *
If an handler is specified, the engine will invoke it for any
- * external resource referenced in the document. However, please note that data URIs
- * (for ex: base64 encoded images like <image xlink:href="data:image/png;base64,/9j/4AAQ..."/>)
- * are required to be decoded by the engine, and therefore the handler will not be invoked
- * in such cases. All these requests must occur before createImage returns, and the
- * engine must only make one call if there exist multiple resources
- * with the same URI. If the handler is set to null, the ScalableImage
- * will try to load images automatically using the engine's default implementation,
- * but might not be able to load all of them. For example, if the ScalableImage
- * is loaded from a file in a Jar file, the implementation will not be able
- * to load images that have relative URIs (ex; <image xlink:href="myImage.png" />).
- * If the handler is not able to locate a requested resource, it informs the SVG engine
- * by calling the requestCompleted method with null for resourceData.
- *
- *
Note that the handler is also called when the xlink:href attribute on
- * <image> is set or changed by the application, but the call is made only when the
- * element is hooked into the document tree i.e. when the ancestors go all the way up to
- * the root <svg> element. There are two cases:
- *
- *
When changing the xlink:href attribute of an existing <image> element that is already hooked or part of the tree.
- *
When creating a new <image>, setting its xlink:href and hooking it to the document tree.
- *
- *
- *
- * @param stream The stream from which the SVG content should be read.
- * @param handler implementation of the ExternalResourceHandler interface
- * @see javax.microedition.m2g.ExternalResourceHandler
- *
- * @return the loaded ScalableImage.
- * @throws IOException if an error occurs while loading the content.
- * @throws NullPointerException if stream is null.
- */
- public static ScalableImage createImage(java.io.InputStream stream,
- ExternalResourceHandler handler) throws IOException
- {
- return SVGImage.createImage(stream, handler);
- }
-
-
- /**
- * This method creates and loads a ScalableImage (e.g. SVG) with the specified
- * URI. A ScalableImage can only be rendered using the render() method in the ScalableGraphics
- * context.The image size is determined by the content specification
- * (eg: width/height attributes on root SVG element). The default viewport size
- * of 100-by-100 pixels is used when the size is unspecified. This method will throw an
- * exception when the image is in error. For SVG document, the document is in error when:
- *
- *
the SVG document does not conform to the XML 1.0 specification
- *
an element has an attribute or property value which is not permissible according to the SVG specification
- *
the required or mandatory attributes according to the SVG specification are missing
- *
the document contains circular references on the <use> element
- *
the document contains <image> element(s) with local references
- *
the document contains elements with duplicate Id's
- *
the document contains animation(s) in error
- *
- *
- *
- *
If an handler is specified, the engine will invoke it for any
- * external resource referenced in the document. However, please note that data URIs
- * (for ex: base64 encoded images like <image xlink:href="data:image/png;base64,/9j/4AAQ..."/>)
- * are required to be decoded by the engine, and therefore the handler will not be invoked
- * in such cases. All these requests must occur before createImage returns, and the
- * engine must only make one call if there exist multiple resources
- * with the same URI. If the handler is set to null, the ScalableImage
- * will try to load images automatically using the engine's default implementation,
- * but might not be able to load all of them. For example, if the ScalableImage
- * is loaded from a file in a Jar file, the implementation will not be able
- * to load images that have relative URIs (ex: <image xlink:href="myImage.png" />).
- * If the handler is not able to locate a requested resource, it informs the SVG engine
- * by calling the requestCompleted method with null for resourceData.
- *
- *
Note that the handler is also called when the xlink:href attribute on
- * <image> is set or changed by the application, but the call is made only when the
- * element is hooked into the document tree i.e. when the ancestors go all the way up to
- * the root <svg> element. There are two cases:
- *
- *
When changing the xlink:href attribute of an existing <image> element that is already hooked or part of the tree.
- *
When creating a new <image>, setting its xlink:href and hooking it to the document tree.
- *
- *
- *
- *
- * If the platform implementation supports the JSR-75 FileConnection, then the file: URLs
- * as used by JSR-75 shall be supported and the images are loaded from files identified
- * by this locator. This can be used to load possible DRM protected image files from the
- * file system.
- *
- * @param url A string in URL syntax that identifies the image source.
- * @param handler implementation of the ExternalResourceHandler interface
- * @see javax.microedition.m2g.ExternalResourceHandler
- *
- * @return the loaded ScalableImage
- * @throws IOException if an error occurs while loading the SVG content.
- * @throws NullPointerException if URL is null.
- * @throws java.lang.IllegalArgumentException if the specified locator is of unsupported type.
- * @throws SecurityException if the application does not have the privilege rights to access
- * the contents of this resource.
- *
- */
- public static ScalableImage createImage(String url,
- ExternalResourceHandler handler) throws IOException
- {
- return SVGImage.createImage(url, handler);
- }
-
- /**
- * This method returns the ScalableImage's viewport height. The initial
- * viewport height is taken from the "height" value specified in the Scalable Image. The value
- * returned is always in pixels. If the specified height is defined in percentages, the
- * values are mapped to the default view port size of 100x100. If the viewport height
- * is explicitly changed by the application, then the percentages are ignored and the content
- * is made to fit to this new viewport height.
- *
- * @return the current height of this ScalableImage.
- * @see #setViewportHeight
- */
- public abstract int getViewportHeight();
-
- /**
- * This method returns the ScalableImage's viewport width. The initial
- * viewport width is taken from the "width" value specified in the Scalable Image. The value
- * returned is always in pixels. If the specified width is defined in percentages, the
- * values are mapped to the default view port size of 100x100. If the viewport width
- * is explicitly changed by the application, then the percentages are ignored and the content
- * is made to fit to this new viewport width.
- *
- * @return the current width of this ScalableImage.
- * @see #setViewportWidth
- */
- public abstract int getViewportWidth();
-
- /**
- * Once the requested external resource is available, the application forwards this information
- * (resourceData) to the SVG engine. If this method is called a second time for a same URL of a
- * same SVGImage, the engine will replace the current resource data with the new
- * one. Note: Setting null for resourceData indicates that the requested resource
- * could not be fetched by the ResourceHandler or application, and in this
- * event the SVG engine will not make further attempts to load this resource.
- *
- * @param URI URI that was requested through requestExternalResource
- * @param resourceData inputstream containing the external resource
- *
- * @see javax.microedition.m2g.ExternalResourceHandler
- *
- * @throws IOException if an error occurs while loading the resource.
- * @throws NullPointerException if URL is null.
- */
- public abstract void requestCompleted(String URI, java.io.InputStream resourceData) throws IOException;
-
- /**
- * This method sets the new (viewport) height of this ScalableImage.
- *
- * @param height the new height to be set.
- * @see #getViewportHeight
- * @throws IllegalArgumentException if height is negative.
- */
- public abstract void setViewportHeight(int height);
-
- /**
- * This method sets the new (viewport) width of this ScalableImage.
- * The viewport is the area where the ScalableImage is rendered. Any parts
- * of the viewport that lie outside the boundaries of the target clipping
- * rectangle are clipped. The viewport upper left corner (x, y) is given
- * relative to the upper left corner of the target rendering surface.
- *
- * @param width the new width to be set.
- * @see #getViewportWidth
- * @throws IllegalArgumentException if width is negative.
- */
- public abstract void setViewportWidth(int width);
-}
diff -r abc41079b313 -r 59b3b4473dc8 javauis/m2g_qt/javasrc/org/w3c/dom/DOMException.java
--- a/javauis/m2g_qt/javasrc/org/w3c/dom/DOMException.java Fri Jul 23 12:27:20 2010 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,97 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:
-*
-*/
-
-package org.w3c.dom;
-
-/**
- *
- */
-public class DOMException extends RuntimeException
-{
-
- /**
- * If a node is used in a different document than the one that created it
- * (that doesn't support it).
- */
- public static final short WRONG_DOCUMENT_ERR = 4;
-
- /**
- * If index or size is negative, or greater than the allowed value.
- */
- public static final short INDEX_SIZE_ERR = 1;
-
- /**
- * If any Node is inserted somewhere it doesn't belong.
- */
- public static final short HIERARCHY_REQUEST_ERR = 3;
-
- /**
- * If an attempt is made to modify an object where modifications are not allowed.
- */
- public static final short NO_MODIFICATION_ALLOWED_ERR = 7;
-
- /**
- * If an attempt is made to reference a {@link org.w3c.dom.Node Node} in a context where it does not exist. See {@link org.w3c.dom.Node#insertBefore insertBefore} for example.
- */
- public static final short NOT_FOUND_ERR = 8;
-
- /**
- * If the implementation does not support the requested type of object or operation.
- */
- public static final short NOT_SUPPORTED_ERR = 9;
-
- /**
- * If an attempt is made to use an object that is not, or is no longer, usable.
- */
- public static final short INVALID_STATE_ERR = 11;
-
- /**
- * If an attempt is made to modify the type of the underlying object.
- */
- public static final short INVALID_MODIFICATION_ERR = 13;
-
- /**
- * If a parameter or an operation is not supported by the underlying object.
- */
- public static final short INVALID_ACCESS_ERR = 15;
-
- /**
- * If the type of an object is incompatible with the expected type of the parameter associated to the object.
- */
- public static final short TYPE_MISMATCH_ERR = 17;
-
- /**
- *
- * The member variable to store exception's code, like INVALID_ACCESS_ERR.
- */
- public short code;
-
- /**
- * Constructs a DOMException with a detailed message.
- *
- * @param code the exception's error code.
- * @param message the exception's descriptive message.
- */
- public DOMException(final short code,
- final String message)
- {
- super(message);
- this.code = code;
- }
-
-
-}
diff -r abc41079b313 -r 59b3b4473dc8 javauis/m2g_qt/javasrc/org/w3c/dom/Document.java
--- a/javauis/m2g_qt/javasrc/org/w3c/dom/Document.java Fri Jul 23 12:27:20 2010 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,105 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:
-*
-*/
-
-package org.w3c.dom;
-
-/**
- * The Document interface represents an XML Document.
- *
- *
This interface is a subset of the Document interface defined
- * in the
- * DOM Level 3 Core.
- *
- *
- *
Note the behavior of the following methods from the
- * Node interface when called on a Document
- * object:
- *
- *
- *
getParentNode returns null
- *
appendChild throws HIERARCHY_REQUEST_ERR
- *
insertBefore throws HIERARCHY_REQUEST_ERR
- *
removeChild throws NOT_SUPPORTED_ERR
- *
- *
- *
- */
-public interface Document extends Node
-{
-
- /**
- * Create a new Element based on the specified
- * (qualified) SVG tag name. This JSR does not require multiple
- * namespaces and may throw a DOMException with a
- * code of NOT_SUPPORTED_ERR if the URI is not the
- * SVG namespace URI, or if the specified name is not a valid SVG
- * Tiny element name. Only the following elements must be supported:
- * <rect>, <circle>, <ellipse>, <line>,
- * <path> <use> <image> <text>,
- * <a> and <g>.
- *
- * @param namespaceURI the namespace uri for the newly created
- * element. This should always be the SVG namespace URI "http://www.w3.org/2000/svg".
- * @param qualifiedName the qualified name for the newly created
- * element (For example: "rect", to create a <rect> element)
- *
- * @return the newly created SVG Element.
- *
- * @throws DOMException NOT_SUPPORTED_ERR if the type of element is
- * not supported by the implementation. JSR 226 only requires creation
- * support for some of the SVG namespace elements and only for a limited
- * number of local names in that namespace (see above documentation).Therefore, in
- * a conformant JSR 226 implementation, trying to create elements with a namespace
- * URIs other than the SVG namespace URI and with a qualified name not in the list
- * of required qualified names may result in this exception being thrown.
- * @throws NullPointerException if namespaceURI or
- * qualifiedName is null.
- *
- */
- public Element createElementNS(String namespaceURI, String qualifiedName)
- throws DOMException;
-
- /**
- * Return a child element of this document Node which corresponds to the top-most
- * tag in XML file. For SVG files it must be SVGSVGElement, but return
- * type is Element for DOM Core compatibility and to allow for future extensions.
- *
- * @return the root Element associated with this
- * document.
- * @throws SecurityException if the application does not have the necessary privilege rights
- * to access this (SVG) content.
- */
-
- public Element getDocumentElement();
-
- /**
- * Return the Element in the current document with
- * the given unique ID. If no such element exists, this returns null.
- *
- * @param id the ID of the object to be retrieved.
- * @return the Element that matches with the given ID or
- * null if the ID is not present.
- *
- * @throws NullPointerException if id is null
- * @throws SecurityException if the application does not have the necessary privilege rights
- * to access this (SVG) content.
- */
-
- public Element getElementById(String id);
-
-}
-
diff -r abc41079b313 -r 59b3b4473dc8 javauis/m2g_qt/javasrc/org/w3c/dom/Element.java
--- a/javauis/m2g_qt/javasrc/org/w3c/dom/Element.java Fri Jul 23 12:27:20 2010 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:
-*
-*/
-package org.w3c.dom;
-
-
-/**
- * This empty interface is defined to ensure compatibility with the DOM
- * specification, and also to be used as a return type of some Document
- * methods.
- *
- */
-public interface Element extends Node
-{
-}
diff -r abc41079b313 -r 59b3b4473dc8 javauis/m2g_qt/javasrc/org/w3c/dom/Node.java
--- a/javauis/m2g_qt/javasrc/org/w3c/dom/Node.java Fri Jul 23 12:27:20 2010 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,132 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:
-*
-*/
-
-package org.w3c.dom;
-
-/**
- * The Node interface describes generic nodes in an SVG document tree.
- *
- *
This interface is a subset of the Node interface defined
- * in the
- * DOM Level 3 Core.
- *
- */
-
-public interface Node
-{
-
-
- /**
- * Returns the namespace URI of the Node.
- *
- * @return the namespace URI of the Node.
- * @throws SecurityException if the application does not have the necessary privilege rights
- * to access this (SVG) content.
- */
- public String getNamespaceURI();
-
- /**
- * Returns the local part of the qualified name of this node. If the node is of type SVGElement, this returns the tag name without a prefix.
- * But, if the node is of type Document then null is returned.
- * @return the local part of the qualified name of this node.
- * @throws SecurityException if the application does not have the necessary privilege rights
- * to access this (SVG) content.
- */
-
- public String getLocalName();
-
- /**
- * Returns the parent Node of this Node.
- *
- * @return the parent node or null if there is no parent (i.e. if a node has
- * just been created and not yet added to the tree, or if it has been removed
- * from the tree, this is null).
- * @throws SecurityException if the application does not have the necessary privilege rights
- * to access this (SVG) content.
- */
-
- public Node getParentNode();
-
- /**
- * Appends a child to this Node.
- *
- * @param newChild the Node to be appended to this
- * Node. This is equivalent to insertBefore(newChild,null)
- * @return the added Node.
- *
- * @throws DOMException with error code HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not allow children
- * of the type of the newChild node, or if the node to append is one of this node's ancestors or this node itself,
- * or if this node is of type Document and the DOM application attempts to append a second Element node.
- * @throws DOMException with error code WRONG_DOCUMENT_ERR: Raised if newChild was created from a different document than
- * the one that created this node.
- * @throws DOMException with error code NOT_SUPPORTED_ERR: if the newChild node is a child of the Document node or if the
- * child is of a type that cannot be created with createElementNS.
- * @throws DOMException with error code INVALID_STATE_ERR: if the newChild node would cause the document to go into
- * error, for ex: when the newChild contains a <use> element with an invalid xlink:href attribute.
- * @throws NullPointerException if newChild is null.
- * @throws SecurityException if the application does not have the necessary privilege rights
- * to access this (SVG) content.
- */
-
- public Node appendChild(Node newChild) throws DOMException;
-
- /**
- * Removes the specified child associated with this Node. Elements that have ids cannot be
- * removed from the tree.
- *
- * @param oldChild the Node that is to be removed.
- * @return the node removed.
- * @throws DOMException with error code NOT_FOUND_ERR: Raised if oldChild is not a child of this node.
- * @throws DOMException with error code NOT_SUPPORTED_ERR: if this node is of type Document or if the
- * child, or any of its descendants, is of a type that cannot be created with createElementNS.
- * @throws DOMException with error code INVALID_ACCESS_ERR: if the element being removed or one of its decendants
- * have non-null id.
- * @throws NullPointerException if oldChild is null.
- * @throws SecurityException if the application does not have the necessary privilege rights
- * to access this (SVG) content.
- */
-
- public Node removeChild(Node oldChild) throws DOMException;
-
- /**
- * Inserts newChild before refChild in the child list for this node. If refChild is null,
- * newChild is inserted at the end of the list. If the newChild is already part of the
- * tree, it is first removed.
- *
- *
- * @param newChild the child to add
- * @param refChild the child before which the new child should be added.
- * @return the node being inserted.
- * @throws DOMException with error code HIERARCHY_REQUEST_ERR: if this node is of a type that does not allow children
- * of the type of the newChild node, or if the node to append is one of this node's ancestors or this node itself,
- * or if this node is of type Document and the DOM application attempts to append a second Element node.
- * @throws DOMException with error code WRONG_DOCUMENT_ERR: Raised if newChild was created from a different document than
- * the one that created this node.
- * @throws DOMException with error code NOT_FOUND_ERR: raised if refChild is not a child of this node.
- * @throws DOMException with error code NOT_SUPPORTED_ERR: if the newChild node is a child of the Document node or if the
- * child is of a type that cannot be created with createElementNS.
- * @throws DOMException with error code INVALID_STATE_ERR: if the newChild node would cause the document to go into
- * error, for ex: when the newChild contains a <use> element with an invalid xlink:href attribute.
- * @throws NullPointerException if newChild is null.
- * @throws SecurityException if the application does not have the necessary privilege rights
- * to access this (SVG) content.
- */
-
- public Node insertBefore(Node newChild, Node refChild) throws DOMException;
-
-
-}
diff -r abc41079b313 -r 59b3b4473dc8 javauis/m2g_qt/javasrc/org/w3c/dom/events/Event.java
--- a/javauis/m2g_qt/javasrc/org/w3c/dom/events/Event.java Fri Jul 23 12:27:20 2010 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:
-*
-*/
-package org.w3c.dom.events;
-
-import java.lang.String;
-
-/**
- * The Event interface is used to provide contextual information about an event to the handler
- * processing the event. An object which implements the Event interface is passed as the first
- * parameter to the {@link org.w3c.dom.events.EventListener#handleEvent handleEvent} call. If
- * an event target is an element instance (see SVGElementInstance), the currentTarget is an implementation of EventTarget
- * that does not implement the Node interface.
- */
-
-public interface Event
-{
- /**
- * This method is used to get the current target of this event.
- * In SVG Tiny, this is always an object to which event listener was attached.
- *
- * @return the event's EventTarget.
- */
- public EventTarget getCurrentTarget();
-
- /**
- * This method returns the event type information. The name of the event is case-sensitive.
- * The following event types are supported:
- *
- * click, DOMActivate, DOMFocusIn, DOMFocusOut (defined DOM Events);
- * @return the event's type.
- */
- public String getType();
-
-
-}
diff -r abc41079b313 -r 59b3b4473dc8 javauis/m2g_qt/javasrc/org/w3c/dom/events/EventListener.java
--- a/javauis/m2g_qt/javasrc/org/w3c/dom/events/EventListener.java Fri Jul 23 12:27:20 2010 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:
-*
-*/
-package org.w3c.dom.events;
-
-/**
-* This interface represents an event listener, and is a subset of the EventListener interface
-* defined in the
-* DOM Level 2 Event model.
-*
-* This interface must be implemented and registered on an EventTarget using the
-* {@link org.w3c.dom.events.EventTarget#addEventListener addEventListener} method to be notified
-* about events that occur on or bubble through the event target.
-*
-*
-*/
-
-public interface EventListener
-{
-
- /**
- * This method is called whenever an event occurs of the type for which the
- * EventListener interface was registered.. The Event object contains the
- * necessary information pertaining to the event, such as its
- * target and type.
- *
- * @param evt the Event object containing necessary event information.
- */
- public void handleEvent(Event evt);
-
-}
diff -r abc41079b313 -r 59b3b4473dc8 javauis/m2g_qt/javasrc/org/w3c/dom/events/EventTarget.java
--- a/javauis/m2g_qt/javasrc/org/w3c/dom/events/EventTarget.java Fri Jul 23 12:27:20 2010 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,70 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:
-*
-*/
-package org.w3c.dom.events;
-
-import org.w3c.dom.DOMException;
-
-/**
-*
-* This interface represents an event target, and is a subset of the EventTarget interface
-* defined in the
-* DOM Level 2 Event model.
-*
-* This interface is implemented by an object (SVGElements) that can notify listeners about events and allows
-* registration and removal of {@link org.w3c.dom.events.EventListener EventListener} objects.
-*
-*
-*/
-
-public interface EventTarget
-{
-
- /**
- * This method registers the specified listener with the event target. If an EventListener is added to an EventTarget
- * while it is processing an event, it will not be triggered by the current actions. If multiple identical EventListeners
- * are registered on the same EventTarget with the same parameters the duplicate instances are discarded. They do not cause
- * the EventListener to be called twice and since they are discarded they do not need to be removed with the removeEventListener
- * method.
- *
- * @param type The type of event to listen to.
- * @param listener Will be notified when an event of the desired type happens on this target or one of its descendant.
- * @param useCapture If true, the listener will be called during the event flow capture phase. Otherwise, the listener
- * will be called during the bubble phase. If the event's target is this target, then the listener will be called during the 'at target' phase of event flow.
- *
- * @throws DOMException with error code NOT_SUPPORTED_ERR if useCapture is true since capture phase is not supported in SVG Tiny.
- * @throws NullPointerException if listener is null.
- * @throws NullPointerException if type is null.
- */
- public void addEventListener(String type, EventListener listener, boolean useCapture);
-
- /**
- * This method removes the specified listener from the event target. If an EventListener is removed
- * from an EventTarget while it is processing an event, it will not be triggered by the current actions. Calling removeEventListener
- * with arguments which do not identify any currently registered EventListener on the EventTarget has no effect.
- *
- * @param type The type of event that was listened to.
- * @param listener The listener that was previously registered.
- * @param useCapture If true, the listener was listening to events in the capture phase of event flow, otherwise the listener
- * was listening to events in the bubble phase.
- *
- * @throws DOMException with error code NOT_SUPPORTED_ERR if useCapture is true since capture phase is not supported in SVG Tiny.
- * @throws NullPointerException if listener is null.
- * @throws NullPointerException if type is null.
- */
- public void removeEventListener(String type, EventListener listener, boolean useCapture);
-
-}
\ No newline at end of file
diff -r abc41079b313 -r 59b3b4473dc8 javauis/m2g_qt/javasrc/org/w3c/dom/svg/SVGAnimationElement.java
--- a/javauis/m2g_qt/javasrc/org/w3c/dom/svg/SVGAnimationElement.java Fri Jul 23 12:27:20 2010 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:
-*
-*/
-package org.w3c.dom.svg;
-
-
-/**
- * This interface represents an Animation element, which contains methods to control the timing of
- * animations.
- */
-public interface SVGAnimationElement extends SVGElement
-{
-
- /**
- * Creates a begin instance time for the current time plus or minus the passed offset.
- * The new instance time is added to the
- * begin instance times list.
-
- *
- * @param offset The offset in seconds at which to begin the element.
- */
- public void beginElementAt(float offset);
-
- /**
- * Creates an end instance time for the current time plus or minus the passed offset.
- * The new instance time is added to the
- * end instance times list.
-
- *
- * @param offset The offset in seconds at which to end the element.
- */
- public void endElementAt(float offset);
-
-}
diff -r abc41079b313 -r 59b3b4473dc8 javauis/m2g_qt/javasrc/org/w3c/dom/svg/SVGElement.java
--- a/javauis/m2g_qt/javasrc/org/w3c/dom/svg/SVGElement.java Fri Jul 23 12:27:20 2010 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1051 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:
-*
-*/
-package org.w3c.dom.svg;
-
-import org.w3c.dom.DOMException;
-
-import org.w3c.dom.Element;
-import org.w3c.dom.events.EventTarget;
-
-/**
- * This interface represents an SVG element in the document tree. Element's id can be set only
- * if it does not already have an id. {@link org.w3c.dom.DOMException DOMException} with error
- * code NO_MODIFICATION_ALLOWED_ERR is raised if an attempt is made to change an existing id.
- * Elements with non-null id can be inserted, but cannot be removed from the DOM tree
- * (see {@link org.w3c.dom.Node#removeChild removeChild}). This interface also provides methods
- * to traverse elements in the DOM tree.
- *
- *
- * This interface can also be used read and manipulate the value of "traits" associated with this
- * SVGElement. Each trait corresponds to an attribute or property,which is parsed and
- * understood by the element and in most cases animatable. Unlike attributes, each element has a
- * well-defined set of traits and attempting to access undefined trait is an error. Also unlike
- * attributes traits are typed and their values are normalized; for instance SVG path specification
- * is parsed and all path commands are converted to their absolute variants, it is not possible to
- * say through the value of the trait if a path command was absolute or relative. When getting and
- * setting trait values, accessor of the correct type must be used or exception will be thrown.
- *
- *
- * Initial trait values come from parsing corresponding attributes. If value is not specified, but
- * corresponing attribute (or property for environments where styling is supported) is inherited,
- * inherited value is returned as a result of the trait query method. If it is not inherited, default
- * value is returned. Default values are also returned in the case when there is no parent to inherit
- * from, for ex: when you create a new element, set a trait value to 'inherit', but there is no parent for
- * inheritance. It is important to note that the value which is returned is always a base value (i.e. before animation
- * is applied), and this is true for both static and animated content.
- *
- *
- * Setting a trait value has the same effect as changing a corresponding attribute, but trait
- * setters can operate on typed values. The value which is modified is always a base value.
- * For inheritable traits the trait value can always be set to "inherit"
- * (but querying the value will always return the actual inherited value as explained above).
- *
- *
- * There are two situations where the various trait setter methods (such as
- * setTrait, setFloatTrait or setPathTrait methods) consider a value
- * invalid and throw a DOMException with the INVALID_ACCESS_ERR code.
- * The first situation is when the trait value is invalid with regards to
- * its definition (for example, trying to set the "stroke-linejoin" trait
- * to "foo" would cause this exception).
- * The second situation is when the trait value is invalid with regards to
- * animations currently applied to the trait. The value is considered
- * invalid because it would put the animation, and therefore the document,
- * in an error state. For example, if a element has animations on
- * its "d" attribute, trying to change the "d" attribute to a value
- * incompatible with the animations will cause the exception to happen.
- *
- *
- *
Traits supported in this specification, SVG Tiny 1.1 DOM
- *
- *
- *
The table below shows the list of attributes and properties that SVG Tiny
- * DOM 1.1 implementations must support. Each light gray section lists one or
- * multiple elements for which the subsequent attributes or properties
- * apply. Each attribute row lists the allowed getter and setter (s). The last
- * column specifies the default values that must be used for each attribute or
- * property.
- *
Note: For 'REQUIRED' attributes, there are two cases:
- *
- *
- *
i) The document is in error, if this attribute was not present at the time of loading.
- *
ii) When using uDOM API, the specified default value (in parenthesis) must be used.
<text> (Notes:
- * For 'x' and 'y', it is only possible
- * to provide floating point scalar values; an array of x or y values is not supported.
- * 'rotate' attribute is not supported.)
- *
- *
- *
- *
x
- *
- *
getFloatTrait
- *
- *
setFloatTrait
- *
- *
0.0f
- *
- *
- *
- *
y
- *
- *
getFloatTrait
- *
- *
setFloatTrait
- *
- *
0.0f
- *
- *
- *
- *
#text
- *
- *
getTrait [not null]
- *
- *
setTrait [not null]
- *
- *
""
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
<svg>
- *
- *
- *
- *
version
- *
- *
getTrait
- *
- *
Not available (readonly)
- *
- *
"1.1"
- *
- *
- *
- *
baseProfile
- *
- *
getTrait
- *
- *
Not available (readonly)
- *
- *
"tiny"
- *
- *
- *
- *
viewBox
- *
- *
getRectTrait [null, SVGRect]
- *
- *
setRectTrait [SVGRect]
- *
- *
null
- *
- *
- *
- *
zoomAndPan
- *
- *
getTrait [disable | magnify]
- *
- *
setTrait [disable | magnify]
- *
- *
"magnify"
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- */
-
-public interface SVGElement extends Element, EventTarget
-{
-
- /**
- * Sets the Element's id attribute.
- * @param Id the value of Id to be set for this Element.
- * @throws DOMException with error code NO_MODIFICATION_ALLOWED_ERR is raised if an attempt is made to change an existing Id.
- * @throws DOMException with error code INVALID_ACCESS_ERR is raised if the Id is not unique i.e. if this Id already exists in the document.
- * @throws NullPointerException if Id is null.
- * @throws SecurityException if the application does not have the necessary privilege rights
- * to access this (SVG) content.
- */
- public void setId(String Id)
- throws DOMException;
-
- /**
- * Returns the Element's Id, null if no id specified.
- * @return the Element's Id.
- */
- public String getId();
-
- /**
- * Returns the first child element node of this element. null if this element has no child elements.
- * @return the first child element node of this element.
- */
- public Element getFirstElementChild();
-
- /**
- * Returns the next sibling element node of this element. null if this element has no element sibling
- * nodes that come after this one in the document tree.
- * @return the next sibling element node of this element.
- */
- public Element getNextElementSibling();
-
-
- /**
- * Returns the trait value as String. In SVG Tiny only certain traits can be obtained as a String value. Syntax of the
- * returned String matches the syntax of the corresponding attribute. This element is exactly equivalent to {@link org.w3c.dom.svg.SVGElement#getTraitNS getTraitNS}
- * with namespaceURI set to null.
- *
- * @param name the name of the trait to retrieve.
- * @return the trait value as String for the specified name.
- * @throws DOMException with error code NOT_SUPPORTED_ERR if the requested trait is not supported on this element or null.
- * @throws DOMException with error code TYPE_MISMATCH_ERR if requested trait's computed value cannot be converted to a String (SVG Tiny only).
- * @throws SecurityException if the application does not have the necessary privilege rights
- * to access this (SVG) content.
- */
- public String getTrait(String name)
- throws DOMException;
-
- /**
- * Same as {@link org.w3c.dom.svg.SVGElement#getTrait getTrait}, but for namespaced traits. Parameter name must be a non-qualified trait name, i.e. without prefix.
- *
- * @param namespaceURI the namespaceURI of the trait to retrieve.
- * @param name the name of the trait to retrieve.
- * @return the trait value as String for the specified name.
- * @throws DOMException with error code NOT_SUPPORTED_ERR if the requested trait is not supported on this element or null.
- * @throws DOMException with error code TYPE_MISMATCH_ERR if requested trait's computed value cannot be converted to a String (SVG Tiny only).
- * @throws SecurityException if the application does not have the necessary privilege rights
- * to access this (SVG) content.
- */
- public String getTraitNS(String namespaceURI, String name)
- throws DOMException;
-
- /**
- * Get the trait value as float.
- *
- * @param name the name of the trait to retrieve.
- * @return the trait value as float for the specified name.
- * @throws DOMException with error code NOT_SUPPORTED_ERR if the requested trait is not supported on this element or null.
- * @throws DOMException with error code TYPE_MISMATCH_ERR if requested trait's computed value cannot be converted to a float
- * @throws SecurityException if the application does not have the necessary privilege rights
- * to access this (SVG) content.
- */
- public float getFloatTrait(String name)
- throws DOMException;
-
- /**
- * Returns the trait value as {@link org.w3c.dom.svg.SVGMatrix SVGMatrix}. The returned object is a copy of the actual trait value and will not change if
- * the corresponding trait changes.
- *
- * @param name the name of the trait to retrieve.
- * @return the trait value as SVGMatrix for the specified name.
- * @throws DOMException with error code NOT_SUPPORTED_ERR if the requested trait is not supported on this element or null.
- * @throws DOMException with error code TYPE_MISMATCH_ERR if requested trait's computed value cannot be converted to {@link org.w3c.dom.svg.SVGMatrix SVGMatrix}
- * @throws SecurityException if the application does not have the necessary privilege rights
- * to access this (SVG) content.
- */
- public SVGMatrix getMatrixTrait(String name)
- throws DOMException;
-
- /**
- * Returns the trait value as {@link org.w3c.dom.svg.SVGRect SVGRect}. The returned object is a copy of the actual trait value and will not change if
- * the corresponding trait changes.
- *
- * @param name the name of the trait to retrieve.
- * @return the trait value as SVGRect for the specified name.
- * @throws DOMException with error code NOT_SUPPORTED_ERR if the requested trait is not supported on this element or null.
- * @throws DOMException with error code TYPE_MISMATCH_ERR if requested trait's computed value cannot be converted to {@link org.w3c.dom.svg.SVGRect SVGRect}
- * @throws SecurityException if the application does not have the necessary privilege rights
- * to access this (SVG) content.
- */
- public SVGRect getRectTrait(String name)
- throws DOMException;
-
- /**
- * Returns the trait value as {@link org.w3c.dom.svg.SVGPath SVGPath}. The returned object is a copy of the actual trait value and will not change if
- * the corresponding trait changes.
- *
- * @param name the name of the trait to retrieve.
- * @return the trait value as SVGPath for the specified name.
- * @throws DOMException with error code NOT_SUPPORTED_ERR if the requested trait is not supported on this element or null.
- * @throws DOMException with error code TYPE_MISMATCH_ERR if requested trait's computed value cannot be converted to {@link org.w3c.dom.svg.SVGPath SVGPath}
- * @throws SecurityException if the application does not have the necessary privilege rights
- * to access this (SVG) content.
- */
- public SVGPath getPathTrait(String name)
- throws DOMException;
-
- /**
- * Returns the trait value as {@link org.w3c.dom.svg.SVGRGBColor SVGRGBColor}. The returned object is a copy of the trait value and will not change if
- * the corresponding trait changes. If the actual trait value is not an RGBColor (i.e. "none"), this method will return null.
- *
- * @param name the name of the trait to retrieve.
- * @return the trait value as SVGRGBColor for the specified name.
- * @throws DOMException with error code NOT_SUPPORTED_ERR if the requested trait is not supported on this element or null.
- * @throws DOMException with error code TYPE_MISMATCH_ERR if requested trait's computed value cannot be converted to {@link org.w3c.dom.svg.SVGRGBColor SVGRGBColor}
- * @throws SecurityException if the application does not have the necessary privilege rights
- * to access this (SVG) content.
- */
- public SVGRGBColor getRGBColorTrait(String name)
- throws DOMException;
-
- /**
- * Set the trait value as String. In SVG Tiny only certain traits can be set through a String value. The syntax of the String
- * that should be given as a value must be the same as syntax of the corresponding XML attribute value. Exactly equivalent
- * to {@link org.w3c.dom.svg.SVGElement#setTraitNS setTraitNS} with namespaceURI attribute set to null.
- *
- * @param name the name of the trait to be set.
- * @param value the value of the trait to be set as String.
- * @throws DOMException with error code NOT_SUPPORTED_ERR if the requested trait is not supported on this element or null.
- * @throws DOMException with error code TYPE_MISMATCH_ERR if the requested trait's value cannot be specified as a String
- * @throws DOMException with error code INVALID_ACCESS_ERR if the input value is an invalid value for the given trait or null.
- * @throws DOMException with error code NO_MODIFICATION_ALLOWED_ERR: if attempt is made to change readonly trait.
- * @throws SecurityException if the application does not have the necessary privilege rights
- * to access this (SVG) content.
- */
- public void setTrait(String name, String value)
- throws DOMException;
-
- /**
- * Same as {@link org.w3c.dom.svg.SVGElement#setTrait setTrait}, but for namespaced traits. Parameter name must be a non-qualified trait name, i.e. without prefix.
- *
- * @param namespaceURI the namespaceURI of the trait to be set.
- * @param name the name of the trait to be set.
- * @param value the value of the trait to be set as String.
- * @throws DOMException with error code NOT_SUPPORTED_ERR if the requested trait is not supported on this element or null.
- * @throws DOMException with error code TYPE_MISMATCH_ERR if the requested trait's value cannot be specified as a String
- * @throws DOMException with error code INVALID_ACCESS_ERR if the input value is an invalid value for the given trait or null.
- * This error is also thrown when the <use> element is hooked into the document tree and the the value of xlink:href is set invalid.
- * @throws DOMException with error code NO_MODIFICATION_ALLOWED_ERR: if attempt is made to change readonly trait.
- * @throws SecurityException if the application does not have the necessary privilege rights
- * to access this (SVG) content.
- */
-
- public void setTraitNS(String namespaceURI, String name, String value)
- throws DOMException;
-
- /**
- * Set the trait value as float.
- *
- * @param name the name of the trait to be set.
- * @param value the value of the trait to be set as float.
- * @throws DOMException with error code NOT_SUPPORTED_ERR if the requested trait is not supported on this element.
- * @throws DOMException with error code TYPE_MISMATCH_ERR if the requested trait's value cannot be specified as a float
- * @throws DOMException with error code INVALID_ACCESS_ERR if the input value is an invalid value for the given trait.
- * @throws SecurityException if the application does not have the necessary privilege rights
- * to access this (SVG) content.
- */
- public void setFloatTrait(String name, float value)
- throws DOMException;
-
- /**
- * Set the trait value as {@link org.w3c.dom.svg.SVGMatrix SVGMatrix}. Values in SVGMatrix are copied in the trait so subsequent changes to the given
- * SVGMatrix have no effect on the value of the trait.
- *
- * @param name the name of the trait to be set.
- * @param matrix the value of the trait to be set as SVGMatrix.
- * @throws DOMException with error code NOT_SUPPORTED_ERR if the requested trait is not supported on this element or null.
- * @throws DOMException with error code TYPE_MISMATCH_ERR if the requested trait's value cannot be specified as an {@link org.w3c.dom.svg.SVGMatrix SVGMatrix}
- * @throws DOMException with error code INVALID_ACCESS_ERR if the input matrix value is null.
- * @throws SecurityException if the application does not have the necessary privilege rights
- * to access this (SVG) content.
- */
-
- public void setMatrixTrait(String name, SVGMatrix matrix)
- throws DOMException;
-
- /**
- * Set the trait value as {@link org.w3c.dom.svg.SVGRect SVGRect}. Values in SVGRect are copied in the trait so subsequent changes to the given
- * SVGRect have no effect on the value of the trait.
- *
- * @param name the name of the trait to be set.
- * @param rect the value of the trait to be set as SVGRect.
- * @throws DOMException with error code NOT_SUPPORTED_ERR if the requested trait is not supported on this element or null.
- * @throws DOMException with error code TYPE_MISMATCH_ERR if the requested trait's value cannot be specified as an {@link org.w3c.dom.svg.SVGRect SVGRect}
- * @throws DOMException with error code INVALID_ACCESS_ERR if the input value is an invalid value for the given trait or null.
- * SVGRect is invalid if the width or height values are set to negative.
- * @throws SecurityException if the application does not have the necessary privilege rights
- * to access this (SVG) content.
- */
-
- public void setRectTrait(String name, SVGRect rect)
- throws DOMException;
-
- /**
- * Set the trait value as {@link org.w3c.dom.svg.SVGPath SVGPath}. Values in SVGPath are copied in the trait so subsequent changes to the given
- * SVGPath have no effect on the value of the trait.
- *
- * @param name the name of the trait to be set.
- * @param path the value of the trait to be set as SVGPath.
- * @throws DOMException with error code NOT_SUPPORTED_ERR if the requested trait is not supported on this element or null.
- * @throws DOMException with error code TYPE_MISMATCH_ERR if the requested trait's value cannot be specified as an {@link org.w3c.dom.svg.SVGPath SVGPath}
- * @throws DOMException with error code INVALID_ACCESS_ERR if the input value is an invalid value for the given trait or null.
- * SVGPath is invalid if it begins with any segment other than MOVE_TO segment. Note that an empty SVGPath is still a valid value.
- * @throws SecurityException if the application does not have the necessary privilege rights
- * to access this (SVG) content.
- */
-
- public void setPathTrait(String name, SVGPath path)
- throws DOMException;
-
- /**
- * Set the trait value as {@link org.w3c.dom.svg.SVGRGBColor SVGRGBColor}. Values in SVGRGBColor are copied in the trait so subsequent changes to the given
- * SVGRGBColor have no effect on the value of the trait.
- *
- * @param name the name of the trait to be set.
- * @param color the value of the trait to be set as SVGRGBColor.
- * @throws DOMException with error code NOT_SUPPORTED_ERR if the requested trait is not supported on this element or null.
- * @throws DOMException with error code TYPE_MISMATCH_ERR if the requested trait's value cannot be specified as an {@link org.w3c.dom.svg.SVGRGBColor SVGRGBColor}
- * @throws DOMException with error code INVALID_ACCESS_ERR if the input value is null.
- * @throws SecurityException if the application does not have the necessary privilege rights
- * to access this (SVG) content.
- */
-
- public void setRGBColorTrait(String name, SVGRGBColor color)
- throws DOMException;
-}
diff -r abc41079b313 -r 59b3b4473dc8 javauis/m2g_qt/javasrc/org/w3c/dom/svg/SVGException.java
--- a/javauis/m2g_qt/javasrc/org/w3c/dom/svg/SVGException.java Fri Jul 23 12:27:20 2010 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,53 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:
-*
-*/
-package org.w3c.dom.svg;
-
-
-/**
- * An exception thrown for SVG-specific errors, such as noninvertable matrix in {@link org.w3c.dom.svg.SVGMatrix#inverse inverse}.
- */
-public class SVGException extends RuntimeException
-{
- /**
- * An integer indicating the type of error generated.
- */
- public short code;
-
- /**
- * Constructs a SVGException with a detailed message.
- *
- * @param code the exception's error code.
- * @param message the exception's descriptive message.
- */
- public SVGException(short code, String message)
- {
- super(message);
- this.code = code;
- }
-
-
- /**
- * Value passed to an SVG-specific method is invalid, such as out of range color component in {@link org.w3c.dom.svg.SVGSVGElement#createSVGRGBColor createSVGRGBColor}.
- */
- public static final short SVG_INVALID_VALUE_ERR = 1;
-
- /**
- * Matrix that has a determinant equal to zero, and therefore not invertable.
- */
- public static final short SVG_MATRIX_NOT_INVERTABLE = 2;
-
-}
diff -r abc41079b313 -r 59b3b4473dc8 javauis/m2g_qt/javasrc/org/w3c/dom/svg/SVGLocatableElement.java
--- a/javauis/m2g_qt/javasrc/org/w3c/dom/svg/SVGLocatableElement.java Fri Jul 23 12:27:20 2010 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,277 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:
-*
-*/
-package org.w3c.dom.svg;
-
-
-/**
- * This interface represents an SVGLocatableElement. It is implemented by all drawable SVG elements
- * in the document tree. Drawable elements are: <rect>, <circle>, <ellipse>,
- * <line>, <path> <use> <image> <text>, <svg>, <a>,
- * and <g>. Note that animations will have an effect on the values of bounding box.
- *
- *
- *
- *
- *The following example further clarify the behavior of the getBBox()
- *method. The example have a short explanation, an SVG fragment and are
- *followed by a set of bounding box values which have the following
- *format:
- *
- *[elementId] : {x, y, width, height} | {null}
- *
- *where x, y, width and height define the values of the SVGRect object's
- *returned from a getBBox call on the element with the specified id.
- *There are a few cases where the bounding box may be null (see example
- *6).
- *
- *
Example #1: Simple groups and bounds
- *
- *This first example shows the values returned by the getBBox method for
- *various simple basic shapes and groups. In particular, it shows that
- *the transform, on an element, does not change the value of its user
- *space bounding box.
- *
- *<g id="group1" transform="translate(10, 20)" fill="red" >
- *
- * <rect id="rect1" transform="scale(2)" x="10" y="10" width="50"
- *height="50"/>
- *
- * <rect id="rect2" x="10" y="10" width="100" height="100"/>
- *
- * <g id="group2" transform="translate(10, 20)" >
- *
- * <rect id="rect3" x="0" y="10" width="150" height="50"/>
- *
- * <circle id="circle1" cx="20" cy="20" r="100" />
- *
- * </g>
- *
- *</g>
- *
- *
- *[group1] : {-70.0, -60.0, 230.0, 200.0}
- *
- *[rect1] : {10.0, 10.0, 50.0, 50.0}
- *
- *[rect2] : {10.0, 10.0, 100.0, 100.0}
- *
- *[group2] : {-80.0, -80.0, 230.0, 200.0}
- *
- *[rect3] : {0.0, 10.0, 150.0, 50.0}
- *
- *[circle1] : {-80.0, -80.0, 200.0, 200.0}
- *
- *
- *
Example #2: Bounding box on zero width or height rectangle
- *
- *This example illustrates that the bounding box on elements is based on
- *the element's geometry coordinates. For example, the bounding box on a
- *zero-width rectangle is defined (see below), even though the rectangle
- *is not rendered.
- *
- *This is another example of how bounding boxes are based on the
- *element's geometry. Here, the bounding box of an ellipse with a zero
- *x-axis radius is still defined, even though the ellipse is not rendered.
- *
- *This example shows that no matter what the viewport is on the root SVG
- *element, the bounding boxes, based on the geometry, are still defined.
- *Here, even though the root svg has a zero width, the bounding boxes for
- *the root itself and its children is precisely defined.
- *
- *This example shows that the bounding box for a <use> element
- *accounts for the x and y attributes defined on the element, just like
- *the x and y attributes impact the bounding box computation on a
- *<rect> or on an <image> element.
- *
- *<svg>
- *
- * <defs>
- *
- * <rect id="myRect" x="0" y="0" width="60" height="40" />
- *
- * </defs>
- *
- * <use id="myUse" xlink:href="#myRect" x="-30" y="-20" />
- *
- *</svg>
- *
- *
- *
- *[myRect] : {0.0, 0.0, 60.0, 40.0}
- *
- *[myUse] : {-30.0, -20.0, 60.0, 40.0}
- *
- *
Example #6: Empty group
- *This example shows that the bounding box for an empty group is null. By
- *the same token, the bounding box of a <path> with an empty
- *SVGPath (i.e., one with no path commands, which may happen after
- *creating a new <path> element with a Document.createElementNS
- *call) is also null.
- *
- *<g id="emptyG" />
- *
- *
- *[emptyG] : {null}
- *
- *
- *
Example #7: Impact of display='none' and visibility='hidden'
- *
- *This example shows how the bounding box of children with display='none'
- *are not accounted for in the computation of their parent's bounding
- *box. This reflects the definition of the display property and its
- *impact on rendering and bounding box computation. The example also
- *shows that elements with a 'hidden' visibility still contribute to
- *their parent's bounding box computation.
- *
- *<g id="g1">
- * <g id="g1.1.display.none" display="none">
- * <rect id="rect1" x="10" y="10" width="40" height="40"/>
- * <g/>
- *
- * <rect id="rect2.visibility.hidden" visibility="hidden"
- * x="30" y="60" width="10" height="20"/>
- *
- *</g>
- *
- *[g1] : {30.0, 60.0, 10.0, 20.0}
- *[g1.1.display.none] : {10.0, 10.0, 40.0, 40.0}
- *[rect1] : {10.0, 10.0, 40.0, 40.0}
- *[rec2.visibility.hidden] : {30.0, 60.0, 10.0, 20.0}
- *
Example #8: Concatenating bounding boxes in the container's user
- *space.
- *
- *This example shows how the concatenation and computation of bounding
- *boxes for container element happens in the container's user space.
- *
- *<g id="g1">
- * <line id="line1" x2="100" y2="100" transform="rotate(-45)"/>
- *</g>
- *
- *[g1] : {0.0, 0.0, 141.42136, 0}
- *[line1] : {0.0, 0.0, 100.0, 100.0}
- *
Example #9: No influence of stroke-width.
- *This example illustrates that stroking has no impact on the computation
- *of bounding boxes.
- *
- *<g>
- * <line id="thickLine" stroke-width="10" x2="100" y2="0" />
- *</g>
- *
- *[thickLine] : {0.0, 0.0, 100.0, 0.0}
- *
- *
- * Returns the tight bounding box in current user coordinate space. Tight bounding box is the smallest
- * possible rectangle that includes the geometry of all contained graphics elements excluding stroke.
- * The calculation is done in the user coordinate space of the element. When bounding box
- * is calculated elements with display property (trait) set to none are ignored. Exact rules for the bounding
- * box calculation are given in the SVG spec.
- *
- *
- * @return the tight bounding box in current user coordinate space.
- */
- public SVGRect getBBox();
-
- /**
- *
- * Returns the transformation matrix from current user units (i.e., after application of the transform attribute, if any)
- * to the parent user agent's notion of a "pixel". For display devices, ideally this represents a physical screen pixel.
- * For other devices or environments where physical pixel sizes are not known, then an algorithm similar to the CSS2
- * definition of a "pixel" can be used instead. Note that null is returned if this element is not hooked into the
- * document tree.
- *
- *
- * @return the transformation matrix from current user units to the parent user agent's notion of a "pixel".
- */
- public SVGMatrix getScreenCTM();
-
- /**
- *
- * Returns the tight bounding box in screen coordinate space. Tight bounding box is the smallest
- * possible rectangle that includes the geometry of all contained graphics elements excluding stroke.
- * The box coordinates are in the screen coordinate space, which is connected to the current user
- * coordinate space by the matrix returned by {@link org.w3c.dom.svg.SVGLocatableElement#getScreenCTM getScreenCTM} method.
- * Note that null is returned if this element is not hooked into the
- * document tree.
- *
- *
- * @return the tight bounding box in screen coordinate space.
- */
- public SVGRect getScreenBBox();
-}
\ No newline at end of file
diff -r abc41079b313 -r 59b3b4473dc8 javauis/m2g_qt/javasrc/org/w3c/dom/svg/SVGMatrix.java
--- a/javauis/m2g_qt/javasrc/org/w3c/dom/svg/SVGMatrix.java Fri Jul 23 12:27:20 2010 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,129 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:
-*
-*/
-package org.w3c.dom.svg;
-
-import org.w3c.dom.svg.SVGException;
-import org.w3c.dom.DOMException;
-
-/**
- * This interface represents an "SVGMatrix" datatype, identified by an affine transform.
- * It can be used to read and modify the values of transform attribute as per SVG specification.
- * Note that the mTranslate, mMultiply, mScale and mRotate methods in this interface
- * mutate the SVGMatrix object and return a reference to the SVGMatrix instance itself, after
- * performing the necessary matrix operation.
- *
This matrix transforms source coordinates (x, y) into destination coordinates (x', y') by
- * considering them to be a column vector and multiplying the coordinate vector by the matrix
- * according to the following process:
- *
- *
- *
- * [ x' ] [ a c e ] [ x ] [ a.x + c.y + e ]
- * [ y' ] = [ b d f ] [ y ] = [ b.x + d.y + f ]
- * [ 1 ] [ 0 0 1 ] [ 1 ] [ 1 ]
- *
- *
- */
-public interface SVGMatrix
-{
-
- /**
- * Returns a component of the matrix by component's zero-based index. getComponent(0) is a, getComponent(1) is b, etc.
- *
- * @param index the index of the matrix component to retrieve.
- * @return the component for the specified index.
- * @throws DOMException - INDEX_SIZE_ERR if the index is invalid.
- */
- public float getComponent(int index)
- throws DOMException;
-
- /**
- * Performs matrix multiplication. This matrix is post-multiplied by another matrix, returning the resulting current matrix.
- *
- * @param secondMatrix the matrix to post-multiply with.
- * @return the resulting current matrix after post-multiplication.
- * @throws NullPointerException - if secondMatrix is null.
- */
- public SVGMatrix mMultiply(SVGMatrix secondMatrix);
-
- /**
- * Returns a new instance of SVGMatrix containing the inverse of the current matrix.
- *
- * @return the inverse of the current matrix.
- * @throws SVGException - SVG_MATRIX_NOT_INVERTABLE when determinant of this matrix is zero.
- */
- public SVGMatrix inverse()
- throws SVGException;
-
- /**
- * Post-multiplies a translation transformation on the current matrix and returns the resulting current matrix.
- * This is equivalent to calling multiply(T), where T is an
- * SVGMatrix object represented by the following
- * matrix:
- *
- *
- *
- * [ 1 0 x ]
- * [ 0 1 y ]
- * [ 0 0 1 ]
- *
- *
- *
- * @param x the distance by which coordinates are translated
- * in the X axis direction.
- * @param y the distance by which coordinates are translated
- * in the Y axis direction.
- * @return the resulting current matrix after post-multiplication.
- */
- public SVGMatrix mTranslate(float x, float y);
-
- /**
- * Post-multiplies a uniform scale transformation on the current matrix and returns the resulting current matrix.
- * This is equivalent to calling multiply(S), where S is an SVGMatrix
- * object represented by the following matrix:
- *
- *
- *
- *
- * @param scaleFactor the factor by which coordinates are scaled along the
- * X and Y axis.
- * @return the resulting current matrix after post-mutiplication.
- */
- public SVGMatrix mScale(float scaleFactor);
-
- /**
- * Post-multiplies a rotation transformation on the current matrix and returns the resulting current matrix.
- * This is equivalent to calling multiply(R), where R is an
- * SVGMatrix object represented by the following matrix:
- *
- *
- *
- *
- * @param angle the angle of rotation in degrees.
- * @return the resulting current matrix after post-multiplication.
- */
- public SVGMatrix mRotate(float angle);
-}
diff -r abc41079b313 -r 59b3b4473dc8 javauis/m2g_qt/javasrc/org/w3c/dom/svg/SVGPath.java
--- a/javauis/m2g_qt/javasrc/org/w3c/dom/svg/SVGPath.java Fri Jul 23 12:27:20 2010 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,139 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:
-*
-*/
-package org.w3c.dom.svg;
-import org.w3c.dom.DOMException;
-
-
-/**
- * This interface represents an "SVGPath" datatype used to define the path geometry.
- * Corresponds to SVG path specification or the "d" attribute.
- *
- *
- *
The native implementations must support the following simplifications or
- * canonicalization of path segments. Any simplifications should be lossless.
- *
- *
- *
Relative commands (c, h, l, m, q, s, t, and v) must be converted to their absolute counterparts·
- *
Horizontal and Vertical lines (H, h, V, and v) must be converted to general lines (L and l)·
- *
Translate command S to command C·
- *
Translate command T to command Q.
- *
- *
- */
-public interface SVGPath
-{
-
- /**
- * Numeric value is ASCII code of the letter 'M'.
- */
- public static final short MOVE_TO = 77;
-
- /**
- * Numeric value is ASCII code of the letter 'L'.
- */
- public static final short LINE_TO = 76;
-
- /**
- * Numeric value is ASCII code of the letter 'C'.
- */
- public static final short CURVE_TO = 67;
-
- /**
- * Numeric value is ASCII code of the letter 'Q'.
- */
- public static final short QUAD_TO = 81;
-
- /**
- * Numeric value is ASCII code of the letter 'Z'.
- */
- public static final short CLOSE = 90;
-
-
- /**
- * Return number of segments in this path.
- *
- * @return the number of segments in this path.
- */
- public int getNumberOfSegments();
-
- /**
- * Returns segment command by zero-based command index. Returns one of MOVE_TO, LINE_TO, CURVE_TO, QUAD_TO or CLOSE.
- *
- * @param cmdIndex the command index for the segment command to retrieve.
- * @return the segment command for the specified cmdIndex.
- * @throws DOMException with error code INDEX_SIZE_ERR if segment index out of bounds.
- *
- */
- public short getSegment(int cmdIndex)
- throws DOMException;
-
- /**
- * Returns segment parameter by zero-based command index and zero-based parametr index.
- *
- * @param cmdIndex the command index for the segment parameter to retrieve.
- * @param paramIndex the parameter index for the segment parameter to retrieve.
- * @return the segment parameter for the specified cmdIndex and paramIndex.
- * @throws DOMException with error code INDEX_SIZE_ERR if segment index out of bounds or param index out of bounds for this segment's type.
- */
- public float getSegmentParam(int cmdIndex, int paramIndex)
- throws DOMException;
-
- /**
- * Appends 'M' (absolute move) segment to the path with the specified coordinates.
- *
- * @param x the x-axis coordinate for the specified point.
- * @param y the y-axis coordinate for the specified point.
- */
- public void moveTo(float x, float y);
-
- /**
- * Appends 'L' (absolute line) segment to the path with the specified coordinates.
- *
- * @param x the x-axis coordinate of the specified point.
- * @param y the y-axis coordinate of the specified point.
- */
- public void lineTo(float x, float y);
-
- /**
- * Appends 'Q' (absolute quadratic curve) segment to the path.
- *
- * @param x1 the x-axis coordinate of the first control point.
- * @param y1 the y-axis coordinate of the first control point.
- * @param x2 the x-axis coordinate of the final end point.
- * @param y2 the y-axis coordinate of the final end point.
- *
- */
- public void quadTo(float x1, float y1, float x2, float y2);
-
- /**
- * Appends 'C' (absolute cubic curve) segment to the path.
- *
- * @param x1 the x-axis coordinate of the first control point.
- * @param y1 the y-axis coordinate of the first control point.
- * @param x2 the x-axis coordinate of the second end point.
- * @param y2 the y-axis coordinate of the second end point.
- * @param x3 the x-axis coordinate of the final end point.
- * @param y3 the y-axis coordinate of the final end point.
- *
- */
- public void curveTo(float x1, float y1, float x2, float y2, float x3, float y3);
-
- /**
- * Appends 'Z' (close path) segment to the path
- */
- public void close();
-}
diff -r abc41079b313 -r 59b3b4473dc8 javauis/m2g_qt/javasrc/org/w3c/dom/svg/SVGPoint.java
--- a/javauis/m2g_qt/javasrc/org/w3c/dom/svg/SVGPoint.java Fri Jul 23 12:27:20 2010 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,61 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:
-*
-*/
-package org.w3c.dom.svg;
-
-
-/**
- * This interface represents an "SVGPoint" datatype, identifiend by its x and y components.
- */
-public interface SVGPoint
-{
-
- /**
- * Sets the x component of the point to the specified float value.
- *
- * @param value the x component value
- *
- */
-
- public void setX(float value);
-
- /**
- * Sets the y component of the point to the specified float value.
- *
- * @param value the y component value
- *
- */
-
- public void setY(float value);
-
-
- /**
- * Returns the x component of the point.
- *
- * @return the x component of the point.
- *
- */
-
- public float getX();
-
- /**
- * Returns the y component of the point.
- *
- * @return the y component of the point.
- *
- */
- public float getY();
-}
diff -r abc41079b313 -r 59b3b4473dc8 javauis/m2g_qt/javasrc/org/w3c/dom/svg/SVGRGBColor.java
--- a/javauis/m2g_qt/javasrc/org/w3c/dom/svg/SVGRGBColor.java Fri Jul 23 12:27:20 2010 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,52 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:
-*
-*/
-package org.w3c.dom.svg;
-
-
-/**
- * This interface represents an "SVGRGBColor" datatype made up of red, green, and blue components.
- * It can be used to read properties that store color values ({@link org.w3c.dom.svg.SVGElement#getRGBColorTrait getRGBColorTrait})
- * such as fill, stroke, and color.
- */
-public interface SVGRGBColor
-{
-
- /**
- * Returns the red component of the SVGRGBColor.
- *
- * @return the red component.
- *
- */
- public int getRed();
-
- /**
- * Returns the green component of the SVGRGBColor.
- *
- * @return the green component.
- *
- */
- public int getGreen();
-
- /**
- * Returns the blue component of the SVGRGBColor.
- *
- * @return the blue component.
- *
- */
- public int getBlue();
-
-}
diff -r abc41079b313 -r 59b3b4473dc8 javauis/m2g_qt/javasrc/org/w3c/dom/svg/SVGRect.java
--- a/javauis/m2g_qt/javasrc/org/w3c/dom/svg/SVGRect.java Fri Jul 23 12:27:20 2010 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,92 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:
-*
-*/
-package org.w3c.dom.svg;
-
-
-/**
- * This interface represents an "SVGRect" datatype, consisting of a minimum X, minimum Y, width
- * and height values.
- */
-public interface SVGRect
-{
-
- /**
- * Sets the minimum X value of this SVGRect to the specified value.
- *
- * @param value the minimum X value.
- *
- */
- public void setX(float value);
-
- /**
- * Sets the minimum Y value of this SVGRect to the specified value.
- *
- * @param value the minimum Y value.
- *
- */
- public void setY(float value);
-
- /**
- * Sets the width of this SVGRect to the specified value.
- *
- * @param value the rectangle width value.
- *
- */
- public void setWidth(float value);
-
- /**
- * Sets the height of this SVGRect to the specified value.
- *
- * @param value the rectangle height value.
- *
- */
- public void setHeight(float value);
-
- /**
- * Returns the minimum X value for this SVGRect.
- *
- * @return the minimum X value.
- *
- */
- public float getX();
-
- /**
- * Returns the minimum Y value for this SVGRect.
- *
- * @return the minimum Y value.
- *
- */
- public float getY();
-
-
- /**
- * Returns the width for this SVGRect.
- *
- * @return the rectangle width.
- *
- */
- public float getWidth();
-
- /**
- * Returns the height for this SVGRect.
- *
- * @return the rectangle height.
- *
- */
- public float getHeight();
-
-}
diff -r abc41079b313 -r 59b3b4473dc8 javauis/m2g_qt/javasrc/org/w3c/dom/svg/SVGSVGElement.java
--- a/javauis/m2g_qt/javasrc/org/w3c/dom/svg/SVGSVGElement.java Fri Jul 23 12:27:20 2010 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,162 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:
-*
-*/
-package org.w3c.dom.svg;
-
-import org.w3c.dom.DOMException;
-
-/**
- *
This interface represents <svg> element in (SVG) document tree.
- *
User Agent Transforms
- *
- * The DOM attributes currentScale, currentRotate and currentTranslate are combined to form user agent transformation
- * which is applied at the outermost level on the SVG document (i.e., outside the outermost 'svg' element) if "magnification"
- * is enabled (i.e., zoomAndPan attribute is set to "magnify"). Their values
- * can potentialy be modified through user-agent specific UI. User agent transformation can be obtained
- * by multiplying matrix
- *
- *
- *
- * i.e. (translate, then scale, then rotate the coordinate system). The reference point for scale and rotate operations is the origin (0, 0).
- *
- *
- *
Note: If the application does not have the necessary privilege rights to access this (SVG)
- * content, a SecurityException may be thrown by the underlying implementation. This is applicable
- * to all the Tree navigation and Trait acessor methods. Features such as zooming, panning and
- * playing of animations will not be affected.
- *
- */
-public interface SVGSVGElement extends SVGLocatableElement
-{
- /**
- * Sets current user agent scale (zoom) coefficient.
- *
- * @param value the value of user agent scale coefficient to be set.
- * @throws DOMException with error code INVALID_ACCESS_ERR if the scale value is set to zero.
- */
- public void setCurrentScale(float value)
- throws DOMException;
-
- /**
- * Returns current user agent scale (zoom) coefficient. The initial value for currentScale is 1.
- *
- * @return the current user agent scale coefficient.
- */
- public float getCurrentScale();
-
- /**
- * Sets current user agent rotate coefficient in degrees.
- *
- * @param value the value of user agent rotate coefficient to be set.
- */
- public void setCurrentRotate(float value);
-
- /**
- * Returns current user agent rotation angle in degrees. The initial value for currentRotate is 0.
- *
- * @return the current user agent rotation coefficient in degrees.
- */
- public float getCurrentRotate();
-
- /**
- * Current user agent translation used for scrolling or panning (The returned {@link org.w3c.dom.svg.SVGPoint SVGPoint} object is "live" and setting its
- * x and y components will change user agent's translation). The initial values for currentTranslate is SVGPoint(0,0).
- *
- * @return returns the current user agent translation.
- */
- public SVGPoint getCurrentTranslate();
-
- /**
- * Returns current animation timeline time in seconds.
- *
- * @return the current animation timeline time in seconds.
- */
- public float getCurrentTime();
-
- /**
- * Sets current animation timeline time (in seconds). This API is required to support moving
- * forwards in timeline. The underlying implementations are normally designed to seek
- * forward in time and setting the time backwards is not meant to play the animation backwards.
- * Note: Moving backwards in time is a costly feature for the implementations to support.
- *
- * @param seconds the value of time to be set in seconds.
- */
-
- public void setCurrentTime(float seconds);
-
- /**
- * Creates new {@link org.w3c.dom.svg.SVGMatrix SVGMatrix} object. This object can be used to modify value of traits which are compatible with {@link org.w3c.dom.svg.SVGMatrix SVGMatrix}
- * type using {@link org.w3c.dom.svg.SVGElement#setMatrixTrait setMatrixTrait} method. The internal representation of the matrix is as follows:
- *