Skip to main content
summaryrefslogtreecommitdiffstats
blob: 5fcef0d92d8ee6b1c9f286df0f98ab750f9fcd44 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*******************************************************************************
 * Copyright (c) 2012 Tilera Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     William R. Swanson (Tilera Corporation)
 *******************************************************************************/

package org.eclipse.cdt.visualizer.ui.canvas;

import org.eclipse.cdt.visualizer.ui.Visualizer;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;


// ---------------------------------------------------------------------------
// GraphicCanvasVisualizer
// ---------------------------------------------------------------------------

/**
 * Viewer canvas -- base class for canvas that displays a collection
 * of persistent, repositionable graphic objects.
 * 
 * Note: painting is done in order objects were added,
 * so objects added last are drawn "on top" of others.
 * Use raise/lower methods to change the object z-ordering, if needed.
 */
public class GraphicCanvasVisualizer extends Visualizer
{
	// --- members ---


	// --- constructors/destructors ---
	
	/** Constructor. */
	public GraphicCanvasVisualizer()
	{
		// TODO: internationalize these strings.
		super("canvas", "Canvas Visualizer", "Displays graphic representation of selection.");
	}
	
	/** Dispose method. */
	public void dispose() {
		super.dispose();
	}

	
	// --- control management ---
	
	/** Creates and returns visualizer control on specified parent. */
	public Control createControl(Composite parent)
	{
		if (m_control == null) {
			GraphicCanvas canvas = createCanvas(parent);
			canvas.setMenu(parent.getMenu());
			setControl(canvas);
			initializeCanvas(canvas);
		}
		return getControl();
	}
	
	/** Invoked when visualizer control should be disposed. */
	public void disposeControl()
	{
		if (m_control != null) {
			disposeCanvas();
			m_control.dispose();
			setControl(null);
		}
	}
	
	
	// --- canvas management ---
	
	/** Creates and returns visualizer canvas control. */
	public GraphicCanvas createCanvas(Composite parent)
	{
		return new GraphicCanvas(parent);
	}

	/** Invoked when canvas control should be disposed. */
	public void disposeCanvas()
	{
		
	}
	
	/** Invoked after visualizer control creation,
	 *  to allow derived classes to do any initialization of canvas.
	 */
	protected void initializeCanvas(GraphicCanvas canvas)
	{
	}
	
	/** Gets downcast reference to canvas control. */
	public GraphicCanvas getCanvas()
	{
		return (GraphicCanvas) getControl();
	}
	

	// --- menu/toolbar management ---

	/** Invoked when visualizer is selected, to populate the toolbar. */
	public void populateToolBar(IToolBarManager toolBarManager)
	{}

	/** Invoked when visualizer is selected, to populate the toolbar's menu. */
	public void populateMenu(IMenuManager menuManager)
	{}

	
	// --- context menu handling ---
	
	/** Invoked when visualizer view's context menu is invoked, to populate it. */
	public void populateContextMenu(IMenuManager menuManager)
	{}
	
}

Back to the top