org.eclipse.swt.graphics.Point Java Examples

The following examples show how to use org.eclipse.swt.graphics.Point. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: translationstudio8   Author: heartsome   File: CellEdgeDetectUtil.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Figure out if the click point is closer to the left/right edge of the cell.
 * @param cellBounds of the table cell containing the click
 * @param clickPt
 * @param distanceFromEdge distance from the edge to qualify as <i>close</i> to the cell edge
 */
public static CellEdgeEnum getHorizontalCellEdge(Rectangle cellBounds, Point clickPt, int distanceFromEdge) {
	if (distanceFromEdge < 0) {
		distanceFromEdge = cellBounds.width / 2;
	}

	Rectangle left = new Rectangle(cellBounds.x, cellBounds.y, distanceFromEdge, cellBounds.height);
	Rectangle right = new Rectangle(cellBounds.x + cellBounds.width - distanceFromEdge, cellBounds.y, 
	        distanceFromEdge, cellBounds.height);

	if (left.contains(clickPt)) {
		return LEFT;
	} else if (right.contains(clickPt)) {
		return RIGHT;
	} else {
		return NONE;
	}
}
 
Example #2
Source Project: nebula   Author: eclipse   File: PaletteShelfRenderer.java    License: Eclipse Public License 2.0 6 votes vote down vote up
/**
    * {@inheritDoc}
    */
   @Override
public Point computeSize(GC gc, int wHint, int hHint, Object value)
   {
       PShelfItem item = (PShelfItem)value;

	if (item.getImage() == null)
		return new Point(wHint,gc.getFontMetrics().getHeight() + (2*(margin+textMargin)));

	int h = Math.max(item.getImage().getBounds().height,gc.getFontMetrics().getHeight() + (2*textMargin)) + (2*margin);

	if (h % 2 != 0)
		h ++;

	return new Point(wHint,h);
}
 
Example #3
Source Project: pentaho-kettle   Author: pentaho   File: UserDefinedJavaClassDialog.java    License: Apache License 2.0 6 votes vote down vote up
private void treeDblClick( Event event ) {
  StyledTextComp wScript = getStyledTextComp();
  Point point = new Point( event.x, event.y );
  TreeItem item = wTree.getItem( point );

  // Qualification where the Click comes from
  if ( item != null && item.getParentItem() != null ) {
    if ( item.getParentItem().equals( wTreeClassesItem ) ) {
      setActiveCtab( item.getText() );
    } else if ( !item.getData().equals( "Snippit" ) ) {
      int iStart = wScript.getCaretOffset();
      int selCount = wScript.getSelectionCount(); // this selection
      // will be replaced
      // by wScript.insert
      iStart = iStart - selCount; // when a selection is already there
      // we need to subtract the position
      if ( iStart < 0 ) {
        iStart = 0; // just safety
      }
      String strInsert = (String) item.getData();
      wScript.insert( strInsert );
      wScript.setSelection( iStart, iStart + strInsert.length() );
    }
  }
}
 
Example #4
Source Project: translationstudio8   Author: heartsome   File: CellSelectionDragMode.java    License: GNU General Public License v2.0 6 votes vote down vote up
public void mouseMove(NatTable natTable, MouseEvent event) {
	if (event.x > natTable.getWidth()) {
		return;
	}
	int selectedColumnPosition = natTable.getColumnPositionByX(event.x);
	int selectedRowPosition = natTable.getRowPositionByY(event.y);

	if (selectedColumnPosition > -1 && selectedRowPosition > -1) {
		Point dragInCellPosition = new Point(selectedColumnPosition, selectedRowPosition);
		if(lastDragInCellPosition == null || !dragInCellPosition.equals(lastDragInCellPosition)){
			lastDragInCellPosition = dragInCellPosition;

			fireSelectionCommand(natTable, selectedColumnPosition, selectedRowPosition, true, false);
		}
	}
}
 
