Exemplo n.º 1
0
 Point minimumSize(int wHint, int hHint, boolean flushCache) {
   Control[] children = _getChildren();
   int width = 0, height = 0;
   for (int i = 0; i < children.length; i++) {
     Control child = children[i];
     int index = 0;
     int count = 0;
     long /*int*/ list = OS.gtk_container_get_children(handle);
     if (list != 0) {
       count = OS.g_list_length(list);
       OS.g_list_free(list);
     }
     while (index < count) {
       if (items[index].control == child) break;
       index++;
     }
     if (index == count) {
       Rectangle rect = child.getBounds();
       width = Math.max(width, rect.x + rect.width);
       height = Math.max(height, rect.y + rect.height);
     } else {
       Point size = child.computeSize(wHint, hHint, flushCache);
       width = Math.max(width, size.x);
       height = Math.max(height, size.y);
     }
   }
   return new Point(width, height);
 }
Exemplo n.º 2
0
 void destroyItem(TabItem item) {
   int index = 0;
   int itemCount = getItemCount();
   while (index < itemCount) {
     if (items[index] == item) break;
     index++;
   }
   if (index == itemCount) error(SWT.ERROR_ITEM_NOT_REMOVED);
   int oldIndex = OS.gtk_notebook_get_current_page(handle);
   OS.g_signal_handlers_block_matched(handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, SWITCH_PAGE);
   OS.gtk_notebook_remove_page(handle, index);
   OS.g_signal_handlers_unblock_matched(handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, SWITCH_PAGE);
   System.arraycopy(items, index + 1, items, index, --itemCount - index);
   items[itemCount] = null;
   if (index == oldIndex) {
     int newIndex = OS.gtk_notebook_get_current_page(handle);
     if (newIndex != -1) {
       Control control = items[newIndex].getControl();
       if (control != null && !control.isDisposed()) {
         control.setBounds(getClientArea());
         control.setVisible(true);
       }
       Event event = new Event();
       event.item = items[newIndex];
       sendSelectionEvent(SWT.Selection, event, true);
       // the widget could be destroyed at this point
     }
   }
 }
