コード例 #1
0
 long /*int*/ menuItemSelected(long /*int*/ widget, ToolItem item) {
   Event event = new Event();
   switch (item.style) {
     case SWT.DROP_DOWN:
       /*
        * Feature in GTK. The DROP_DOWN item does not
        * contain arrow button in the overflow menu. So, it
        * is impossible to select the menu of that item.
        * The fix is to consider the item selection
        * as Arrow click, in order to popup the drop-down.
        */
       event.detail = SWT.ARROW;
       GtkAllocation allocation = new GtkAllocation();
       OS.gtk_widget_get_allocation(widget, allocation);
       event.x = allocation.x;
       if ((style & SWT.MIRRORED) != 0) event.x = getClientWidth() - allocation.width - event.x;
       event.y = allocation.y + allocation.height;
       break;
     case SWT.RADIO:
       if ((style & SWT.NO_RADIO_GROUP) == 0) item.selectRadio();
       break;
     case SWT.CHECK:
       boolean currentSelection = item.getSelection();
       item.setSelection(!currentSelection);
   }
   item.sendSelectionEvent(SWT.Selection, event, false);
   return 0;
 }
コード例 #2
0
 void relayout() {
   ToolItem[] items = getItems();
   boolean hasText = false, hasImage = false;
   for (int i = 0; i < items.length; i++) {
     ToolItem item = items[i];
     if (item != null) {
       item.resizeControl();
       hasText |= item.text != null && item.text.length() > 0;
       hasImage |= item.image != null;
     }
   }
   int type = OS.GTK_TOOLBAR_ICONS;
   if (hasText && hasImage) {
     if ((style & SWT.RIGHT) != 0) {
       type = OS.GTK_TOOLBAR_BOTH_HORIZ;
     } else {
       type = OS.GTK_TOOLBAR_BOTH;
     }
   } else if (hasText) {
     type = OS.GTK_TOOLBAR_TEXT;
   } else if (hasImage) {
     type = OS.GTK_TOOLBAR_ICONS;
   }
   OS.gtk_toolbar_set_style(handle, type);
 }
コード例 #3
0
 static long /*int*/ MenuItemSelectedProc(long /*int*/ widget, long /*int*/ user_data) {
   Display display = Display.getCurrent();
   ToolItem item = (ToolItem) display.getWidget(user_data);
   if (item != null) {
     return item.getParent().menuItemSelected(widget, item);
   }
   return 0;
 }
コード例 #4
0
 @Override
 void removeControl(Control control) {
   super.removeControl(control);
   ToolItem[] items = getItems();
   for (int i = 0; i < items.length; i++) {
     ToolItem item = items[i];
     if (item.control == control) item.setControl(null);
   }
 }
コード例 #5
0
 @Override
 void reskinChildren(int flags) {
   ToolItem[] items = _getItems();
   if (items != null) {
     for (int i = 0; i < items.length; i++) {
       ToolItem item = items[i];
       if (item != null) item.reskin(flags);
     }
   }
   super.reskinChildren(flags);
 }
コード例 #6
0
 @Override
 void releaseChildren(boolean destroy) {
   ToolItem[] items = getItems();
   for (int i = 0; i < items.length; i++) {
     ToolItem item = items[i];
     if (item != null && !item.isDisposed()) {
       item.release(false);
     }
   }
   super.releaseChildren(destroy);
 }
コード例 #7
0
ファイル: ToolItem.java プロジェクト: fzoli/RemoteControlCar
 boolean isTabGroup() {
   ToolItem[] tabList = parent._getTabItemList();
   if (tabList != null) {
     for (int i = 0; i < tabList.length; i++) {
       if (tabList[i] == this) return true;
     }
   }
   if ((style & SWT.SEPARATOR) != 0) return true;
   int index = parent.indexOf(this);
   if (index == 0) return true;
   ToolItem previous = parent.getItem(index - 1);
   return (previous.getStyle() & SWT.SEPARATOR) != 0;
 }
コード例 #8
0
 /*public*/ void setTabItemList(ToolItem[] tabList) {
   checkWidget();
   if (tabList != null) {
     for (int i = 0; i < tabList.length; i++) {
       ToolItem item = tabList[i];
       if (item == null) error(SWT.ERROR_INVALID_ARGUMENT);
       if (item.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
       if (item.parent != this) error(SWT.ERROR_INVALID_PARENT);
     }
     ToolItem[] newList = new ToolItem[tabList.length];
     System.arraycopy(tabList, 0, newList, 0, tabList.length);
     tabList = newList;
   }
   this.tabItemList = tabList;
 }
コード例 #9
0
 @Override
 Widget computeTabGroup() {
   ToolItem[] items = _getItems();
   if (tabItemList == null) {
     int i = 0;
     while (i < items.length && items[i].control == null) i++;
     if (i == items.length) return super.computeTabGroup();
   }
   int index = indexOf(currentFocusItem);
   if (index == -1) index = items.length - 1;
   while (index >= 0) {
     ToolItem item = items[index];
     if (item.isTabGroup()) return item;
     index--;
   }
   return super.computeTabGroup();
 }
コード例 #10
0
 @Override
 void fixChildren(
     Shell newShell,
     Shell oldShell,
     Decorations newDecorations,
     Decorations oldDecorations,
     Menu[] menus) {
   super.fixChildren(newShell, oldShell, newDecorations, oldDecorations, menus);
   ToolItem[] items = getItems();
   if (toolTipText == null) {
     for (int i = 0; i < items.length; i++) {
       ToolItem item = items[i];
       if (item.toolTipText != null) {
         item.setToolTipText(oldShell, null);
         item.setToolTipText(newShell, item.toolTipText);
       }
     }
   }
 }
コード例 #11
0
 @Override
 Widget[] computeTabList() {
   ToolItem[] items = _getItems();
   if (tabItemList == null) {
     int i = 0;
     while (i < items.length && items[i].control == null) i++;
     if (i == items.length) return super.computeTabList();
   }
   Widget result[] = {};
   if (!isTabGroup() || !isEnabled() || !isVisible()) return result;
   ToolItem[] list = tabList != null ? _getTabItemList() : items;
   for (int i = 0; i < list.length; i++) {
     ToolItem child = list[i];
     Widget[] childList = child.computeTabList();
     if (childList.length != 0) {
       Widget[] newResult = new Widget[result.length + childList.length];
       System.arraycopy(result, 0, newResult, 0, result.length);
       System.arraycopy(childList, 0, newResult, result.length, childList.length);
       result = newResult;
     }
   }
   if (result.length == 0) result = new Widget[] {this};
   return result;
 }