1
|
/*******************************************************************************
|
2
|
* Copyright (c) 2010 IBM Corporation and others.
|
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
|
7
|
*
|
8
|
* Contributors:
|
9
|
* Research Group Software Construction,
|
10
|
* RWTH Aachen University, Germany - initial API and implementation
|
11
|
*/
|
12
|
package org.eclipse.draw2d;
|
13
|
|
14
|
import java.beans.PropertyChangeEvent;
|
15
|
import java.beans.PropertyChangeListener;
|
16
|
|
17
|
/**
|
18
|
* A {@link ScrollPane} with transparent {@link ScrollBar}s.
|
19
|
*
|
20
|
* @author Alexander Nyssen
|
21
|
* @author Philip Ritzkopf
|
22
|
*
|
23
|
* @since 3.6
|
24
|
*/
|
25
|
public class PuristicScrollPane extends ScrollPane {
|
26
|
|
27
|
/**
|
28
|
* A {@link ScrollBar} with no thumb and non-opaque buttons.
|
29
|
*
|
30
|
* @author Alexander Nyssen
|
31
|
* @author Philip Ritzkopf
|
32
|
*/
|
33
|
public class PuristicScrollBar extends ScrollBar {
|
34
|
|
35
|
/**
|
36
|
* Instantiates a new transparent scroll bar.
|
37
|
*
|
38
|
* @param isHorizontal
|
39
|
* whether this scroll bar is used as a horizontal one.
|
40
|
*/
|
41
|
public PuristicScrollBar(boolean isHorizontal) {
|
42
|
super();
|
43
|
setHorizontal(isHorizontal);
|
44
|
setOpaque(false);
|
45
|
}
|
46
|
|
47
|
/**
|
48
|
* @see org.eclipse.draw2d.ScrollBar#createDefaultDownButton()
|
49
|
*/
|
50
|
protected Clickable createDefaultDownButton() {
|
51
|
Clickable buttonDown = super.createDefaultDownButton();
|
52
|
buttonDown.setBorder(null);
|
53
|
buttonDown.setOpaque(false);
|
54
|
return buttonDown;
|
55
|
}
|
56
|
|
57
|
/**
|
58
|
* @see org.eclipse.draw2d.ScrollBar#createDefaultThumb()
|
59
|
*/
|
60
|
protected IFigure createDefaultThumb() {
|
61
|
return null;
|
62
|
}
|
63
|
|
64
|
/**
|
65
|
* @see org.eclipse.draw2d.ScrollBar#createDefaultUpButton()
|
66
|
*/
|
67
|
protected Clickable createDefaultUpButton() {
|
68
|
Clickable buttonUp = super.createDefaultUpButton();
|
69
|
buttonUp.setBorder(null);
|
70
|
buttonUp.setOpaque(false);
|
71
|
return buttonUp;
|
72
|
}
|
73
|
|
74
|
/**
|
75
|
* @see org.eclipse.draw2d.ScrollBar#createPageDown()
|
76
|
*/
|
77
|
protected Clickable createPageDown() {
|
78
|
return null;
|
79
|
}
|
80
|
|
81
|
/**
|
82
|
* @see org.eclipse.draw2d.ScrollBar#createPageUp()
|
83
|
*/
|
84
|
protected Clickable createPageUp() {
|
85
|
return null;
|
86
|
}
|
87
|
|
88
|
/**
|
89
|
* @see PropertyChangeListener#propertyChange(java.beans.
|
90
|
* PropertyChangeEvent )
|
91
|
*/
|
92
|
public void propertyChange(PropertyChangeEvent event) {
|
93
|
if (event.getSource() instanceof RangeModel) {
|
94
|
getButtonDown().setVisible(
|
95
|
getValue() != getMaximum() - getExtent());
|
96
|
getButtonUp().setVisible(getValue() != getMinimum());
|
97
|
}
|
98
|
super.propertyChange(event);
|
99
|
}
|
100
|
|
101
|
}
|
102
|
|
103
|
public PuristicScrollPane() {
|
104
|
// layout to ensure, viewport gets complete client area
|
105
|
setLayoutManager(new ScrollPaneLayout() {
|
106
|
public void layout(IFigure parent) {
|
107
|
// scroll panes are layouted normally
|
108
|
super.layout(parent);
|
109
|
// viewport gets complete client area
|
110
|
ScrollPane scrollpane = (ScrollPane) parent;
|
111
|
Viewport viewport = scrollpane.getViewport();
|
112
|
viewport.setBounds(parent.getClientArea());
|
113
|
}
|
114
|
});
|
115
|
}
|
116
|
|
117
|
/**
|
118
|
* @see org.eclipse.draw2d.ScrollPane#createVerticalScrollBar()
|
119
|
*/
|
120
|
protected void createVerticalScrollBar() {
|
121
|
PuristicScrollBar verticalScrollBar = new PuristicScrollBar(false);
|
122
|
setVerticalScrollBar(verticalScrollBar);
|
123
|
}
|
124
|
|
125
|
/**
|
126
|
* @see org.eclipse.draw2d.ScrollPane#createHorizontalScrollBar()
|
127
|
*/
|
128
|
protected void createHorizontalScrollBar() {
|
129
|
PuristicScrollBar horizontalScrollBar = new PuristicScrollBar(true);
|
130
|
setHorizontalScrollBar(horizontalScrollBar);
|
131
|
}
|
132
|
|
133
|
}
|