Exemplo n.º 3
0
 /**
  * Sets the control that is shown when the item is expanded.
  *
  * @param control the new control (or null)
  * @exception IllegalArgumentException
  *     <ul>
  *       <li>ERROR_INVALID_ARGUMENT - if the control has been disposed
  *       <li>ERROR_INVALID_PARENT - if the control is not in the same widget tree
  *     </ul>
  *
  * @exception SWTException
  *     <ul>
  *       <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  *       <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  *     </ul>
  */
 public void setControl(Control control) {
   checkWidget();
   if (control != null) {
     if (control.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
     if (control.parent != parent) error(SWT.ERROR_INVALID_PARENT);
   }
   if (this.control == control) return;
   this.control = control;
   if (control != null) {
     control.setVisible(expanded);
   }
   parent.layoutItems(0, true);
 }
Exemplo n.º 4
0
 int setBounds(int x, int y, int width, int height, boolean move, boolean resize) {
   int result = super.setBounds(x, y, width, height, move, resize);
   if ((result & RESIZED) != 0) {
     int index = getSelectionIndex();
     if (index != -1) {
       TabItem item = items[index];
       Control control = item.control;
       if (control != null && !control.isDisposed()) {
         control.setBounds(getClientArea());
       }
     }
   }
   return result;
 }
Exemplo n.º 5
0
 @Override
 void createWidget(int index) {
   super.createWidget(index);
   layout.setFont(getFont());
   text = "";
   initAccessible();
 }
Exemplo n.º 6
0
 void setSelection(int index, boolean notify) {
   if (index < 0) return;
   int oldIndex = OS.gtk_notebook_get_current_page(handle);
   if (oldIndex == index) return;
   if (oldIndex != -1) {
     TabItem item = items[oldIndex];
     Control control = item.control;
     if (control != null && !control.isDisposed()) {
       control.setVisible(false);
     }
   }
   OS.g_signal_handlers_block_matched(handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, SWITCH_PAGE);
   OS.gtk_notebook_set_current_page(handle, index);
   OS.g_signal_handlers_unblock_matched(handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, SWITCH_PAGE);
   int newIndex = OS.gtk_notebook_get_current_page(handle);
   if (newIndex != -1) {
     TabItem item = items[newIndex];
     Control control = item.control;
     if (control != null && !control.isDisposed()) {
       control.setBounds(getClientArea());
       control.setVisible(true);
     }
     if (notify) {
       Event event = new Event();
       event.item = item;
       sendSelectionEvent(SWT.Selection, event, true);
     }
   }
 }
Exemplo n.º 7
0
 void resizeControl() {
   if (control != null && !control.isDisposed()) {
     /*
      * Set the size and location of the control
      * separately to minimize flashing in the
      * case where the control does not resize
      * to the size that was requested.  This
      * case can occur when the control is a
      * combo box.
      */
     Rectangle itemRect = getBounds();
     control.setSize(itemRect.width, itemRect.height);
     OS.gtk_widget_set_size_request(handle, itemRect.width, itemRect.height);
     Rectangle rect = control.getBounds();
     rect.x = itemRect.x + (itemRect.width - rect.width) / 2;
     rect.y = itemRect.y + (itemRect.height - rect.height) / 2;
     control.setLocation(rect.x, rect.y);
   }
 }
Exemplo n.º 8
0
 /**
  * Sets the control that is used to fill the bounds of the item when the item is a <code>SEPARATOR
  * </code>.
  *
  * @param control the new control
  * @exception IllegalArgumentException
  *     <ul>
  *       <li>ERROR_INVALID_ARGUMENT - if the control has been disposed
  *       <li>ERROR_INVALID_PARENT - if the control is not in the same widget tree
  *     </ul>
  *
  * @exception SWTException
  *     <ul>
  *       <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  *       <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  *     </ul>
  */
 public void setControl(Control control) {
   checkWidget();
   if (control != null) {
     if (control.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
     if (control.parent != parent) error(SWT.ERROR_INVALID_PARENT);
   }
   if ((style & SWT.SEPARATOR) == 0) return;
   if (this.control == control) return;
   this.control = control;
   parent.relayout();
 }
Exemplo n.º 9
0
 Widget[] computeTabList() {
   if (isTabGroup()) {
     if (getEnabled()) {
       if ((style & SWT.SEPARATOR) != 0) {
         if (control != null) return control.computeTabList();
       } else {
         return new Widget[] {this};
       }
     }
   }
   return new Widget[0];
 }
Exemplo n.º 10
0
 void setBounds(int x, int y, int width, int height, boolean move, boolean size) {
   redraw();
   int headerHeight = parent.getBandHeight();
   if (move) {
     if (imageHeight > headerHeight) {
       y += (imageHeight - headerHeight);
     }
     this.x = x;
     this.y = y;
     redraw();
   }
   if (size) {
     this.width = width;
     this.height = height;
     redraw();
   }
   if (control != null && !control.isDisposed()) {
     if (move) control.setLocation(x + BORDER, y + headerHeight);
     if (size) control.setSize(Math.max(0, width - 2 * BORDER), Math.max(0, height - BORDER));
   }
 }
Exemplo n.º 11
0
 @Override
 void enableWidget(boolean enabled) {
   super.enableWidget(enabled);
   if (isDisposed()) return;
   TextStyle linkStyle = new TextStyle(null, enabled ? linkColor : disabledColor, null);
   linkStyle.underline = true;
   for (int i = 0; i < offsets.length; i++) {
     Point point = offsets[i];
     layout.setStyle(linkStyle, point.x, point.y);
   }
   redraw();
 }
Exemplo n.º 12
0
 @Override
 void releaseWidget() {
   super.releaseWidget();
   if (layout != null) layout.dispose();
   layout = null;
   linkColor = null;
   if (disabledColor != null) disabledColor.dispose();
   disabledColor = null;
   offsets = null;
   ids = null;
   mnemonics = null;
   text = null;
 }
Exemplo n.º 13
0
  void resizeControl(int yScroll) {
    if (control != null && !control.isDisposed()) {
      boolean visible = OS.gtk_expander_get_expanded(handle);
      if (visible) {
        int x = OS.GTK_WIDGET_X(clientHandle);
        int y = OS.GTK_WIDGET_Y(clientHandle);
        if (x != -1 && y != -1) {
          int width = OS.GTK_WIDGET_WIDTH(clientHandle);
          int height = OS.GTK_WIDGET_HEIGHT(clientHandle);
          int[] property = new int[1];
          OS.gtk_widget_style_get(handle, OS.focus_line_width, property, 0);
          y += property[0] * 2;
          height -= property[0] * 2;

          /*
           * Feature in GTK. When the ExpandBar is resize too small the control
           * shows up on top of the vertical scrollbar. This happen because the
           * GtkExpander does not set the size of child smaller than the request
           * size of its parent and because the control is not parented in the
           * hierarchy of the GtkScrolledWindow.
           * The fix is calculate the width ourselves when the scrollbar is visible.
           */
          ScrollBar vBar = parent.verticalBar;
          if (vBar != null) {
            if (OS.GTK_WIDGET_VISIBLE(vBar.handle)) {
              width =
                  OS.GTK_WIDGET_WIDTH(parent.scrolledHandle)
                      - parent.vScrollBarWidth()
                      - 2 * parent.spacing;
            }
          }
          control.setBounds(x, y - yScroll, width, Math.max(0, height), true, true);
        }
      }
      control.setVisible(visible);
    }
  }
Exemplo n.º 14
0
 long /*int*/ gtk_switch_page(long /*int*/ widget, long /*int*/ page, long /*int*/ page_num) {
   int index = OS.gtk_notebook_get_current_page(handle);
   if (index != -1) {
     Control control = items[index].getControl();
     if (control != null && !control.isDisposed()) {
       control.setVisible(false);
     }
   }
   TabItem item = items[(int) /*64*/ page_num];
   Control control = item.getControl();
   if (control != null && !control.isDisposed()) {
     control.setBounds(getClientArea());
     control.setVisible(true);
   }
   Event event = new Event();
   event.item = item;
   sendSelectionEvent(SWT.Selection, event, false);
   return 0;
 }
Exemplo n.º 15
0
 void releaseWidget() {
   super.releaseWidget();
   if (timerId != 0) OS.gtk_timeout_remove(timerId);
   timerId = 0;
 }
Exemplo n.º 16
0
 @Override
 void setFontDescription(long /*int*/ font) {
   super.setFontDescription(font);
   layout.setFont(Font.gtk_new(display, font));
 }
Exemplo n.º 17
0
 @Override
 void setOrientation(boolean create) {
   super.setOrientation(create);
   layout.setOrientation(style & (SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT));
   if (!create) redraw(true);
 }
Exemplo n.º 18
0
 @Override
 void showWidget() {
   super.showWidget();
   fixStyle(handle);
 }