Examples of GCStringPrinter


Examples of org.gudy.azureus2.ui.swt.shells.GCStringPrinter

      }
    });

    Rectangle printArea = new Rectangle(BORDER_X, 0, WIDTH - (BORDER_X * 2),
        5000);
    spText = new GCStringPrinter(gc, text, printArea, true, false, SWT.WRAP);
    spText.setUrlColor(Colors.blues[Colors.FADED_DARKEST]);
    spText.calculateMetrics();

    gc.setFont(fontCount);
    String sCount = MessageText.getString("OpenTorrentWindow.xOfTotal",
        new String[] {
          "" + historyPosition + 1,
          "" + getWarningCount()
        });
    spCount = new GCStringPrinter(gc, sCount, printArea, true, false, SWT.WRAP);
    spCount.calculateMetrics();

    gc.setFont(fontTitle);
    spTitle = new GCStringPrinter(gc, title, printArea, true, false, SWT.WRAP);
    spTitle.calculateMetrics();

    gc.dispose();
    sizeText = spText.getCalculatedSize();
    sizeTitle = spTitle.getCalculatedSize();
    sizeCount = spCount.getCalculatedSize();

    FormData fd;

    Button btnDismiss = new Button(shell, SWT.PUSH);
    Messages.setLanguageText(btnDismiss, "Button.dismiss");
    final int btnHeight = btnDismiss.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;

    Button btnPrev = new Button(shell, SWT.PUSH);
    btnPrev.setText("<");

    Button btnNext = new Button(shell, SWT.PUSH);
    btnNext.setText(">");

    fd = new FormData();
    fd.bottom = new FormAttachment(100, -BORDER_Y1);
    fd.right = new FormAttachment(100, -BORDER_X);
    btnNext.setLayoutData(fd);

    fd = new FormData();
    fd.bottom = new FormAttachment(100, -BORDER_Y1);
    fd.right = new FormAttachment(btnNext, -BORDER_X);
    btnPrev.setLayoutData(fd);

    fd = new FormData();
    fd.bottom = new FormAttachment(100, -BORDER_Y1);
    fd.right = new FormAttachment(btnPrev, -BORDER_X);
    btnDismiss.setLayoutData(fd);

    height = BORDER_Y0 + sizeTitle.y + GAP_Y + sizeText.y + GAP_Y_TITLE_COUNT
        + sizeCount.y + GAP_BUTTON_Y + btnHeight + BORDER_Y1;

    Rectangle area = shell.computeTrim(ptBottomRight.x - WIDTH, ptBottomRight.y
        - height, WIDTH, height);
    shell.setBounds(area);
    shell.setLocation(ptBottomRight.x - area.width, ptBottomRight.y
        - area.height - 2);

    rectX = new Rectangle(area.width - BORDER_X - boundsClose.width, BORDER_Y0,
        boundsClose.width, boundsClose.height);

    shell.addMouseMoveListener(new MouseMoveListener() {
      int lastCursor = SWT.CURSOR_ARROW;

      public void mouseMove(MouseEvent e) {
        if (shell == null || shell.isDisposed()) {
          return;
        }
        URLInfo hitUrl = spText.getHitUrl(e.x, e.y);

        int cursor = (rectX.contains(e.x, e.y)) || hitUrl != null
            ? SWT.CURSOR_HAND : SWT.CURSOR_ARROW;
        if (cursor != lastCursor) {
          lastCursor = cursor;
          shell.setCursor(e.display.getSystemCursor(cursor));
        }
      }
    });

    shell.addMouseListener(new MouseListener() {
      public void mouseUp(MouseEvent e) {
        if (shell == null || shell.isDisposed()) {
          return;
        }
        if (rectX.contains(e.x, e.y)) {
          shell.dispose();
        }
        URLInfo hitUrl = spText.getHitUrl(e.x, e.y);
        if (hitUrl != null) {
          if (hitUrl.url.equals("details")) {
            MessageBoxShell mb = new MessageBoxShell(Constants.APP_NAME,
                logAlert.details, new String[] {
                  MessageText.getString("Button.ok")
                }, 0);
            mb.setUseTextBox(true);
            mb.setParent(Utils.findAnyShell());
            mb.open(null);
          } else {
            Utils.launch(hitUrl.url);
          }
        }
      }

      public void mouseDown(MouseEvent e) {
      }

      public void mouseDoubleClick(MouseEvent e) {
      }
    });

    shell.addPaintListener(new PaintListener() {
      public void paintControl(PaintEvent e) {
        e.gc.drawImage(imgClose, WIDTH - BORDER_X - boundsClose.width,
            BORDER_Y0);

        Rectangle printArea;
        printArea = new Rectangle(BORDER_X, BORDER_Y0 + sizeTitle.y + GAP_Y_TITLE_COUNT,
            WIDTH, 100);
        String sCount = MessageText.getString("OpenTorrentWindow.xOfTotal",
            new String[] {
              "" + (historyPosition + 1),
              "" + getWarningCount()
            });
        e.gc.setAlpha(180);
        Font lastFont = e.gc.getFont();
        e.gc.setFont(fontCount);
        spCount = new GCStringPrinter(e.gc, sCount, printArea, true, false,
            SWT.WRAP | SWT.TOP);
        spCount.printString();
        e.gc.setAlpha(255);
        sizeCount = spCount.getCalculatedSize();

View Full Code Here

Examples of org.gudy.azureus2.ui.swt.shells.GCStringPrinter

      Image image = getImage();
      Rectangle imageBounds = null;
      if (image != null && !image.isDisposed()) {
        imageBounds = image.getBounds();
      }
      GCStringPrinter sp = new GCStringPrinter(e.gc, getText(), clientArea,
          true, true, SWT.CENTER);
      sp.calculateMetrics();
      Point textSize = sp.getCalculatedSize();

      if (imageBounds != null) {
        int pad = 2;
        int ofs = imageBounds.width + imageBounds.x;
        int xStartImage = (clientArea.width - textSize.x - ofs - pad) / 2;
        e.gc.drawImage(image, xStartImage,
            (clientArea.height / 2) - (imageBounds.height / 2));
        clientArea.x += xStartImage + ofs + pad;
        clientArea.width -= xStartImage + ofs + pad;
      } else {
        int ofs = (clientArea.width / 2) - (textSize.x / 2);
        clientArea.x += ofs;
        clientArea.width -= ofs;
      }
      sp.printString(e.gc, clientArea, SWT.LEFT);

      int x = clientArea.x + clientArea.width - 1;
      e.gc.setAlpha(20);
      e.gc.drawLine(x, 3, x, clientArea.height - 3);
    }
View Full Code Here

Examples of org.gudy.azureus2.ui.swt.shells.GCStringPrinter

        lastSize.x += ofs;
        lastSize.y = bounds.height;
      }

      GC gc = new GC(this);
      GCStringPrinter sp = new GCStringPrinter(gc, getText(), new Rectangle(0,
          0, 10000, 20), true, true, SWT.LEFT);
      sp.calculateMetrics();
      Point lastTextSize = sp.getCalculatedSize();
      gc.dispose();

      lastSize.x += lastTextSize.x + 10;
      lastSize.y = Math.max(lastSize.y, lastTextSize.y);
View Full Code Here

Examples of org.gudy.azureus2.ui.swt.shells.GCStringPrinter

        // put some padding on text
        ofsx += 6;
        cellBounds.x += 3;
        cellBounds.width -= 6;
        if (!cellBounds.isEmpty()) {
          GCStringPrinter sp = new GCStringPrinter(gc, text, cellBounds, true,
              cellBounds.height > 20, style);

          boolean fit = sp.printString();
          if (fit) {

            cell.setDefaultToolTip(null);
          } else {

            cell.setDefaultToolTip(text);
          }

          Point size = sp.getCalculatedSize();
          size.x += ofsx;

          if (cell.getTableColumn().getPreferredWidth() < size.x) {
            cell.getTableColumn().setPreferredWidth(size.x);
          }
View Full Code Here

Examples of org.gudy.azureus2.ui.swt.shells.GCStringPrinter

    bounds.y += 3;
    bounds.x += 7;
    bounds.width -= 14;
    String name = MessageText.getString(key, column.getName());
    GCStringPrinter sp = new GCStringPrinter(gc, name, bounds, GCStringPrinter.FLAG_SKIPCLIP, SWT.TOP);
    sp.printString();

    Point titleSize = sp.getCalculatedSize();

    gc.setFont(fontDefault);
    String info = MessageText.getString(key + ".info", "");
    Rectangle infoBounds = new Rectangle(bounds.x + 10, bounds.y + titleSize.y
        + 5, bounds.width - 15, bounds.height - 20);
    GCStringPrinter.printString(gc, info, infoBounds, true, false);

    TableColumnInfo columnInfo = (TableColumnInfo) cell.getTableRow().getData(
        "columninfo");
    if (columnInfo == null) {
      final TableColumnManager tcm = TableColumnManager.getInstance();
      columnInfo = tcm.getColumnInfo(column.getForDataSourceType(),
          column.getTableID(), column.getName());
      cell.getTableRowCore().setData("columninfo", columnInfo);
    }
    Rectangle profBounds = new Rectangle(bounds.width - 100, bounds.y - 2, 100, 20);
    byte proficiency = columnInfo.getProficiency();
    if (proficiency > 0 && proficiency < profText.length) {
      Color oldColor = gc.getForeground();
      gc.setForeground(Colors.grey);
      GCStringPrinter.printString(gc,
          MessageText.getString("ConfigView.section.mode."
              + profText[proficiency]), profBounds, true,
          false, SWT.RIGHT | SWT.TOP);
      gc.setForeground(oldColor);
    }

    Rectangle hitArea;
    TableViewColumnSetup tv = (TableViewColumnSetup) ((TableCellCore) cell).getTableRowCore().getView();
    if (tv.isColumnAdded(column)) {
      hitArea = Utils.EMPTY_RECT;
    } else {
      int x = bounds.x + titleSize.x + 15;
      int y = bounds.y - 1;
      int h = 15;

      String textAdd = MessageText.getString("Button.add");
      GCStringPrinter sp2 = new GCStringPrinter(gc, textAdd,
          new Rectangle(x, y, 500, h), true, false, SWT.CENTER);
      sp2.calculateMetrics();
      int w = sp2.getCalculatedSize().x + 12;
     
      gc.setAdvanced(true);
      gc.setAntialias(SWT.ON);
      gc.setBackground(ColorCache.getColor(gc.getDevice(), 255, 255, 255));
      gc.fillRoundRectangle(x, y, w, h, 15, h);
      gc.setBackground(ColorCache.getColor(gc.getDevice(), 215, 215, 215));
      gc.fillRoundRectangle(x + 2, y + 2, w, h, 15, h);
      gc.setForeground(ColorCache.getColor(gc.getDevice(), 145, 145, 145));
      gc.drawRoundRectangle(x, y, w, h, 15, h);

      gc.setForeground(ColorCache.getColor(gc.getDevice(), 50, 50, 50));
      hitArea = new Rectangle(x, y, w + 2, h);
      sp2.printString(gc, hitArea, SWT.CENTER);
      bounds = cell.getBounds();
      hitArea.x -= bounds.x;
      hitArea.y -= bounds.y;
    }
    cell.getTableRowCore().setData("AddHitArea", hitArea);
View Full Code Here

Examples of org.gudy.azureus2.ui.swt.shells.GCStringPrinter

            width, height);
      }
    }

    if (text != null && text.length() > 0) {
      GCStringPrinter sp = new GCStringPrinter(gc, text, bounds, true, false,
          wrapText?( orientation | SWT.WRAP ):orientation );
      sp.printString();
      hadMore = sp.isCutoff();
    }

    invokeSWTPaintListeners(gc);
  }
