Пример #1
0
 void propagateWidget(boolean enabled) {
   super.propagateWidget(enabled);
   if (formHandle != 0) propagateHandle(enabled, formHandle, OS.None);
   if (scrolledHandle != 0) {
     propagateHandle(enabled, scrolledHandle, OS.None);
     if (horizontalBar != null) horizontalBar.propagateWidget(enabled);
     if (verticalBar != null) verticalBar.propagateWidget(enabled);
   }
 }
Пример #2
0
 void releaseChildren(boolean destroy) {
   if (horizontalBar != null) {
     horizontalBar.release(false);
     horizontalBar = null;
   }
   if (verticalBar != null) {
     verticalBar.release(false);
     verticalBar = null;
   }
   super.releaseChildren(destroy);
 }
Пример #3
0
 void redrawWidget(
     int x, int y, int width, int height, boolean redrawAll, boolean allChildren, boolean trim) {
   super.redrawWidget(x, y, width, height, redrawAll, allChildren, trim);
   if (!trim) return;
   if (formHandle == 0 && scrolledHandle == 0) return;
   short[] root_x = new short[1], root_y = new short[1];
   OS.XtTranslateCoords(handle, (short) x, (short) y, root_x, root_y);
   if (formHandle != 0) {
     short[] form_x = new short[1], form_y = new short[1];
     OS.XtTranslateCoords(formHandle, (short) 0, (short) 0, form_x, form_y);
     redrawHandle(
         root_x[0] - form_x[0], root_y[0] - form_y[0], width, height, redrawAll, formHandle);
   }
   if (scrolledHandle != 0) {
     short[] scrolled_x = new short[1], scrolled_y = new short[1];
     OS.XtTranslateCoords(scrolledHandle, (short) 0, (short) 0, scrolled_x, scrolled_y);
     redrawHandle(
         root_x[0] - scrolled_x[0],
         root_y[0] - scrolled_y[0],
         width,
         height,
         redrawAll,
         scrolledHandle);
     if (horizontalBar != null && horizontalBar.getVisible()) {
       int horizontalHandle = horizontalBar.handle;
       short[] hscroll_x = new short[1], hscroll_y = new short[1];
       OS.XtTranslateCoords(horizontalHandle, (short) 0, (short) 0, hscroll_x, hscroll_y);
       redrawHandle(
           root_x[0] - hscroll_x[0],
           root_y[0] - hscroll_y[0],
           width,
           height,
           redrawAll,
           horizontalHandle);
     }
     if (verticalBar != null && verticalBar.getVisible()) {
       int verticalHandle = verticalBar.handle;
       short[] vscroll_x = new short[1], vscroll_y = new short[1];
       OS.XtTranslateCoords(verticalHandle, (short) 0, (short) 0, vscroll_x, vscroll_y);
       redrawHandle(
           root_x[0] - vscroll_x[0],
           root_y[0] - vscroll_y[0],
           width,
           height,
           redrawAll,
           verticalHandle);
     }
   }
 }
Пример #4
0
  boolean setScrollBarVisible(ScrollBar bar, boolean visible) {
    if (scrolledHandle == 0) return false;
    int barHandle = bar.handle;
    boolean managed = OS.XtIsManaged(barHandle);
    if (managed == visible) return false;

    /*
     * Feature in Motif.  Hiding or showing a scroll bar
     * can cause the widget to automatically resize in
     * the OS.  This behavior is unwanted.  The fix is
     * to force the widget to resize to original size.
     */
    int[] argList = {OS.XmNwidth, 0, OS.XmNheight, 0, OS.XmNborderWidth, 0};
    OS.XtGetValues(scrolledHandle, argList, argList.length / 2);

    int[] argList1 = {OS.XmNwidth, 0, OS.XmNheight, 0};
    OS.XtGetValues(handle, argList1, argList1.length / 2);

    /* Hide or show the scroll bar */
    if (visible) {
      OS.XtManageChild(barHandle);
    } else {
      OS.XtUnmanageChild(barHandle);
    }
    if ((state & CANVAS) != 0) {
      if (formHandle != 0) {
        boolean showBorder = (style & SWT.BORDER) != 0;
        int margin = showBorder || visible ? 3 : 0;
        if ((bar.style & SWT.V_SCROLL) != 0) {
          int[] argList2 = new int[] {OS.XmNmarginWidth, margin};
          OS.XtSetValues(formHandle, argList2, argList2.length / 2);
        }
        if ((bar.style & SWT.H_SCROLL) != 0) {
          int[] argList2 = new int[] {OS.XmNmarginHeight, margin};
          OS.XtSetValues(formHandle, argList2, argList2.length / 2);
        }
      }
    }

    /*
     * Feature in Motif.  When XtSetValues() is used to restore the width and
     * height of the widget, the new width and height are sometimes ignored.
     * The fix is to use XtResizeWidget().
     */
    OS.XtResizeWidget(scrolledHandle, argList[1], argList[3], argList[5]);

    bar.sendEvent(visible ? SWT.Show : SWT.Hide);
    int[] argList3 = {OS.XmNwidth, 0, OS.XmNheight, 0};
    OS.XtGetValues(handle, argList3, argList3.length / 2);
    return argList1[1] != argList3[1] || argList1[3] != argList3[3];
  }
Пример #5
0
 ScrollBar createStandardBar(int style) {
   if (scrolledHandle == 0) return null;
   ScrollBar bar = new ScrollBar();
   bar.parent = this;
   bar.style = style;
   bar.display = display;
   int[] argList = {OS.XmNhorizontalScrollBar, 0, OS.XmNverticalScrollBar, 0};
   OS.XtGetValues(scrolledHandle, argList, argList.length / 2);
   if (style == SWT.H_SCROLL) bar.handle = argList[1];
   if (style == SWT.V_SCROLL) bar.handle = argList[3];
   bar.hookEvents();
   bar.register();
   return bar;
 }
Пример #6
0
 void reskinChildren(int flags) {
   if (horizontalBar != null) horizontalBar.reskin(flags);
   if (verticalBar != null) verticalBar.reskin(flags);
   super.reskinChildren(flags);
 }
Пример #7
0
 void destroyScrollBar(ScrollBar bar) {
   setScrollBarVisible(bar, false);
   if ((state & CANVAS) != 0) bar.destroyHandle();
 }