summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelipe Heidrich <fheidric>2007-02-22 16:27:52 +0000
committerFelipe Heidrich <fheidric>2007-02-22 16:27:52 +0000
commit29b024ee312f844d4f7ab73dd22326302188e56c (patch)
tree8820571a94a90bc5bffb6bd185cd126e643cf9f1
parent696aea6756a0a7d46df771aafb6e94481b81ce87 (diff)
downloadeclipse.platform.swt-29b024ee312f844d4f7ab73dd22326302188e56c.tar.gz
eclipse.platform.swt-29b024ee312f844d4f7ab73dd22326302188e56c.tar.xz
eclipse.platform.swt-29b024ee312f844d4f7ab73dd22326302188e56c.zip
Group#computeTrim starts to fail when parent tree is set as the control of an unselect TabItem, problem can be seing in ControlExample. The fix is stop reparenting in TabItem#setControl().
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/TabFolder.java36
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/TabItem.java27
2 files changed, 44 insertions, 19 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/TabFolder.java b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/TabFolder.java
index f53969ce02..8e7beda5a9 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/TabFolder.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/TabFolder.java
@@ -222,6 +222,20 @@ Control [] _getChildren () {
return result;
}
+public Rectangle getClientArea () {
+ checkWidget ();
+ Rectangle rect = super.getClientArea ();
+ int clientHandle = clientHandle ();
+ int topHandle = topHandle ();
+ int point = OS.gcnew_Point (0, 0);
+ int result = OS.UIElement_TranslatePoint (clientHandle, point, topHandle);
+ rect.x = (int) OS.Point_X (result);
+ rect.y = (int) OS.Point_Y (result);
+ OS.GCHandle_Free (point);
+ OS.GCHandle_Free (result);
+ return rect;
+}
+
/**
* Returns the item at the given, zero-relative index in the
* receiver. Throws an exception if the index is out of range.
@@ -340,13 +354,29 @@ boolean hasItems () {
return true;
}
-void HandleSelectionChange (int sender, int e) {
+void HandleSelectionChanged (int sender, int e) {
if (!checkEvent (e)) return;
- if (ignoreSelection) return;
+ int removed = OS.SelectionChangedEventArgs_RemovedItems (e);
+ if (OS.ICollection_Count (removed) > 0) {
+ int oldSelection = OS.IList_default (removed, 0);
+ TabItem item = (TabItem) display.getWidget (oldSelection);
+ OS.GCHandle_Free (oldSelection);
+ Control control = item.getControl();
+ if (control != null && !control.isDisposed ()) {
+ control.setVisible (false);
+ }
+ }
+ OS.GCHandle_Free (removed);
int selectedItem = OS.Selector_SelectedItem (handle);
if (selectedItem == 0) return;
TabItem item = (TabItem) display.getWidget (selectedItem);
OS.GCHandle_Free (selectedItem);
+
+ Control control = item.getControl();
+ if (control != null && !control.isDisposed ()) {
+ control.setVisible (true);
+ }
+ if (ignoreSelection) return;
Event event = new Event ();
event.item = item;
postEvent (SWT.Selection, event);
@@ -354,7 +384,7 @@ void HandleSelectionChange (int sender, int e) {
void hookEvents () {
super.hookEvents ();
- int handler = OS.gcnew_SelectionChangedEventHandler (jniRef, "HandleSelectionChange");
+ int handler = OS.gcnew_SelectionChangedEventHandler (jniRef, "HandleSelectionChanged");
OS.Selector_SelectionChanged (handle, handler);
OS.GCHandle_Free (handler);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/TabItem.java b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/TabItem.java
index ff37292228..dca8e1e6d7 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/TabItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/TabItem.java
@@ -272,26 +272,21 @@ public void setControl (Control control) {
if (control.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
if (control.parent != parent) error (SWT.ERROR_INVALID_PARENT);
}
+ if (this.control != null && this.control.isDisposed ()) {
+ this.control = null;
+ }
Control oldControl = this.control, newControl = control;
this.control = control;
- int children = OS.Panel_Children (contentHandle);
- int parentHandle = parent.parentingHandle ();
- int parentChildren = OS.Panel_Children (parentHandle);
- if (newControl != null) {
- int topHandle = newControl.topHandle ();
- OS.UIElementCollection_Remove (parentChildren, topHandle);
- OS.UIElementCollection_Add (children, topHandle);
- if (OS.FrameworkElement_IsLoaded (handle)) {
- newControl.setBounds (parent.getClientArea ());
- }
+ int index = parent.indexOf (this);
+ if (index != parent.getSelectionIndex ()) {
+ if (newControl != null) newControl.setVisible (false);
+ return;
}
- if (oldControl != null) {
- int topHandle = oldControl.topHandle ();
- OS.UIElementCollection_Remove (children, topHandle);
- OS.UIElementCollection_Add (parentChildren, topHandle);
+ if (newControl != null) {
+ newControl.setBounds (parent.getClientArea ());
+ newControl.setVisible (true);
}
- OS.GCHandle_Free (children);
- OS.GCHandle_Free (parentChildren);
+ if (oldControl != null) oldControl.setVisible (false);
}
public void setImage (Image image) {