Java Code Examples for org.eclipse.swt.widgets.Display#getSystemColor()

The following examples show how to use org.eclipse.swt.widgets.Display#getSystemColor() . 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: TimeSlot.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Constructor EmptyTablePlaceholder. Construct an EmptyTablePlaceholder
 * control.
 * 
 * @param parent
 *            The parent control
 * @param style
 *            Style bits. These are the same as what Canvas accepts.
 */
public TimeSlot(Composite parent, int style) {
	super(parent, style);

	addTraverseListener(traverseListener);
	addFocusListener(focusListener);
	addPaintListener(paintListener);
	addDisposeListener(disposeListener);
	addKeyListener(keyListener);
	addMouseListener(mouseListener);

	Display display = Display.getCurrent();

	WHITE = display.getSystemColor(SWT.COLOR_WHITE);

	CELL_BACKGROUND_WHITE = display.getSystemColor(SWT.COLOR_WHITE);
	CELL_BORDER_EMPHASIZED = display.getSystemColor(SWT.COLOR_LIST_SELECTION);
	CELL_BACKGROUND_LIGHT = new Color(display, new RGB(248, 248, 248));
	CELL_BORDER_LIGHT = new Color(display, saturate(CELL_BORDER_EMPHASIZED.getRGB(), .2f));
	TIME_BAR_COLOR = new Color(display, saturate(CELL_BORDER_EMPHASIZED.getRGB(), .1f));
	FOCUS_RUBBERBAND = new Color(display, lighten(saturate(display.getSystemColor(SWT.COLOR_TITLE_BACKGROUND).getRGB(), .85f), -.333f));

	setBackground(CELL_BACKGROUND_LIGHT);
}
 
Example 2
Source File: SWTUtil.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Creates the tab folder for displaying the composite fragments
 * 
 * @param parent
 */
public static CTabFolder createTabFolder(Composite parent)
{
	Display display = getStandardDisplay();
	Color c1 = display.getSystemColor(SWT.COLOR_TITLE_BACKGROUND), c2 = display
			.getSystemColor(SWT.COLOR_TITLE_BACKGROUND_GRADIENT);
	CTabFolder tabs = new CTabFolder(parent, SWT.NO_REDRAW_RESIZE | SWT.NO_TRIM | SWT.FLAT);
	GridData gd = new GridData(GridData.FILL_BOTH);
	gd.horizontalSpan = 2;
	tabs.setSelectionBackground(new Color[] { c1, c2 }, new int[] { 100 }, true);
	tabs.setSelectionForeground(getStandardDisplay().getSystemColor(SWT.COLOR_TITLE_FOREGROUND));
	tabs.setSimple(PlatformUI.getPreferenceStore().getBoolean(
			IWorkbenchPreferenceConstants.SHOW_TRADITIONAL_STYLE_TABS));
	tabs.setLayoutData(gd);
	tabs.setBorderVisible(true);
	tabs.setFont(parent.getFont());
	return tabs;
}
 
Example 3
Source File: ImageLabel.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Paint the Label's border.
 */
private void paintBorder( GC gc, Rectangle r )
{
	Display disp = getDisplay( );

	Color c1 = null;
	Color c2 = null;

	int style = getStyle( );
	if ( ( style & SWT.SHADOW_IN ) != 0 )
	{
		c1 = disp.getSystemColor( SWT.COLOR_WIDGET_NORMAL_SHADOW );
		c2 = disp.getSystemColor( SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW );
	}
	if ( ( style & SWT.SHADOW_OUT ) != 0 )
	{
		c1 = disp.getSystemColor( SWT.COLOR_WIDGET_LIGHT_SHADOW );
		c2 = disp.getSystemColor( SWT.COLOR_WIDGET_NORMAL_SHADOW );
	}

	if ( c1 != null && c2 != null )
	{
		gc.setLineWidth( 1 );
		drawBevelRect( gc, r.x, r.y, r.width - 1, r.height - 1, c1, c2 );
	}
}
 
Example 4
Source File: ComponentStatusLabel.java    From arx with Apache License 2.0 6 votes vote down vote up
/**
 * Drawing method
 *
 * @param gc
 * @param r
 */
