Java Code Examples for org.eclipse.swt.SWT#Deactivate

The following examples show how to use org.eclipse.swt.SWT#Deactivate . 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 vote down vote up
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: DatePickerCombo.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
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 3
Source File: CalculatorCombo.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
private void createPopupShell() {
	popup = new Shell(getShell(), SWT.NO_TRIM | SWT.ON_TOP);
	popup.setLayout(new GridLayout());

	final int[] popupEvents = { SWT.Close, SWT.Paint, SWT.Deactivate, SWT.Dispose };
	for (final int popupEvent : popupEvents) {
		popup.addListener(popupEvent, listener);
	}

	composite = new CalculatorButtonsComposite(popup, SWT.NONE);
	composite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
	composite.setDisplayArea(label);
	keyListener = composite.getKeyListener();
	label.addKeyListener(keyListener);

	popup.pack();
}
 
Example 4
Source File: MultiChoice.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Handle a popup event
 *
 * @param event event to handle
 */
private void handlePopupEvent(final Event event) {
	switch (event.type) {
		case SWT.Close:
			event.doit = false;
			changeVisibilityOfPopupWindow(false);
			break;
		case SWT.Deactivate:
			changeVisibilityOfPopupWindow(false);
			break;
		case SWT.Dispose:
			if (this.checkboxes != null) {
				this.checkboxes.clear();
			}
			this.checkboxes = null;
			break;
	}
}
 
Example 5
Source File: CustomCombo.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
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 6
Source File: StyleCombo.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
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 7
Source File: TableCombo.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 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 8
Source File: CTreeCombo.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
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 9
Source File: TableCombo.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * 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 10
Source File: AbstractCombo.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Manages popup shell events.
 * 
 * @param event event
 */
protected void popupEvent(Event event) {
	switch (event.type) {
		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 = button.toControl(getDisplay().getCursorLocation());
				Point size = button.getSize();
				Rectangle rect = new Rectangle(0, 0, size.x, size.y);
				if (!rect.contains(point))
					dropDown(false);
			} else {
				dropDown(false);
			}
			break;
	}
}
 
Example 11
Source File: CustomCombo.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
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 12
Source File: BaseCombo.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
private void init(int style) {
	this.style = style;
	simple = (style & SWT.SIMPLE) != 0;
	dropDown = (style & (BUTTON_ONLY | SWT.DROP_DOWN)) != 0;
	leftAlign = (style & SWT.LEFT) != 0;

	if (simple) {
		panel.setLayout(new VSimpleLayout());
	} else if (dropDown) {
		createButton(style);
		if ((style & BUTTON_ONLY) == 0) {
			createText(style);
			if (win32) {
				setPositionControl(panel);
			} else {
				setPositionControl(text);
			}
			panel.setLayout(new DropComboLayout());
		} else {
			setPositionControl(button);
			panel.setLayout(new VSimpleLayout());
		}

		shellListener = new Listener() {
			public void handleEvent(Event event) {
				switch (event.type) {
				case SWT.Close:
					event.doit = false;
					setOpen(false);
					break;
				case SWT.Deactivate:
					if (!checkContent() || content.getMenu() == null
							|| !content.getMenu().isVisible()) {
						setOpen(false);
					}
					break;
				}
			}
		};

		addListener(SWT.Move, comboListener);
		addListener(SWT.Resize, comboListener);
	} else {
		panel.setLayout(new VSimpleLayout());
		createText(style);
	}

	addListener(SWT.Dispose, disposeListener);
}
 
Example 13
Source File: MultiChoice.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Create the popup that contains all checkboxes
 */
