Exemplo n.º 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;
  }
Exemplo n.º 2
0
 /**
  * This implementation of <code>dragOver</code> provides a default drag under effect for the
  * feedback specified in <code>event.feedback</code>. The class description lists the FEEDBACK
  * constants that are applicable to the class.
  *
  * <p>For additional information see <code>DropTargetAdapter.dragOver</code>.
  *
  * <p>Subclasses that override this method should call <code>super.dragOver(event)</code> to get
  * the default drag under effect implementation.
  *
  * @param event the information associated with the drag over event
  * @see DropTargetAdapter
  * @see DropTargetEvent
  * @see DND#FEEDBACK_SELECT
  * @see DND#FEEDBACK_SCROLL
  */
 public void dragOver(DropTargetEvent event) {
   Table table = (Table) control;
   long /*int*/ handle = table.handle;
   int effect = checkEffect(event.feedback);
   Point coordinates = new Point(event.x, event.y);
   coordinates = table.toControl(coordinates);
   long /*int*/[] path = new long /*int*/[1];
   OS.gtk_tree_view_get_path_at_pos(handle, coordinates.x, coordinates.y, path, null, null, null);
   int index = -1;
   if (path[0] != 0) {
     long /*int*/ indices = OS.gtk_tree_path_get_indices(path[0]);
     if (indices != 0) {
       int[] temp = new int[1];
       OS.memmove(temp, indices, 4);
       index = temp[0];
     }
   }
   if ((effect & DND.FEEDBACK_SCROLL) == 0) {
     scrollBeginTime = 0;
     scrollIndex = -1;
   } else {
     if (index != -1 && scrollIndex == index && scrollBeginTime != 0) {
       if (System.currentTimeMillis() >= scrollBeginTime) {
         if (coordinates.y < table.getItemHeight()) {
           OS.gtk_tree_path_prev(path[0]);
         } else {
           OS.gtk_tree_path_next(path[0]);
         }
         if (path[0] != 0) {
           OS.gtk_tree_view_scroll_to_cell(handle, path[0], 0, false, 0, 0);
           OS.gtk_tree_path_free(path[0]);
           path[0] = 0;
           OS.gtk_tree_view_get_path_at_pos(
               handle, coordinates.x, coordinates.y, path, null, null, null);
         }
         scrollBeginTime = 0;
         scrollIndex = -1;
       }
     } else {
       scrollBeginTime = System.currentTimeMillis() + SCROLL_HYSTERESIS;
       scrollIndex = index;
     }
   }
   if (path[0] != 0) {
     int position = 0;
     if ((effect & DND.FEEDBACK_SELECT) != 0) position = OS.GTK_TREE_VIEW_DROP_INTO_OR_BEFORE;
     // if ((effect & DND.FEEDBACK_INSERT_BEFORE) != 0) position = OS.GTK_TREE_VIEW_DROP_BEFORE;
     // if ((effect & DND.FEEDBACK_INSERT_AFTER) != 0) position = OS.GTK_TREE_VIEW_DROP_AFTER;
     if (position != 0) {
       OS.gtk_tree_view_set_drag_dest_row(handle, path[0], OS.GTK_TREE_VIEW_DROP_INTO_OR_BEFORE);
     } else {
       OS.gtk_tree_view_set_drag_dest_row(handle, 0, OS.GTK_TREE_VIEW_DROP_BEFORE);
     }
   } else {
     OS.gtk_tree_view_set_drag_dest_row(handle, 0, OS.GTK_TREE_VIEW_DROP_BEFORE);
   }
   if (path[0] != 0) OS.gtk_tree_path_free(path[0]);
 }
Exemplo n.º 3
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
   }
 }