Example #5
Source Project: swt-bling   Author: ReadyTalk   File: TextIconButton.java    License: MIT License 6 votes vote down vote up
/**
 * @see org.eclipse.swt.widgets.Composite#computeSize(int, int, boolean)
 */
@Override
public Point computeSize(int wHint, int hHint, boolean changed) {
  checkWidget();

  final Point computedSize = buttonRenderer.computeSize(this);

  if (wHint != SWT.DEFAULT) {
    computedSize.x = wHint;
  }

  if (hHint != SWT.DEFAULT) {
    computedSize.y = hHint;
  }

  return computedSize;
}
 
Example #6
Source Project: nebula   Author: eclipse   File: BadgedLabel.java    License: Eclipse Public License 2.0 6 votes vote down vote up
/**
 * @see org.eclipse.swt.widgets.Control#computeSize(int, int, boolean)
 */
@Override
public Point computeSize(final int wHint, final int hHint, final boolean changed) {
	checkWidget();
	
	if (image == null && text == null) {
		return super.computeSize(wHint, hHint, changed);
	}
	
	// Button
	final Point buttonSize = computeButtonSize();
	int width = buttonSize.x;
	int height = buttonSize.y;

	// Margin
	width += 3 * MARGIN;
	height += 3 * MARGIN;
	return new Point(Math.max(width, wHint), Math.max(height, hHint));
}
 
Example #7
Source Project: nebula   Author: eclipse   File: TitleControl.java    License: Eclipse Public License 2.0 6 votes vote down vote up
private void onPaint(PaintEvent e) {
	GC gc = e.gc;
	Point s = getSize();
	int w = s.x;
	int h = s.y;

	gc.setForeground(gradient1Color);
	gc.setBackground(gradient2Color);
	gc.fillGradientRectangle(0, 0, w, h - 1, true);

	Rectangle imgsize = new Rectangle(0, 0, 0, 0);
	if (image != null) {
		imgsize = image.getBounds();
		gc.drawImage(image, 12, 0);
	}
	gc.setForeground(bottomLineColor);
	gc.drawLine(0, h - 1, w, h - 1);

	gc.setFont(font);
	gc.setForeground(writingColor);
	Point textSize = gc.stringExtent(text);
	int ty = (h - textSize.y) / 2;
	gc.drawString(text, 22 + imgsize.width, TOP_SPACE + ty, true);
}
 
Example #8
Source Project: nebula   Author: eclipse   File: VControlPainter.java    License: Eclipse Public License 2.0 6 votes vote down vote up
private static void paintImageAndText(VControl control, Event e) {
	e.gc.setTextAntialias(SWT.ON);
	if(control.foreground != null && !control.foreground.isDisposed()) {
		e.gc.setForeground(control.foreground);
	}

	Rectangle ibounds = control.image.getBounds();
	Point tsize = e.gc.textExtent(control.text);

	int x = (int)getX(control, ibounds.width + tsize.x);
	
	e.gc.drawImage(control.image, x, (int)getY(control, ibounds.height));
	
	x += ibounds.width + 3;
	
	e.gc.drawText(control.text, x, (int)getY(control, tsize.y), true);
}
 
Example #9
Source Project: n4js   Author: eclipse   File: TypeInformationPopup.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Returns the initial location to use for the shell based upon the current selection in the viewer. Bottom is
 * preferred to top, and right is preferred to left, therefore if possible the popup will be located below and to
 * the right of the selection.
 *
 * @param initialSize
 *            the initial size of the shell, as returned by {@code getInitialSize}.
 * @return the initial location of the shell
 */
@Override
protected Point getInitialLocation(final Point initialSize) {
	if (null == anchor) {
		return super.getInitialLocation(initialSize);
	}

	final Point point = anchor;
	final Rectangle monitor = getShell().getMonitor().getClientArea();
	if (monitor.width < point.x + initialSize.x) {
		point.x = max(0, point.x - initialSize.x);
	}
	if (monitor.height < point.y + initialSize.y) {
		point.y = max(0, point.y - initialSize.y);
	}

	return point;
}
 
