1 /*****************************************************************************
2 * Copyright (c) 2007 Intel Corporation, 2009, 2012 Ericsson.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
9 * Intel Corporation - Initial API and implementation
10 * Ruslan A. Scherbakov, Intel - Initial API and implementation
11 * Alvaro Sanchez-Leon - Updated for TMF
12 * Patrick Tasse - Refactoring
14 *****************************************************************************/
16 package org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.timegraph
.widgets
;
18 import org
.eclipse
.swt
.SWT
;
19 import org
.eclipse
.swt
.events
.PaintEvent
;
20 import org
.eclipse
.swt
.events
.PaintListener
;
21 import org
.eclipse
.swt
.graphics
.Color
;
22 import org
.eclipse
.swt
.graphics
.Rectangle
;
23 import org
.eclipse
.swt
.widgets
.Canvas
;
24 import org
.eclipse
.swt
.widgets
.Composite
;
26 public abstract class TimeGraphBaseControl
extends Canvas
implements PaintListener
{
28 static public final int MARGIN
= 4;
29 static public final int EXPAND_SIZE
= 9; // the [+] or [-] control size
30 static public final int RIGHT_MARGIN
= 1; // 1 pixels less to make sure end time is visible
31 static public final int SMALL_ICON_SIZE
= 16;
33 protected TimeGraphColorScheme _colors
;
34 protected int _fontHeight
= 0;
36 public TimeGraphBaseControl(Composite parent
, TimeGraphColorScheme colors
) {
37 this(parent
, colors
, SWT
.NO_BACKGROUND
| SWT
.NO_FOCUS
);
40 public TimeGraphBaseControl(Composite parent
, TimeGraphColorScheme colors
, int style
) {
43 addPaintListener(this);
47 public void dispose() {
52 public void paintControl(PaintEvent e
) {
55 _fontHeight
= e
.gc
.getFontMetrics().getHeight();
56 Rectangle bound
= getClientArea();
57 if (!bound
.isEmpty()) {
58 Color colBackup
= e
.gc
.getBackground();
60 e
.gc
.setBackground(colBackup
);
64 public int getFontHeight() {
68 abstract void paint(Rectangle bound
, PaintEvent e
);