예제 #1
0
  /*
   * EnumFormatEtc([in] dwDirection, [out] ppenumFormatetc)
   * Ownership of ppenumFormatetc transfers from callee to caller so reference count on ppenumFormatetc
   * must be incremented before returning.  Caller is responsible for releasing ppenumFormatetc.
   */
  private int EnumFormatEtc(int dwDirection, long /*int*/ ppenumFormatetc) {
    // only allow getting of data - SetData is not currently supported
    if (dwDirection == COM.DATADIR_SET) return COM.E_NOTIMPL;

    // what types have been registered?
    TransferData[] allowedDataTypes = new TransferData[0];
    for (int i = 0; i < transferAgents.length; i++) {
      Transfer transferAgent = transferAgents[i];
      if (transferAgent != null) {
        TransferData[] formats = transferAgent.getSupportedTypes();
        TransferData[] newAllowedDataTypes =
            new TransferData[allowedDataTypes.length + formats.length];
        System.arraycopy(allowedDataTypes, 0, newAllowedDataTypes, 0, allowedDataTypes.length);
        System.arraycopy(formats, 0, newAllowedDataTypes, allowedDataTypes.length, formats.length);
        allowedDataTypes = newAllowedDataTypes;
      }
    }

    OleEnumFORMATETC enumFORMATETC = new OleEnumFORMATETC();
    enumFORMATETC.AddRef();

    FORMATETC[] formats = new FORMATETC[allowedDataTypes.length];
    for (int i = 0; i < formats.length; i++) {
      formats[i] = allowedDataTypes[i].formatetc;
    }
    enumFORMATETC.setFormats(formats);

    OS.MoveMemory(ppenumFormatetc, new long /*int*/[] {enumFORMATETC.getAddress()}, OS.PTR_SIZEOF);
    return COM.S_OK;
  }
예제 #2
0
 void createItem(TabItem item, int index) {
   long /*int*/ list = OS.gtk_container_get_children(handle);
   int itemCount = 0;
   if (list != 0) {
     itemCount = OS.g_list_length(list);
     OS.g_list_free(list);
   }
   if (!(0 <= index && index <= itemCount)) error(SWT.ERROR_INVALID_RANGE);
   if (itemCount == items.length) {
     TabItem[] newItems = new TabItem[items.length + 4];
     System.arraycopy(items, 0, newItems, 0, items.length);
     items = newItems;
   }
   long /*int*/ boxHandle = gtk_box_new(OS.GTK_ORIENTATION_HORIZONTAL, false, 0);
   if (boxHandle == 0) error(SWT.ERROR_NO_HANDLES);
   long /*int*/ labelHandle = OS.gtk_label_new_with_mnemonic(null);
   if (labelHandle == 0) error(SWT.ERROR_NO_HANDLES);
   long /*int*/ imageHandle = OS.gtk_image_new();
   if (imageHandle == 0) error(SWT.ERROR_NO_HANDLES);
   OS.gtk_container_add(boxHandle, imageHandle);
   OS.gtk_container_add(boxHandle, labelHandle);
   long /*int*/ pageHandle = OS.g_object_new(display.gtk_fixed_get_type(), 0);
   if (pageHandle == 0) error(SWT.ERROR_NO_HANDLES);
   if (OS.GTK3) {
     OS.gtk_widget_override_background_color(pageHandle, OS.GTK_STATE_FLAG_NORMAL, new GdkRGBA());
     long /*int*/ region = OS.gdk_region_new();
     OS.gtk_widget_input_shape_combine_region(pageHandle, region);
     OS.gdk_region_destroy(region);
   }
   OS.g_signal_handlers_block_matched(handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, SWITCH_PAGE);
   OS.gtk_notebook_insert_page(handle, pageHandle, boxHandle, index);
   OS.g_signal_handlers_unblock_matched(handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, SWITCH_PAGE);
   OS.gtk_widget_show(boxHandle);
   OS.gtk_widget_show(labelHandle);
   OS.gtk_widget_show(pageHandle);
   item.state |= HANDLE;
   item.handle = boxHandle;
   item.labelHandle = labelHandle;
   item.imageHandle = imageHandle;
   item.pageHandle = pageHandle;
   System.arraycopy(items, index, items, index + 1, itemCount++ - index);
   items[index] = item;
   if ((state & FOREGROUND) != 0) {
     item.setForegroundColor(getForegroundColor());
   }
   if ((state & FONT) != 0) {
     item.setFontDescription(getFontDescription());
   }
   if (itemCount == 1) {
     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, 0);
     OS.g_signal_handlers_unblock_matched(handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, SWITCH_PAGE);
     Event event = new Event();
     event.item = items[0];
     sendSelectionEvent(SWT.Selection, event, false);
     // the widget could be destroyed at this point
   }
 }
