Пример #1
0
 public void setImage(Image image) {
   checkWidget();
   if ((style & SWT.SEPARATOR) != 0) return;
   super.setImage(image);
   if (image != null) {
     ImageList imageList = parent.imageList;
     if (imageList == null) imageList = parent.imageList = new ImageList();
     int imageIndex = imageList.indexOf(image);
     if (imageIndex == -1) {
       imageIndex = imageList.add(image);
     } else {
       imageList.put(imageIndex, image);
     }
     long /*int*/ pixbuf = imageList.getPixbuf(imageIndex);
     OS.gtk_image_set_from_pixbuf(imageHandle, pixbuf);
   } else {
     OS.gtk_image_set_from_pixbuf(imageHandle, 0);
   }
   /*
    * If Text/Image of a tool-item changes, then it is
    * required to reset the proxy menu. Otherwise, the
    * old menuItem appears in the overflow menu.
    */
   if ((style & SWT.DROP_DOWN) != 0) {
     proxyMenuItem = 0;
     proxyMenuItem = OS.gtk_tool_item_retrieve_proxy_menu_item(handle);
     OS.g_signal_connect(
         proxyMenuItem, OS.activate, ToolBar.menuItemSelectedFunc.getAddress(), handle);
   }
   parent.relayout();
 }
Пример #2
0
  /**
   * Sets the selection state of the receiver.
   *
   * <p>When the receiver is of type <code>CHECK</code> or <code>RADIO</code>, it is selected when
   * it is checked (which some platforms draw as a pushed in button).
   *
   * @param selected the new selection state
   * @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 setSelection(boolean selected) {
    checkWidget();
    if ((style & (SWT.CHECK | SWT.RADIO)) == 0) return;
    long /*int*/ hwnd = parent.handle;
    int fsState = (int) /*64*/ OS.SendMessage(hwnd, OS.TB_GETSTATE, id, 0);
    /*
     * Feature in Windows.  When TB_SETSTATE is used to set the
     * state of a tool item, the item redraws even when the state
     * has not changed.  The fix is to detect this case and avoid
     * setting the state.
     */
    if (((fsState & OS.TBSTATE_CHECKED) != 0) == selected) return;
    if (selected) {
      fsState |= OS.TBSTATE_CHECKED;
    } else {
      fsState &= ~OS.TBSTATE_CHECKED;
    }
    OS.SendMessage(hwnd, OS.TB_SETSTATE, id, fsState);

    /*
     * Bug in Windows.  When a tool item with the style
     * BTNS_CHECK or BTNS_CHECKGROUP is selected and then
     * disabled, the item does not draw using the disabled
     * image.  The fix is to use the disabled image in all
     * image lists for the item.
     *
     * NOTE: This means that the image list must be updated
     * when the selection changes in a disabled tool item.
     */
    if ((style & (SWT.CHECK | SWT.RADIO)) != 0) {
      if (!getEnabled() || !parent.getEnabled()) {
        updateImages(false);
      }
    }
  }
 void onDispose(long /*int*/ embedHandle) {
   if (SubclassProc == null) return;
   long /*int*/ hwndChild = OS.GetWindow(browser.handle, OS.GW_CHILD);
   OS.SetWindowLongPtr(hwndChild, OS.GWL_WNDPROC, MozillaProc);
   childWindows = null;
   browser = null;
 }
Пример #4
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
     }
   }
 }
Пример #5
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);
 }
Пример #6
0
  private int QueryContinueDrag(int fEscapePressed, int grfKeyState) {
    if (topControl != null && topControl.isDisposed()) return COM.DRAGDROP_S_CANCEL;
    if (fEscapePressed != 0) {
      if (hwndDrag != 0) OS.ImageList_DragLeave(hwndDrag);
      return COM.DRAGDROP_S_CANCEL;
    }
    /*
     * Bug in Windows.  On some machines that do not have XBUTTONs,
     * the MK_XBUTTON1 and OS.MK_XBUTTON2 bits are sometimes set,
     * causing mouse capture to become stuck.  The fix is to test
     * for the extra buttons only when they exist.
     */
    int mask = OS.MK_LBUTTON | OS.MK_MBUTTON | OS.MK_RBUTTON;
    //	if (display.xMouse) mask |= OS.MK_XBUTTON1 | OS.MK_XBUTTON2;
    if ((grfKeyState & mask) == 0) {
      if (hwndDrag != 0) OS.ImageList_DragLeave(hwndDrag);
      return COM.DRAGDROP_S_DROP;
    }

    if (hwndDrag != 0) {
      POINT pt = new POINT();
      OS.GetCursorPos(pt);
      RECT rect = new RECT();
      OS.GetWindowRect(hwndDrag, rect);
      OS.ImageList_DragMove(pt.x - rect.left, pt.y - rect.top);
    }
    return COM.S_OK;
  }
