Java Code Examples for org.eclipse.swt.SWT#Paint
The following examples show how to use
org.eclipse.swt.SWT#Paint .
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: StyleCombo.java From birt with Eclipse Public License 1.0 | 6 votes |
void popupEvent( Event event ) { switch ( event.type ) { case SWT.Paint : // draw black rectangle around list Rectangle tableRect = table.getBounds( ); Color black = getDisplay( ).getSystemColor( SWT.COLOR_BLACK ); event.gc.setForeground( black ); event.gc.drawRectangle( 0, 0, tableRect.width + 1, tableRect.height + 1 ); break; case SWT.Close : event.doit = false; dropDown( false ); break; case SWT.Deactivate : dropDown( false ); break; } }
Example 2
Source File: CCombo.java From birt with Eclipse Public License 1.0 | 6 votes |
void createPopup(String[] items, int selectionIndex) { // create shell and list popup = new Shell (getShell(), SWT.NO_TRIM | SWT.ON_TOP); int style = getStyle(); int listStyle = SWT.SINGLE | SWT.V_SCROLL; if ((style & SWT.FLAT) != 0) listStyle |= SWT.FLAT; if ((style & SWT.RIGHT_TO_LEFT) != 0) listStyle |= SWT.RIGHT_TO_LEFT; if ((style & SWT.LEFT_TO_RIGHT) != 0) listStyle |= SWT.LEFT_TO_RIGHT; list = new List (popup, listStyle); if (font != null) list.setFont(font); if (foreground != null) list.setForeground(foreground); if (background != null) list.setBackground(background); int [] popupEvents = {SWT.Close, SWT.Paint, SWT.Deactivate}; for (int i=0; i<popupEvents.length; i++) popup.addListener (popupEvents [i], listener); int [] listEvents = {SWT.MouseUp, SWT.Selection, SWT.Traverse, SWT.KeyDown, SWT.KeyUp, SWT.FocusIn, SWT.FocusOut, SWT.Dispose}; for (int i=0; i<listEvents.length; i++) list.addListener (listEvents [i], listener); if (items != null) list.setItems(items); if (selectionIndex != -1) list.setSelection(selectionIndex); }
Example 3
Source File: FillChooserComposite.java From birt with Eclipse Public License 1.0 | 6 votes |
public void handleEvent( Event event ) { switch ( event.type ) { case SWT.Paint : paintControl( new PaintEvent( event ) ); break; case SWT.FocusIn : redraw( ); break; case SWT.KeyDown : keyDown( event ); break; case SWT.MouseDown : if ( !bEnabled ) { return; } fireHandleEvent( MOUSE_CLICKED_EVENT ); setColorToModel( this.getColorAt( event.x, event.y ) ); cmpDropDown.getShell( ).close( ); break; } }
Example 4
Source File: Bubble.java From swt-bling with MIT License | 6 votes |
private void attachListeners() { listener = new Listener() { public void handleEvent(Event event) { switch (event.type) { case SWT.Paint: onPaint(event); break; case SWT.MouseDown: onMouseDown(event); break; case SWT.MouseEnter: BubbleRegistrant registrant = BubbleRegistry.getInstance().findRegistrant(getPoppedOverItem().getControlOrCustomElement()); registrant.dismissBubble(); registrant.bubble.setDisableAutoHide(false); break; default: break; } } }; popOverShell.addListener(SWT.Paint, listener); popOverShell.addListener(SWT.MouseDown, listener); popOverShell.addListener(SWT.MouseEnter, listener); addAccessibilityHooks(parentControl); }
Example 5
Source File: CalculatorCombo.java From nebula with Eclipse Public License 2.0 | 6 votes |
/** * Handle a popup event * * @param event event to handle */ private void handlePopupEvent(final Event event) { switch (event.type) { case SWT.Paint: final Rectangle listRect = popup.getBounds(); final Color black = getDisplay().getSystemColor(SWT.COLOR_BLACK); event.gc.setForeground(black); event.gc.drawRectangle(0, 0, listRect.width - 1, listRect.height - 1); break; case SWT.Close: event.doit = false; hidePopupWindow(false); break; case SWT.Deactivate: hidePopupWindow(false); break; case SWT.Dispose: if (keyListener != null) { label.removeKeyListener(keyListener); } break; } }
Example 6
Source File: DatePickerCombo.java From elexis-3-core with Eclipse Public License 1.0 | 6 votes |
private void popupEvent(Event event){ switch (event.type) { case SWT.Paint: // draw black rectangle around dp Rectangle listRect = dp.getBounds(); Color black = getDisplay().getSystemColor(SWT.COLOR_BLACK); event.gc.setForeground(black); event.gc.drawRectangle(0, 0, listRect.width + 1, listRect.height + 1); break; case SWT.Close: event.doit = false; dropDown(false); break; case SWT.Deactivate: dropDown(false); break; } }
Example 7
Source File: StyleCombo.java From birt with Eclipse Public License 1.0 | 5 votes |
void createPopup( Object[] items, int selectionIndex ) { // create shell and list popup = new Shell( getShell( ), SWT.NO_TRIM | SWT.ON_TOP ); table = new Table( popup, SWT.SINGLE | SWT.V_SCROLL | SWT.FULL_SELECTION ); new TableColumn( table, SWT.LEFT ); if ( font != null ) table.setFont( font ); if ( foreground != null ) table.setForeground( foreground ); if ( background != null ) table.setBackground( background ); label.setBackground( table.getBackground( ) ); label.setForeground( table.getForeground( ) ); label.setFont( table.getFont( ) ); int[] popupEvents = { SWT.Close, SWT.Paint, SWT.Deactivate }; for ( int i = 0; i < popupEvents.length; i++ ) popup.addListener( popupEvents[i], listener ); int[] tableEvents = { SWT.MouseUp, SWT.Selection, SWT.Traverse, SWT.KeyDown, SWT.KeyUp, SWT.FocusIn, SWT.FocusOut, SWT.Dispose }; for ( int i = 0; i < tableEvents.length; i++ ) table.addListener( tableEvents[i], listener ); }
Example 8
Source File: TableCombo.java From Pydev with Eclipse Public License 1.0 | 5 votes |
/** * creates the popup shell. * @param selectionIndex */ void createPopup(int selectionIndex) { // create shell and table popup = new Shell(getShell(), SWT.NO_TRIM | SWT.ON_TOP); // create table table = new Table(popup, SWT.SINGLE | SWT.FULL_SELECTION); if (font != null) table.setFont(font); if (foreground != null) table.setForeground(foreground); if (background != null) table.setBackground(background); // Add popup listeners int[] popupEvents = { SWT.Close, SWT.Paint, SWT.Deactivate }; for (int i = 0; i < popupEvents.length; i++) { popup.addListener(popupEvents[i], listener); } // add table listeners int[] tableEvents = { SWT.MouseUp, SWT.Selection, SWT.Traverse, SWT.KeyDown, SWT.KeyUp, SWT.FocusIn, SWT.Dispose }; for (int i = 0; i < tableEvents.length; i++) { table.addListener(tableEvents[i], listener); } // set the selection if (selectionIndex != -1) { table.setSelection(selectionIndex); } }
Example 9
Source File: CustomCombo.java From nebula with Eclipse Public License 2.0 | 5 votes |
void createPopup(String[] items, int selectionIndex) { // create shell and list popup = new Shell(getShell(), SWT.NO_TRIM | SWT.ON_TOP); int style = getStyle(); int listStyle = SWT.SINGLE | SWT.V_SCROLL; if ((style & SWT.FLAT) != 0) listStyle |= SWT.FLAT; if ((style & SWT.RIGHT_TO_LEFT) != 0) listStyle |= SWT.RIGHT_TO_LEFT; if ((style & SWT.LEFT_TO_RIGHT) != 0) listStyle |= SWT.LEFT_TO_RIGHT; list = new List(popup, listStyle); if (font != null) list.setFont(font); if (foreground != null) list.setForeground(foreground); if (background != null) list.setBackground(background); int[] popupEvents = { SWT.Close, SWT.Paint, SWT.Deactivate }; for (int i = 0; i < popupEvents.length; i++) popup.addListener(popupEvents[i], listener); int[] listEvents = { SWT.MouseUp, SWT.Selection, SWT.Traverse, SWT.KeyDown, SWT.KeyUp, SWT.FocusIn, SWT.Dispose }; for (int i = 0; i < listEvents.length; i++) list.addListener(listEvents[i], listener); if (items != null) list.setItems(items); if (selectionIndex != -1) list.setSelection(selectionIndex); }
Example 10
Source File: CTreeCombo.java From nebula with Eclipse Public License 2.0 | 5 votes |
void popupEvent(Event event) { switch (event.type) { case SWT.Paint: // draw black rectangle around list final Rectangle listRect = tree.getBounds(); final Color black = getDisplay().getSystemColor(SWT.COLOR_BLACK); event.gc.setForeground(black); event.gc.drawRectangle(0, 0, listRect.width + 1, listRect.height + 1); break; case SWT.Close: event.doit = false; dropDown(false); break; case SWT.Deactivate: if (!"carbon".equals(SWT.getPlatform())) { final Point point = arrow.toControl(getDisplay().getCursorLocation()); final Point size = arrow.getSize(); final Rectangle rect = new Rectangle(0, 0, size.x, size.y); if (!rect.contains(point)) { dropDown(false); } } else { dropDown(false); } break; } }
Example 11
Source File: TableCombo.java From nebula with Eclipse Public License 2.0 | 5 votes |
/** * creates the popup shell. * * @param selectionIndex */ void createPopup(final int selectionIndex) { // create shell and table popup = new Shell(getShell(), SWT.NO_TRIM | SWT.ON_TOP); // create table table = new Table(popup, SWT.SINGLE | SWT.FULL_SELECTION); if (font != null) { table.setFont(font); } if (foreground != null) { table.setForeground(foreground); } if (background != null) { table.setBackground(background); } // Add popup listeners final int[] popupEvents = { SWT.Close, SWT.Paint, SWT.Deactivate, SWT.Help }; for (final int popupEvent : popupEvents) { popup.addListener(popupEvent, listener); } // add table listeners final int[] tableEvents = { SWT.MouseUp, SWT.Selection, SWT.Traverse, SWT.KeyDown, SWT.KeyUp, SWT.FocusIn, SWT.Dispose }; for (final int tableEvent : tableEvents) { table.addListener(tableEvent, listener); } // set the selection if (selectionIndex != -1) { table.setSelection(selectionIndex); } }
Example 12
Source File: CustomCombo.java From nebula with Eclipse Public License 2.0 | 5 votes |
void popupEvent(Event event) { switch (event.type) { case SWT.Paint: // draw black rectangle around list Rectangle listRect = list.getBounds(); Color black = getDisplay().getSystemColor(SWT.COLOR_BLACK); event.gc.setForeground(black); event.gc.drawRectangle(0, 0, listRect.width + 1, listRect.height + 1); break; case SWT.Close: event.doit = false; dropDown(false); break; case SWT.Deactivate: /* * Bug in GTK. When the arrow button is pressed the popup control * receives a deactivate event and then the arrow button receives a * selection event. If we hide the popup in the deactivate event, * the selection event will show it again. To prevent the popup from * showing again, we will let the selection event of the arrow * button hide the popup. In Windows, hiding the popup during the * deactivate causes the deactivate to be called twice and the * selection event to be disappear. */ if (!"carbon".equals(SWT.getPlatform())) { Point point = arrow.toControl(getDisplay().getCursorLocation()); Point size = arrow.getSize(); Rectangle rect = new Rectangle(0, 0, size.x, size.y); if (!rect.contains(point)) dropDown(false); } else { dropDown(false); } break; } }
Example 13
Source File: TableCombo.java From translationstudio8 with GNU General Public License v2.0 | 4 votes |
/** * creates the popup shell. * @param selectionIndex */ void createPopup(int selectionIndex) { // create shell and table popup = new Shell(getShell(), SWT.NO_TRIM | SWT.ON_TOP); // set style int style = getStyle(); int tableStyle = SWT.SINGLE | SWT.V_SCROLL; if ((style & SWT.FLAT) != 0) tableStyle |= SWT.FLAT; if ((style & SWT.RIGHT_TO_LEFT) != 0) tableStyle |= SWT.RIGHT_TO_LEFT; if ((style & SWT.LEFT_TO_RIGHT) != 0) tableStyle |= SWT.LEFT_TO_RIGHT; // create table table = new Table(popup, SWT.SINGLE | SWT.FULL_SELECTION); if (font != null) table.setFont(font); if (foreground != null) table.setForeground(foreground); if (background != null) table.setBackground(background); // Add popup listeners int[] popupEvents = { SWT.Close, SWT.Paint, SWT.Deactivate, SWT.Help }; for (int i = 0; i < popupEvents.length; i++) { popup.addListener(popupEvents[i], listener); } // add table listeners int[] tableEvents = { SWT.MouseMove, SWT.MouseUp, SWT.Selection, SWT.Traverse, SWT.KeyDown, SWT.KeyUp, SWT.FocusIn, SWT.Dispose }; for (int i = 0; i < tableEvents.length; i++) { table.addListener(tableEvents[i], listener); } // set the selection if (selectionIndex != -1) { table.setSelection(selectionIndex); } }
Example 14
Source File: TableCombo.java From tmxeditor8 with GNU General Public License v2.0 | 4 votes |
/** * creates the popup shell. * @param selectionIndex */ void createPopup(int selectionIndex) { // create shell and table popup = new Shell(getShell(), SWT.NO_TRIM | SWT.ON_TOP); // set style int style = getStyle(); int tableStyle = SWT.SINGLE | SWT.V_SCROLL; if ((style & SWT.FLAT) != 0) tableStyle |= SWT.FLAT; if ((style & SWT.RIGHT_TO_LEFT) != 0) tableStyle |= SWT.RIGHT_TO_LEFT; if ((style & SWT.LEFT_TO_RIGHT) != 0) tableStyle |= SWT.LEFT_TO_RIGHT; // create table table = new Table(popup, SWT.SINGLE | SWT.FULL_SELECTION); if (font != null) table.setFont(font); if (foreground != null) table.setForeground(foreground); if (background != null) table.setBackground(background); // Add popup listeners int[] popupEvents = { SWT.Close, SWT.Paint, SWT.Deactivate, SWT.Help }; for (int i = 0; i < popupEvents.length; i++) { popup.addListener(popupEvents[i], listener); } // add table listeners int[] tableEvents = { SWT.MouseMove, SWT.MouseUp, SWT.Selection, SWT.Traverse, SWT.KeyDown, SWT.KeyUp, SWT.FocusIn, SWT.Dispose }; for (int i = 0; i < tableEvents.length; i++) { table.addListener(tableEvents[i], listener); } // set the selection if (selectionIndex != -1) { table.setSelection(selectionIndex); } }
Example 15
Source File: CTreeCombo.java From nebula with Eclipse Public License 2.0 | 4 votes |
void createPopup(Collection<CTreeComboItem> items, CTreeComboItem selectedItem) { // create shell and list popup = new Shell(getShell(), SWT.NO_TRIM | SWT.ON_TOP); final int style = getStyle(); int listStyle = SWT.H_SCROLL | SWT.V_SCROLL | SWT.SINGLE; if ((style & SWT.FLAT) != 0) { listStyle |= SWT.FLAT; } if ((style & SWT.RIGHT_TO_LEFT) != 0) { listStyle |= SWT.RIGHT_TO_LEFT; } if ((style & SWT.LEFT_TO_RIGHT) != 0) { listStyle |= SWT.LEFT_TO_RIGHT; } tree = new Tree(popup, listStyle); tree.addTreeListener(hookListener); if (font != null) { tree.setFont(font); } if (foreground != null) { tree.setForeground(foreground); } if (background != null) { tree.setBackground(background); } final int[] popupEvents = { SWT.Close, SWT.Paint, SWT.Deactivate }; for (int i = 0; i < popupEvents.length; i++) { popup.addListener(popupEvents[i], listener); } final int[] listEvents = { SWT.MouseUp, SWT.Selection, SWT.Traverse, SWT.KeyDown, SWT.KeyUp, SWT.FocusIn, SWT.Dispose, SWT.Collapse, SWT.Expand }; for (int i = 0; i < listEvents.length; i++) { tree.addListener(listEvents[i], listener); } for (final CTreeComboColumn c : columns) { final TreeColumn col = new TreeColumn(tree, SWT.NONE); c.setRealTreeColumn(col); } if (items != null) { createTreeItems(items.toArray(new CTreeComboItem[0])); } if (selectedItem != null) { tree.setSelection(selectedItem.getRealTreeItem()); } }
Example 16
Source File: TableCombo.java From nebula with Eclipse Public License 2.0 | 4 votes |
/** * Handles Popup Events * * @param event */ private void popupEvent(final Event event) { switch (event.type) { case SWT.Paint: // draw rectangle around table final Rectangle tableRect = table.getBounds(); event.gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION)); event.gc.drawRectangle(0, 0, tableRect.width + 1, tableRect.height + 1); break; case SWT.Close: event.doit = false; dropDown(false); break; case SWT.Deactivate: /* * Bug in GTK. When the arrow button is pressed the popup control receives a * deactivate event and then the arrow button receives a selection event. If we * hide the popup in the deactivate event, the selection event will show it * again. To prevent the popup from showing again, we will let the selection * event of the arrow button hide the popup. In Windows, hiding the popup during * the deactivate causes the deactivate to be called twice and the selection * event to be disappear. */ if (!"carbon".equals(SWT.getPlatform())) { final Point point = arrow.toControl(getDisplay().getCursorLocation()); final Point size = arrow.getSize(); final Rectangle rect = new Rectangle(0, 0, size.x, size.y); if (!rect.contains(point)) { dropDown(false); } } else { dropDown(false); } break; case SWT.Help: if (isDropped()) { dropDown(false); } Composite comp = TableCombo.this; do { if (comp.getListeners(event.type) != null && comp.getListeners(event.type).length > 0) { comp.notifyListeners(event.type, event); break; } comp = comp.getParent(); } while (null != comp); break; } }
Example 17
Source File: DataItemCombo.java From birt with Eclipse Public License 1.0 | 4 votes |
void createPopup( String[] items, int selectionIndex ) { // create shell and list popup = new Shell( getShell( ), SWT.NO_TRIM | SWT.ON_TOP ); int style = getStyle( ); int listStyle = SWT.SINGLE | SWT.V_SCROLL; if ( ( style & SWT.FLAT ) != 0 ) listStyle |= SWT.FLAT; if ( ( style & SWT.RIGHT_TO_LEFT ) != 0 ) listStyle |= SWT.RIGHT_TO_LEFT; if ( ( style & SWT.LEFT_TO_RIGHT ) != 0 ) listStyle |= SWT.LEFT_TO_RIGHT; list = new List( popup, listStyle ); if ( font != null ) list.setFont( font ); if ( foreground != null ) list.setForeground( foreground ); if ( background != null ) list.setBackground( background ); int[] popupEvents = { SWT.Close, SWT.Paint, SWT.Deactivate }; for ( int i = 0; i < popupEvents.length; i++ ) popup.addListener( popupEvents[i], listener ); int[] listEvents = { SWT.MouseUp, SWT.Selection, SWT.Traverse, SWT.KeyDown, SWT.KeyUp, SWT.FocusIn, SWT.Dispose }; for ( int i = 0; i < listEvents.length; i++ ) list.addListener( listEvents[i], listener ); if ( items != null ) list.setItems( items ); if ( selectionIndex != -1 ) list.setSelection( selectionIndex ); }
Example 18
Source File: DataItemCombo.java From birt with Eclipse Public License 1.0 | 4 votes |
void popupEvent( Event event ) { switch ( event.type ) { case SWT.Paint : // draw black rectangle around list Rectangle listRect = list.getBounds( ); Color black = getDisplay( ).getSystemColor( SWT.COLOR_BLACK ); event.gc.setForeground( black ); event.gc.drawRectangle( 0, 0, listRect.width + 1, listRect.height + 1 ); break; case SWT.Close : event.doit = false; dropDown( false ); break; case SWT.Deactivate : /* * Bug in GTK. When the arrow button is pressed the popup * control receives a deactivate event and then the arrow button * receives a selection event. If we hide the popup in the * deactivate event, the selection event will show it again. To * prevent the popup from showing again, we will let the * selection event of the arrow button hide the popup. In * Windows, hiding the popup during the deactivate causes the * deactivate to be called twice and the selection event to be * disappear. */ if ( !"carbon".equals( SWT.getPlatform( ) ) ) //$NON-NLS-1$ { Point point = arrow.toControl( getDisplay( ).getCursorLocation( ) ); Point size = arrow.getSize( ); Rectangle rect = new Rectangle( 0, 0, size.x, size.y ); if ( !rect.contains( point ) ) dropDown( false ); } else { dropDown( false ); } break; } }
Example 19
Source File: MarkerEditorComposite.java From birt with Eclipse Public License 1.0 | 4 votes |
private void canvasEvent( Event event ) { switch ( event.type ) { case SWT.FocusIn : { cnvMarker.redraw( ); break; } case SWT.FocusOut : { cnvMarker.redraw( ); break; } case SWT.KeyDown : { // At this point the widget may have been disposed. // If so, do not continue. if ( isDisposed( ) ) break; if ( event.keyCode == SWT.ARROW_DOWN || event.keyCode == SWT.CR || event.keyCode == SWT.KEYPAD_CR ) { event.doit = true; toggleDropDown( ); } break; } case SWT.Traverse : { switch ( event.detail ) { case SWT.TRAVERSE_RETURN : case SWT.TRAVERSE_TAB_NEXT : case SWT.TRAVERSE_TAB_PREVIOUS : case SWT.TRAVERSE_ARROW_PREVIOUS : case SWT.TRAVERSE_ARROW_NEXT : event.doit = true; cnvMarker.redraw( ); } break; } case SWT.Paint : paintMarker( event.gc, getMarker( ), LocationImpl.create( 10, 10 ) ); break; } }
Example 20
Source File: SComposite.java From nebula with Eclipse Public License 2.0 | 4 votes |
public void handleEvent(Event event) { if(event.type == SWT.Paint) { paintControl(event.gc); } }