Exemplo n.º 1
0
 void internalLayout(boolean changed) {
   if (isDropped()) dropDown(false);
   Rectangle rect = getClientArea();
   int width = rect.width;
   int height = rect.height;
   Point arrowSize = arrow.computeSize(SWT.DEFAULT, height, changed);
   if (icon != null) {
     Point iconSize = icon.computeSize(SWT.DEFAULT, height, changed);
     text.setBounds(0, 0, width - arrowSize.x - iconSize.x, height);
     icon.setBounds(width - arrowSize.x - iconSize.x, 0, iconSize.x, height);
     arrow.setBounds(width - arrowSize.x, 0, arrowSize.x, arrowSize.y);
   } else {
     text.setBounds(0, 0, width - arrowSize.x, height);
     arrow.setBounds(width - arrowSize.x, 0, arrowSize.x, arrowSize.y);
   }
 }
Exemplo n.º 2
0
 public void redraw() {
   super.redraw();
   text.redraw();
   arrow.redraw();
   if (icon != null) icon.redraw();
   if (popup.isVisible()) list.redraw();
 }
Exemplo n.º 3
0
  public Point computeSize(int wHint, int hHint, boolean changed) {
    checkWidget();
    int width = 0, height = 0;
    String[] items = list.getItems();
    int textWidth = 0;
    GC gc = new GC(text);
    int spacer = gc.stringExtent(" ").x; // $NON-NLS-1$
    for (int i = 0; i < items.length; i++) {
      textWidth = Math.max(gc.stringExtent(items[i]).x, textWidth);
    }
    gc.dispose();

    Point textSize = text.computeSize(SWT.DEFAULT, SWT.DEFAULT, changed);
    Point arrowSize = arrow.computeSize(SWT.DEFAULT, SWT.DEFAULT, changed);
    Point listSize = list.computeSize(wHint, SWT.DEFAULT, changed);
    int borderWidth = getBorderWidth();

    if (icon == null) {
      height = Math.max(hHint, Math.max(textSize.y, arrowSize.y) + 2 * borderWidth);
      width =
          Math.max(
              wHint, Math.max(textWidth + 2 * spacer + arrowSize.x + 2 * borderWidth, listSize.x));
    } else {
      Point iconSize = icon.computeSize(SWT.DEFAULT, SWT.DEFAULT, changed);
      height = Math.max(hHint, Math.max(textSize.y, arrowSize.y) + 2 * borderWidth);
      width =
          Math.max(
              wHint,
              Math.max(
                  textWidth + 2 * spacer + arrowSize.x + iconSize.x + 2 * borderWidth, listSize.x));
    }
    return new Point(width, height);
  }
Exemplo n.º 4
0
 public void setEnabled(boolean enabled) {
   super.setEnabled(enabled);
   if (popup != null) popup.setVisible(false);
   if (text != null) text.setEnabled(enabled);
   if (icon != null) icon.setEnabled(enabled);
   if (arrow != null) arrow.setEnabled(enabled);
 }
Exemplo n.º 5
0
 public void setForeground(Color color) {
   super.setForeground(color);
   foreground = color;
   if (text != null) text.setForeground(color);
   if (list != null) list.setForeground(color);
   if (icon != null) icon.setForeground(color);
   if (arrow != null) arrow.setForeground(color);
 }
Exemplo n.º 6
0
 public void setFont(Font font) {
   super.setFont(font);
   this.font = font;
   text.setFont(font);
   if (icon != null) icon.setFont(font);
   list.setFont(font);
   internalLayout(true);
 }
Exemplo n.º 7
0
 private void update(Hyperlink hyperlink, Object object) {
   String text = labelProvider != null ? labelProvider.getText(object) : object.toString();
   Image image = labelProvider != null ? labelProvider.getImage(object) : null;
   String tooltip = labelProvider != null ? labelProvider.getToolTipText(object) : text;
   hyperlink.setText(text);
   hyperlink.setToolTipText(tooltip);
   if (hyperlink instanceof ImageHyperlink) ((ImageHyperlink) hyperlink).setImage(image);
   reflow();
 }
Exemplo n.º 8
0
 public boolean isFocusControl() {
   checkWidget();
   if (text.isFocusControl()
       || arrow.isFocusControl()
       || list.isFocusControl()
       || icon.isFocusControl()
       || popup.isFocusControl()) {
     return true;
   }
   return super.isFocusControl();
 }
Exemplo n.º 9
0
 private void createLink(Object object) {
   Image image = labelProvider != null ? labelProvider.getImage(object) : null;
   Hyperlink hyperlink;
   if (image != null) {
     hyperlink = getManagedForm().getToolkit().createImageHyperlink(linkContainer, SWT.NULL);
     ((ImageHyperlink) hyperlink).setImage(image);
   } else hyperlink = getManagedForm().getToolkit().createHyperlink(linkContainer, null, SWT.NULL);
   update(hyperlink, object);
   hyperlink.setData(object);
   hyperlink.addHyperlinkListener(linkHandler);
 }