diff options
author | Silenio Quarti <silenio> | 2008-03-04 17:32:39 +0000 |
---|---|---|
committer | Silenio Quarti <silenio> | 2008-03-04 17:32:39 +0000 |
commit | 42b119d584670d7ea864dc313368f65356cf1296 (patch) | |
tree | 7ee518ebf6c97a8d6d605df54e2b99e30cc5756f | |
parent | cc2bd64c274580df1c6195b2c4272a7b594e391b (diff) | |
download | eclipse.platform.swt-42b119d584670d7ea864dc313368f65356cf1296.tar.gz eclipse.platform.swt-42b119d584670d7ea864dc313368f65356cf1296.tar.xz eclipse.platform.swt-42b119d584670d7ea864dc313368f65356cf1296.zip |
wpf support for e4
8 files changed, 255 insertions, 8 deletions
diff --git a/bundles/org.eclipse.swt/.classpath_wpf b/bundles/org.eclipse.swt/.classpath_wpf index e53cfda71a..3ecce1fc1c 100644 --- a/bundles/org.eclipse.swt/.classpath_wpf +++ b/bundles/org.eclipse.swt/.classpath_wpf @@ -32,6 +32,7 @@ <classpathentry kind="src" path="Eclipse SWT OpenGL/emulated"/> <classpathentry kind="src" path="Eclipse SWT OpenGL/common"/> <classpathentry kind="src" path="Eclipse SWT Theme/emulated"/> + <classpathentry kind="src" path="Eclipse SWT Effects/emulated"/> <classpathentry kind="lib" path="extra_jars/exceptions.jar"/> <classpathentry kind="output" path="bin"/> </classpath> diff --git a/bundles/org.eclipse.swt/.classpath_wpf_e4 b/bundles/org.eclipse.swt/.classpath_wpf_e4 new file mode 100644 index 0000000000..a2a4c6f13e --- /dev/null +++ b/bundles/org.eclipse.swt/.classpath_wpf_e4 @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/CDC-1.0%Foundation-1.0"/> + <classpathentry kind="src" path="Eclipse SWT/wpf"/> + <classpathentry kind="src" path="Eclipse SWT/common"/> + <classpathentry kind="src" path="Eclipse SWT/common_j2se"/> + <classpathentry kind="src" path="Eclipse SWT PI/common"/> + <classpathentry kind="src" path="Eclipse SWT PI/wpf"> + <attributes> + <attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="org.eclipse.swt.wpf.win32.x86"/> + </attributes> + </classpathentry> + <classpathentry kind="src" path="Eclipse SWT PI/wpf_win32"/> + <classpathentry kind="src" path="Eclipse SWT PI/common_j2se"/> + <classpathentry kind="src" path="Eclipse SWT/emulated/datetime"/> + <classpathentry kind="src" path="Eclipse SWT/emulated/bidi"/> + <classpathentry kind="src" path="Eclipse SWT/emulated/tooltip"/> + <classpathentry kind="src" path="Eclipse SWT/emulated/ime"/> + <classpathentry kind="src" path="Eclipse SWT Accessibility/emulated"/> + <classpathentry kind="src" path="Eclipse SWT Accessibility/common"/> + <classpathentry kind="src" path="Eclipse SWT AWT/emulated"/> + <classpathentry kind="src" path="Eclipse SWT AWT/common"/> + <classpathentry kind="src" path="Eclipse SWT Drag and Drop/wpf"/> + <classpathentry kind="src" path="Eclipse SWT Drag and Drop/common"/> + <classpathentry kind="src" path="Eclipse SWT Printing/wpf"/> + <classpathentry kind="src" path="Eclipse SWT Printing/common"/> + <classpathentry kind="src" path="Eclipse SWT Program/wpf"/> + <classpathentry kind="src" path="Eclipse SWT Program/common"/> + <classpathentry kind="src" path="Eclipse SWT Custom Widgets/common"/> + <classpathentry kind="src" path="Eclipse SWT Browser/common"/> + <classpathentry kind="src" path="Eclipse SWT Browser/forms"/> + <classpathentry kind="src" path="Eclipse SWT OpenGL/emulated"/> + <classpathentry kind="src" path="Eclipse SWT OpenGL/common"/> + <classpathentry kind="src" path="Eclipse SWT Theme/emulated"/> + <classpathentry kind="lib" path="extra_jars/exceptions.jar"/> + <classpathentry combineaccessrules="false" kind="src" path="/org.eclipse.swt.e4"/> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/bundles/org.eclipse.swt/Eclipse SWT Effects/emulated/org/eclipse/swt/effects/Effect.java b/bundles/org.eclipse.swt/Eclipse SWT Effects/emulated/org/eclipse/swt/effects/Effect.java new file mode 100644 index 0000000000..4748695ae4 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT Effects/emulated/org/eclipse/swt/effects/Effect.java @@ -0,0 +1,28 @@ +/******************************************************************************* + * Copyright (c) 2000, 2008 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.swt.effects; + +/** + * WARNING: THIS API IS UNDER CONSTRUCTION AND SHOULD NOT BE USED + */ +public class Effect { + public int handle; + + public Effect() { + } + + public void dispose() { + } + + public boolean isDisposed() { + return handle == 0; + } +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Composite.java b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Composite.java index 9c87b314d2..2548630c9f 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Composite.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Composite.java @@ -876,6 +876,34 @@ void removeControl (Control control) { fixTabList (control); } +void resized () { + super.resized(); + if (isDisposed ()) return; + if (layout != null) { + markLayout (false, false); + updateLayout (false, false); + } +} + +/** + * WARNING: THIS API IS UNDER CONSTRUCTION AND SHOULD NOT BE USED + */ +public void setAlpha(int alpha) { + checkWidget (); + int backgroundHandle = backgroundHandle (); + int property = backgroundProperty (); + int brush = OS.DependencyObject_GetValue (backgroundHandle, property); + if (brush != 0) { + int newBrush = OS.Freezable_Clone(brush); + OS.Brush_Opacity (newBrush, (alpha & 0xFF) / (double)0xFF); + OS.DependencyObject_SetValue (backgroundHandle, property, newBrush); + OS.GCHandle_Free (brush); + OS.GCHandle_Free (newBrush); + } + OS.GCHandle_Free (property); +// OS.UIElement_Opacity (handle, (alpha & 0xFF) / (double)0xFF); +} + void setBackgroundBrush (int brush) { if (brush != 0) { OS.Panel_Background (handle, brush); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Control.java index 19329a0cf6..d923c1b4c2 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Control.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Control.java @@ -16,6 +16,9 @@ import org.eclipse.swt.*; import org.eclipse.swt.events.*; import org.eclipse.swt.accessibility.*; +//TEMPORARY CODE +import org.eclipse.swt.effects.*; + /** * Control is the abstract superclass of all windowed user interface classes. * <p> @@ -45,6 +48,7 @@ public abstract class Control extends Widget implements Drawable { Region region; // int drawCount; int foreground, background; + int x, y, width, height; Font font; Composite parent; @@ -609,6 +613,14 @@ void createWidget () { } } +/** + * WARNING: THIS API IS UNDER CONSTRUCTION AND SHOULD NOT BE USED + */ +public void setAlpha(int alpha) { + checkWidget (); + OS.UIElement_Opacity (handle, (alpha & 0xFF) / (double)0xFF); +} + void setClipping () { //accept default clipping } @@ -850,6 +862,14 @@ public Accessible getAccessible () { } /** + * WARNING: THIS API IS UNDER CONSTRUCTION AND SHOULD NOT BE USED + */ +public int getAlpha () { + checkWidget (); + return (int) (0XFF * OS.UIElement_Opacity (handle)); +} + +/** * Returns the receiver's background color. * * @return the background color @@ -1194,6 +1214,24 @@ public String getToolTipText () { } /** + * WARNING: THIS API IS UNDER CONSTRUCTION AND SHOULD NOT BE USED + */ +public Transform getTransform () { + int transform = OS.FrameworkElement_RenderTransform (handle); + int matrix = OS.MatrixTransform_Matrix (transform); + OS.GCHandle_Free (transform); + float m11 = (float) OS.Matrix_M11 (matrix); + float m12 = (float) OS.Matrix_M12 (matrix); + float m21 = (float) OS.Matrix_M21 (matrix); + float m22 = (float) OS.Matrix_M22 (matrix); + float dx = (float) OS.Matrix_OffsetX (matrix); + float dy = (float) OS.Matrix_OffsetY (matrix); + OS.GCHandle_Free (matrix); + //TODO - leaking + return new Transform (display, m11, m12, m21, m22, dx, dy); +} + +/** * Returns <code>true</code> if the receiver is visible, and * <code>false</code> otherwise. * <p> @@ -1260,6 +1298,49 @@ void hookEvents () { handler = OS.gcnew_ContextMenuEventHandler (jniRef, "HandleContextMenuOpening"); OS.FrameworkElement_ContextMenuOpening (handle, handler); OS.GCHandle_Free (handler); + + handler = OS.gcnew_SizeChangedEventHandler(jniRef, "HandleSizeChanged"); + OS.FrameworkElement_SizeChanged (topHandle, handler); + OS.GCHandle_Free (handler); + + int typeid = OS.Canvas_typeid(); + handler = OS.gcnew_EventHandler(jniRef, "HandleTopChanged"); + int property = OS.Canvas_TopProperty(); + int dpd = OS.DependencyPropertyDescriptor_FromProperty(property, typeid); + OS.DependencyPropertyDescriptor_AddValueChanged(dpd, topHandle, handler); + OS.GCHandle_Free(handler); + OS.GCHandle_Free(property); + OS.GCHandle_Free(dpd); + handler = OS.gcnew_EventHandler(jniRef, "HandleLeftChanged"); + property = OS.Canvas_LeftProperty(); + dpd = OS.DependencyPropertyDescriptor_FromProperty(property, typeid); + OS.DependencyPropertyDescriptor_AddValueChanged(dpd, topHandle, handler); + OS.GCHandle_Free(handler); + OS.GCHandle_Free(property); + OS.GCHandle_Free(dpd); + OS.GCHandle_Free(typeid); +} + +void HandleLeftChanged (int sender, int e) { + int topHandle = topHandle(); + int x = (int)OS.Canvas_GetLeft(topHandle); + int y = (int)OS.Canvas_GetTop(topHandle); + if (x != this.x || y != this.y) { + this.x = x; + this.y = y; + sendEvent(SWT.Move); + } +} + +void HandleTopChanged (int sender, int e) { + int topHandle = topHandle(); + int x = (int)OS.Canvas_GetLeft(topHandle); + int y = (int)OS.Canvas_GetTop(topHandle); + if (x != this.x || y != this.y) { + this.x = x; + this.y = y; + sendEvent(SWT.Move); + } } void HandleContextMenuOpening (int sender, int e) { @@ -1401,6 +1482,22 @@ void HandlePreviewTextInput(int sender, int e) { sendKeyEvent (SWT.KeyDown, e, true); } +void HandleSizeChanged (int sender, int e) { + if (!checkEvent (e)) return; + int topHandle = topHandle(); + int width = (int) OS.FrameworkElement_ActualWidth (topHandle); + int height = (int) OS.FrameworkElement_ActualHeight (topHandle); + if (this.width != width || this.height != height) { + this.width = width; + this.height = height; + resized (); + } +} + +void resized () { + sendEvent (SWT.Resize); +} + boolean hasFocus () { // return OS.UIElement_IsFocused (handle); // return OS.UIElement_IsKeyboardFocused (handle); @@ -2400,8 +2497,14 @@ int setBounds (int x, int y, int width, int height, int flags) { if ((flags & MOVED) != 0) { int oldX = (int) OS.Canvas_GetLeft (topHandle); int oldY = (int) OS.Canvas_GetTop (topHandle); - if (oldX != x) OS.Canvas_SetLeft (topHandle, x); - if (oldY != y) OS.Canvas_SetTop (topHandle, y); + if (oldX != x) { + this.x = x; + OS.Canvas_SetLeft (topHandle, x); + } + if (oldY != y) { + this.y = y; + OS.Canvas_SetTop (topHandle, y); + } if (oldX != x || oldY != y) { sendEvent (SWT.Move); if (isDisposed ()) return 0; @@ -2411,8 +2514,14 @@ int setBounds (int x, int y, int width, int height, int flags) { if ((flags & RESIZED) != 0) { int oldWidth = (int) OS.FrameworkElement_Width (topHandle); int oldHeight = (int) OS.FrameworkElement_Height (topHandle); - if (oldWidth != width) OS.FrameworkElement_Width (topHandle, width); - if (oldHeight != height) OS.FrameworkElement_Height (topHandle, height); + if (oldWidth != width) { + this.width = width; + OS.FrameworkElement_Width (topHandle, width); + } + if (oldHeight != height) { + this.height = height; + OS.FrameworkElement_Height (topHandle, height); + } if (oldWidth != width || oldHeight != height) { sendEvent (SWT.Resize); if (isDisposed ()) return 0; @@ -2523,6 +2632,22 @@ public void setDragDetect (boolean dragDetect) { } /** + * WARNING: THIS API IS UNDER CONSTRUCTION AND SHOULD NOT BE USED + */ +public void setEffect(Effect effect){ + checkWidget (); + if (effect != null && effect.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT); + if (effect != null) { + OS.UIElement_BitmapEffect (handle, effect.handle); + OS.UIElement_ClipToBounds (topHandle (), false); + } else { + OS.UIElement_BitmapEffect (handle, 0); + setClipping(); + } +// updateLayout(handle); +} + +/** * Enables the receiver if the argument is <code>true</code>, * and disables it otherwise. A disabled control is typically * not selectable from the user interface and draws with an @@ -2928,6 +3053,21 @@ public void setToolTipText (String string) { } /** + * WARNING: THIS API IS UNDER CONSTRUCTION AND SHOULD NOT BE USED + */ +public void setTransform (Transform t) { + checkWidget (); + if (t == null) { + OS.FrameworkElement_RenderTransform (handle, 0); + return; + } + int matrixTransform = OS.gcnew_MatrixTransform (t.handle); +// OS.FrameworkElement_LayoutTransform (handle, matrixTransform); + OS.FrameworkElement_RenderTransform (handle, matrixTransform); + OS.GCHandle_Free (matrixTransform); +} + +/** * Marks the receiver as visible if the argument is <code>true</code>, * and marks it invisible otherwise. * <p> diff --git a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Display.java index 2fc5d66f69..f25eabc495 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Display.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Display.java @@ -93,8 +93,7 @@ import org.eclipse.swt.graphics.*; public class Display extends Device { - - int application, dispatcher, frame, jniRef; + int application, dispatcher, frame, jniRef, nameScope; boolean idle; int sleepOperation, operation; int operationCount; @@ -672,6 +671,8 @@ void createDisplay (DeviceData data) { application = OS.gcnew_Application(); if (application == 0) SWT.error(SWT.ERROR_NO_HANDLES); OS.Application_ShutdownMode (application, OS.ShutdownMode_OnExplicitShutdown); + nameScope = OS.gcnew_NameScope (); + if (nameScope == 0) SWT.error (SWT.ERROR_NO_HANDLES); } static void deregister (Display display) { @@ -2287,7 +2288,8 @@ void releaseDisplay () { } timerHandles = null; timerList = null; - + if (nameScope != 0) OS.GCHandle_Free (nameScope); + nameScope = 0; if (application != 0) { OS.Application_Shutdown (application); OS.GCHandle_Free (application); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Label.java b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Label.java index eef06e44de..171c4da750 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Label.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Label.java @@ -126,7 +126,9 @@ void createHandle () { } int defaultBackground () { - return OS.SystemColors_ControlColor; + //TEMPORARY CODE +// return OS.SystemColors_ControlColor; + return 0; } /** diff --git a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Widget.java b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Widget.java index 4f06fc5717..7b84029fe8 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Widget.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Widget.java @@ -385,6 +385,7 @@ void createWidget () { addWidget (); register (); hookEvents (); + setNameScope (); } void deregister () { @@ -1420,6 +1421,13 @@ boolean setKeyState (Event event, int type, int e) { return setInputState (event, type, 0, e); } +void setNameScope() { +// Name Scope should most likely be on topHandle, but animation +// is using handle right now because topHandle isn't visible +// OS.NameScope_SetNameScope(topHandle(), display.nameScope); + OS.NameScope_SetNameScope(handle, display.nameScope); +} + boolean showMenu (int x, int y) { Event event = new Event (); event.x = x; |