ctf: Handle traces with unknown event attributes
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / widgets / timegraph / widgets / TimeGraphBaseControl.java
CommitLineData
fb5cad3d
PT
1/*****************************************************************************\r
2 * Copyright (c) 2007 Intel Corporation, 2009, 2012 Ericsson.\r
3 * All rights reserved. This program and the accompanying materials\r
4 * are made available under the terms of the Eclipse Public License v1.0\r
5 * which accompanies this distribution, and is available at\r
6 * http://www.eclipse.org/legal/epl-v10.html\r
7 *\r
8 * Contributors:\r
9 * Intel Corporation - Initial API and implementation\r
10 * Ruslan A. Scherbakov, Intel - Initial API and implementation\r
11 * Alvaro Sanchez-Leon - Updated for TMF\r
12 * Patrick Tasse - Refactoring\r
13 *\r
14 *****************************************************************************/\r
15\r
16package org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets;\r
17\r
18import org.eclipse.swt.SWT;\r
19import org.eclipse.swt.events.PaintEvent;\r
20import org.eclipse.swt.events.PaintListener;\r
21import org.eclipse.swt.graphics.Color;\r
22import org.eclipse.swt.graphics.Rectangle;\r
23import org.eclipse.swt.widgets.Canvas;\r
24import org.eclipse.swt.widgets.Composite;\r
25\r
013a5f1c
AM
26/**\r
27 * Base control abstract class for the time graph widget\r
28 *\r
29 * @version 1.0\r
30 * @author Alvaro Sanchez-Leon\r
31 * @author Patrick Tasse\r
32 */\r
fb5cad3d
PT
33public abstract class TimeGraphBaseControl extends Canvas implements PaintListener {\r
34\r
3934297e 35 /** Default left margin size */\r
fb5cad3d 36 static public final int MARGIN = 4;\r
3934297e
AM
37\r
38 /** Default expanded size */\r
fb5cad3d 39 static public final int EXPAND_SIZE = 9; // the [+] or [-] control size\r
3934297e
AM
40\r
41 /** Default size of the right margin */\r
b83af2c3 42 static public final int RIGHT_MARGIN = 1; // 1 pixels less to make sure end time is visible\r
3934297e
AM
43\r
44 /** Default size for small icons */\r
fb5cad3d
PT
45 static public final int SMALL_ICON_SIZE = 16;\r
46\r
47 protected TimeGraphColorScheme _colors;\r
48 protected int _fontHeight = 0;\r
49\r
3934297e
AM
50 /**\r
51 * Basic constructor. Uses a default style value\r
52 *\r
53 * @param parent\r
54 * The parent composite object\r
55 * @param colors\r
56 * The color scheme to use\r
57 */\r
fb5cad3d
PT
58 public TimeGraphBaseControl(Composite parent, TimeGraphColorScheme colors) {\r
59 this(parent, colors, SWT.NO_BACKGROUND | SWT.NO_FOCUS);\r
60 }\r
61\r
3934297e
AM
62 /**\r
63 * Standard constructor\r
64 *\r
65 * @param parent\r
66 * The parent composite object\r
67 * @param colors\r
68 * The color scheme to use\r
69 * @param style\r
70 * The index of the style to use\r
71 */\r
fb5cad3d
PT
72 public TimeGraphBaseControl(Composite parent, TimeGraphColorScheme colors, int style) {\r
73 super(parent, style);\r
74 _colors = colors;\r
75 addPaintListener(this);\r
76 }\r
77\r
78 @Override\r
79 public void dispose() {\r
80 super.dispose();\r
81 }\r
82\r
83 @Override\r
84 public void paintControl(PaintEvent e) {\r
013a5f1c 85 if (e.widget != this) {\r
fb5cad3d 86 return;\r
013a5f1c 87 }\r
fb5cad3d
PT
88 _fontHeight = e.gc.getFontMetrics().getHeight();\r
89 Rectangle bound = getClientArea();\r
90 if (!bound.isEmpty()) {\r
91 Color colBackup = e.gc.getBackground();\r
92 paint(bound, e);\r
93 e.gc.setBackground(colBackup);\r
94 }\r
95 }\r
96\r
3934297e
AM
97 /**\r
98 * Retrieve the current font's height\r
99 *\r
100 * @return The height\r
101 */\r
fb5cad3d
PT
102 public int getFontHeight() {\r
103 return _fontHeight;\r
104 }\r
105\r
106 abstract void paint(Rectangle bound, PaintEvent e);\r
107}\r
This page took 0.056949 seconds and 5 git commands to generate.