private void paintBorder(GC gc, Rectangle r) {
    Display disp = getDisplay();

    Color c1 = null;
    Color c2 = null;

    int style = getStyle();
    if ((style & SWT.SHADOW_IN) != 0) {
        c1 = disp.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW);
        c2 = disp.getSystemColor(SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW);
    }
    if ((style & SWT.SHADOW_OUT) != 0) {
        c1 = disp.getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW);
        c2 = disp.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW);
    }

    if (c1 != null && c2 != null) {
        gc.setLineWidth(1);
        drawBevelRect(gc, r.x, r.y, r.width - 1, r.height - 1, c1, c2);
    }
}
 
Example 5
Source File: RenameInformationPopup.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private void createContent(Composite parent) {
	Display display= parent.getDisplay();
	Color foreground= display.getSystemColor(SWT.COLOR_INFO_FOREGROUND);
	Color background= display.getSystemColor(SWT.COLOR_INFO_BACKGROUND);
	addMoveSupport(fPopup, parent);

	StyledText hint= new StyledText(fPopup, SWT.READ_ONLY | SWT.SINGLE);
	String enterKeyName= getEnterBinding();
	String hintTemplate= ReorgMessages.RenameInformationPopup_EnterNewName;
	hint.setText(Messages.format(hintTemplate, enterKeyName));
	hint.setForeground(foreground);
	hint.setStyleRange(new StyleRange(hintTemplate.indexOf("{0}"), enterKeyName.length(), null, null, SWT.BOLD)); //$NON-NLS-1$
	hint.setEnabled(false); // text must not be selectable
	addMoveSupport(fPopup, hint);

	addViewMenu(parent);

	recursiveSetBackgroundColor(parent, background);

}
 
Example 6
Source File: LiveSashForm.java    From http4e with Apache License 2.0 5 votes vote down vote up
private void drawBorderAround(Control c, GC gc)
{
  int sh = getChildBorder(c);
  if(sh == SWT.SHADOW_NONE) return;

  Display disp = getDisplay();
  Color shadow = disp.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW);
  Color highlight = disp.getSystemColor(SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW);
  if(shadow == null || highlight == null) return;
  Rectangle r = c.getBounds();

  switch(sh)
  {
    case SWT.SHADOW_IN:
      drawBevelRect(gc, r.x-1, r.y-1, r.width+1, r.height+1, shadow, highlight);
      break;

    case SWT.SHADOW_OUT:
      drawBevelRect(gc, r.x-1, r.y-1, r.width+1, r.height+1, highlight, shadow);
      break;

    case SWT.SHADOW_ETCHED_IN:
      drawBevelRect(gc, r.x-1, r.y-1, r.width+1, r.height+1, highlight, shadow);
      drawBevelRect(gc, r.x-2, r.y-2, r.width+3, r.height+3, shadow, highlight);
      break;

    case SWT.SHADOW_ETCHED_OUT:
      drawBevelRect(gc, r.x-1, r.y-1, r.width+1, r.height+1, shadow, highlight);
      drawBevelRect(gc, r.x-2, r.y-2, r.width+3, r.height+3, highlight, shadow);
      break;
  }
}
 
Example 7
Source File: CPVariableElementLabelProvider.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public Color getBackground(Object element) {
	if (isUnmodifiable(element)) {
		Display display= Display.getCurrent();
		return display.getSystemColor(SWT.COLOR_INFO_BACKGROUND);
	}
	return null;
}
 
Example 8
Source File: CFNode.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public Color getBackgroundColor() {
	Color col = null;
	if (isDeadCode) {
		Display displ = Display.getCurrent();
		col = displ.getSystemColor(SWT.COLOR_GRAY);
	} else {
		col = super.getBackgroundColor();
	}
	return col;
}
 
Example 9
Source File: CFEdge.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
/** Sets the color of the {@link GC} depending on the edge type. */
void setColor(GC gc) {
	Display displ = Display.getCurrent();
	Color color = GraphUtils.getColor(50, 50, 50);

	if (isDead || cfTypes.contains(ControlFlowType.DeadCode)) {
		color = displ.getSystemColor(SWT.COLOR_GRAY);
	} else {
		for (ControlFlowType cfType : cfTypes) {
			switch (cfType) {
			case LoopEnter:
			case LoopReenter:
			case LoopInfinite:
			case Break:
			case Continue:
			case Return:
				color = displ.getSystemColor(SWT.COLOR_BLUE);
				break;
			case Throw:
				color = displ.getSystemColor(SWT.COLOR_RED);
				break;
			default:
				break;
			}
		}
	}
	gc.setForeground(color);
}
 