private void createPopup() {
	this.popup = new Shell(getShell(), SWT.NO_TRIM | SWT.ON_TOP);
	this.popup.setLayout(new FillLayout());

	final int[] popupEvents = { SWT.Close, SWT.Deactivate, SWT.Dispose };
	for (final int popupEvent : popupEvents) {
		this.popup.addListener(popupEvent, this.listener);
	}

	if (this.elements == null) {
		return;
	}

	this.scrolledComposite = new ScrolledComposite(this.popup, SWT.BORDER | SWT.V_SCROLL);
	final Composite content = new Composite(this.scrolledComposite, SWT.NONE);
	content.setLayout(new GridLayout(this.numberOfColumns, true));

	this.checkboxes = new ArrayList<>(this.elements.size());
	for (final T o : this.elements) {
		final Button checkBoxButton = new Button(content, SWT.CHECK);

		if (this.font != null) {
			checkBoxButton.setFont(this.font);
		}
		if (this.foreground != null) {
			checkBoxButton.setForeground(this.foreground);
		}
		if (this.background != null) {
			checkBoxButton.setBackground(this.background);
		}
		checkBoxButton.setEnabled(text.getEditable());

		checkBoxButton.setData(o);
		checkBoxButton.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false));
		checkBoxButton.setText(this.labelProvider.getText(o));
		checkBoxButton.addListener(SWT.Selection, e -> {
			if (checkBoxButton.getSelection()) {
				MultiChoice.this.selection.add(o);
			} else {
				MultiChoice.this.selection.remove(o);
			}
			MultiChoice.this.lastModified = o;
			setLabel();
		});

		if (this.selectionListener != null) {
			checkBoxButton.addSelectionListener(this.selectionListener);
		}

		checkBoxButton.setSelection(this.selection.contains(o));
		this.checkboxes.add(checkBoxButton);
	}

	this.scrolledComposite.setContent(content);
	this.scrolledComposite.setExpandHorizontal(false);
	this.scrolledComposite.setExpandVertical(true);
	content.pack();
	this.preferredHeightOfPopup = content.getSize().y;
}
 
Example 14
Source File: CTreeCombo.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
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 15
Source File: TableCombo.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * 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 16
Source File: AnalogTimePicker.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
protected void createContents() {
	setLayout(new BaseLayout());

	dialPanel = new VPanel(this, SWT.NONE);
	dialPanel.setLayout(new DialLayout());

	timeAmPm = new VButton(dialPanel, SWT.NO_FOCUS);
	timeAmPm.setText("PM"); //$NON-NLS-1$
	timeAmPm.setForeground(
			getDisplay().getSystemColor(SWT.COLOR_DARK_BLUE));
	timeAmPm.setMargins(4, 4);
	timeAmPm.setEnabled(!dialPanel.hasStyle(CDT.READ_ONLY));
	tapl = event -> {
		if (event.widget == null) {
			Calendar tmpcal = cdt.getCalendarInstance();
			tmpcal.set(Calendar.AM_PM,
					tmpcal.get(Calendar.AM_PM) == 0 ? 1 : 0);
			setSelection(tmpcal.getTime());
			cdt.fireSelectionChanged(Calendar.AM_PM);
		}
	};
	timeAmPm.addListener(SWT.Selection, tapl);
	timeAmPm.addListener(SWT.MouseWheel, tapl);

	Listener listener = event -> {
		if (cdt.getEditable()) {
			switch (event.type) {
			case SWT.Deactivate:
				if (VTracker.isMouseDown()) {
					handleMouseUp();
					overHour = overMin = overSec = false;
					redraw();
				}
				break;
			case SWT.MouseDown:
				handleMouseDown();
				break;
			case SWT.MouseMove:
				handleMouseMove(event.x, event.y);
				break;
			case SWT.MouseUp:
				handleMouseUp();
				break;
			case SWT.MouseWheel:
				handleMouseWheel(event.count);
				break;
			}
		}
	};

	dialPanel.addListener(SWT.Deactivate, listener);
	dialPanel.addListener(SWT.MouseDown, listener);
	dialPanel.addListener(SWT.MouseMove, listener);
	dialPanel.addListener(SWT.MouseUp, listener);
	dialPanel.addListener(SWT.MouseWheel, listener);

	dialPanel.setPainter(new AnalogClockPainter(cdt, this));
}
 
Example 17
Source File: TableCombo.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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 18
Source File: TableCombo.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Handles Popup Events
 * @param event
 */
private void popupEvent(Event event) {
	switch (event.type) {
	case SWT.Paint:
		// draw rectangle around table
		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())) {
			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;

	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 19
Source File: DataItemCombo.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
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 20
Source File: DataItemCombo.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
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;
	}
}