Example #10
Source Project: SWET   Author: sergueik   File: ImageLabel.java    License: MIT License 6 votes vote down vote up
@Override
protected Point onComputeSize(Composite composite, int wHint, int hHint,
		boolean flushCache) {
	// System.out.println("imageLabel.computeSize(" + wHint + "," + hHint +
	// ")");
	Point imgPrefSize = image.computeSize(SWT.DEFAULT, SWT.DEFAULT);
	// System.out.println("\tImage Width: " + imgPrefSize.x);

	if (wHint != SWT.DEFAULT)
		wHint = Math.max(0, wHint - imgPrefSize.x - hgap);

	// System.out.println("\tReduced wHint: " + wHint);

	Point textPrefSize = text.computeSize(wHint, hHint);

	// System.out.println("\tImage Height: " + imgPrefSize.y);
	// System.out.println("\tText Height: " + textPrefSize.y);

	int height = Math.max(imgPrefSize.y, textPrefSize.y);
	int width = imgPrefSize.x + hgap + textPrefSize.x;

	// System.out.println("\t-> Result: " + width + "," + height);

	return new Point(width, height);
}
 
Example #11
Source Project: nebula   Author: eclipse   File: ColumnFilterDialog.java    License: Eclipse Public License 2.0 6 votes vote down vote up
public void updateDate2Composite() {
   if (isBetweenDates()) {

      date2Widget = new DateTime(widgetComp, SWT.CALENDAR);
      date2Widget.addListener(SWT.Selection, e-> setDate2Selection());

      time2Widget = new DateTime(widgetComp, SWT.TIME);
      time2Widget.addListener(SWT.Selection, e-> setDate2Selection());
      time2Widget.setHours(0);
      time2Widget.setMinutes(0);
      time2Widget.setSeconds(0);
   } else {
      if (date2Widget != null) {
         date2Widget.dispose();
         date2Widget = null;
         time2Widget.dispose();
         time2Widget = null;
      }
   }
   widgetComp.layout(true, true);
   final Point newSize = getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
   getShell().setSize(newSize);
}
 
Example #12
Source Project: hop   Author: project-hop   File: UserDefinedJavaClassDialog.java    License: Apache License 2.0 6 votes vote down vote up
private void treeDblClick( Event event ) {
  StyledTextComp wScript = getStyledTextComp();
  Point point = new Point( event.x, event.y );
  TreeItem item = wTree.getItem( point );

  // Qualification where the Click comes from
  if ( item != null && item.getParentItem() != null ) {
    if ( item.getParentItem().equals( wTreeClassesItem ) ) {
      setActiveCtab( item.getText() );
    } else if ( !item.getData().equals( "Snippit" ) ) {
      int iStart = wScript.getCaretOffset();
      int selCount = wScript.getSelectionCount(); // this selection
      // will be replaced
      // by wScript.insert
      iStart = iStart - selCount; // when a selection is already there
      // we need to subtract the position
      if ( iStart < 0 ) {
        iStart = 0; // just safety
      }
      String strInsert = (String) item.getData();
      wScript.insert( strInsert );
      wScript.setSelection( iStart, iStart + strInsert.length() );
    }
  }
}
 
Example #13
Source Project: pentaho-kettle   Author: pentaho   File: EnterPrintDialog.java    License: Apache License 2.0 6 votes vote down vote up
public EnterPrintDialog( Shell parent, int nrcols, int nrrows, int scale, double factorX, double factorY,
  Rectangle m, double marginLeft, double marginRigth, double marginTop, double marginBottom, Image image ) {
  super( parent, SWT.NONE );
  props = PropsUI.getInstance();
  this.nrcols = nrcols;
  this.nrrows = nrrows;
  this.scale = scale;
  this.image = image;
  this.factorx = factorX;
  this.factory = factorY;
  this.leftMargin = marginLeft;
  this.rightMargin = marginRigth;
  this.topMargin = marginTop;
  this.bottomMargin = marginBottom;

  page = new Point( m.width, m.height );
}
 