Example 10
Source File: CPVariableElementLabelProvider.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public Color getForeground(Object element) {
	if (isUnmodifiable(element)) {
		Display display= Display.getCurrent();
		return display.getSystemColor(SWT.COLOR_INFO_FOREGROUND);
	}
	return null;
}
 
Example 11
Source File: SourceView.java    From lapse-plus with GNU General Public License v3.0 5 votes vote down vote up
public Color getForeground(Object element) {
	Display display = Display.getCurrent();
	ViewMatch match = (ViewMatch) element;
	
	return match.isSource() ?
			display.getSystemColor(SWT.COLOR_LIST_FOREGROUND) :
			display.getSystemColor(SWT.COLOR_GRAY);
}
 
Example 12
Source File: SinkView.java    From lapse-plus with GNU General Public License v3.0 5 votes vote down vote up
public Color getForeground(Object element) {
    Display display = Display.getCurrent();
    ViewMatch match = (ViewMatch) element;
    if (match.isSource() && !match.isSafe()) {
        return display.getSystemColor(SWT.COLOR_LIST_FOREGROUND);
    } else {
        return display.getSystemColor(SWT.COLOR_GRAY);
    }
}
 
Example 13
Source File: BrowseKillRingHandler.java    From e4macs with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Create or update console view of the kill ring
 */
private void updateBrowseRing() {
	final KillRing kr = KillRing.getInstance();
	Display display = PlatformUI.getWorkbench().getDisplay();
	final Color onColor = new Color(display,highlightColor);
	final Color offColor = display.getSystemColor(OFF_COLOR);

	cleanup();
	if (!kr.isEmpty()) {
		final EmacsPlusConsole console = EmacsPlusConsole.getInstance();
		final BrowseKillRingHandler handler = this;
		console.clear();
		console.activate();
		console.setName(KR_CONSOLE);
		offsetHash = new HashMap<Integer,KilledText>(); 
		// run asynchronously to ensure widget has been set up
		EmacsPlusUtils.asyncUiRun(new Runnable() { 
			public void run() {
				int count = kr.length();
				ringEntries = new KilledText[count];
				boolean flip = false;
				int plen=0,len = 0;
				Color color = offColor;
				console.addBackground(handler);
				console.setKeyHandler(handler);
				IRingBufferElement<String> e = kr.yankElement();
				for (int i = 0; i < count; i++) {
					String text = e.get();
					int tlen = text.length();
					KilledText kt = new KilledText(text,color);
					offsetHash.put(len,kt);
					ringEntries[i]=kt;
					kt.begin = plen;
					kt.end = plen + tlen;
					plen = kt.end + 1;
					console.print(text + (i == count-1 ? EMPTY_STR : CR));
					if (flip = !flip) {
						color = onColor;
					} else {
						color = offColor;
					}
					e = kr.rotateYankPos();
					len += 1 + tlen;
				}
				console.setFocus(false);
			}});
	}
}
 
Example 14
Source File: PasswordRevealerSnippet.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
public static void main(final String[] args) {
	final Display display = new Display();
	final Shell shell = new Shell(display);
	shell.setLayout(new GridLayout(1, false));
	final Color white = display.getSystemColor(SWT.COLOR_WHITE);
	shell.setBackground(white);
	shell.setText("Password Revealer Snippet");

	final Image image = new Image(display, PasswordRevealerSnippet.class.getResourceAsStream("eye.png"));
	final Image clickImage = new Image(display, PasswordRevealerSnippet.class.getResourceAsStream("eye-slash.png"));
	shell.addListener(SWT.Dispose, e -> {
		image.dispose();
		clickImage.dispose();
	});

	final Label lbl1 = new Label(shell, SWT.NONE);
	lbl1.setText("Password Revealer:");
	final GridData gdLabel1 = new GridData(GridData.BEGINNING, GridData.CENTER, true, false);
	gdLabel1.widthHint = 150;
	lbl1.setBackground(white);
	lbl1.setLayoutData(gdLabel1);

	final PasswordRevealer revealer = new PasswordRevealer(shell, SWT.NONE);
	final GridData gd = new GridData(GridData.FILL, GridData.CENTER, true, false);
	gd.widthHint = 250;
	revealer.setLayoutData(gd);
	revealer.setBackground(white);

	new Label(shell, SWT.NONE);

	final Label lbl2 = new Label(shell, SWT.NONE);
	lbl2.setText("Password Revealer with other icon:");
	final GridData gdLabel2 = new GridData(GridData.FILL, GridData.CENTER, true, false);
	gdLabel2.widthHint = 150;
	lbl2.setBackground(white);
	lbl2.setLayoutData(gdLabel2);

	final PasswordRevealer revealer2 = new PasswordRevealer(shell, SWT.NONE);
	final GridData gd2 = new GridData(GridData.FILL, GridData.CENTER, true, false);
	gd2.widthHint = 250;
	revealer2.setLayoutData(gd2);
	revealer2.setBackground(white);
	revealer2.setImage(image);
	revealer2.setClickImage(clickImage);

	shell.pack();
	shell.open();

	while (!shell.isDisposed()) {
		if (!display.readAndDispatch()) {
			display.sleep();
		}
	}
	display.dispose();
}
 
