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 File: ColumnFilterDialog.java    From nebula with 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 #2
Source File: FormatterModifyDialog.java    From APICloud-Studio with 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 #3
Source File: TitleControl.java    From nebula with 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 #4
Source File: BadgedLabel.java    From nebula with 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 #5
Source File: CellSelectionDragMode.java    From translationstudio8 with 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 #6
Source File: TextIconButton.java    From swt-bling with 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 #7
Source File: UserDefinedJavaClassDialog.java    From pentaho-kettle with 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 #8
Source File: PaletteShelfRenderer.java    From nebula with 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 #9
Source File: FindReplaceDialog.java    From translationstudio8 with 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 #10
Source File: CellEdgeDetectUtil.java    From translationstudio8 with 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 #11
Source File: VControlPainter.java    From nebula with 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 #12
Source File: EnterPrintDialog.java    From pentaho-kettle with 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 #13
Source File: UserDefinedJavaClassDialog.java    From hop with 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 #14
Source File: TypeInformationPopup.java    From n4js with 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 #15
Source File: ImageLabel.java    From SWET with 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 #16
Source File: ClassPathsPageHelper.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public void createPageCustomControl( Composite parent )
{	
	this.parent = parent;
	ScrolledComposite sComposite = new ScrolledComposite( parent,
			SWT.H_SCROLL | SWT.V_SCROLL );
	sComposite.setLayout( new GridLayout( ) );
	sComposite.setMinWidth( 560 );
	sComposite.setExpandHorizontal( true );
	sComposite.setMinHeight( 400 );
	sComposite.setExpandVertical( true );

	Composite composite = new Composite( sComposite, SWT.NONE );
	GridLayout layout = new GridLayout( 1, false );
	layout.horizontalSpacing = 10;
	composite.setLayout( layout );
	
	createTabFolderArea( composite );
	
	createCheckboxArea( composite );

	Point size = composite.computeSize( SWT.DEFAULT, SWT.DEFAULT );
	composite.setSize( size.x, size.y );

	sComposite.setContent( composite );

	HelpUtil.setSystemHelp( parent, HelpUtil.CONEXT_ID_DATASOURCE_POJO );
	
}
 
Example #17
Source File: TBSearchCellRenderer.java    From tmxeditor8 with 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 #18
Source File: ProtocolEditor.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * If there is more than one page in the multi-page editor part,
 * this shows the tabs at the bottom.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void showTabs ()
{
    if ( getPageCount () > 1 )
    {
        setPageText ( 0, getString ( "_UI_SelectionPage_label" ) ); //$NON-NLS-1$
        if ( getContainer () instanceof CTabFolder )
        {
            ( (CTabFolder)getContainer () ).setTabHeight ( SWT.DEFAULT );
            Point point = getContainer ().getSize ();
            getContainer ().setSize ( point.x, point.y - 6 );
        }
    }
}
 
Example #19
Source File: SWTBotTimeGraphEntry.java    From tracecompass with 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 #20
Source File: TextFieldNavigationHandler.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
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 File: EditVariableEntryDialog.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected void updateStatus(IStatus status) {
	super.updateStatus(status);
	Shell shell= getShell();
	if (shell != null && ! shell.isDisposed()) {
		Point size= shell.getSize();
		Point minSize= shell.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
		if (minSize.x > size.x || minSize.y > size.y) {
			shell.setSize(minSize);
		}
	}
}
 
Example #22
Source File: MonthCalendar.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
public void mouseDown(MouseEvent e) {
	Day day = getDay(e);
	Point coordinates = day.getMonthPosition();
	e.data = new MonthCalendarSelectedDay(day.getDate(), coordinates);

	for (Iterator<MouseListener> mouseListenersIter = mouseListeners.iterator(); mouseListenersIter.hasNext();) {
		MouseListener listener = (MouseListener) mouseListenersIter.next();
		listener.mouseDown(e);
	}
}
 
Example #23
Source File: TabBar.java    From nebula with 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 #24
Source File: ViewLattice.java    From arx with 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 #25
Source File: JavaElementImageDescriptor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
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 #26
Source File: DiskExplorerTab.java    From AppleCommander with 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 #27
Source File: ChangeHoverInformationControl.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public Point computeSizeHint() {
	Point size= super.computeSizeHint();
	size.x= Math.min(size.x, fMaxWidth);
	size.y= Math.min(size.y, fMaxHeight);
	return size;
}
 
Example #28
Source File: AccountsPanel.java    From google-cloud-eclipse with 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 #29
Source File: Gallery.java    From nebula with 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 File: SwitchButton.java    From nebula with 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);
}