예제 #3
0
 /**
  * Returns an array of <code>TabItem</code>s which are the items in the receiver.
  *
  * <p>Note: This is not the actual structure used by the receiver to maintain its list of items,
  * so modifying the array will not affect the receiver.
  *
  * @return the items in the receiver
  * @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[] getItems() {
   checkWidget();
   int count = getItemCount();
   TabItem[] result = new TabItem[count];
   System.arraycopy(items, 0, result, 0, count);
   return result;
 }
예제 #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
 /**
  * Returns the styles for the ranges.
  *
  * <p>The ranges array contains start and end pairs. Each pair refers to the corresponding style
  * in the styles array. For example, the pair that starts at ranges[n] and ends at ranges[n+1]
  * uses the style at styles[n/2].
  *
  * @return the ranges for the styles
  * @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>
  *
  * @see IME#getRanges
  */
 public TextStyle[] getStyles() {
   checkWidget();
   if (styles == null) return new TextStyle[0];
   TextStyle[] result = new TextStyle[styles.length];
   System.arraycopy(styles, 0, result, 0, styles.length);
   return result;
 }
 static char[] mbcsToWcs(String codePage, byte[] buffer) {
   char[] chars = new char[buffer.length];
   int charCount =
       OS.MultiByteToWideChar(
           OS.CP_ACP, OS.MB_PRECOMPOSED, buffer, buffer.length, chars, chars.length);
   if (charCount == chars.length) return chars;
   char[] result = new char[charCount];
   System.arraycopy(chars, 0, result, 0, charCount);
   return result;
 }
예제 #7
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;
 }
예제 #8
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;
 }
 static String getProfilePath() {
   String baseDir;
   /* Use the character encoding for the default locale */
   TCHAR buffer = new TCHAR(0, OS.MAX_PATH);
   if (OS.SHGetFolderPath(0, OS.CSIDL_APPDATA, 0, OS.SHGFP_TYPE_CURRENT, buffer) == OS.S_OK) {
     baseDir = buffer.toString(0, buffer.strlen());
   } else {
     baseDir = System.getProperty("user.home"); // $NON-NLS-1$
   }
   return baseDir
       + Mozilla.SEPARATOR_OS
       + "Mozilla"
       + Mozilla.SEPARATOR_OS
       + "eclipse"; //$NON-NLS-1$ //$NON-NLS-2$
 }
예제 #10
0
 static synchronized void loadLibrary() {
   if (loaded) return;
   loaded = true;
   /*
    * Note that the jawt library is loaded explicitly
    * because it cannot be found by the library loader.
    * All exceptions are caught because the library may
    * have been loaded already.
    */
   try {
     System.loadLibrary("jawt");
   } catch (Throwable e) {
   }
   Library.loadLibrary("swt-awt");
 }
예제 #11
0
 /**
  * Returns an array of listeners who will be notified when a drag and drop operation is in
  * progress, by sending it one of the messages defined in the <code>DragSourceListener</code>
  * interface.
  *
  * @return the listeners who will be notified when a drag and drop operation is in progress
  * @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>
  *
  * @see DragSourceListener
  * @see #addDragListener
  * @see #removeDragListener
  * @see DragSourceEvent
  * @since 3.4
  */
 public DragSourceListener[] getDragListeners() {
   Listener[] listeners = getListeners(DND.DragStart);
   int length = listeners.length;
   DragSourceListener[] dragListeners = new DragSourceListener[length];
   int count = 0;
   for (int i = 0; i < length; i++) {
     Listener listener = listeners[i];
     if (listener instanceof DNDListener) {
       dragListeners[count] = (DragSourceListener) ((DNDListener) listener).getEventListener();
       count++;
     }
   }
   if (count == length) return dragListeners;
   DragSourceListener[] result = new DragSourceListener[count];
   System.arraycopy(dragListeners, 0, result, 0, count);
   return result;
 }
 static byte[] wcsToMbcs(String codePage, String string, boolean terminate) {
   int byteCount;
   char[] chars = new char[string.length()];
   string.getChars(0, chars.length, chars, 0);
   byte[] bytes = new byte[byteCount = chars.length * 2 + (terminate ? 1 : 0)];
   byteCount =
       OS.WideCharToMultiByte(OS.CP_ACP, 0, chars, chars.length, bytes, byteCount, null, null);
   if (terminate) {
     byteCount++;
   } else {
     if (bytes.length != byteCount) {
       byte[] result = new byte[byteCount];
       System.arraycopy(bytes, 0, result, 0, byteCount);
       bytes = result;
     }
   }
   return bytes;
 }
예제 #13
0
 ToolItem[] _getItems() {
   long /*int*/ list = OS.gtk_container_get_children(handle);
   if (list == 0) return new ToolItem[0];
   int count = OS.g_list_length(list);
   ToolItem[] items = new ToolItem[count];
   long /*int*/ originalList = list;
   int index = 0;
   for (int i = 0; i < count; i++) {
     long /*int*/ data = OS.g_list_data(list);
     Widget widget = display.getWidget(data);
     if (widget != null) items[index++] = (ToolItem) widget;
     list = OS.g_list_next(list);
   }
   OS.g_list_free(originalList);
   if (index != items.length) {
     ToolItem[] newItems = new ToolItem[index];
     System.arraycopy(items, 0, newItems, 0, index);
     items = newItems;
   }
   return items;
 }
예제 #14
0
 static {
   System.setProperty("apple.awt.usingSWT", "true");
 }