Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelipe Heidrich2008-03-03 13:41:22 -0500
committerFelipe Heidrich2008-03-03 13:41:22 -0500
commitd96bb7d14b0502175aaffe21366e4259f6bf8cfc (patch)
tree51dd7748c1d985face2f3c8742c3b222b16a16d0
parent8dffe457addf7aa23b16b0bf1a105aafd890d061 (diff)
downloadeclipse.platform.swt-wpf_work.tar.gz
eclipse.platform.swt-wpf_work.tar.xz
eclipse.platform.swt-wpf_work.zip
WPF hacks for Animation and FlickerViewerwpf_work
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Animation2/wpf/org/eclipse/swt/animation/LinearPropertyAnimation.java63
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Animation2/wpf/org/eclipse/swt/animation/Properties.java1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Animation2/wpf/org/eclipse/swt/animation/PropertyAnimation.java11
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Composite.java25
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Control.java92
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Label.java2
6 files changed, 180 insertions, 14 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Animation2/wpf/org/eclipse/swt/animation/LinearPropertyAnimation.java b/bundles/org.eclipse.swt/Eclipse SWT Animation2/wpf/org/eclipse/swt/animation/LinearPropertyAnimation.java
index 5e697f05ef..46bcba7bdd 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Animation2/wpf/org/eclipse/swt/animation/LinearPropertyAnimation.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Animation2/wpf/org/eclipse/swt/animation/LinearPropertyAnimation.java
@@ -28,6 +28,27 @@ public class LinearPropertyAnimation extends PropertyAnimation {
setTargetProperty(animation, property);
}
+ void createPointAnimation() {
+ int children = OS.TimelineGroup_Children(handle);
+ if ("location".equals(property)) {
+ xAnim = OS.gcnew_DoubleAnimation();
+ OS.IList_Add(children, xAnim);
+ setTargetProperty(xAnim, "x");
+ yAnim = OS.gcnew_DoubleAnimation();
+ OS.IList_Add(children, yAnim);
+ setTargetProperty(yAnim, "y");
+ }
+ if ("size".equals(property)) {
+ wAnim = OS.gcnew_DoubleAnimation();
+ OS.IList_Add(children, wAnim);
+ setTargetProperty(wAnim, "Width");
+ hAnim = OS.gcnew_DoubleAnimation();
+ OS.IList_Add(children, hAnim);
+ setTargetProperty(hAnim, "Height");
+ }
+ OS.GCHandle_Free(children);
+ }
+
void createRectangleAnimation() {
int children = OS.TimelineGroup_Children(handle);
xAnim = OS.gcnew_DoubleAnimation();
@@ -104,27 +125,55 @@ public class LinearPropertyAnimation extends PropertyAnimation {
void updateFromToValues() {
if (paramType == Double.TYPE) {
- OS.DoubleAnimation_From(animation, ((Double)from).doubleValue());
- OS.DoubleAnimation_To(animation, ((Double)to).doubleValue());
+ double fromValue = 0, toValue;
+ if ("alpha".equals(property)) {
+ if (from != null) fromValue = ((Number)from).doubleValue() / 255;
+ toValue = ((Number)to).doubleValue() / 255;
+ } else {
+ if (from != null) fromValue = ((Number)from).doubleValue();
+ toValue = ((Number)to).doubleValue();
+ }
+ if (from != null) OS.DoubleAnimation_From(animation, fromValue);
+ OS.DoubleAnimation_To(animation, toValue);
}
if (paramType == Color.class || paramType == Transform.class) {
OS.DoubleAnimation_From(animation, 0);
OS.DoubleAnimation_To(animation, 1);
}
if (paramType == Integer.TYPE) {
- OS.Int32Animation_From(animation, ((Integer)from).intValue());
+ if (from != null) OS.Int32Animation_From(animation, ((Integer)from).intValue());
OS.Int32Animation_To(animation, ((Integer)to).intValue());
}
if (paramType == Rectangle.class) {
- OS.DoubleAnimation_From(xAnim, ((Rectangle)from).x);
+ if (from != null) {
+ OS.DoubleAnimation_From(xAnim, ((Rectangle)from).x);
+ OS.DoubleAnimation_From(yAnim, ((Rectangle)from).y);
+ OS.DoubleAnimation_From(wAnim, ((Rectangle)from).width);
+ OS.DoubleAnimation_From(hAnim, ((Rectangle)from).height);
+ }
OS.DoubleAnimation_To(xAnim, ((Rectangle)to).x);
- OS.DoubleAnimation_From(yAnim, ((Rectangle)from).y);
OS.DoubleAnimation_To(yAnim, ((Rectangle)to).y);
- OS.DoubleAnimation_From(wAnim, ((Rectangle)from).width);
OS.DoubleAnimation_To(wAnim, ((Rectangle)to).width);
- OS.DoubleAnimation_From(hAnim, ((Rectangle)from).height);
OS.DoubleAnimation_To(hAnim, ((Rectangle)to).height);
}
+ if (paramType == Point.class) {
+ if ("location".equals(property)) {
+ if (from != null) {
+ OS.DoubleAnimation_From(xAnim, ((Point)from).x);
+ OS.DoubleAnimation_From(yAnim, ((Point)from).y);
+ }
+ OS.DoubleAnimation_To(xAnim, ((Point)to).x);
+ OS.DoubleAnimation_To(yAnim, ((Point)to).y);
+ }
+ if ("size".equals(property)) {
+ if (from != null) {
+ OS.DoubleAnimation_From(wAnim, ((Point)from).x);
+ OS.DoubleAnimation_From(hAnim, ((Point)from).y);
+ }
+ OS.DoubleAnimation_To(wAnim, ((Point)to).x);
+ OS.DoubleAnimation_To(hAnim, ((Point)to).y);
+ }
+ }
// else {
// throw new RuntimeException(paramType.getName() + " is not supported yet.");
// }
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Animation2/wpf/org/eclipse/swt/animation/Properties.java b/bundles/org.eclipse.swt/Eclipse SWT Animation2/wpf/org/eclipse/swt/animation/Properties.java
index d6506457ce..ae35daa1cc 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Animation2/wpf/org/eclipse/swt/animation/Properties.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Animation2/wpf/org/eclipse/swt/animation/Properties.java
@@ -18,6 +18,7 @@ class Properties {
}
static int getDependencyProperty(Object target, String property) {
+ if (property.equalsIgnoreCase("alpha")) return OS.UIElement_OpacityProperty();
if (property.equalsIgnoreCase("x")) return OS.Canvas_LeftProperty();
if (property.equalsIgnoreCase("y")) return OS.Canvas_TopProperty();
if (property.equalsIgnoreCase("Width")) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Animation2/wpf/org/eclipse/swt/animation/PropertyAnimation.java b/bundles/org.eclipse.swt/Eclipse SWT Animation2/wpf/org/eclipse/swt/animation/PropertyAnimation.java
index c347eaf2c8..2fe609f5cf 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Animation2/wpf/org/eclipse/swt/animation/PropertyAnimation.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Animation2/wpf/org/eclipse/swt/animation/PropertyAnimation.java
@@ -48,6 +48,9 @@ public class PropertyAnimation extends Animation {
void createRectangleAnimation() {
}
+ void createPointAnimation() {
+ }
+
void OnPropertyChanged(int object, int args) {
try {
if (nextValue != null) {
@@ -173,6 +176,10 @@ public class PropertyAnimation extends Animation {
// }
void setParamType() {
+ if ("alpha".equals(property) || "x".equals(property) || "y".equals(property) || "width".equals(property) || "height".equals(property)) {
+ paramType = Double.TYPE;
+ return;
+ }
String mName = "set" + property.substring(0, 1).toUpperCase() + property.substring(1);
Class clazz = target.getClass();
Method[] methods = clazz.getMethods();
@@ -245,6 +252,10 @@ public class PropertyAnimation extends Animation {
createRectangleAnimation();
return;
}
+ if (paramType == Point.class) {
+ createPointAnimation();
+ return;
+ }
throw new RuntimeException(paramType + " is not supported yet.");
}
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 7860829221..ae9890c7a6 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
@@ -871,6 +871,31 @@ void removeControl (Control control) {
fixTabList (control);
}
+void resized () {
+ super.resized();
+ if (isDisposed ()) return;
+ if (layout != null) {
+ markLayout (false, false);
+ updateLayout (false, false);
+ }
+}
+
+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 c097fa425c..f66aa840d2 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
@@ -46,6 +46,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;
@@ -1286,6 +1287,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) {
@@ -1427,6 +1471,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);
@@ -2416,8 +2476,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;
@@ -2427,8 +2493,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;
@@ -2538,8 +2610,16 @@ public void setDragDetect (boolean dragDetect) {
}
}
-public void setBitmapEffect(Effect effect){
- OS.UIElement_BitmapEffect (handle, effect.handle);
+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);
}
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 f2709294ff..53d86c2062 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,7 @@ void createHandle () {
}
int defaultBackground () {
- return OS.SystemColors_ControlColor;
+ return 0;
}
/**

Back to the top