Exemplo n.º 4
0
 final void removeData(final int index) {
   if (data != null && parent.getColumnCount() > 1) {
     Data[] newData = new Data[data.length - 1];
     System.arraycopy(data, 0, newData, 0, index);
     int offSet = data.length - index - 1;
     System.arraycopy(data, index + 1, newData, index, offSet);
     data = newData;
   }
 }
 public void show(int effect, int x, int y) {
   effect = checkEffect(effect);
   int handle = table.handle;
   Point coordinates = new Point(x, y);
   coordinates = table.toControl(coordinates);
   LVHITTESTINFO pinfo = new LVHITTESTINFO();
   pinfo.x = coordinates.x;
   pinfo.y = coordinates.y;
   OS.SendMessage(handle, OS.LVM_HITTEST, 0, pinfo);
   if ((effect & DND.FEEDBACK_SCROLL) == 0) {
     scrollBeginTime = 0;
     scrollIndex = -1;
   } else {
     if (pinfo.iItem != -1 && scrollIndex == pinfo.iItem && scrollBeginTime != 0) {
       if (System.currentTimeMillis() >= scrollBeginTime) {
         int top = Math.max(0, OS.SendMessage(handle, OS.LVM_GETTOPINDEX, 0, 0));
         int count = OS.SendMessage(handle, OS.LVM_GETITEMCOUNT, 0, 0);
         int index =
             (scrollIndex - 1 < top)
                 ? Math.max(0, scrollIndex - 1)
                 : Math.min(count - 1, scrollIndex + 1);
         OS.SendMessage(handle, OS.LVM_ENSUREVISIBLE, index, 0);
         scrollBeginTime = 0;
         scrollIndex = -1;
       }
     } else {
       scrollBeginTime = System.currentTimeMillis() + SCROLL_HYSTERESIS;
       scrollIndex = pinfo.iItem;
     }
   }
   LVITEM lvItem = new LVITEM();
   lvItem.stateMask = OS.LVIS_DROPHILITED;
   OS.SendMessage(handle, OS.LVM_SETITEMSTATE, -1, lvItem);
   if (pinfo.iItem != -1 && (effect & DND.FEEDBACK_SELECT) != 0) {
     lvItem.state = OS.LVIS_DROPHILITED;
     OS.SendMessage(handle, OS.LVM_SETITEMSTATE, pinfo.iItem, lvItem);
   }
   // Insert mark only supported on Windows XP with manifest
   //	if (OS.COMCTL32_MAJOR >= 6) {
   //		if ((effect & DND.FEEDBACK_INSERT_BEFORE) != 0 || (effect & DND.FEEDBACK_INSERT_AFTER) != 0)
   // {
   //			LVINSERTMARK lvinsertmark = new LVINSERTMARK();
   //			lvinsertmark.cbSize = LVINSERTMARK.sizeof;
   //			lvinsertmark.dwFlags = (effect & DND.FEEDBACK_INSERT_BEFORE) != 0 ? 0 : OS.LVIM_AFTER;
   //			lvinsertmark.iItem = pinfo.iItem == -1 ? 0 : pinfo.iItem;
   //			int hItem = pinfo.iItem;
   //			OS.SendMessage (handle, OS.LVM_SETINSERTMARK, 0, lvinsertmark);
   //		} else {
   //			OS.SendMessage (handle, OS.LVM_SETINSERTMARK, 0, 0);
   //		}
   //	}
   return;
 }
 /**
  * Unload the given image's data into the given byte stream using the given compression strategy.
  * Answer the number of bytes written. Method modified to use the passed data if it is not null.
  */
 int unloadData(ImageData image, byte[] data, OutputStream out, int comp) {
   int totalSize = 0;
   try {
     if (comp == 0) return unloadDataNoCompression(image, data, out);
     int bpl = (image.width * image.depth + 7) / 8;
     int bmpBpl = (bpl + 3) / 4 * 4; // BMP pads scanlines to multiples of 4 bytes
     int imageBpl = image.bytesPerLine;
     // Compression can actually take twice as much space, in worst case
     byte[] buf = new byte[bmpBpl * 2];
     int srcOffset = imageBpl * (image.height - 1); // Start at last line
     if (data == null) data = image.data;
     totalSize = 0;
     byte[] buf2 = new byte[32768];
     int buf2Offset = 0;
     for (int y = image.height - 1; y >= 0; y--) {
       int lineSize = compress(comp, data, srcOffset, bpl, buf, y == 0);
       if (buf2Offset + lineSize > buf2.length) {
         out.write(buf2, 0, buf2Offset);
         buf2Offset = 0;
       }
       System.arraycopy(buf, 0, buf2, buf2Offset, lineSize);
       buf2Offset += lineSize;
       totalSize += lineSize;
       srcOffset -= imageBpl;
     }
     if (buf2Offset > 0) out.write(buf2, 0, buf2Offset);
   } catch (IOException e) {
     SWT.error(SWT.ERROR_IO, e);
   }
   return totalSize;
 }