Пример #7
0
 int /*long*/ gtk_commit(int /*long*/ imcontext, int /*long*/ textPtr) {
   if (!isInlineEnabled()) return 0;
   boolean doit = true;
   ranges = null;
   styles = null;
   caretOffset = commitCount = 0;
   if (textPtr != 0 && inComposition) {
     int length = OS.strlen(textPtr);
     if (length != 0) {
       byte[] buffer = new byte[length];
       OS.memmove(buffer, textPtr, length);
       char[] chars = Converter.mbcsToWcs(null, buffer);
       Event event = new Event();
       event.detail = SWT.COMPOSITION_CHANGED;
       event.start = startOffset;
       event.end = startOffset + text.length();
       event.text = text = chars != null ? new String(chars) : "";
       commitCount = text.length();
       sendEvent(SWT.ImeComposition, event);
       doit = event.doit;
       text = "";
       startOffset = -1;
       commitCount = 0;
     }
   }
   inComposition = false;
   return doit ? 0 : 1;
 }
Пример #8
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);
     }
   }
 }
Пример #9
0
 /**
  * Sets the selection state of the receiver.
  *
  * <p>When the receiver is of type <code>CHECK</code> or <code>RADIO</code>, it is selected when
  * it is checked (which some platforms draw as a pushed in button).
  *
  * @param selected the new selection state
  * @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 setSelection(boolean selected) {
   checkWidget();
   if ((style & (SWT.CHECK | SWT.RADIO)) == 0) return;
   OS.g_signal_handlers_block_matched(handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CLICKED);
   OS.gtk_toggle_tool_button_set_active(handle, selected);
   OS.g_signal_handlers_unblock_matched(handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CLICKED);
 }
Пример #10
0
 /**
  * Gets the width of the receiver.
  *
  * @return the width
  * @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 getWidth() {
   checkWidget();
   long /*int*/ hwnd = parent.handle;
   int index = (int) /*64*/ OS.SendMessage(hwnd, OS.TB_COMMANDTOINDEX, id, 0);
   RECT rect = new RECT();
   OS.SendMessage(hwnd, OS.TB_GETITEMRECT, index, rect);
   return rect.right - rect.left;
 }
Пример #11
0
 void setOrientation(boolean create) {
   super.setOrientation(create);
   if ((parent.style & SWT.RIGHT_TO_LEFT) != 0 || !create) {
     int dir = (parent.style & SWT.RIGHT_TO_LEFT) != 0 ? OS.GTK_TEXT_DIR_RTL : OS.GTK_TEXT_DIR_LTR;
     OS.gtk_widget_set_direction(handle, dir);
     OS.gtk_container_forall(handle, display.setDirectionProc, dir);
   }
 }
Пример #12
0
 public static final int WebKitCreateInstance(
     GUID clsid, long /*int*/ pUnkOuter, GUID iid, long /*int*/[] ppvObject) {
   byte[] rclsid = new byte[GUID.sizeof];
   OS.IIDFromString((clsid.toString() + '\0').toCharArray(), rclsid);
   byte[] refiid = new byte[GUID.sizeof];
   OS.IIDFromString((iid.toString() + '\0').toCharArray(), refiid);
   return WebKitCreateInstance(rclsid, pUnkOuter, refiid, ppvObject);
 }
Пример #13
0
 boolean traversePage(final boolean next) {
   if (next) {
     OS.gtk_notebook_next_page(handle);
   } else {
     OS.gtk_notebook_prev_page(handle);
   }
   return true;
 }
 void addWindowSubclass() {
   long /*int*/ hwndChild = OS.GetWindow(browser.handle, OS.GW_CHILD);
   if (SubclassProc == null) {
     SubclassProc = new Callback(MozillaDelegate.class, "windowProc", 4); // $NON-NLS-1$
     MozillaProc = OS.GetWindowLongPtr(hwndChild, OS.GWL_WNDPROC);
   }
   OS.SetWindowLongPtr(hwndChild, OS.GWL_WNDPROC, SubclassProc.getAddress());
 }
Пример #15
0
 /**
  * Returns the number of items contained in the receiver.
  *
  * @return the number of items
  * @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 getItemCount() {
   checkWidget();
   long /*int*/ list = OS.gtk_container_get_children(handle);
   if (list == 0) return 0;
   int itemCount = OS.g_list_length(list);
   OS.g_list_free(list);
   return itemCount;
 }
