core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/editor/RoundedCornerComposite.java
author dadubrow
Thu, 16 Sep 2010 17:29:37 -0500
changeset 2035 42a3ddebe583
parent 1831 3319dd953212
permissions -rw-r--r--
Some portal tweaks
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1609
085da1889c59 Portal initial commit
dadubrow
parents:
diff changeset
     1
/*
085da1889c59 Portal initial commit
dadubrow
parents:
diff changeset
     2
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
085da1889c59 Portal initial commit
dadubrow
parents:
diff changeset
     3
* All rights reserved.
085da1889c59 Portal initial commit
dadubrow
parents:
diff changeset
     4
* This component and the accompanying materials are made available
085da1889c59 Portal initial commit
dadubrow
parents:
diff changeset
     5
* under the terms of the License "Eclipse Public License v1.0"
085da1889c59 Portal initial commit
dadubrow
parents:
diff changeset
     6
* which accompanies this distribution, and is available
085da1889c59 Portal initial commit
dadubrow
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
085da1889c59 Portal initial commit
dadubrow
parents:
diff changeset
     8
*
085da1889c59 Portal initial commit
dadubrow
parents:
diff changeset
     9
* Initial Contributors:
085da1889c59 Portal initial commit
dadubrow
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
085da1889c59 Portal initial commit
dadubrow
parents:
diff changeset
    11
*
085da1889c59 Portal initial commit
dadubrow
parents:
diff changeset
    12
* Contributors:
085da1889c59 Portal initial commit
dadubrow
parents:
diff changeset
    13
*
085da1889c59 Portal initial commit
dadubrow
parents:
diff changeset
    14
* Description: 
085da1889c59 Portal initial commit
dadubrow
parents:
diff changeset
    15
*
085da1889c59 Portal initial commit
dadubrow
parents:
diff changeset
    16
*/
085da1889c59 Portal initial commit
dadubrow
parents:
diff changeset
    17
package com.nokia.carbide.internal.discovery.ui.editor;
085da1889c59 Portal initial commit
dadubrow
parents:
diff changeset
    18
085da1889c59 Portal initial commit
dadubrow
parents:
diff changeset
    19
import org.eclipse.swt.graphics.Color;
085da1889c59 Portal initial commit
dadubrow
parents:
diff changeset
    20
import org.eclipse.swt.graphics.GC;
085da1889c59 Portal initial commit
dadubrow
parents:
diff changeset
    21
import org.eclipse.swt.widgets.Composite;
085da1889c59 Portal initial commit
dadubrow
parents:
diff changeset
    22
085da1889c59 Portal initial commit
dadubrow
parents:
diff changeset
    23
class RoundedCornerComposite extends SharedBackgroundComposite {
085da1889c59 Portal initial commit
dadubrow
parents:
diff changeset
    24
1831
3319dd953212 UI tweaks
dadubrow
parents: 1810
diff changeset
    25
	private static final int ARC = 9;
1609
085da1889c59 Portal initial commit
dadubrow
parents:
diff changeset
    26
	private final Color background;
085da1889c59 Portal initial commit
dadubrow
parents:
diff changeset
    27
	private final Color outline;
085da1889c59 Portal initial commit
dadubrow
parents:
diff changeset
    28
085da1889c59 Portal initial commit
dadubrow
parents:
diff changeset
    29
	public RoundedCornerComposite(Composite parent, Composite backgroundParent, Color outline, Color background) {
085da1889c59 Portal initial commit
dadubrow
parents:
diff changeset
    30
		super(parent, backgroundParent);
085da1889c59 Portal initial commit
dadubrow
parents:
diff changeset
    31
		this.background = background;
085da1889c59 Portal initial commit
dadubrow
parents:
diff changeset
    32
		this.outline = outline;
085da1889c59 Portal initial commit
dadubrow
parents:
diff changeset
    33
	}
085da1889c59 Portal initial commit
dadubrow
parents:
diff changeset
    34
085da1889c59 Portal initial commit
dadubrow
parents:
diff changeset
    35
	@Override
085da1889c59 Portal initial commit
dadubrow
parents:
diff changeset
    36
	public void drawBackground(GC gc, int x, int y, int width, int height) {
085da1889c59 Portal initial commit
dadubrow
parents:
diff changeset
    37
		super.drawBackground(gc, x, y, width, height);
085da1889c59 Portal initial commit
dadubrow
parents:
diff changeset
    38
		if (background != null) {
085da1889c59 Portal initial commit
dadubrow
parents:
diff changeset
    39
			gc.setBackground(background);
1831
3319dd953212 UI tweaks
dadubrow
parents: 1810
diff changeset
    40
			gc.fillRoundRectangle(0, 0, width, height, ARC, ARC);
1609
085da1889c59 Portal initial commit
dadubrow
parents:
diff changeset
    41
		}
085da1889c59 Portal initial commit
dadubrow
parents:
diff changeset
    42
		if (outline != null) {
085da1889c59 Portal initial commit
dadubrow
parents:
diff changeset
    43
			gc.setForeground(outline);
1831
3319dd953212 UI tweaks
dadubrow
parents: 1810
diff changeset
    44
			gc.drawRoundRectangle(0, 0, width - 1, height - 1, ARC, ARC);
1609
085da1889c59 Portal initial commit
dadubrow
parents:
diff changeset
    45
		}
085da1889c59 Portal initial commit
dadubrow
parents:
diff changeset
    46
	}
085da1889c59 Portal initial commit
dadubrow
parents:
diff changeset
    47
}