Exemplo n.º 7
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;
 }
Exemplo n.º 8
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.º 9
0
 Rectangle[] getRectangles(int linkIndex) {
   int lineCount = layout.getLineCount();
   Rectangle[] rects = new Rectangle[lineCount];
   int[] lineOffsets = layout.getLineOffsets();
   Point point = offsets[linkIndex];
   int lineStart = 1;
   while (point.x > lineOffsets[lineStart]) lineStart++;
   int lineEnd = 1;
   while (point.y > lineOffsets[lineEnd]) lineEnd++;
   int index = 0;
   if (lineStart == lineEnd) {
     rects[index++] = layout.getBounds(point.x, point.y);
   } else {
     rects[index++] = layout.getBounds(point.x, lineOffsets[lineStart] - 1);
     rects[index++] = layout.getBounds(lineOffsets[lineEnd - 1], point.y);
     if (lineEnd - lineStart > 1) {
       for (int i = lineStart; i < lineEnd - 1; i++) {
         rects[index++] = layout.getLineBounds(i);
       }
     }
   }
   if (rects.length != index) {
     Rectangle[] tmp = new Rectangle[index];
     System.arraycopy(rects, 0, tmp, 0, index);
     rects = tmp;
   }
   return rects;
 }
Exemplo n.º 10
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;
 }
Exemplo n.º 11
0
Arquivo: View.java Projeto: shader/gdr
  /**
   * Initialize the toolbar with icons and selection listeners in the appropriate part of the window
   */
  public void initToolbar() {

    Device dev = shell.getDisplay();
    try {
      exitImg = new Image(dev, "img/exit.png");
      //            openImg = new Image(dev, "img/open.png");
      playImg = new Image(dev, "img/play.png");
      //            pauseImg = new Image(dev, "img/pause.png");

    } catch (Exception e) {
      System.out.println("Cannot load images");
      System.out.println(e.getMessage());
      System.exit(1);
    }

    ToolBar toolBar = new ToolBar(shell, SWT.BORDER);

    GridData gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    toolBar.setLayoutData(gridData);

    ToolItem exit = new ToolItem(toolBar, SWT.PUSH);
    exit.setImage(exitImg);

    // ToolItem open = new ToolItem(toolBar, SWT.PUSH);
    // exit.setImage(openImg);

    ToolItem play = new ToolItem(toolBar, SWT.PUSH);
    play.setImage(playImg);

    //        ToolItem pause = new ToolItem(toolBar, SWT.PUSH);
    //        pause.setImage(pauseImg);

    toolBar.pack();

    exit.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            System.exit(0);
          }
        });

    // open.addSelectionListener(new SelectionAdapter() {
    //     @Override
    //     public void widgetSelected(SelectionEvent e) {
    //         FileDialog dialog = new FileDialog(shell, SWT.NULL);
    //         String path = dialog.open();
    //     }
    // });

    play.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            controller.RunAnimation();
          }
        });
  }
Exemplo n.º 12
0
 /**
  * We have just read the Comment extension identifier from the input stream. Read in the rest of
  * the comment and return it. GIF comment blocks are variable size.
  */
 byte[] readCommentExtension() {
   try {
     byte[] comment = new byte[0];
     byte[] block = new byte[255];
     int size = inputStream.read();
     while ((size > 0) && (inputStream.read(block, 0, size) != -1)) {
       byte[] oldComment = comment;
       comment = new byte[oldComment.length + size];
       System.arraycopy(oldComment, 0, comment, 0, oldComment.length);
       System.arraycopy(block, 0, comment, oldComment.length, size);
       size = inputStream.read();
     }
     return comment;
   } catch (Exception e) {
     SWT.error(SWT.ERROR_IO, e);
     return null;
   }
 }
 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;
 }