Пример #16
0
 Color _getForeground() {
   int /*long*/[] ptr = new int /*long*/[1];
   OS.gtk_tree_model_get(parent.modelHandle, handle, Table.FOREGROUND_COLUMN, ptr, -1);
   if (ptr[0] == 0) return parent.getForeground();
   GdkColor gdkColor = new GdkColor();
   OS.memmove(gdkColor, ptr[0], GdkColor.sizeof);
   return Color.gtk_new(display, gdkColor);
 }
Пример #17
0
 @Override
 int setBounds(int x, int y, int width, int height, boolean move, boolean resize) {
   OS.gtk_toolbar_set_show_arrow(handle, false);
   int result = super.setBounds(x, y, width, height, move, resize);
   if ((result & RESIZED) != 0) relayout();
   if ((style & SWT.WRAP) != 0) OS.gtk_toolbar_set_show_arrow(handle, true);
   return result;
 }
Пример #18
0
 boolean setTabItemFocus() {
   if (parent.setTabItemFocus()) {
     long /*int*/ hwnd = parent.handle;
     int index = (int) /*64*/ OS.SendMessage(hwnd, OS.TB_COMMANDTOINDEX, id, 0);
     OS.SendMessage(hwnd, OS.TB_SETHOTITEM, index, 0);
     return true;
   }
   return false;
 }
Пример #19
0
 /**
  * Returns a rectangle describing the receiver's size and location relative to its parent.
  *
  * @return the receiver's bounding rectangle
  * @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 Rectangle getBounds() {
   checkWidget();
   long /*int*/ hwnd = parent.handle;
   int index = (int) /*64*/ OS.SendMessage(hwnd, OS.TB_COMMANDTOINDEX, id, 0);
   RECT rect = new RECT();
   OS.SendMessage(hwnd, OS.TB_GETITEMRECT, index, rect);
   int width = rect.right - rect.left;
   int height = rect.bottom - rect.top;
   return new Rectangle(rect.left, rect.top, width, height);
 }
Пример #20
0
 TableItem(Table parent, int style, int index, boolean create) {
   super(parent, style);
   this.parent = parent;
   if (create) {
     parent.createItem(this, index);
   } else {
     handle = OS.g_malloc(OS.GtkTreeIter_sizeof());
     OS.gtk_tree_model_iter_nth_child(parent.modelHandle, handle, 0, index);
   }
 }
Пример #21
0
 /**
  * Returns the item at the given, zero-relative index in the receiver. Throws an exception if the
  * index is out of range.
  *
  * @param index the index of the item to return
  * @return the item at the given index
  * @exception IllegalArgumentException
  *     <ul>
  *       <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the
  *           list minus 1 (inclusive)
  *     </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 TabItem getItem(int index) {
   checkWidget();
   if (!(0 <= index && index < getItemCount())) error(SWT.ERROR_INVALID_RANGE);
   long /*int*/ list = OS.gtk_container_get_children(handle);
   if (list == 0) error(SWT.ERROR_CANNOT_GET_ITEM);
   int itemCount = OS.g_list_length(list);
   OS.g_list_free(list);
   if (!(0 <= index && index < itemCount)) error(SWT.ERROR_CANNOT_GET_ITEM);
   return items[index];
 }
Пример #22
0
 boolean setFocus() {
   if (!OS.gtk_widget_get_child_visible(handle)) return false;
   OS.GTK_WIDGET_SET_FLAGS(handle, OS.GTK_CAN_FOCUS);
   OS.gtk_widget_grab_focus(handle);
   // widget could be disposed at this point
   if (isDisposed()) return false;
   boolean result = OS.gtk_widget_is_focus(handle);
   if (!result) OS.GTK_WIDGET_UNSET_FLAGS(handle, OS.GTK_CAN_FOCUS);
   return result;
 }
Пример #23
0
 void clearArea(int x, int y, int width, int height) {
   checkWidget();
   if (OS.IsWindowVisible(handle)) {
     RECT rect = new RECT();
     OS.SetRect(rect, x, y, x + width, y + height);
     long /*int*/ hDC =
         OS.GetDCEx(handle, 0, OS.DCX_CACHE | OS.DCX_CLIPCHILDREN | OS.DCX_CLIPSIBLINGS);
     drawBackground(hDC, rect);
     OS.ReleaseDC(handle, hDC);
   }
 }
Пример #24
0
 Color _getForeground(int index) {
   int count = Math.max(1, parent.columnCount);
   if (0 > index || index > count - 1) return _getForeground();
   int /*long*/[] ptr = new int /*long*/[1];
   int modelIndex =
       parent.columnCount == 0 ? Table.FIRST_COLUMN : parent.columns[index].modelIndex;
   OS.gtk_tree_model_get(parent.modelHandle, handle, modelIndex + Table.CELL_FOREGROUND, ptr, -1);
   if (ptr[0] == 0) return _getForeground();
   GdkColor gdkColor = new GdkColor();
   OS.memmove(gdkColor, ptr[0], GdkColor.sizeof);
   return Color.gtk_new(display, gdkColor);
 }