Example #14
Source Project: translationstudio8   Author: heartsome   File: FindReplaceDialog.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * 替换 ;
 */
private void doReplace() {
	CellRegion activeCellRegion = ActiveCellRegion.getActiveCellRegion();
	if (activeCellRegion == null) {
		return;
	}
	StyledTextCellEditor cellEditor = HsMultiActiveCellEditor.getTargetStyledEditor();
	if(cellEditor != null){
		StyledText text = cellEditor.getSegmentViewer().getTextWidget();
		String sleText = text.getSelectionText();
		String findStr = cmbFind.getText();
		if (XliffEditorParameter.getInstance().isShowNonpirnttingCharacter()) {
			findStr = findStr.replaceAll("\\n", Constants.LINE_SEPARATOR_CHARACTER + "\n");
			findStr = findStr.replaceAll("\\t", Constants.TAB_CHARACTER + "\u200B");
			findStr = findStr.replaceAll(" ", Constants.SPACE_CHARACTER + "\u200B");
		}
		if( sleText != null  && sleText.toLowerCase().equals(findStr.toLowerCase())){
			Point p = text.getSelection();
			text.replaceTextRange(p.x, p.y - p.x, cmbReplace.getText());
		}
	}
}
 
Example #15
Source Project: APICloud-Studio   Author: apicloudcom   File: FormatterModifyDialog.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
protected Point getInitialSize()
{
	Point initialSize = super.getInitialSize();
	try
	{
		int lastWidth = fDialogSettings.getInt(KEY_WIDTH);
		// if (initialSize.x > lastWidth)
		// lastWidth = initialSize.x;
		int lastHeight = fDialogSettings.getInt(KEY_HEIGHT);
		// if (initialSize.y > lastHeight)
		// lastHeight = initialSize.y;
		return new Point(lastWidth, lastHeight);
	}
	catch (NumberFormatException ex)
	{
	}
	return initialSize;
}
 
Example #16
Source Project: google-cloud-eclipse   Author: GoogleCloudPlatform   File: AccountsPanel.java    License: Apache License 2.0 5 votes vote down vote up
@VisibleForTesting
void createAccountsPane(Composite accountArea) {
  for (Account account : loginService.getAccounts()) {
    Composite accountRow = new Composite(accountArea, SWT.NONE);
    Label avatar = new Label(accountRow, SWT.NONE);
    Composite secondColumn = new Composite(accountRow, SWT.NONE);
    Label name = new Label(secondColumn, SWT.LEAD);
    Label email = new Label(secondColumn, SWT.LEAD);
    Label separator = new Label(accountArea, SWT.HORIZONTAL | SWT.SEPARATOR);
    separator.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));

    // <Avatar size> = 3 * <email label height>
    Point emailSize = email.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    int avatarSize = emailSize.y * 3;

    GridDataFactory.swtDefaults().hint(avatarSize, avatarSize).applyTo(avatar);
    GridLayoutFactory.fillDefaults().numColumns(2).applyTo(accountRow);
    GridLayoutFactory.fillDefaults().generateLayout(secondColumn);

    if (account.getName() != null) {
      name.setText(account.getName());
    }
    email.setText(account.getEmail());  // email is never null.

    if (account.getAvatarUrl() != null) {
      try {
        imageLoader.loadImage(account.getAvatarUrl() + "=s" + avatarSize, avatar);
      } catch (MalformedURLException ex) {
        logger.log(Level.WARNING, "malformed avatar image URL", ex);
      }
    }
  }
}
 