Exemplo n.º 14
0
 private void exitMenuItemWidgetSelected(SelectionEvent evt) {
   try {
     // Save app settings to file
     appSettings.store(new FileOutputStream("appsettings.ini"), "");
   } catch (FileNotFoundException e) {
   } catch (IOException e) {
   }
   getShell().dispose();
   System.exit(1);
 }
 /**
  * Adds an object to the container for later drawing.
  *
  * @param object the object to add to the drawing list
  */
 public void add(Figure object) {
   if (objectStack == null) {
     objectStack = new Figure[INITIAL_ARRAY_SIZE];
   } else if (objectStack.length <= nextIndex) {
     Figure[] newObjectStack = new Figure[objectStack.length * 2];
     System.arraycopy(objectStack, 0, newObjectStack, 0, objectStack.length);
     objectStack = newObjectStack;
   }
   objectStack[nextIndex] = object;
   ++nextIndex;
 }
Exemplo n.º 16
0
 private void ensureData(final int index, final int columnCount) {
   if (data == null) {
     data = new Data[columnCount];
   } else if (data.length < columnCount) {
     Data[] newData = new Data[columnCount];
     System.arraycopy(data, 0, newData, 0, data.length);
     data = newData;
   }
   if (data[index] == null) {
     data[index] = new Data();
   }
 }
Exemplo n.º 17
0
 /**
  * We have just read the Application extension identifier from the input stream. Read in the rest
  * of the extension, look for and store 'number of repeats', and return the data.
  */
 byte[] readApplicationExtension() {
   try {
     // Read block data.
     int blockSize = inputStream.read();
     byte[] blockData = new byte[blockSize];
     inputStream.read(blockData);
     // Read application data.
     byte[] data = new byte[0];
     byte[] block = new byte[255];
     int size = inputStream.read();
     while ((size > 0) && (inputStream.read(block, 0, size) != -1)) {
       byte[] oldData = data;
       data = new byte[oldData.length + size];
       System.arraycopy(oldData, 0, data, 0, oldData.length);
       System.arraycopy(block, 0, data, oldData.length, size);
       size = inputStream.read();
     }
     // Look for the NETSCAPE 'repeat count' field for an animated GIF.
     boolean netscape =
         blockSize > 7
             && blockData[0] == 'N'
             && blockData[1] == 'E'
             && blockData[2] == 'T'
             && blockData[3] == 'S'
             && blockData[4] == 'C'
             && blockData[5] == 'A'
             && blockData[6] == 'P'
             && blockData[7] == 'E';
     boolean authentic =
         blockSize > 10 && blockData[8] == '2' && blockData[9] == '.' && blockData[10] == '0';
     if (netscape && authentic && data[0] == 01) { // $NON-NLS-1$ //$NON-NLS-2$
       repeatCount = (data[1] & 0xFF) | ((data[2] & 0xFF) << 8);
       loader.repeatCount = repeatCount;
     }
     return data;
   } catch (Exception e) {
     SWT.error(SWT.ERROR_IO, e);
     return null;
   }
 }
Exemplo n.º 18
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$
 }
Exemplo n.º 20
0
 /**
  * We have just read the PlainText extension identifier from the input stream. Read in the plain
  * text info and text, and return the text. GIF plain text blocks are variable size.
  */
 byte[] readPlainTextExtension() {
   try {
     // Read size of block = 0x0C.
     inputStream.read();
     // Read the text information (x, y, width, height, colors).
     byte[] info = new byte[12];
     inputStream.read(info);
     // Read the text.
     byte[] text = new byte[0];
     byte[] block = new byte[255];
     int size = inputStream.read();
     while ((size > 0) && (inputStream.read(block, 0, size) != -1)) {
       byte[] oldText = text;
       text = new byte[oldText.length + size];
       System.arraycopy(oldText, 0, text, 0, oldText.length);
       System.arraycopy(block, 0, text, oldText.length, size);
       size = inputStream.read();
     }
     return text;
   } catch (Exception e) {
     SWT.error(SWT.ERROR_IO, e);
     return null;
   }
 }
Exemplo n.º 21
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;
 }
Exemplo n.º 22
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;
 }
