summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSilenio Quarti <silenio>2009-10-19 18:42:52 +0000
committerSilenio Quarti <silenio>2009-10-19 18:42:52 +0000
commitc949dc84dfa58b502a8204ec55b149cae7841fbf (patch)
treeef1953e3b1efe3ba5d47ec3e1c93bc1c2230c69d
parent350de16780c32ce21cbcdf1b0bb6f4c1e2e8e6de (diff)
downloadeclipse.platform.swt-c949dc84dfa58b502a8204ec55b149cae7841fbf.tar.gz
eclipse.platform.swt-c949dc84dfa58b502a8204ec55b149cae7841fbf.tar.xz
eclipse.platform.swt-c949dc84dfa58b502a8204ec55b149cae7841fbf.zip
Bug 40258 - Position in editor overview ruler does not align with scrollbar
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ScrollBar.java76
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ScrollBar.java84
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ScrollBar.java12
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ScrollBar.java97
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/ScrollBar.java31
5 files changed, 300 insertions, 0 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ScrollBar.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ScrollBar.java
index b2fcd24553..34930fbeb6 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ScrollBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ScrollBar.java
@@ -325,6 +325,82 @@ public int getThumb () {
return (int) adjustment.page_size;
}
+public Rectangle getThumbBounds () {
+ checkWidget();
+ int slider_start = OS.GTK_RANGE_SLIDER_START (handle);
+ int slider_end = OS.GTK_RANGE_SLIDER_END (handle);
+ int x, y, width, height;
+ if ((style & SWT.VERTICAL) != 0) {
+ x = OS.GTK_WIDGET_X (handle);
+ y = slider_start;
+ width = OS.GTK_WIDGET_WIDTH (handle);
+ height = slider_end - slider_start;
+ } else {
+ x = slider_start;
+ y = OS.GTK_WIDGET_Y (handle);
+ width = slider_end - slider_start;
+ height = OS.GTK_WIDGET_HEIGHT (handle);
+ }
+ Rectangle rect = new Rectangle(x, y, width, height);
+ int [] origin_x = new int [1], origin_y = new int [1];
+ int /*long*/ window = OS.GTK_WIDGET_WINDOW (parent.scrolledHandle);
+ if (window != 0) OS.gdk_window_get_origin (window, origin_x, origin_y);
+ rect.x += origin_x [0];
+ rect.y += origin_y [0];
+ window = OS.GTK_WIDGET_WINDOW (parent.handle);
+ if (window != 0) OS.gdk_window_get_origin (window, origin_x, origin_y);
+ rect.x -= origin_x [0];
+ rect.y -= origin_y [0];
+ return rect;
+}
+
+public Rectangle getThumbTrackBounds () {
+ checkWidget();
+ int x = 0, y = 0, width, height;
+ boolean hasA = OS.GTK_RANGE_HAS_STEPPER_A (handle);
+ boolean hasB = OS.GTK_RANGE_HAS_STEPPER_B (handle);
+ boolean hasC = OS.GTK_RANGE_HAS_STEPPER_C (handle);
+ boolean hasD = OS.GTK_RANGE_HAS_STEPPER_D (handle);
+ if ((style & SWT.VERTICAL) != 0) {
+ int stepperSize = OS.GTK_WIDGET_WIDTH (handle);
+ x = OS.GTK_WIDGET_X (handle);
+ if (hasA) y += stepperSize;
+ if (hasB) y += stepperSize;
+ width = OS.GTK_WIDGET_WIDTH (handle);
+ height = OS.GTK_WIDGET_HEIGHT (handle) - y;
+ if (hasC) height -= stepperSize;
+ if (hasD) height -= stepperSize;
+ if (height < 0) {
+ y = OS.GTK_RANGE_SLIDER_START (handle);
+ height = 0;
+ }
+ } else {
+ int stepperSize = OS.GTK_WIDGET_HEIGHT (handle);
+ if (hasA) x += stepperSize;
+ if (hasB) x += stepperSize;
+ y = OS.GTK_WIDGET_Y (handle);
+ width = OS.GTK_WIDGET_WIDTH (handle) - x;
+ if (hasC) width -= stepperSize;
+ if (hasD) width -= stepperSize;
+ height = OS.GTK_WIDGET_HEIGHT (handle);
+ if (width < 0) {
+ x = OS.GTK_RANGE_SLIDER_START (handle);
+ width = 0;
+ }
+ }
+ Rectangle rect = new Rectangle(x, y, width, height);
+ int [] origin_x = new int [1], origin_y = new int [1];
+ int /*long*/ window = OS.GTK_WIDGET_WINDOW (parent.scrolledHandle);
+ if (window != 0) OS.gdk_window_get_origin (window, origin_x, origin_y);
+ rect.x += origin_x [0];
+ rect.y += origin_y [0];
+ window = OS.GTK_WIDGET_WINDOW (parent.handle);
+ if (window != 0) OS.gdk_window_get_origin (window, origin_x, origin_y);
+ rect.x -= origin_x [0];
+ rect.y -= origin_y [0];
+ return rect;
+}
+
/**
* Returns <code>true</code> if the receiver is visible, and
* <code>false</code> otherwise.
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ScrollBar.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ScrollBar.java
index f7756ac77a..1a5def919b 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ScrollBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ScrollBar.java
@@ -312,6 +312,90 @@ public int getThumb () {
OS.XtGetValues (handle, argList, argList.length / 2);
return argList [1];
}
+public Rectangle getThumbBounds () {
+ checkWidget();
+ int [] argList = {
+ OS.XmNsliderSize, 0, //1
+ OS.XmNwidth, 0, //3
+ OS.XmNheight, 0, //5
+ OS.XmNminimum, 0, //7
+ OS.XmNmaximum, 0, //9
+ OS.XmNvalue, 0, //11
+ };
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ Rectangle rect;
+ if ((style & SWT.VERTICAL) != 0) {
+ int slideSize = argList [5], sliderSize, sliderPos;
+ if (slideSize > 2 * argList [3]) {
+ slideSize -= 2 * argList [3];
+ float factor = (float)slideSize / (argList[9] - argList[7]);
+ sliderSize = (int)(0.5f + argList[1] * factor);
+ sliderPos = (int) (((argList[11] - argList[7]) * factor) + 0.5) + argList [3];
+ } else {
+ sliderPos = slideSize / 2;
+ sliderSize = 0;
+ }
+ rect = new Rectangle(0, sliderPos, argList[3], sliderSize);
+ } else {
+ int slideSize = argList [3], sliderSize, sliderPos;
+ if (slideSize > 2 * argList [5]) {
+ slideSize -= 2 * argList [5];
+ float factor = (float)slideSize / (argList[9] - argList[7]);
+ sliderSize = (int)(0.5f + argList[1] * factor);
+ sliderPos = (int) (((argList[11] - argList[7]) * factor) + 0.5) + argList [5];
+ } else {
+ sliderPos = slideSize / 2;
+ sliderSize = 0;
+ }
+ rect = new Rectangle(sliderPos, 0, sliderSize, argList[5]);
+ }
+ short [] root_x = new short [1], root_y = new short [1];
+ OS.XtTranslateCoords (handle, (short) rect.x, (short) rect.y, root_x, root_y);
+ rect.x = root_x [0];
+ rect.y = root_y [0];
+ OS.XtTranslateCoords (parent.handle, (short) 0, (short) 0, root_x, root_y);
+ rect.x -= root_x [0];
+ rect.y -= root_y [0];
+ return rect;
+}
+public Rectangle getThumbTrackBounds () {
+ checkWidget();
+ int [] argList = {
+ OS.XmNwidth, 0, //1
+ OS.XmNheight, 0, //3
+ };
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ Rectangle rect;
+ if ((style & SWT.VERTICAL) != 0) {
+ int slideSize = argList [3], slidePos;
+ if (slideSize > 2 * argList [1]) {
+ slidePos = argList [1];
+ slideSize -= 2 * (argList [1]);
+ } else {
+ slidePos = slideSize / 2;
+ slideSize = 0;
+ }
+ rect = new Rectangle(0, slidePos, argList[1], slideSize);
+ } else {
+ int slideSize = argList [1], slidePos;
+ if (slideSize > 2 * argList [3]) {
+ slidePos = argList [3];
+ slideSize -= 2 * (argList [3]);
+ } else {
+ slidePos = slideSize / 2;
+ slideSize = 0;
+ }
+ rect = new Rectangle(slidePos, 0, slideSize, argList[3]);
+ }
+ short [] root_x = new short [1], root_y = new short [1];
+ OS.XtTranslateCoords (handle, (short) rect.x, (short) rect.y, root_x, root_y);
+ rect.x = root_x [0];
+ rect.y = root_y [0];
+ OS.XtTranslateCoords (parent.handle, (short) 0, (short) 0, root_x, root_y);
+ rect.x -= root_x [0];
+ rect.y -= root_y [0];
+ return rect;
+}
/**
* Returns <code>true</code> if the receiver is visible, and
* <code>false</code> otherwise.
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ScrollBar.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ScrollBar.java
index e92f951cd6..42117cd7ab 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ScrollBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ScrollBar.java
@@ -338,6 +338,18 @@ public int getThumb () {
return args [1];
}
+public Rectangle getThumbBounds () {
+ checkWidget();
+ //TODO implement getThumbBounds()
+ return null;
+}
+
+public Rectangle getThumbTrackBounds () {
+ checkWidget();
+ //TODO implement getThumbTrackBounds()
+ return null;
+}
+
/**
* Returns <code>true</code> if the receiver is visible, and
* <code>false</code> otherwise.
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ScrollBar.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ScrollBar.java
index 80e8ca68af..2c397f136a 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ScrollBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ScrollBar.java
@@ -406,6 +406,103 @@ public int getThumb () {
}
/**
+ * Returns a rectangle describing the size and location of the
+ * receiver's thumb relative to its parent.
+ *
+ * @return the thumb bounds, relative to the {@link #getParent() parent}
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.6
+ */
+public Rectangle getThumbBounds () {
+ checkWidget();
+ parent.forceResize ();
+ SCROLLBARINFO info = new SCROLLBARINFO();
+ info.cbSize = SCROLLBARINFO.sizeof;
+ int x, y, width, height;
+ if ((style & SWT.HORIZONTAL) != 0) {
+ OS.GetScrollBarInfo(parent.handle, OS.OBJID_HSCROLL, info);
+ x = info.rcScrollBar.left + info.xyThumbTop;
+ y = info.rcScrollBar.top;
+ width = info.xyThumbBottom - info.xyThumbTop;
+ height = info.rcScrollBar.bottom - info.rcScrollBar.top;
+ } else {
+ OS.GetScrollBarInfo(parent.handle, OS.OBJID_VSCROLL, info);
+ x = info.rcScrollBar.left;
+ y = info.rcScrollBar.top + info.xyThumbTop;
+ width = info.rcScrollBar.right - info.rcScrollBar.left;
+ height = info.xyThumbBottom - info.xyThumbTop;
+ }
+ RECT rect = new RECT ();
+ rect.left = x;
+ rect.top = y;
+ rect.right = x + width;
+ rect.bottom = y + height;
+ OS.MapWindowPoints (0, parent.handle, rect, 2);
+ return new Rectangle(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top);
+}
+
+/**
+ * Returns a rectangle describing the size and location of the
+ * receiver's thumb track relative to its parent. This rectangle
+ * comprises the areas 2, 3, and 4 as described in {@link ScrollBar}.
+ *
+ * @return the thumb track bounds, relative to the {@link #getParent() parent}
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.6
+ */
+public Rectangle getThumbTrackBounds () {
+ checkWidget();
+ parent.forceResize ();
+ SCROLLBARINFO info = new SCROLLBARINFO();
+ info.cbSize = SCROLLBARINFO.sizeof;
+ int x = 0, y = 0, width, height;
+ if ((style & SWT.HORIZONTAL) != 0) {
+ OS.GetScrollBarInfo(parent.handle, OS.OBJID_HSCROLL, info);
+ int size = OS.GetSystemMetrics (OS.SM_CYHSCROLL);
+ y = info.rcScrollBar.top;
+ width = info.rcScrollBar.right - info.rcScrollBar.left;
+ height = size;
+ if (width <= 2 * size) {
+ x = info.rcScrollBar.left + width / 2;
+ width = 0;
+ } else {
+ x = info.rcScrollBar.left + size;
+ width -= 2 * size;
+ }
+ } else {
+ OS.GetScrollBarInfo(parent.handle, OS.OBJID_VSCROLL, info);
+ int size = OS.GetSystemMetrics (OS.SM_CYVSCROLL);
+ x = info.rcScrollBar.left;
+ width = size;
+ height = info.rcScrollBar.bottom - info.rcScrollBar.top;
+ if (height <= 2 * size) {
+ y = info.rcScrollBar.top + height / 2;
+ height = 0;
+ } else {
+ y = info.rcScrollBar.top + size;
+ height -= 2 * size;
+ }
+ }
+ RECT rect = new RECT ();
+ rect.left = x;
+ rect.top = y;
+ rect.right = x + width;
+ rect.bottom = y + height;
+ OS.MapWindowPoints (0, parent.handle, rect, 2);
+ return new Rectangle(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top);
+}
+
+/**
* Returns <code>true</code> if the receiver is visible, and
* <code>false</code> otherwise.
* <p>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/ScrollBar.java b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/ScrollBar.java
index db6026d2b5..c023abe452 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/ScrollBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/ScrollBar.java
@@ -339,6 +339,37 @@ public int getThumb () {
return (int) OS.ScrollBar_ViewportSize (handle);
}
+public Rectangle getThumbBounds () {
+ checkWidget();
+ int track = OS.ScrollBar_Track(handle);
+ int thumb = OS.Track_Thumb(track);
+ int point = OS.gcnew_Point (0, 0);
+ int newPoint = OS.UIElement_TranslatePoint (thumb, point, parent.handle);
+ int x = (int) (OS.Point_X (newPoint) + 0.5);
+ int y = (int) (OS.Point_Y (newPoint) + 0.5);
+ int width = (int) (OS.FrameworkElement_ActualWidth(thumb) + 0.5);
+ int height = (int) (OS.FrameworkElement_ActualHeight(thumb) + 0.5);
+ Rectangle rect = new Rectangle(x, y, width, height);
+ OS.GCHandle_Free (point);
+ OS.GCHandle_Free (newPoint);
+ return rect;
+}
+
+public Rectangle getThumbTrackBounds () {
+ checkWidget();
+ int track = OS.ScrollBar_Track(handle);
+ int point = OS.gcnew_Point (0, 0);
+ int newPoint = OS.UIElement_TranslatePoint (track, point, parent.handle);
+ int x = (int) (OS.Point_X (newPoint) + 0.5);
+ int y = (int) (OS.Point_Y (newPoint) + 0.5);
+ int width = (int) (OS.FrameworkElement_ActualWidth(track) + 0.5);
+ int height = (int) (OS.FrameworkElement_ActualHeight(track) + 0.5);
+ Rectangle rect = new Rectangle(x, y, width, height);
+ OS.GCHandle_Free (point);
+ OS.GCHandle_Free (newPoint);
+ return rect;
+}
+
/**
* Returns <code>true</code> if the receiver is visible, and
* <code>false</code> otherwise.