Beispiel #1
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];
  }
Beispiel #2
0
 void manageChildren() {
   if (scrolledHandle != 0) {
     OS.XtSetMappedWhenManaged(scrolledHandle, false);
     OS.XtManageChild(scrolledHandle);
   }
   if (formHandle != 0) {
     OS.XtSetMappedWhenManaged(formHandle, false);
     OS.XtManageChild(formHandle);
   }
   super.manageChildren();
   if (formHandle != 0) {
     int[] argList = {OS.XmNborderWidth, 0};
     OS.XtGetValues(formHandle, argList, argList.length / 2);
     OS.XtResizeWidget(formHandle, 1, 1, argList[1]);
     OS.XtSetMappedWhenManaged(formHandle, true);
   }
   if (scrolledHandle != 0) {
     int[] argList = {OS.XmNborderWidth, 0};
     OS.XtGetValues(scrolledHandle, argList, argList.length / 2);
     OS.XtResizeWidget(scrolledHandle, 1, 1, argList[1]);
     OS.XtSetMappedWhenManaged(scrolledHandle, true);
   }
 }