|
Lines 28-33
Link Here
|
| 28 |
/** |
28 |
/** |
| 29 |
* A Canvas that contains {@link Figure Figures}. |
29 |
* A Canvas that contains {@link Figure Figures}. |
| 30 |
* |
30 |
* |
|
|
31 |
* <dl> |
| 32 |
* <dt><b>Required Styles (when using certain constructors):</b></dt> |
| 33 |
* <dd>V_SCROLL, H_SCROLL, NO_REDRAW_RESIZE</dd> |
| 34 |
* <dt><b>Optional Styles:</b></dt> |
| 35 |
* <dd>DOUBLE_BUFFERED, RIGHT_TO_LEFT, LEFT_TO_RIGHT, NO_BACKGROUND, BORDER</dd> |
| 36 |
* </dl> |
| 31 |
* <p> |
37 |
* <p> |
| 32 |
* Note: Only one of the styles RIGHT_TO_LEFT, LEFT_TO_RIGHT may be specified. |
38 |
* Note: Only one of the styles RIGHT_TO_LEFT, LEFT_TO_RIGHT may be specified. |
| 33 |
* </p> |
39 |
* </p> |
|
Lines 36-41
Link Here
|
| 36 |
extends Canvas |
42 |
extends Canvas |
| 37 |
{ |
43 |
{ |
| 38 |
|
44 |
|
|
|
45 |
private static final int ACCEPTED_STYLES = |
| 46 |
SWT.RIGHT_TO_LEFT | SWT.LEFT_TO_RIGHT |
| 47 |
| SWT.V_SCROLL | SWT.H_SCROLL |
| 48 |
| SWT.NO_BACKGROUND |
| 49 |
| SWT.NO_REDRAW_RESIZE |
| 50 |
| SWT.DOUBLE_BUFFERED |
| 51 |
| SWT.BORDER; |
| 52 |
|
| 53 |
/** |
| 54 |
* The default styles are mixed in when certain constructors are used. This |
| 55 |
* constant is a bitwise OR of the following SWT style constants: |
| 56 |
* <UL> |
| 57 |
* <LI>{@link SWT#NO_REDRAW_RESIZE}</LI> |
| 58 |
* <LI>{@link SWT#NO_BACKGROUND}</LI> |
| 59 |
* <LI>{@link SWT#V_SCROLL}</LI> |
| 60 |
* <LI>{@link SWT#H_SCROLL}</LI> |
| 61 |
* </UL> |
| 62 |
*/ |
| 63 |
static final int DEFAULT_STYLES = |
| 64 |
SWT.NO_REDRAW_RESIZE |
| 65 |
| SWT.NO_BACKGROUND |
| 66 |
| SWT.V_SCROLL |
| 67 |
| SWT.H_SCROLL; |
| 68 |
|
| 69 |
private static final int REQUIRED_STYLES = |
| 70 |
SWT.NO_REDRAW_RESIZE |
| 71 |
| SWT.V_SCROLL |
| 72 |
| SWT.H_SCROLL; |
| 73 |
|
| 39 |
/** Never show scrollbar */ |
74 |
/** Never show scrollbar */ |
| 40 |
public static int NEVER = 0; |
75 |
public static int NEVER = 0; |
| 41 |
/** Automatically show scrollbar when needed */ |
76 |
/** Automatically show scrollbar when needed */ |
|
Lines 81-87
Link Here
|
| 81 |
private final LightweightSystem lws; |
116 |
private final LightweightSystem lws; |
| 82 |
|
117 |
|
| 83 |
/** |
118 |
/** |
| 84 |
* Creates a new FigureCanvas with the given parent. |
119 |
* Creates a new FigureCanvas with the given parent and the {@link #DEFAULT_STYLES}. |
| 85 |
* |
120 |
* |
| 86 |
* @param parent the parent |
121 |
* @param parent the parent |
| 87 |
*/ |
122 |
*/ |
|
Lines 90-98
Link Here
|
| 90 |
} |
125 |
} |
| 91 |
|
126 |
|
| 92 |
/** |
127 |
/** |
| 93 |
* Constructor |
128 |
* Constructor which applies the default styles plus any optional styles indicated. |
| 94 |
* @param parent the parent composite |
129 |
* @param parent the parent composite |
| 95 |
* @param style look at class javadoc for valid styles |
130 |
* @param style see the class javadoc for optional styles |
| 96 |
* @since 3.1 |
131 |
* @since 3.1 |
| 97 |
*/ |
132 |
*/ |
| 98 |
public FigureCanvas(Composite parent, int style) { |
133 |
public FigureCanvas(Composite parent, int style) { |
|
Lines 100-106
Link Here
|
| 100 |
} |
135 |
} |
| 101 |
|
136 |
|
| 102 |
/** |
137 |
/** |
| 103 |
* Constructs a new FigureCanvas with the given parent and LightweightSystem. |
138 |
* Constructor which uses the given styles verbatim. Certain styles must be used |
|
|
139 |
* with this class. Refer to the class javadoc for more details. |
| 140 |
* @param style see the class javadoc for <b>required</b> and optional styles |
| 141 |
* @param parent the parent composite |
| 142 |
* @since 3.4 |
| 143 |
*/ |
| 144 |
public FigureCanvas(int style, Composite parent) { |
| 145 |
this(style, parent, new LightweightSystem()); |
| 146 |
} |
| 147 |
|
| 148 |
/** |
| 149 |
* Constructs a new FigureCanvas with the given parent and LightweightSystem, using |
| 150 |
* the {@link #DEFAULT_STYLES}. |
| 104 |
* @param parent the parent |
151 |
* @param parent the parent |
| 105 |
* @param lws the LightweightSystem |
152 |
* @param lws the LightweightSystem |
| 106 |
*/ |
153 |
*/ |
|
Lines 109-123
Link Here
|
| 109 |
} |
156 |
} |
| 110 |
|
157 |
|
| 111 |
/** |
158 |
/** |
| 112 |
* Constructor |
159 |
* Constructor taking a lightweight system and SWT style, which is used verbatim. |
|
|
160 |
* Certain styles must be used with this class. Refer to the class javadoc for |
| 161 |
* more details. |
| 162 |
* @param style see the class javadoc for <b>required</b> and optional styles |
| 113 |
* @param parent the parent composite |
163 |
* @param parent the parent composite |
| 114 |
* @param style look at class javadoc for valid styles |
164 |
* @param lws the LightweightSystem |
| 115 |
* @param lws the lightweight system |
165 |
* @since 3.4 |
| 116 |
* @since 3.1 |
|
|
| 117 |
*/ |
166 |
*/ |
| 118 |
public FigureCanvas(Composite parent, int style, LightweightSystem lws) { |
167 |
public FigureCanvas(int style, Composite parent, LightweightSystem lws) { |
| 119 |
super(parent, checkStyle(style | SWT.NO_REDRAW_RESIZE | SWT.NO_BACKGROUND |
168 |
super(parent, checkStyle(style)); |
| 120 |
| SWT.V_SCROLL | SWT.H_SCROLL)); |
|
|
| 121 |
getHorizontalBar().setVisible(false); |
169 |
getHorizontalBar().setVisible(false); |
| 122 |
getVerticalBar().setVisible(false); |
170 |
getVerticalBar().setVisible(false); |
| 123 |
this.lws = lws; |
171 |
this.lws = lws; |
|
Lines 125-134
Link Here
|
| 125 |
hook(); |
173 |
hook(); |
| 126 |
} |
174 |
} |
| 127 |
|
175 |
|
|
|
176 |
/** |
| 177 |
* Constructor |
| 178 |
* @param parent the parent composite |
| 179 |
* @param style look at class javadoc for valid styles |
| 180 |
* @param lws the lightweight system |
| 181 |
* @since 3.1 |
| 182 |
*/ |
| 183 |
public FigureCanvas(Composite parent, int style, LightweightSystem lws) { |
| 184 |
this(style | DEFAULT_STYLES, parent, lws); |
| 185 |
} |
| 186 |
|
| 128 |
private static int checkStyle(int style) { |
187 |
private static int checkStyle(int style) { |
| 129 |
int validStyles = SWT.RIGHT_TO_LEFT | SWT.LEFT_TO_RIGHT | SWT.V_SCROLL | SWT.H_SCROLL |
188 |
if ((style & REQUIRED_STYLES) != REQUIRED_STYLES) |
| 130 |
| SWT.NO_BACKGROUND | SWT.NO_REDRAW_RESIZE | SWT.DOUBLE_BUFFERED | SWT.BORDER; |
189 |
throw new IllegalArgumentException("Required style missing on FigureCanvas"); //$NON-NLS-1$ |
| 131 |
if ((style & ~validStyles) != 0) |
190 |
if ((style & ~ACCEPTED_STYLES) != 0) |
| 132 |
throw new IllegalArgumentException("Invalid style being set on FigureCanvas"); //$NON-NLS-1$ |
191 |
throw new IllegalArgumentException("Invalid style being set on FigureCanvas"); //$NON-NLS-1$ |
| 133 |
return style; |
192 |
return style; |
| 134 |
} |
193 |
} |