Exemplo n.º 24
0
 private String[] splitString(String text) {
   String[] lines = new String[1];
   int start = 0, pos;
   do {
     pos = text.indexOf('\n', start);
     if (pos == -1) {
       lines[lines.length - 1] = text.substring(start);
     } else {
       boolean crlf = (pos > 0) && (text.charAt(pos - 1) == '\r');
       lines[lines.length - 1] = text.substring(start, pos - (crlf ? 1 : 0));
       start = pos + 1;
       String[] newLines = new String[lines.length + 1];
       System.arraycopy(lines, 0, newLines, 0, lines.length);
       lines = newLines;
     }
   } while (pos != -1);
   return lines;
 }
 public static boolean test() {
   int fail = 0;
   String url;
   String pluginPath = System.getProperty("PLUGIN_PATH");
   if (verbose) System.out.println("PLUGIN_PATH <" + pluginPath + ">");
   if (pluginPath == null)
     url = Browser5.class.getClassLoader().getResource("browser5.html").toString();
   else url = pluginPath + "/data/browser5.html";
   String[] urls = {url};
   for (int i = 0; i < urls.length; i++) {
     // TEST1 TEMPORARILY NOT RUN FOR MOZILLA
     if (!isMozilla) {
       boolean result = test1(urls[i]);
       if (verbose) System.out.print(result ? "." : "E");
       if (!result) fail++;
     }
   }
   return fail == 0;
 }
 /**
  * Prepare the given image's data for unloading into a byte stream using no compression strategy.
  * Answer the number of bytes written. Method modified to use the passed data if it is not null.
  */
 int unloadDataNoCompression(ImageData image, byte[] data, OutputStream out) {
   int bmpBpl = 0;
   try {
     int bpl = (image.width * image.depth + 7) / 8;
     bmpBpl = (bpl + 3) / 4 * 4; // BMP pads scanlines to multiples of 4 bytes
     int linesPerBuf = 32678 / bmpBpl;
     byte[] buf = new byte[linesPerBuf * bmpBpl];
     if (data == null) data = image.data;
     int imageBpl = image.bytesPerLine;
     int dataIndex = imageBpl * (image.height - 1); // Start at last line
     if (image.depth == 16) {
       for (int y = 0; y < image.height; y += linesPerBuf) {
         int count = image.height - y;
         if (linesPerBuf < count) count = linesPerBuf;
         int bufOffset = 0;
         for (int i = 0; i < count; i++) {
           for (int wIndex = 0; wIndex < bpl; wIndex += 2) {
             buf[bufOffset + wIndex + 1] = data[dataIndex + wIndex + 1];
             buf[bufOffset + wIndex] = data[dataIndex + wIndex];
           }
           bufOffset += bmpBpl;
           dataIndex -= imageBpl;
         }
         out.write(buf, 0, bufOffset);
       }
     } else {
       for (int y = 0; y < image.height; y += linesPerBuf) {
         int tmp = image.height - y;
         int count = tmp < linesPerBuf ? tmp : linesPerBuf;
         int bufOffset = 0;
         for (int i = 0; i < count; i++) {
           System.arraycopy(data, dataIndex, buf, bufOffset, bpl);
           bufOffset += bmpBpl;
           dataIndex -= imageBpl;
         }
         out.write(buf, 0, bufOffset);
       }
     }
   } catch (IOException e) {
     SWT.error(SWT.ERROR_IO, e);
   }
   return bmpBpl * image.height;
 }
Exemplo n.º 27
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;
 }