Пример #25
0
 /**
  * Searches the receiver's list starting at the first item (index 0) until an item is found that
  * is equal to the argument, and returns the index of that item. If no item is found, returns -1.
  *
  * @param item the search item
  * @return the index of the item
  * @exception IllegalArgumentException
  *     <ul>
  *       <li>ERROR_NULL_ARGUMENT - if the item is null
  *     </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 int indexOf(TabItem item) {
   checkWidget();
   if (item == null) error(SWT.ERROR_NULL_ARGUMENT);
   long /*int*/ list = OS.gtk_container_get_children(handle);
   if (list == 0) return -1;
   int count = OS.g_list_length(list);
   OS.g_list_free(list);
   for (int i = 0; i < count; i++) {
     if (items[i] == item) return i;
   }
   return -1;
 }
Пример #26
0
 /**
  * Returns a rectangle describing the receiver's size and location relative to its parent.
  *
  * @return the receiver's bounding rectangle
  * @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 Rectangle getBounds() {
   checkWidget();
   parent.forceResize();
   long /*int*/ topHandle = topHandle();
   int x, y, width, height;
   x = OS.GTK_WIDGET_X(topHandle);
   y = OS.GTK_WIDGET_Y(topHandle);
   width = OS.GTK_WIDGET_WIDTH(topHandle);
   height = OS.GTK_WIDGET_HEIGHT(topHandle);
   if ((parent.style & SWT.MIRRORED) != 0) x = parent.getClientWidth() - width - x;
   if ((style & SWT.SEPARATOR) != 0 && control != null) height = Math.max(height, 23);
   return new Rectangle(x, y, width, height);
 }
Пример #27
0
 public Point computeSize(int wHint, int hHint, boolean changed) {
   checkWidget();
   Point size = super.computeSize(wHint, hHint, changed);
   if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0;
   if (hHint != SWT.DEFAULT && hHint < 0) hHint = 0;
   boolean scrollable = OS.gtk_notebook_get_scrollable(handle);
   OS.gtk_notebook_set_scrollable(handle, false);
   Point notebookSize = computeNativeSize(handle, wHint, hHint, changed);
   OS.gtk_notebook_set_scrollable(handle, scrollable);
   size.x = Math.max(notebookSize.x, size.x);
   size.y = Math.max(notebookSize.y, size.y);
   return size;
 }
Пример #28
0
 void reskinChildren(int flags) {
   if (items != null) {
     long /*int*/ list = OS.gtk_container_get_children(handle);
     if (list != 0) {
       int count = OS.g_list_length(list);
       OS.g_list_free(list);
       for (int i = 0; i < count; i++) {
         TabItem item = items[i];
         if (item != null) item.reskin(flags);
       }
     }
   }
   super.reskinChildren(flags);
 }
Пример #29
0
 /**
  * Returns the tab item at the given point in the receiver or null if no such item exists. The
  * point is in the coordinate system of the receiver.
  *
  * @param point the point used to locate the item
  * @return the tab item at the given point, or null if the point is not in a tab item
  * @exception IllegalArgumentException
  *     <ul>
  *       <li>ERROR_NULL_ARGUMENT - if the point is null
  *     </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>
  *
  * @since 3.4
  */
 public TabItem getItem(Point point) {
   checkWidget();
   if (point == null) error(SWT.ERROR_NULL_ARGUMENT);
   long /*int*/ list = OS.gtk_container_get_children(handle);
   if (list == 0) return null;
   int itemCount = OS.g_list_length(list);
   OS.g_list_free(list);
   for (int i = 0; i < itemCount; i++) {
     TabItem item = items[i];
     Rectangle rect = item.getBounds();
     if (rect.contains(point)) return item;
   }
   return null;
 }
Пример #30
0
 long /*int*/ gtk_button_release_event(long /*int*/ widget, long /*int*/ event) {
   GdkEventButton gdkEvent = new GdkEventButton();
   OS.memmove(gdkEvent, event, GdkEventButton.sizeof);
   double x = gdkEvent.x;
   gdkEvent.x += OS.GTK_WIDGET_X(handle);
   double y = gdkEvent.y;
   gdkEvent.y += OS.GTK_WIDGET_Y(handle);
   OS.memmove(event, gdkEvent, GdkEventButton.sizeof);
   long /*int*/ result = parent.gtk_button_release_event(widget, event);
   gdkEvent.x = x;
   gdkEvent.y = y;
   OS.memmove(event, gdkEvent, GdkEventButton.sizeof);
   return result;
 }