View Full Code Here

Examples of org.gudy.azureus2.ui.swt.shells.GCStringPrinter

              gc.fillRectangle(bounds);
              String title = MessageText.getString(
                  tableColumn.getTitleLanguageKey(), tableColumn.getName());
              String s = title
                  + " Column will be placed at the location you drop it, shifting other columns down";
              GCStringPrinter sp = new GCStringPrinter(gc, s, bounds, false, false,
                  SWT.CENTER | SWT.WRAP);
              sp.calculateMetrics();
              if (sp.isCutoff()) {
                GCStringPrinter.printString(gc, title, bounds, false, false,
                    SWT.CENTER | SWT.WRAP);
              } else {
                sp.printString();
              }
            } finally {
              gc.dispose();
            }
          } catch (Throwable t) {
View Full Code Here

Examples of org.gudy.azureus2.ui.swt.shells.GCStringPrinter

          }
        }

        gc.setAlpha(alpha);

        GCStringPrinter sp = new GCStringPrinter(gc, sDisplayText,
            new Rectangle(0, 0, wHint == -1 ? 3000 : wHint, hHint == -1
                ? 3000 : hHint), true, false, style & SWT.WRAP);
        sp.calculateMetrics();
        pt = sp.getCalculatedSize();
        pt.x += border + hpadding * 2;
        pt.y += border + vpadding * 2;
        gc.dispose();

        if (isUnderline) {
View Full Code Here

Examples of org.gudy.azureus2.ui.swt.shells.GCStringPrinter

      GCStringPrinter.printString(gc, sDisplayText, r, true, false, style);
      gc.setForeground(foreground);
    }

    gc.setAlpha(alpha);
    lastStringPrinter = new GCStringPrinter(gc, sDisplayText, clientArea, true,
        false, style);
    if (colorUrl != null) {
      lastStringPrinter.setUrlColor(colorUrl);
    }
    if (colorUrl2 != null && mouseDown) {
View Full Code Here

Examples of org.gudy.azureus2.ui.swt.shells.GCStringPrinter

        gc.setForeground(ColorCache.getColor(gc.getDevice(), 255, 255, 255));
        gc.setAlpha(100);
        clipping.x++;
        clipping.y++;
        //style = SWT.TOP;
        GCStringPrinter sp = new GCStringPrinter(gc, text, clipping, true, false,
            style);
        sp.printString();
        gc.setAlpha(255);

        clipping.x--;
        clipping.y--;
        gc.setForeground(fgText);
      } else {
        gc.setForeground(fgText);
      }
      //gc.setClipping(clipping);

      GCStringPrinter sp = new GCStringPrinter(gc, text, clipping, true, false,
          style);
      sp.printString();
      clipping.x += sp.getCalculatedSize().x + 5;
      //gc.setClipping((Rectangle) null);
    }
   
    // Vitality Images
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.