Exemplo n.º 28
0
 /**
  * Returns a (possibly empty) array of <code>MenuItem</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 MenuItem[] getItems() {
   checkWidget();
   int[] handles = OS.QWidget_actions(handle);
   int count = handles.length;
   if (count == 0) return new MenuItem[0];
   MenuItem[] children = new MenuItem[count];
   int items = 0;
   for (int i = 0; i < count; ++i) {
     int handle = handles[i];
     if (handle != 0) {
       Widget widget = Display.getWidget(handle);
       if (widget != null && widget != this) {
         if (widget instanceof MenuItem) {
           children[items++] = (MenuItem) widget;
         }
       }
     }
   }
   if (items == count) return children;
   MenuItem[] newChildren = new MenuItem[items];
   System.arraycopy(children, 0, newChildren, 0, items);
   return newChildren;
 }
Exemplo n.º 29
0
 // --------------------------------------------------------------------------------
 private void onSashResize() {
   if (System.currentTimeMillis() >= initializedTime + 3000) {
     prop.setProperty(DOCUMENT_COMPOSITE_WEIGHT, sashForm.getWeights());
   }
 }
Exemplo n.º 30
0
 String parse(String string) {
   int length = string.length();
   offsets = new Point[length / 4];
   ids = new String[length / 4];
   mnemonics = new int[length / 4 + 1];
   StringBuffer result = new StringBuffer();
   char[] buffer = new char[length];
   string.getChars(0, string.length(), buffer, 0);
   int index = 0, state = 0, linkIndex = 0;
   int start = 0, tagStart = 0, linkStart = 0, endtagStart = 0, refStart = 0;
   while (index < length) {
     char c = Character.toLowerCase(buffer[index]);
     switch (state) {
       case 0:
         if (c == '<') {
           tagStart = index;
           state++;
         }
         break;
       case 1:
         if (c == 'a') state++;
         break;
       case 2:
         switch (c) {
           case 'h':
             state = 7;
             break;
           case '>':
             linkStart = index + 1;
             state++;
             break;
           default:
             if (Character.isWhitespace(c)) break;
             else state = 13;
         }
         break;
       case 3:
         if (c == '<') {
           endtagStart = index;
           state++;
         }
         break;
       case 4:
         state = c == '/' ? state + 1 : 3;
         break;
       case 5:
         state = c == 'a' ? state + 1 : 3;
         break;
       case 6:
         if (c == '>') {
           mnemonics[linkIndex] = parseMnemonics(buffer, start, tagStart, result);
           int offset = result.length();
           parseMnemonics(buffer, linkStart, endtagStart, result);
           offsets[linkIndex] = new Point(offset, result.length() - 1);
           if (ids[linkIndex] == null) {
             ids[linkIndex] = new String(buffer, linkStart, endtagStart - linkStart);
           }
           linkIndex++;
           start = tagStart = linkStart = endtagStart = refStart = index + 1;
           state = 0;
         } else {
           state = 3;
         }
         break;
       case 7:
         state = c == 'r' ? state + 1 : 0;
         break;
       case 8:
         state = c == 'e' ? state + 1 : 0;
         break;
       case 9:
         state = c == 'f' ? state + 1 : 0;
         break;
       case 10:
         state = c == '=' ? state + 1 : 0;
         break;
       case 11:
         if (c == '"') {
           state++;
           refStart = index + 1;
         } else {
           state = 0;
         }
         break;
       case 12:
         if (c == '"') {
           ids[linkIndex] = new String(buffer, refStart, index - refStart);
           state = 2;
         }
         break;
       case 13:
         if (Character.isWhitespace(c)) {
           state = 0;
         } else if (c == '=') {
           state++;
         }
         break;
       case 14:
         state = c == '"' ? state + 1 : 0;
         break;
       case 15:
         if (c == '"') state = 2;
         break;
       default:
         state = 0;
         break;
     }
     index++;
   }
   if (start < length) {
     int tmp = parseMnemonics(buffer, start, tagStart, result);
     int mnemonic = parseMnemonics(buffer, Math.max(tagStart, linkStart), length, result);
     if (mnemonic == -1) mnemonic = tmp;
     mnemonics[linkIndex] = mnemonic;
   } else {
     mnemonics[linkIndex] = -1;
   }
   if (offsets.length != linkIndex) {
     Point[] newOffsets = new Point[linkIndex];
     System.arraycopy(offsets, 0, newOffsets, 0, linkIndex);
     offsets = newOffsets;
     String[] newIDs = new String[linkIndex];
     System.arraycopy(ids, 0, newIDs, 0, linkIndex);
     ids = newIDs;
     int[] newMnemonics = new int[linkIndex + 1];
     System.arraycopy(mnemonics, 0, newMnemonics, 0, linkIndex + 1);
     mnemonics = newMnemonics;
   }
   return result.toString();
 }