Пример #1
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);
     }
   }
 }
Пример #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
     }
   }
 }
Пример #3
0
 long /*int*/ clientHandle() {
   int index = OS.gtk_notebook_get_current_page(handle);
   if (index != -1 && items[index] != null) {
     return items[index].pageHandle;
   }
   return handle;
 }
Пример #4
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;
 }
Пример #5
0
 /**
  * Returns the zero-relative index of the item which is currently selected in the receiver, or -1
  * if no item is selected.
  *
  * @return the index of the selected item
  * @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 int getSelectionIndex() {
   checkWidget();
   return OS.gtk_notebook_get_current_page(handle);
 }
Пример #6
0
 /**
  * Returns an array of <code>TabItem</code>s that are currently selected in the receiver. An empty
  * array indicates that no items are selected.
  *
  * <p>Note: This is not the actual structure used by the receiver to maintain its selection, so
  * modifying the array will not affect the receiver.
  *
  * @return an array representing the selection
  * @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 TabItem[] getSelection() {
   checkWidget();
   int index = OS.gtk_notebook_get_current_page(handle);
   if (index == -1) return new TabItem[0];
   return new TabItem[] {items[index]};
 }