Example #17
Source Project: birt   Author: eclipse   File: HighlightRuleBuilder.java    License: Eclipse Public License 1.0 5 votes vote down vote up
private void layout( )
{
	GridData gd = (GridData) condition.getLayoutData( );
	Point size = condition.computeSize( SWT.DEFAULT, SWT.DEFAULT );
	if ( gd.widthHint < size.x )
		gd.widthHint = size.x;
	if ( gd.heightHint < size.y )
		gd.heightHint = size.y;
	condition.setLayoutData( gd );
	condition.getShell( ).layout( );
	if ( getButtonBar( ) != null )
		condition.getShell( ).pack( );
}
 
Example #18
Source Project: elexis-3-core   Author: elexis   File: DatePicker.java    License: Eclipse Public License 1.0 5 votes vote down vote up
private int getDayFromPoint(int x, int y){
	int result = -1;
	
	for (int i = 1; i <= 31; i++) {
		Point p = getDayPoint(i);
		Rectangle r = new Rectangle(p.x, p.y, colSize, rowSize);
		if (r.contains(x, y)) {
			result = i;
			break;
		}
	}
	return result;
}
 
Example #19
Source Project: tmxeditor8   Author: heartsome   File: TBSearchCellRenderer.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public Rectangle getTextBounds(GridItem item, boolean preferred) {
	int x = leftMargin;

	if (isTree()) {
		x += getToggleIndent(item);

		x += toggleRenderer.getBounds().width + insideMargin;

	}

	if (isCheck()) {
		x += checkRenderer.getBounds().width + insideMargin;
	}

	Image image = item.getImage(getColumn());
	if (image != null) {
		x += image.getBounds().width + insideMargin;
	}

	Rectangle bounds = new Rectangle(x, topMargin + textTopMargin, 0, 0);

	GC gc = new GC(item.getParent());
	gc.setFont(item.getFont(getColumn()));
	Point size = gc.stringExtent(item.getText(getColumn()));

	bounds.height = size.y;

	if (preferred) {
		bounds.width = size.x - 1;
	} else {
		bounds.width = getBounds().width - x - rightMargin;
	}

	gc.dispose();

	return bounds;
}
 
Example #20
void selectionChanged() {
	Point selection= getSelection();
	if (selection.equals(fLastSelection)) {
		// leave caret position
	} else if (selection.x == selection.y) { //empty range
		fCaretPosition= selection.x;
	} else if (fLastSelection.y == selection.y) {
		fCaretPosition= selection.x; //same end -> assume caret at start
	} else {
		fCaretPosition= selection.y;
	}
	fLastSelection= selection;
}
 
Example #21
Source Project: tlaplus   Author: tlaplus   File: ApplicationWorkbenchWindowAdvisor.java    License: MIT License 5 votes vote down vote up
public void preWindowOpen()
{
    IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
    configurer.setInitialSize(new Point(800, 600));
    configurer.setShowFastViewBars(true);
    configurer.setShowStatusLine(true);
    configurer.setShowProgressIndicator(true);
    configurer.setShowCoolBar(false);
    
    // A DropTargetAdapter is need for editor DND support
    final DropTargetListener dtl = new EditorAreaDropAdapter(
            configurer.getWindow());
    configurer.configureEditorAreaDropListener(dtl);
}
 
Example #22
Source Project: BiglyBT   Author: BiglySoftware   File: SideBarToolTips.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * @return
 *
 * @since 3.1.1.1
 */
private String getToolTip(Point mousePos_RelativeToItem) {
	List<MdiEntryVitalityImageSWT> vitalityImages = mdiEntry.getVitalityImages();
	for (MdiEntryVitalityImageSWT vitalityImage : vitalityImages) {
		if (vitalityImage == null) {
			continue;
		}
		String indicatorToolTip = vitalityImage.getToolTip();
		if (indicatorToolTip == null || !vitalityImage.isVisible()) {
			continue;
		}
		Rectangle hitArea = vitalityImage.getHitArea();
		if (hitArea == null) {
			continue;
		}
		if (hitArea.contains(mousePos_RelativeToItem)) {
			return indicatorToolTip;
		}
	}

	if (mdiEntry.getViewTitleInfo() != null) {
		String tt = (String) mdiEntry.getViewTitleInfo().getTitleInfoProperty(ViewTitleInfo.TITLE_INDICATOR_TEXT_TOOLTIP);
		return tt;
	}

	return null;
}
 