Example 15
Source File: InformationControl.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
protected Color getForeground()
{
	Display display= fShell.getDisplay();
	return display.getSystemColor(SWT.COLOR_INFO_FOREGROUND);
}
 
Example 16
Source File: DayEditorCalendarableItemControl.java    From nebula with Eclipse Public License 2.0 3 votes vote down vote up
/**
 * Constructs a new instance of this class given its parent
 * and a style value describing its behavior and appearance.
 * <p>
 * The style value is either one of the style constants defined in
 * class <code>SWT</code> which is applicable to instances of this
 * class, or must be built by <em>bitwise OR</em>'ing together 
 * (that is, using the <code>int</code> "|" operator) two or more
 * of those <code>SWT</code> style constants. The class description
 * lists the style constants that are applicable to the class.
 * Style bits are also inherited from superclasses.
 * </p>
 *
 * @param parent a composite control which will be the parent of the new instance (cannot be null)
 * @param style the style of control to construct
 *
 * @exception IllegalArgumentException <ul>
 *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
 * </ul>
 * @exception SWTException <ul>
 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
 *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
 * </ul>
 *
 * @see Widget#checkSubclass
 * @see Widget#getStyle
 */
public DayEditorCalendarableItemControl(Composite parent, int style) {
	super(parent, style);
	Display display = parent.getDisplay();

	BACKGROUND_COLOR = new Color(display, lighten(saturate(display.getSystemColor(SWT.COLOR_TITLE_BACKGROUND_GRADIENT).getRGB(), .08f), .3f));
	BORDER_COLOR = new Color(display, lighten(saturate(display.getSystemColor(SWT.COLOR_TITLE_BACKGROUND).getRGB(), .18f), .1f));
	SELECTED_BACKGROUND_COLOR = display.getSystemColor(SWT.COLOR_WHITE);
	SELECTED_BORDER_COLOR = new Color(display, saturate(BORDER_COLOR.getRGB(), .4f));

	initialize();
}
 
Example 17
Source File: SWTResourceManager.java    From WebpifyYourAndroidApp with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the system {@link Color} matching the specific ID.
 * 
 * @param systemColorID
 *            the ID value for the color
 * @return the system {@link Color} matching the specific ID
 */
public static Color getColor(int systemColorID) {
	Display display = Display.getCurrent();
	return display.getSystemColor(systemColorID);
}
 
Example 18
Source File: ManagedColor.java    From hop with Apache License 2.0 2 votes vote down vote up
/**
 * Create a managed color by specifying the color (SWT.COLOR_*)
 *
 * @param display
 * @param color
 */
public ManagedColor( Display display, int color ) {
  this.color = display.getSystemColor( color );
  this.systemColor = false;
}
 
Example 19
Source File: SWTResourceManager.java    From developer-studio with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the system {@link Color} matching the specific ID.
 * 
 * @param systemColorID
 *            the ID value for the color
 * @return the system {@link Color} matching the specific ID
 */
public static Color getColor(int systemColorID) {
	Display display = Display.getCurrent();
	return display.getSystemColor(systemColorID);
}
 
Example 20
Source File: SWTResourceManager.java    From Rel with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the system {@link Color} matching the specific ID.
 * 
 * @param systemColorID
 *            the ID value for the color
 * @return the system {@link Color} matching the specific ID
 */
public static Color getColor(int systemColorID) {
	Display display = Display.getCurrent();
	return display.getSystemColor(systemColorID);
}