Example #23
Source Project: tracecompass   Author: tracecompass   File: SWTBotTimeGraphEntry.java    License: Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Get the time in the entry for a given X point
 *
 * @param x
 *            the x point
 * @return the time or {@code null} or {@code -1} if it is out of bounds
 */
public Long getTimeForPoint(int x) {
    return UIThreadRunnable.syncExec((Result<@Nullable Long>) () -> {
        Rectangle bounds = widget.getBounds();
        Point p = new Point(x, bounds.y + bounds.height / 2);
        if (!bounds.contains(p)) {
            return null;
        }
        return widget.getTimeAtX(x);
    });
}
 
Example #24
Source Project: translationstudio8   Author: heartsome   File: TSWizardDialog.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Calculates the difference in size between the given page and the page
 * container. A larger page results in a positive delta.
 * 
 * @param page
 *            the page
 * @return the size difference encoded as a
 *         <code>new Point(deltaWidth,deltaHeight)</code>
 */
private Point calculatePageSizeDelta(IWizardPage page) {
	Control pageControl = page.getControl();
	if (pageControl == null) {
		// control not created yet
		return new Point(0, 0);
	}
	Point contentSize = pageControl.computeSize(SWT.DEFAULT, SWT.DEFAULT,
			true);
	Rectangle rect = pageContainerLayout.getClientArea(pageContainer);
	Point containerSize = new Point(rect.width, rect.height);
	return new Point(Math.max(0, contentSize.x - containerSize.x), Math
			.max(0, contentSize.y - containerSize.y));
}
 
Example #25
Source Project: nebula   Author: eclipse   File: TabBar.java    License: Eclipse Public License 2.0 5 votes vote down vote up
public TabBarItem getItem(Point point)
{
    int tabStartY = getBounds().height - barHeight - itemHeight;
    if (point.y < tabStartY)
        return null;
    
    if (point.y > tabStartY + itemHeight - 1)
        return null;
    
    int totalWidth = horzMargin + (itemWidth * items.size()) + (itemSpacing * items.size()) - itemSpacing + horzMargin;
    
    int x = horzMargin; 
    if ((getStyle() & SWT.RIGHT) != 0)
    {
        if (getBounds().width > totalWidth)
        {
            x += getBounds().width - totalWidth;
        }
    }
    
    for (Iterator iterator = items.iterator(); iterator.hasNext();)
    {
        TabBarItem item = (TabBarItem)iterator.next();
        
        if (point.x >= x && point.x < x + itemWidth)
        {
            return item;
        }
        
        x += itemWidth + itemSpacing;
    }
    
    return null;
}
 
Example #26
Source Project: arx   Author: arx-deidentifier   File: ViewLattice.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Utility method which centers a text in a rectangle.
 *
 * @param gc
 * @param text
 * @param x
 * @param y
 * @param width
 * @param height
 */
private void drawText(final GC gc, final String text, final int x, final int y, final int width, final int height) {

    Point size = canvas.getSize();
    Point extent = gc.textExtent(text);
    gc.setClipping(x, y, width, height);
    int xx = x + (width - extent.x) / 2;
    int yy = y + height / 2 - extent.y / 2;
    gc.drawText(text, xx, yy, true);
    gc.setClipping(0, 0, size.x, size.y);
}
 
Example #27
private void drawTopRight() {
	Point pos= new Point(getSize().x, 0);
	if ((fFlags & ABSTRACT) != 0) {
		addTopRightImage(JavaPluginImages.DESC_OVR_ABSTRACT, pos);
	}
	if ((fFlags & CONSTRUCTOR) != 0) {
		addTopRightImage(JavaPluginImages.DESC_OVR_CONSTRUCTOR, pos);
	}
	if ((fFlags & FINAL) != 0) {
		addTopRightImage(JavaPluginImages.DESC_OVR_FINAL, pos);
	}
	if ((fFlags & VOLATILE) != 0) {
		addTopRightImage(JavaPluginImages.DESC_OVR_VOLATILE, pos);
	}
	if ((fFlags & STATIC) != 0) {
		addTopRightImage(JavaPluginImages.DESC_OVR_STATIC, pos);
	}
	if ((fFlags & NATIVE) != 0) {
		addTopRightImage(JavaPluginImages.DESC_OVR_NATIVE, pos);
	}
	if ((fFlags & DEFAULT_METHOD) != 0) {
		addTopRightImage(JavaPluginImages.DESC_OVR_ANNOTATION_DEFAULT_METHOD, pos);
	}
	if ((fFlags & ANNOTATION_DEFAULT) != 0) {
		addTopRightImage(JavaPluginImages.DESC_OVR_ANNOTATION_DEFAULT_METHOD, pos);
	}
}
 
Example #28
Source Project: AppleCommander   Author: AppleCommander   File: DiskExplorerTab.java    License: GNU General Public License v2.0 5 votes vote down vote up
protected void printFooter() {
	TextBundle textBundle = UiBundle.getInstance();
	String text = textBundle.format("PageNumberText", page); //$NON-NLS-1$
	Point point = gc.stringExtent(text);
	gc.drawString(text, 
		clientArea.x + (clientArea.width - point.x)/2, 
		clientArea.y + clientArea.height + dpiY - point.y);
	page++;
}
 
Example #29
Source Project: nebula   Author: eclipse   File: Gallery.java    License: Eclipse Public License 2.0 5 votes vote down vote up
void onMouseDown(Event e) {
	if (DEBUG)
		System.out.println("Mouse down "); //$NON-NLS-1$

	mouseClickHandled = false;

	if (!_mouseDown(e)) {
		// Stop handling as requested by the group renderer
		mouseClickHandled = true;
		return;
	}

	GalleryItem item = getItem(new Point(e.x, e.y));

	if (e.button == 1) {

		if (item == null) {
			_deselectAll(true);
			redraw();
			mouseClickHandled = true;
			lastSingleClick = null;
		} else {
			if ((e.stateMask & SWT.MOD1) > 0) {
				onMouseHandleLeftMod1(e, item, true, false);
			} else if ((e.stateMask & SWT.SHIFT) > 0) {
				onMouseHandleLeftShift(e, item, true, false);
			} else {
				onMouseHandleLeft(e, item, true, false);
			}
		}
	} else if (e.button == 3) {
		onMouseHandleRight(e, item, true, false);
	}
}
 
Example #30
Source Project: nebula   Author: eclipse   File: SwitchButton.java    License: Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Draw the right part of the button
 *
 * @param buttonSize size of the button
 */
private void drawRightPart(final Point buttonSize) {
	gc.setForeground(selectedBackgroundColor);
	gc.setBackground(selectedBackgroundColor);
	gc.setClipping(3, 3, buttonSize.x / 2, buttonSize.y - 1);
	if (round) {
		gc.fillRoundRectangle(2, 2, buttonSize.x, buttonSize.y, arc, arc);
	} else {
		gc.fillRectangle(2, 2, buttonSize.x, buttonSize.y);
	}
	gc.setForeground(selectedForegroundColor);
	final Point textSize = gc.textExtent(textForSelect);
	gc.drawString(textForSelect, (buttonSize.x / 2 - textSize.x) / 2 + arc, (buttonSize.y - textSize.y) / 2 + arc);
}