|
@@ -1,1143 +1,1144 @@ |
1 |
|
- |
// This Source Code is in the Public Domain per: http://unlicense.org |
2 |
|
- |
package org.litesoft.GWT.client.nonpublic; |
3 |
|
- |
|
4 |
|
- |
import org.litesoft.GWT.client.widgets.*; |
5 |
|
- |
import org.litesoft.commonfoundation.typeutils.*; |
6 |
|
- |
import org.litesoft.configuration.*; |
7 |
|
- |
|
8 |
|
- |
import com.google.gwt.user.client.*; |
9 |
|
- |
import com.google.gwt.user.client.ui.*; |
10 |
|
- |
import com.google.gwt.user.client.ui.Button; |
11 |
|
- |
|
12 |
|
- |
public class FloaterMoveSizeDialog extends AbstractDialog { |
13 |
|
- |
// vvvvvvvvvv These can only be static cause there is only expected to be one at any one time vvvvvvvv // |
14 |
|
- |
|
15 |
|
- |
private static final String PINNED_ID = "PinnedID"; |
16 |
|
- |
private static final String ANCHOR_RIGHT_ID = "AnchorRightID"; |
17 |
|
- |
private static final String ANCHOR_BOTTOM_ID = "AnchorBottomID"; |
18 |
|
- |
|
19 |
|
- |
private static final String MOVE_UP_ID = "MoveUpID"; |
20 |
|
- |
private static final String MOVE_DOWN_ID = "MoveDownID"; |
21 |
|
- |
private static final String MOVE_LEFT_ID = "MoveLeftID"; |
22 |
|
- |
private static final String MOVE_RIGHT_ID = "MoveRightID"; |
23 |
|
- |
private static final String MOVE_LEFT_UP_ID = "MoveLeftUpID"; |
24 |
|
- |
private static final String MOVE_RIGHT_UP_ID = "MoveRightUpID"; |
25 |
|
- |
private static final String MOVE_LEFT_DOWN_ID = "MoveLeftDownID"; |
26 |
|
- |
private static final String MOVE_RIGHT_DOWN_ID = "MoveRightDownID"; |
27 |
|
- |
private static final String MOVE_TEXTBOX_ID = "MoveTextboxID"; |
28 |
|
- |
|
29 |
|
- |
private static final String MOVE_CONTROL_INNER_HTML_ID = "MoveControlInnerHtmlID"; |
30 |
|
- |
|
31 |
|
- |
private static final String MOVE_CONTROL_INNER_HTML = // |
32 |
|
- |
"<table cellpadding='0' cellspacing='0' border='0'><tr><td id=" + MOVE_LEFT_UP_ID + |
33 |
|
- |
" align='center'></td><td id=" + MOVE_UP_ID + " align='center'></td><td id=" + MOVE_RIGHT_UP_ID + |
34 |
|
- |
" align='center'></td></tr><tr><td id=" + MOVE_LEFT_ID + " align='center'></td><td id=" + |
35 |
|
- |
MOVE_TEXTBOX_ID + "></td><td id=" + MOVE_RIGHT_ID + " align='center'></td></tr><tr><td id=" + |
36 |
|
- |
MOVE_LEFT_DOWN_ID + " align='center'></td><td id=" + MOVE_DOWN_ID + |
37 |
|
- |
" align='center'></td><td id=" + MOVE_RIGHT_DOWN_ID + " align='center'></td></tr></table>"; |
38 |
|
- |
|
39 |
|
- |
private static final String MOVE_CONTROL_HTML = // |
40 |
|
- |
"<table cellpadding='0' cellspacing='0' border='0'><tr><td id=" + PINNED_ID + "></td>" + |
41 |
|
- |
"<td></td><td></td></tr><tr><td></td><td>" + |
42 |
|
- |
"<table cellpadding='0' cellspacing='0' border='0'><tr><td id=" + MOVE_CONTROL_INNER_HTML_ID + |
43 |
|
- |
"></td></tr></table></td><td id=" + ANCHOR_RIGHT_ID + "></td></tr><tr><td></td><td id=" + |
44 |
|
- |
ANCHOR_BOTTOM_ID + " align='center'></td><td></td></tr></table>"; |
45 |
|
- |
|
46 |
|
- |
private static final String SIZE_HORIZONTAL_PLUS_ID = "SizeHorizontalPlusID"; |
47 |
|
- |
private static final String SIZE_HORIZONTAL_MINUS_ID = "SizeHorizontalMinusID"; |
48 |
|
- |
private static final String SIZE_VERTICAL_PLUS_ID = "SizeVerticalPlusID"; |
49 |
|
- |
private static final String SIZE_VERTICAL_MINUS_ID = "SizeVerticalMinusID"; |
50 |
|
- |
private static final String SIZE_DIAGONAL_PLUS_ID = "SizeDiagonalPlusID"; |
51 |
|
- |
private static final String SIZE_DIAGONAL_MINUS_ID = "SizeDiagonalMinusID"; |
52 |
|
- |
private static final String SIZE_TEXTBOX_ID = "SizeTextboxID"; |
53 |
|
- |
|
54 |
|
- |
private static final String SIZE_CONTROL_HTML = // |
55 |
|
- |
"<table cellpadding='0' cellspacing='0' border='0'><tr><td id=" + SIZE_TEXTBOX_ID + |
56 |
|
- |
"></td><td id=" + SIZE_HORIZONTAL_MINUS_ID + " style='padding-left:1px;'></td><td id=" + |
57 |
|
- |
SIZE_HORIZONTAL_PLUS_ID + " style='padding-left:2px;'></td></tr><tr><td id=" + |
58 |
|
- |
SIZE_VERTICAL_MINUS_ID + " style='padding-bottom:0px;'></td>" + |
59 |
|
- |
"<td colspan='2' rowspan='2' style='padding-left:0px;' valign='top'>" + |
60 |
|
- |
"<table cellpadding='0' cellspacing='0' border='0'><tr><td id=" + SIZE_DIAGONAL_MINUS_ID + |
61 |
|
- |
"></td><td></td></tr><tr><td></td><td id=" + SIZE_DIAGONAL_PLUS_ID + "></td></tr></table>" + |
62 |
|
- |
"</td><td></td></tr><tr><td id=" + SIZE_VERTICAL_PLUS_ID + " style='padding-top:2px;'></td>" + |
63 |
|
- |
"<td></td><td></td></tr></table>"; |
64 |
|
- |
|
65 |
|
- |
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ // |
66 |
|
- |
|
67 |
|
- |
private SimpleLabel mCurPosition = new SimpleLabel().style( "simpleLabel" ); |
68 |
|
- |
private SimpleLabel mCurSize = new SimpleLabel().style( "simpleLabel" ); |
69 |
|
- |
private SimpleLabel mContentSize = new SimpleLabel().style( "simpleLabel" ); |
70 |
|
- |
|
71 |
|
- |
private CheckBox mChromeCheckbox; |
72 |
|
- |
|
73 |
|
- |
private TextBoxHelper mSizeTextbox = new TextBoxHelper( "SizeTextbox" ); |
74 |
|
- |
private TextBoxHelper mMoveTextbox = new TextBoxHelper( "MoveTextbox" ); |
75 |
|
- |
|
76 |
|
- |
private SimplePanel mMoveControlInnerHtmlPanel = new SimplePanel(); |
77 |
|
- |
|
78 |
|
- |
private SizeableHorizontalPanel mControlsPanel = new SizeableHorizontalPanel( true ).style( "reg" ); |
79 |
|
- |
|
80 |
|
- |
IFloaterPanelMoveAndSize mFloater; |
81 |
|
- |
|
82 |
|
- |
private boolean mNoChromeOrPinning = SimpleMapConfiguration.getBoolean( "TurnOffChromeAndPinning", false ); |
83 |
|
- |
|
84 |
|
- |
public FloaterMoveSizeDialog( String pDefaultTitle, IFloaterPanelMoveAndSize pFloater ) { |
85 |
|
- |
super( pDefaultTitle, Opaqueness.None ); |
86 |
|
- |
|
87 |
|
- |
mFloater = pFloater; |
88 |
|
- |
|
89 |
|
- |
mChromeCheckbox = new CheckBox( "Chrome" ); |
90 |
|
- |
mChromeCheckbox.setChecked( mFloater.isChromed() ); |
91 |
|
- |
mChromeCheckbox.addClickListener( new ClickListener() { |
92 |
|
- |
public void onClick( Widget sender ) { |
93 |
|
- |
mFloater.setChromed( !mFloater.isChromed() ); |
94 |
|
- |
|
95 |
|
- |
updateChromeBorderIndicator(); |
96 |
|
- |
} |
97 |
|
- |
} ); |
98 |
|
- |
|
99 |
|
- |
updateStatus(); |
100 |
|
- |
} |
101 |
|
- |
|
102 |
|
- |
private void updateChromeBorderIndicator() { |
103 |
|
- |
BackDoorToWidget.manageStyle( mMoveControlInnerHtmlPanel, mFloater.isChromed(), |
104 |
|
- |
"MoveControlInnerPanelBorder", "MoveControlInnerPanelNoBorder" ); |
105 |
|
- |
} |
106 |
|
- |
|
107 |
|
- |
private void updateBottomAnchor() { |
108 |
|
- |
BackDoorToWidget.manageStyle( mControlsPanel, mFloater.isBottomAnchor(), // |
109 |
|
- |
"bottomAnchored", "bottomUnanchored" ); |
110 |
|
- |
} |
111 |
|
- |
|
112 |
|
- |
private void updateRightAnchor() { |
113 |
|
- |
BackDoorToWidget.manageStyle( mControlsPanel, mFloater.isRightAnchor(), // |
114 |
|
- |
"rightAnchored", "rightUnanchored" ); |
115 |
|
- |
} |
116 |
|
- |
|
117 |
|
- |
private void updatePinButton() { |
118 |
|
- |
BackDoorToWidget.manageStyle( mControlsPanel, mFloater.isPinned(), "pinned", "unpinned" ); |
119 |
|
- |
} |
120 |
|
- |
|
121 |
|
- |
private void updateAltState() { |
122 |
|
- |
BackDoorToWidget.manageStyle( mControlsPanel, mAltDown, "alt", "reg" ); |
123 |
|
- |
} |
124 |
|
- |
|
125 |
|
- |
private boolean mAltDown = false; |
126 |
|
- |
|
127 |
|
- |
private void setAltState( boolean pAltDown ) { |
128 |
|
- |
if ( mAltDown != pAltDown ) { |
129 |
|
- |
mAltDown = pAltDown; |
130 |
|
- |
|
131 |
|
- |
updateAltState(); |
132 |
|
- |
} |
133 |
|
- |
} |
134 |
|
- |
|
135 |
|
- |
public boolean onKeyDownPreview( char key, int modifiers ) { |
136 |
|
- |
if ( 0 != (modifiers & KeyboardListener.MODIFIER_ALT) ) { |
137 |
|
- |
setAltState( true ); |
138 |
|
- |
} |
139 |
|
- |
return super.onKeyDownPreview( key, modifiers ); |
140 |
|
- |
} |
141 |
|
- |
|
142 |
|
- |
public boolean onKeyUpPreview( char key, int modifiers ) { |
143 |
|
- |
if ( 0 == (modifiers & KeyboardListener.MODIFIER_ALT) ) { |
144 |
|
- |
setAltState( false ); |
145 |
|
- |
} |
146 |
|
- |
return super.onKeyUpPreview( key, modifiers ); |
147 |
|
- |
} |
148 |
|
- |
|
149 |
|
- |
protected Widget createBodyPanel() { |
150 |
|
- |
SizeableVerticalPanel zPanel = new SizeableVerticalPanel( true ).stretchable(); |
151 |
|
- |
|
152 |
|
- |
SizeableTitledBorderedSimplePanel zStatusFieldset = |
153 |
|
- |
new SizeableTitledBorderedSimplePanel( true, "Status" ).stretchableHorizontally(); |
154 |
|
- |
zStatusFieldset.add( createStatusGrid() ); |
155 |
|
- |
|
156 |
|
- |
zPanel.add( zStatusFieldset ); |
157 |
|
- |
zPanel.add( createControlsPanel() ); |
158 |
|
- |
|
159 |
|
- |
zPanel.setHorizontalAlignment( HasHorizontalAlignment.ALIGN_CENTER ); |
160 |
|
- |
zPanel.add( new Button( "Close", new ClickListener() { |
161 |
|
- |
public void onClick( Widget sender ) { |
162 |
|
- |
hide(); |
163 |
|
- |
} |
164 |
|
- |
} ) ); |
165 |
|
- |
|
166 |
|
- |
return zPanel; |
167 |
|
- |
} |
168 |
|
- |
|
169 |
|
- |
private Grid createStatusGrid() { |
170 |
|
- |
final IFloaterPanelMoveAndSize[] zFloaters = mFloater.getAllFloaters(); |
171 |
|
- |
final ListBox zBox = new ListBox(); |
172 |
|
- |
zBox.setWidth( "120" ); |
173 |
|
- |
|
174 |
|
- |
for ( int i = 0; i < zFloaters.length; i++ ) { |
175 |
|
- |
IFloaterPanelMoveAndSize zFloater = zFloaters[i]; |
176 |
|
- |
zBox.addItem( zFloater.getCurrentTitle(), "" + i ); |
177 |
|
- |
} |
178 |
|
- |
|
179 |
|
- |
zBox.addChangeListener( new ChangeListener() { |
180 |
|
- |
public void onChange( Widget sender ) { |
181 |
|
- |
setActiveAndUpdateStatus( zBox, zFloaters ); |
182 |
|
- |
} |
183 |
|
- |
} ); |
184 |
|
- |
|
185 |
|
- |
Grid zStatusGrid = new Grid( 5, 2 ); |
186 |
|
- |
zStatusGrid.setWidget( 0, 0, new SimpleLabel( "Title:" ).style( "simpleLabel" ) ); |
187 |
|
- |
zStatusGrid.setWidget( 0, 1, zBox ); |
188 |
|
- |
zStatusGrid.setWidget( 1, 0, new SimpleLabel( "Current Position:" ).style( "simpleLabel" ) ); |
189 |
|
- |
zStatusGrid.setWidget( 1, 1, mCurPosition ); |
190 |
|
- |
zStatusGrid.setWidget( 2, 0, new SimpleLabel( "Current Size:" ).style( "simpleLabel" ) ); |
191 |
|
- |
zStatusGrid.setWidget( 2, 1, mCurSize ); |
192 |
|
- |
zStatusGrid.setWidget( 3, 0, new SimpleLabel( "Content Size:" ).style( "simpleLabel" ) ); |
193 |
|
- |
zStatusGrid.setWidget( 3, 1, mContentSize ); |
194 |
|
- |
if ( mNoChromeOrPinning ) { |
195 |
|
- |
zStatusGrid.setWidget( 4, 0, new Spacer( 5 ) ); |
196 |
|
- |
} else { |
197 |
|
- |
zStatusGrid.setWidget( 4, 0, mChromeCheckbox ); |
198 |
|
- |
} |
199 |
|
- |
|
200 |
|
- |
int zIndexForValue = getIndexForValue( zFloaters, mFloater.getCurrentTitle() ); |
201 |
|
- |
if ( zIndexForValue >= 0 ) { |
202 |
|
- |
zBox.setSelectedIndex( zIndexForValue ); |
203 |
|
- |
} |
204 |
|
- |
|
205 |
|
- |
return zStatusGrid; |
206 |
|
- |
} |
207 |
|
- |
|
208 |
|
- |
private void setActiveAndUpdateStatus( ListBox pBox, IFloaterPanelMoveAndSize[] pFloaters ) { |
209 |
|
- |
String zIndxValue = pBox.getValue( pBox.getSelectedIndex() ); |
210 |
|
- |
int zIntIndx = Integer.parseInt( zIndxValue ); |
211 |
|
- |
mFloater = pFloaters[zIntIndx]; |
212 |
|
- |
mFloater.setActive(); |
213 |
|
- |
updateStatus(); |
214 |
|
- |
setTitle( mFloater.getCurrentTitle() ); |
215 |
|
- |
} |
216 |
|
- |
|
217 |
|
- |
private int getIndexForValue( IFloaterPanelMoveAndSize[] pFloaters, String pValue ) { |
218 |
|
- |
int rv = -1; |
219 |
|
- |
for ( int i = 0; i < pFloaters.length; i++ ) { |
220 |
|
- |
IFloaterPanelMoveAndSize myFloater = pFloaters[i]; |
221 |
|
- |
if ( pValue.equals( myFloater.getCurrentTitle() ) ) { |
222 |
|
- |
rv = i; |
223 |
|
- |
} |
224 |
|
- |
} |
225 |
|
- |
return rv; |
226 |
|
- |
} |
227 |
|
- |
|
228 |
|
- |
private SizeableHorizontalPanel createControlsPanel() { |
229 |
|
- |
mControlsPanel.add( createFieldset( "Move", createMoveControl() ) ); |
230 |
|
- |
mControlsPanel.add( createFieldset( "Size", createSizeControl() ) ); |
231 |
|
- |
|
232 |
|
- |
return mControlsPanel.stretchable(); |
233 |
|
- |
} |
234 |
|
- |
|
235 |
|
- |
private SizeableTitledBorderedVerticalPanel createFieldset( String pTitle, HTMLPanel pPanel ) { |
236 |
|
- |
SizeableTitledBorderedVerticalPanel fieldset = |
237 |
|
- |
new SizeableTitledBorderedVerticalPanel( true, pTitle ).style( |
238 |
|
- |
"MoveSizeFieldset" ).stretchable(); |
239 |
|
- |
|
240 |
|
- |
DOM.setStyleAttribute( fieldset.getElement(), "textAlign", "center" ); |
241 |
|
- |
fieldset.add( new SizeableSpacer().stretchableVertically() ); |
242 |
|
- |
fieldset.add( pPanel ); |
243 |
|
- |
fieldset.add( new SizeableSpacer().stretchableVertically() ); |
244 |
|
- |
|
245 |
|
- |
return fieldset; |
246 |
|
- |
} |
247 |
|
- |
|
248 |
|
- |
private void updateStatus() { |
249 |
|
- |
mCurPosition.setText( "x:" + mFloater.getPosLeft() + "; y:" + mFloater.getPosTop() ); |
250 |
|
- |
mCurSize.setText( "w:" + mFloater.getOffsetWidth() + "; h:" + mFloater.getOffsetHeight() ); |
251 |
|
- |
mContentSize.setText( "w:" + (mFloater.getContentSize()).getIntWidth() + "; h:" + |
252 |
|
- |
(mFloater.getContentSize()).getIntHeight() ); |
253 |
|
- |
updatePinButton(); |
254 |
|
- |
updateRightAnchor(); |
255 |
|
- |
updateBottomAnchor(); |
256 |
|
- |
updateChromeBorderIndicator(); |
257 |
|
- |
} |
258 |
|
- |
|
259 |
|
- |
private HTMLPanel createMoveControl() { |
260 |
|
- |
HTMLPanel innerHTMLPanel = new HTMLPanel( MOVE_CONTROL_INNER_HTML ); |
261 |
|
- |
|
262 |
|
- |
innerHTMLPanel.add( mMoveTextbox.getWidget(), MOVE_TEXTBOX_ID ); |
263 |
|
- |
|
264 |
|
- |
innerHTMLPanel.add( createMoveUpButton(), MOVE_UP_ID ); |
265 |
|
- |
innerHTMLPanel.add( createMoveDownButton(), MOVE_DOWN_ID ); |
266 |
|
- |
innerHTMLPanel.add( createMoveLeftButton(), MOVE_LEFT_ID ); |
267 |
|
- |
innerHTMLPanel.add( createMoveRightButton(), MOVE_RIGHT_ID ); |
268 |
|
- |
|
269 |
|
- |
innerHTMLPanel.add( createMoveLeftUpButton(), MOVE_LEFT_UP_ID ); |
270 |
|
- |
innerHTMLPanel.add( createMoveRightUpButton(), MOVE_RIGHT_UP_ID ); |
271 |
|
- |
innerHTMLPanel.add( createMoveLeftDownButton(), MOVE_LEFT_DOWN_ID ); |
272 |
|
- |
innerHTMLPanel.add( createMoveRightDownButton(), MOVE_RIGHT_DOWN_ID ); |
273 |
|
- |
|
274 |
|
- |
mMoveControlInnerHtmlPanel.add( innerHTMLPanel ); |
275 |
|
- |
|
276 |
|
- |
HTMLPanel panel = new HTMLPanel( MOVE_CONTROL_HTML ); |
277 |
|
- |
|
278 |
|
- |
if ( mNoChromeOrPinning ) { |
279 |
|
- |
panel.add( new Spacer( 5 ), PINNED_ID ); |
280 |
|
- |
panel.add( mMoveControlInnerHtmlPanel, MOVE_CONTROL_INNER_HTML_ID ); |
281 |
|
- |
panel.add( new Spacer( 5 ), ANCHOR_RIGHT_ID ); |
282 |
|
- |
panel.add( new Spacer( 5 ), ANCHOR_BOTTOM_ID ); |
283 |
|
- |
} else { |
284 |
|
- |
panel.add( createPinnedButton(), PINNED_ID ); |
285 |
|
- |
panel.add( mMoveControlInnerHtmlPanel, MOVE_CONTROL_INNER_HTML_ID ); |
286 |
|
- |
panel.add( createAnchorRightButton(), ANCHOR_RIGHT_ID ); |
287 |
|
- |
panel.add( createAnchorBottomButton(), ANCHOR_BOTTOM_ID ); |
288 |
|
- |
} |
289 |
|
- |
return panel; |
290 |
|
- |
} |
291 |
|
- |
|
292 |
|
- |
private Widget createPinnedButton() { |
293 |
|
- |
return null; // todo: translate: |
294 |
|
- |
// new BGImageButton( "FloaterPushPin", "Pin to This Position;", new ClickListener() |
295 |
|
- |
// { |
296 |
|
- |
// public void onClick( Widget sender ) |
297 |
|
- |
// { |
298 |
|
- |
// mFloater.setPinned( !mFloater.isPinned() ); |
299 |
|
- |
// |
300 |
|
- |
// updatePinButton(); |
301 |
|
- |
// } |
302 |
|
- |
// } ); |
303 |
|
- |
} |
304 |
|
- |
|
305 |
|
- |
private Widget createAnchorRightButton() { |
306 |
|
- |
return null; // todo: translate: |
307 |
|
- |
// new BGImageButton( "FloaterAnchorRight", "Anchor to Right Window Border;", new ClickListener() |
308 |
|
- |
// { |
309 |
|
- |
// public void onClick( Widget sender ) |
310 |
|
- |
// { |
311 |
|
- |
// mFloater.setRightAnchor( !mFloater.isRightAnchor() ); |
312 |
|
- |
// |
313 |
|
- |
// updateRightAnchor(); |
314 |
|
- |
// } |
315 |
|
- |
// } ); |
316 |
|
- |
} |
317 |
|
- |
|
318 |
|
- |
private Widget createAnchorBottomButton() { |
319 |
|
- |
return null; // todo: translate: |
320 |
|
- |
// new BGImageButton( "FloaterAnchorBottom", "Anchor to Bottom Window Border;", |
321 |
|
- |
// new ClickListener() |
322 |
|
- |
// { |
323 |
|
- |
// public void onClick( Widget sender ) |
324 |
|
- |
// { |
325 |
|
- |
// mFloater.setBottomAnchor( !mFloater.isBottomAnchor() ); |
326 |
|
- |
// |
327 |
|
- |
// updateBottomAnchor(); |
328 |
|
- |
// } |
329 |
|
- |
// } ); |
330 |
|
- |
} |
331 |
|
- |
|
332 |
|
- |
private MyTimer mTimer = null; |
333 |
|
- |
|
334 |
|
- |
private void start_N_Timer() { |
335 |
|
- |
mTimer = new MoveNorthTimer(); |
336 |
|
- |
mTimer.init(); |
337 |
|
- |
} |
338 |
|
- |
|
339 |
|
- |
private void start_S_Timer() { |
340 |
|
- |
mTimer = new MoveSouthTimer(); |
341 |
|
- |
mTimer.init(); |
342 |
|
- |
} |
343 |
|
- |
|
344 |
|
- |
private void start_W_Timer() { |
345 |
|
- |
mTimer = new MoveWestTimer(); |
346 |
|
- |
mTimer.init(); |
347 |
|
- |
} |
348 |
|
- |
|
349 |
|
- |
private void start_E_Timer() { |
350 |
|
- |
mTimer = new MoveEastTimer(); |
351 |
|
- |
mTimer.init(); |
352 |
|
- |
} |
353 |
|
- |
|
354 |
|
- |
private void start_NW_Timer() { |
355 |
|
- |
mTimer = new MoveNorthWestTimer(); |
356 |
|
- |
mTimer.init(); |
357 |
|
- |
} |
358 |
|
- |
|
359 |
|
- |
private void start_NE_Timer() { |
360 |
|
- |
mTimer = new MoveNorthEastTimer(); |
361 |
|
- |
mTimer.init(); |
362 |
|
- |
} |
363 |
|
- |
|
364 |
|
- |
private void start_SW_Timer() { |
365 |
|
- |
mTimer = new MoveSouthWestTimer(); |
366 |
|
- |
mTimer.init(); |
367 |
|
- |
} |
368 |
|
- |
|
369 |
|
- |
private void start_SE_Timer() { |
370 |
|
- |
mTimer = new MoveSouthEastTimer(); |
371 |
|
- |
mTimer.init(); |
372 |
|
- |
} |
373 |
|
- |
|
374 |
|
- |
private void startIncreaseWidthTimer() { |
375 |
|
- |
mTimer = new IncreaseWidthTimer(); |
376 |
|
- |
mTimer.init(); |
377 |
|
- |
} |
378 |
|
- |
|
379 |
|
- |
private void startDecreaseWidthTimer() { |
380 |
|
- |
mTimer = new DecreaseWidthTimer(); |
381 |
|
- |
mTimer.init(); |
382 |
|
- |
} |
383 |
|
- |
|
384 |
|
- |
private void startIncreaseHeightTimer() { |
385 |
|
- |
mTimer = new IncreaseHeightTimer(); |
386 |
|
- |
mTimer.init(); |
387 |
|
- |
} |
388 |
|
- |
|
389 |
|
- |
private void startDecreaseHeightTimer() { |
390 |
|
- |
mTimer = new DecreaseHeightTimer(); |
391 |
|
- |
mTimer.init(); |
392 |
|
- |
} |
393 |
|
- |
|
394 |
|
- |
private void startIncreaseDiagonalTimer() { |
395 |
|
- |
mTimer = new IncreaseDiagonalTimer(); |
396 |
|
- |
mTimer.init(); |
397 |
|
- |
} |
398 |
|
- |
|
399 |
|
- |
private void startDecreaseDiagonalTimer() { |
400 |
|
- |
mTimer = new DecreaseDiagonalTimer(); |
401 |
|
- |
mTimer.init(); |
402 |
|
- |
} |
403 |
|
- |
|
404 |
|
- |
private void stopTimer() { |
405 |
|
- |
if ( mTimer != null ) { |
406 |
|
- |
mTimer.cancel(); |
407 |
|
- |
} |
408 |
|
- |
} |
409 |
|
- |
|
410 |
|
- |
private abstract class MyTimer extends Timer { |
411 |
|
- |
public static final int MIN_DELAY = 25; |
412 |
|
- |
public static final int DELAY_ADJUST = 10; |
413 |
|
- |
|
414 |
|
- |
private int mDelay; |
415 |
|
- |
|
416 |
|
- |
public void init() { |
417 |
|
- |
schedule( mDelay = 200 ); |
418 |
|
- |
} |
419 |
|
- |
|
420 |
|
- |
public void run() { |
421 |
|
- |
adjustValue(); |
422 |
|
- |
if ( (mDelay -= DELAY_ADJUST) < MIN_DELAY ) { |
423 |
|
- |
mDelay = MIN_DELAY; |
424 |
|
- |
} |
425 |
|
- |
schedule( mDelay ); |
426 |
|
- |
} |
427 |
|
- |
|
428 |
|
- |
public abstract void adjustValue(); |
429 |
|
- |
} |
430 |
|
- |
|
431 |
|
- |
private class MoveNorthTimer extends MyTimer { |
432 |
|
- |
public void adjustValue() { |
433 |
|
- |
mFloater.moveN( mMoveTextbox.getTextboxValue() ); |
434 |
|
- |
updateStatus(); |
435 |
|
- |
} |
436 |
|
- |
} |
437 |
|
- |
|
438 |
|
- |
private class MoveSouthTimer extends MyTimer { |
439 |
|
- |
public void adjustValue() { |
440 |
|
- |
mFloater.moveS( mMoveTextbox.getTextboxValue() ); |
441 |
|
- |
updateStatus(); |
442 |
|
- |
} |
443 |
|
- |
} |
444 |
|
- |
|
445 |
|
- |
private class MoveWestTimer extends MyTimer { |
446 |
|
- |
public void adjustValue() { |
447 |
|
- |
mFloater.moveW( mMoveTextbox.getTextboxValue() ); |
448 |
|
- |
updateStatus(); |
449 |
|
- |
} |
450 |
|
- |
} |
451 |
|
- |
|
452 |
|
- |
private class MoveEastTimer extends MyTimer { |
453 |
|
- |
public void adjustValue() { |
454 |
|
- |
mFloater.moveE( mMoveTextbox.getTextboxValue() ); |
455 |
|
- |
updateStatus(); |
456 |
|
- |
} |
457 |
|
- |
} |
458 |
|
- |
|
459 |
|
- |
private class MoveNorthWestTimer extends MyTimer { |
460 |
|
- |
public void adjustValue() { |
461 |
|
- |
mFloater.moveNW( mMoveTextbox.getTextboxValue() ); |
462 |
|
- |
updateStatus(); |
463 |
|
- |
} |
464 |
|
- |
} |
465 |
|
- |
|
466 |
|
- |
private class MoveNorthEastTimer extends MyTimer { |
467 |
|
- |
public void adjustValue() { |
468 |
|
- |
mFloater.moveNE( mMoveTextbox.getTextboxValue() ); |
469 |
|
- |
updateStatus(); |
470 |
|
- |
} |
471 |
|
- |
} |
472 |
|
- |
|
473 |
|
- |
private class MoveSouthWestTimer extends MyTimer { |
474 |
|
- |
public void adjustValue() { |
475 |
|
- |
mFloater.moveSW( mMoveTextbox.getTextboxValue() ); |
476 |
|
- |
updateStatus(); |
477 |
|
- |
} |
478 |
|
- |
} |
479 |
|
- |
|
480 |
|
- |
private class MoveSouthEastTimer extends MyTimer { |
481 |
|
- |
public void adjustValue() { |
482 |
|
- |
mFloater.moveSE( mMoveTextbox.getTextboxValue() ); |
483 |
|
- |
updateStatus(); |
484 |
|
- |
} |
485 |
|
- |
} |
486 |
|
- |
|
487 |
|
- |
private class IncreaseWidthTimer extends MyTimer { |
488 |
|
- |
public void adjustValue() { |
489 |
|
- |
mFloater.increaseWidthBy( mSizeTextbox.getTextboxValue() ); |
490 |
|
- |
updateStatus(); |
491 |
|
- |
} |
492 |
|
- |
} |
493 |
|
- |
|
494 |
|
- |
private class DecreaseWidthTimer extends MyTimer { |
495 |
|
- |
public void adjustValue() { |
496 |
|
- |
mFloater.decreaseWidthBy( mSizeTextbox.getTextboxValue() ); |
497 |
|
- |
updateStatus(); |
498 |
|
- |
} |
499 |
|
- |
} |
500 |
|
- |
|
501 |
|
- |
private class IncreaseHeightTimer extends MyTimer { |
502 |
|
- |
public void adjustValue() { |
503 |
|
- |
mFloater.increaseHeightBy( mSizeTextbox.getTextboxValue() ); |
504 |
|
- |
updateStatus(); |
505 |
|
- |
} |
506 |
|
- |
} |
507 |
|
- |
|
508 |
|
- |
private class DecreaseHeightTimer extends MyTimer { |
509 |
|
- |
public void adjustValue() { |
510 |
|
- |
mFloater.decreaseHeightBy( mSizeTextbox.getTextboxValue() ); |
511 |
|
- |
updateStatus(); |
512 |
|
- |
} |
513 |
|
- |
} |
514 |
|
- |
|
515 |
|
- |
private class IncreaseDiagonalTimer extends MyTimer { |
516 |
|
- |
public void adjustValue() { |
517 |
|
- |
mFloater.increaseWidthBy( mSizeTextbox.getTextboxValue() ); |
518 |
|
- |
mFloater.increaseHeightBy( mSizeTextbox.getTextboxValue() ); |
519 |
|
- |
updateStatus(); |
520 |
|
- |
} |
521 |
|
- |
} |
522 |
|
- |
|
523 |
|
- |
private class DecreaseDiagonalTimer extends MyTimer { |
524 |
|
- |
public void adjustValue() { |
525 |
|
- |
mFloater.decreaseWidthBy( mSizeTextbox.getTextboxValue() ); |
526 |
|
- |
mFloater.decreaseHeightBy( mSizeTextbox.getTextboxValue() ); |
527 |
|
- |
updateStatus(); |
528 |
|
- |
} |
529 |
|
- |
} |
530 |
|
- |
|
531 |
|
- |
private Widget createMoveUpButton() { |
532 |
|
- |
// BGImageButton imageButton = new BGImageButton( "FloaterMoveUp", |
533 |
|
- |
// "Click to Move Up;\nAlt-Click to Move to Top Window Border;", |
534 |
|
- |
// new ClickListener() |
535 |
|
- |
// { |
536 |
|
- |
// public void onClick( Widget sender ) |
537 |
|
- |
// { |
538 |
|
- |
// if ( mAltDown ) |
539 |
|
- |
// { |
540 |
|
- |
// mFloater.moveToMaxN(); |
541 |
|
- |
// } |
542 |
|
- |
// else |
543 |
|
- |
// { |
544 |
|
- |
// mFloater.moveN( |
545 |
|
- |
// mMoveTextbox.getTextboxValue() ); |
546 |
|
- |
// } |
547 |
|
- |
// updateStatus(); |
548 |
|
- |
// } |
549 |
|
- |
// } ); |
550 |
|
- |
// imageButton.addMouseListener( new MouseListenerAdapter() |
551 |
|
- |
// { |
552 |
|
- |
// public void onMouseDown( Widget sender, int x, int y ) |
553 |
|
- |
// { |
554 |
|
- |
// start_N_Timer(); |
555 |
|
- |
// } |
556 |
|
- |
// |
557 |
|
- |
// public void onMouseUp( Widget sender, int x, int y ) |
558 |
|
- |
// { |
559 |
|
- |
// stopTimer(); |
560 |
|
- |
// } |
561 |
|
- |
// } ); |
562 |
|
- |
// |
563 |
|
- |
return null; // todo: translate: imageButton; |
564 |
|
- |
} |
565 |
|
- |
|
566 |
|
- |
private Widget createMoveDownButton() { |
567 |
|
- |
// BGImageButton imageButton = new BGImageButton( "FloaterMoveDown", |
568 |
|
- |
// "Click to Move Down;\nAlt-Click to Move to Bottom Window Border;", |
569 |
|
- |
// new ClickListener() |
570 |
|
- |
// { |
571 |
|
- |
// public void onClick( Widget sender ) |
572 |
|
- |
// { |
573 |
|
- |
// if ( mAltDown ) |
574 |
|
- |
// { |
575 |
|
- |
// mFloater.moveToMaxS(); |
576 |
|
- |
// } |
577 |
|
- |
// else |
578 |
|
- |
// { |
579 |
|
- |
// mFloater.moveS( |
580 |
|
- |
// mMoveTextbox.getTextboxValue() ); |
581 |
|
- |
// } |
582 |
|
- |
// updateStatus(); |
583 |
|
- |
// } |
584 |
|
- |
// } ); |
585 |
|
- |
// imageButton.addMouseListener( new MouseListenerAdapter() |
586 |
|
- |
// { |
587 |
|
- |
// public void onMouseDown( Widget sender, int x, int y ) |
588 |
|
- |
// { |
589 |
|
- |
// start_S_Timer(); |
590 |
|
- |
// } |
591 |
|
- |
// |
592 |
|
- |
// public void onMouseUp( Widget sender, int x, int y ) |
593 |
|
- |
// { |
594 |
|
- |
// stopTimer(); |
595 |
|
- |
// } |
596 |
|
- |
// } ); |
597 |
|
- |
return null; // todo: translate: imageButton; |
598 |
|
- |
} |
599 |
|
- |
|
600 |
|
- |
private Widget createMoveLeftButton() { |
601 |
|
- |
// BGImageButton imageButton = new BGImageButton( "FloaterMoveLeft", |
602 |
|
- |
// "Click to Move Left;\nAlt-Click to Move to Left Window Border;", |
603 |
|
- |
// new ClickListener() |
604 |
|
- |
// { |
605 |
|
- |
// public void onClick( Widget sender ) |
606 |
|
- |
// { |
607 |
|
- |
// if ( mAltDown ) |
608 |
|
- |
// { |
609 |
|
- |
// mFloater.moveToMaxW(); |
610 |
|
- |
// } |
611 |
|
- |
// else |
612 |
|
- |
// { |
613 |
|
- |
// mFloater.moveW( |
614 |
|
- |
// mMoveTextbox.getTextboxValue() ); |
615 |
|
- |
// } |
616 |
|
- |
// updateStatus(); |
617 |
|
- |
// } |
618 |
|
- |
// } ); |
619 |
|
- |
// imageButton.addMouseListener( new MouseListenerAdapter() |
620 |
|
- |
// { |
621 |
|
- |
// public void onMouseDown( Widget sender, int x, int y ) |
622 |
|
- |
// { |
623 |
|
- |
// start_W_Timer(); |
624 |
|
- |
// } |
625 |
|
- |
// |
626 |
|
- |
// public void onMouseUp( Widget sender, int x, int y ) |
627 |
|
- |
// { |
628 |
|
- |
// stopTimer(); |
629 |
|
- |
// } |
630 |
|
- |
// } ); |
631 |
|
- |
return null; // todo: translate: imageButton; |
632 |
|
- |
} |
633 |
|
- |
|
634 |
|
- |
private Widget createMoveRightButton() { |
635 |
|
- |
// BGImageButton imageButton = new BGImageButton( "FloaterMoveRight", |
636 |
|
- |
// "Click to Move Right;\nAlt-Click to Move to Right Window Border;", |
637 |
|
- |
// new ClickListener() |
638 |
|
- |
// { |
639 |
|
- |
// public void onClick( Widget sender ) |
640 |
|
- |
// { |
641 |
|
- |
// if ( mAltDown ) |
642 |
|
- |
// { |
643 |
|
- |
// mFloater.moveToMaxE(); |
644 |
|
- |
// } |
645 |
|
- |
// else |
646 |
|
- |
// { |
647 |
|
- |
// mFloater.moveE( |
648 |
|
- |
// mMoveTextbox.getTextboxValue() ); |
649 |
|
- |
// } |
650 |
|
- |
// updateStatus(); |
651 |
|
- |
// } |
652 |
|
- |
// } ); |
653 |
|
- |
// imageButton.addMouseListener( new MouseListenerAdapter() |
654 |
|
- |
// { |
655 |
|
- |
// public void onMouseDown( Widget sender, int x, int y ) |
656 |
|
- |
// { |
657 |
|
- |
// start_E_Timer(); |
658 |
|
- |
// } |
659 |
|
- |
// |
660 |
|
- |
// public void onMouseUp( Widget sender, int x, int y ) |
661 |
|
- |
// { |
662 |
|
- |
// stopTimer(); |
663 |
|
- |
// } |
664 |
|
- |
// } ); |
665 |
|
- |
return null; // todo: translate: imageButton; |
666 |
|
- |
} |
667 |
|
- |
|
668 |
|
- |
private Widget createMoveLeftUpButton() { |
669 |
|
- |
// BGImageButton imageButton = new BGImageButton( "FloaterMoveLeftUp", |
670 |
|
- |
// "Click to Move Top Left;\nAlt-Click to Move to Top Left Corner of Window;", |
671 |
|
- |
// new ClickListener() |
672 |
|
- |
// { |
673 |
|
- |
// public void onClick( Widget sender ) |
674 |
|
- |
// { |
675 |
|
- |
// if ( mAltDown ) |
676 |
|
- |
// { |
677 |
|
- |
// mFloater.moveToMaxNW(); |
678 |
|
- |
// } |
679 |
|
- |
// else |
680 |
|
- |
// { |
681 |
|
- |
// mFloater.moveNW( |
682 |
|
- |
// mMoveTextbox.getTextboxValue() ); |
683 |
|
- |
// } |
684 |
|
- |
// updateStatus(); |
685 |
|
- |
// } |
686 |
|
- |
// } ); |
687 |
|
- |
// imageButton.addMouseListener( new MouseListenerAdapter() |
688 |
|
- |
// { |
689 |
|
- |
// public void onMouseDown( Widget sender, int x, int y ) |
690 |
|
- |
// { |
691 |
|
- |
// start_NW_Timer(); |
692 |
|
- |
// } |
693 |
|
- |
// |
694 |
|
- |
// public void onMouseUp( Widget sender, int x, int y ) |
695 |
|
- |
// { |
696 |
|
- |
// stopTimer(); |
697 |
|
- |
// } |
698 |
|
- |
// } ); |
699 |
|
- |
return null; // todo: translate: imageButton; |
700 |
|
- |
} |
701 |
|
- |
|
702 |
|
- |
private Widget createMoveRightUpButton() { |
703 |
|
- |
// BGImageButton imageButton = new BGImageButton( "FloaterMoveRightUp", |
704 |
|
- |
// "Click to Move Top Right;\nAlt-Click to Move to Top Right Corner of Window;", |
705 |
|
- |
// new ClickListener() |
706 |
|
- |
// { |
707 |
|
- |
// public void onClick( Widget sender ) |
708 |
|
- |
// { |
709 |
|
- |
// if ( mAltDown ) |
710 |
|
- |
// { |
711 |
|
- |
// mFloater.moveToMaxNE(); |
712 |
|
- |
// } |
713 |
|
- |
// else |
714 |
|
- |
// { |
715 |
|
- |
// mFloater.moveNE( |
716 |
|
- |
// mMoveTextbox.getTextboxValue() ); |
717 |
|
- |
// } |
718 |
|
- |
// updateStatus(); |
719 |
|
- |
// } |
720 |
|
- |
// } ); |
721 |
|
- |
// imageButton.addMouseListener( new MouseListenerAdapter() |
722 |
|
- |
// { |
723 |
|
- |
// public void onMouseDown( Widget sender, int x, int y ) |
724 |
|
- |
// { |
725 |
|
- |
// start_NE_Timer(); |
726 |
|
- |
// } |
727 |
|
- |
// |
728 |
|
- |
// public void onMouseUp( Widget sender, int x, int y ) |
729 |
|
- |
// { |
730 |
|
- |
// stopTimer(); |
731 |
|
- |
// } |
732 |
|
- |
// } ); |
733 |
|
- |
return null; // todo: translate: imageButton; |
734 |
|
- |
} |
735 |
|
- |
|
736 |
|
- |
private Widget createMoveLeftDownButton() { |
737 |
|
- |
// BGImageButton imageButton = new BGImageButton( "FloaterMoveLeftDown", |
738 |
|
- |
// "Click to Move Bottom Left;\nAlt-Click to Move to Bottom Left Corner of Window;", |
739 |
|
- |
// new ClickListener() |
740 |
|
- |
// { |
741 |
|
- |
// public void onClick( Widget sender ) |
742 |
|
- |
// { |
743 |
|
- |
// if ( mAltDown ) |
744 |
|
- |
// { |
745 |
|
- |
// mFloater.moveToMaxSW(); |
746 |
|
- |
// } |
747 |
|
- |
// else |
748 |
|
- |
// { |
749 |
|
- |
// mFloater.moveSW( |
750 |
|
- |
// mMoveTextbox.getTextboxValue() ); |
751 |
|
- |
// } |
752 |
|
- |
// updateStatus(); |
753 |
|
- |
// } |
754 |
|
- |
// } ); |
755 |
|
- |
// imageButton.addMouseListener( new MouseListenerAdapter() |
756 |
|
- |
// { |
757 |
|
- |
// public void onMouseDown( Widget sender, int x, int y ) |
758 |
|
- |
// { |
759 |
|
- |
// start_SW_Timer(); |
760 |
|
- |
// } |
761 |
|
- |
// |
762 |
|
- |
// public void onMouseUp( Widget sender, int x, int y ) |
763 |
|
- |
// { |
764 |
|
- |
// stopTimer(); |
765 |
|
- |
// } |
766 |
|
- |
// } ); |
767 |
|
- |
return null; // todo: translate: imageButton; |
768 |
|
- |
} |
769 |
|
- |
|
770 |
|
- |
private Widget createMoveRightDownButton() { |
771 |
|
- |
// BGImageButton imageButton = new BGImageButton( "FloaterMoveRightDown", |
772 |
|
- |
// "Click to Move Bottom Right;\nAlt-Click to Move to Bottom Right Corner of Window;", |
773 |
|
- |
// new ClickListener() |
774 |
|
- |
// { |
775 |
|
- |
// public void onClick( Widget sender ) |
776 |
|
- |
// { |
777 |
|
- |
// if ( mAltDown ) |
778 |
|
- |
// { |
779 |
|
- |
// mFloater.moveToMaxSE(); |
780 |
|
- |
// } |
781 |
|
- |
// else |
782 |
|
- |
// { |
783 |
|
- |
// mFloater.moveSE( |
784 |
|
- |
// mMoveTextbox.getTextboxValue() ); |
785 |
|
- |
// } |
786 |
|
- |
// updateStatus(); |
787 |
|
- |
// } |
788 |
|
- |
// } ); |
789 |
|
- |
// imageButton.addMouseListener( new MouseListenerAdapter() |
790 |
|
- |
// { |
791 |
|
- |
// public void onMouseDown( Widget sender, int x, int y ) |
792 |
|
- |
// { |
793 |
|
- |
// start_SE_Timer(); |
794 |
|
- |
// } |
795 |
|
- |
// |
796 |
|
- |
// public void onMouseUp( Widget sender, int x, int y ) |
797 |
|
- |
// { |
798 |
|
- |
// stopTimer(); |
799 |
|
- |
// } |
800 |
|
- |
// } ); |
801 |
|
- |
return null; // todo: translate: imageButton; |
802 |
|
- |
} |
803 |
|
- |
|
804 |
|
- |
private HTMLPanel createSizeControl() { |
805 |
|
- |
HTMLPanel panel = new HTMLPanel( SIZE_CONTROL_HTML ); |
806 |
|
- |
|
807 |
|
- |
panel.add( mSizeTextbox.getWidget(), SIZE_TEXTBOX_ID ); |
808 |
|
- |
|
809 |
|
- |
panel.add( createSizeHorizontalPlusButton(), SIZE_HORIZONTAL_PLUS_ID ); |
810 |
|
- |
panel.add( createSizeHorizontalMinusButton(), SIZE_HORIZONTAL_MINUS_ID ); |
811 |
|
- |
panel.add( createSizeVerticalPlusButton(), SIZE_VERTICAL_PLUS_ID ); |
812 |
|
- |
panel.add( createSizeVerticalMinusButton(), SIZE_VERTICAL_MINUS_ID ); |
813 |
|
- |
panel.add( createSizeDiagonalPlusButton(), SIZE_DIAGONAL_PLUS_ID ); |
814 |
|
- |
panel.add( createSizeDiagonalMinusButton(), SIZE_DIAGONAL_MINUS_ID ); |
815 |
|
- |
|
816 |
|
- |
return panel; |
817 |
|
- |
} |
818 |
|
- |
|
819 |
|
- |
private Widget createSizeHorizontalPlusButton() { |
820 |
|
- |
// BGImageButton imageButton = new BGImageButton( "FloaterSizeHorizontalPlus", |
821 |
|
- |
// "Click to Increase Width;\nAlt-Click to Resize Width to Right Window Border;", |
822 |
|
- |
// new ClickListener() |
823 |
|
- |
// { |
824 |
|
- |
// public void onClick( Widget sender ) |
825 |
|
- |
// { |
826 |
|
- |
// if ( mAltDown ) |
827 |
|
- |
// { |
828 |
|
- |
// mFloater.expandToMaxWidth(); |
829 |
|
- |
// } |
830 |
|
- |
// else |
831 |
|
- |
// { |
832 |
|
- |
// mFloater.increaseWidthBy( |
833 |
|
- |
// mSizeTextbox.getTextboxValue() ); |
834 |
|
- |
// } |
835 |
|
- |
// updateStatus(); |
836 |
|
- |
// } |
837 |
|
- |
// } ); |
838 |
|
- |
// imageButton.addMouseListener( new MouseListenerAdapter() |
839 |
|
- |
// { |
840 |
|
- |
// public void onMouseDown( Widget sender, int x, int y ) |
841 |
|
- |
// { |
842 |
|
- |
// startIncreaseWidthTimer(); |
843 |
|
- |
// } |
844 |
|
- |
// |
845 |
|
- |
// public void onMouseUp( Widget sender, int x, int y ) |
846 |
|
- |
// { |
847 |
|
- |
// stopTimer(); |
848 |
|
- |
// } |
849 |
|
- |
// } ); |
850 |
|
- |
return null; // todo: translate: imageButton; |
851 |
|
- |
} |
852 |
|
- |
|
853 |
|
- |
private Widget createSizeHorizontalMinusButton() { |
854 |
|
- |
// BGImageButton imageButton = new BGImageButton( "FloaterSizeHorizontalMinus", |
855 |
|
- |
// "Click to Decrease Width;\nAlt-Click to Set Exact Width;", |
856 |
|
- |
// new ClickListener() |
857 |
|
- |
// { |
858 |
|
- |
// public void onClick( Widget sender ) |
859 |
|
- |
// { |
860 |
|
- |
// if ( mAltDown ) |
861 |
|
- |
// { |
862 |
|
- |
// mFloater.setWidth( |
863 |
|
- |
// mSizeTextbox.getTextboxValue() ); |
864 |
|
- |
// } |
865 |
|
- |
// else |
866 |
|
- |
// { |
867 |
|
- |
// mFloater.decreaseWidthBy( |
868 |
|
- |
// mSizeTextbox.getTextboxValue() ); |
869 |
|
- |
// } |
870 |
|
- |
// updateStatus(); |
871 |
|
- |
// } |
872 |
|
- |
// } ); |
873 |
|
- |
// imageButton.addMouseListener( new MouseListenerAdapter() |
874 |
|
- |
// { |
875 |
|
- |
// public void onMouseDown( Widget sender, int x, int y ) |
876 |
|
- |
// { |
877 |
|
- |
// startDecreaseWidthTimer(); |
878 |
|
- |
// } |
879 |
|
- |
// |
880 |
|
- |
// public void onMouseUp( Widget sender, int x, int y ) |
881 |
|
- |
// { |
882 |
|
- |
// stopTimer(); |
883 |
|
- |
// } |
884 |
|
- |
// } ); |
885 |
|
- |
return null; // todo: translate: imageButton; |
886 |
|
- |
} |
887 |
|
- |
|
888 |
|
- |
private Widget createSizeVerticalPlusButton() { |
889 |
|
- |
// BGImageButton imageButton = new BGImageButton( "FloaterSizeVerticalPlus", |
890 |
|
- |
// "Click to Increase Height;\nAlt-Click to Resize Height to Bottom Window Border;", |
891 |
|
- |
// new ClickListener() |
892 |
|
- |
// { |
893 |
|
- |
// public void onClick( Widget sender ) |
894 |
|
- |
// { |
895 |
|
- |
// if ( mAltDown ) |
896 |
|
- |
// { |
897 |
|
- |
// mFloater.expandToMaxHeight(); |
898 |
|
- |
// } |
899 |
|
- |
// else |
900 |
|
- |
// { |
901 |
|
- |
// mFloater.increaseHeightBy( |
902 |
|
- |
// mSizeTextbox.getTextboxValue() ); |
903 |
|
- |
// } |
904 |
|
- |
// updateStatus(); |
905 |
|
- |
// } |
906 |
|
- |
// } ); |
907 |
|
- |
// imageButton.addMouseListener( new MouseListenerAdapter() |
908 |
|
- |
// { |
909 |
|
- |
// public void onMouseDown( Widget sender, int x, int y ) |
910 |
|
- |
// { |
911 |
|
- |
// startIncreaseHeightTimer(); |
912 |
|
- |
// } |
913 |
|
- |
// |
914 |
|
- |
// public void onMouseUp( Widget sender, int x, int y ) |
915 |
|
- |
// { |
916 |
|
- |
// stopTimer(); |
917 |
|
- |
// } |
918 |
|
- |
// } ); |
919 |
|
- |
return null; // todo: translate: imageButton; |
920 |
|
- |
} |
921 |
|
- |
|
922 |
|
- |
private Widget createSizeVerticalMinusButton() { |
923 |
|
- |
// BGImageButton imageButton = new BGImageButton( "FloaterSizeVerticalMinus", |
924 |
|
- |
// "Click to Decrease Height;\nAlt-Click to Set Exact Height;", |
925 |
|
- |
// new ClickListener() |
926 |
|
- |
// { |
927 |
|
- |
// public void onClick( Widget sender ) |
928 |
|
- |
// { |
929 |
|
- |
// if ( mAltDown ) |
930 |
|
- |
// { |
931 |
|
- |
// mFloater.setHeight( |
932 |
|
- |
// mSizeTextbox.getTextboxValue() ); |
933 |
|
- |
// } |
934 |
|
- |
// else |
935 |
|
- |
// { |
936 |
|
- |
// mFloater.decreaseHeightBy( |
937 |
|
- |
// mSizeTextbox.getTextboxValue() ); |
938 |
|
- |
// } |
939 |
|
- |
// updateStatus(); |
940 |
|
- |
// } |
941 |
|
- |
// } ); |
942 |
|
- |
// imageButton.addMouseListener( new MouseListenerAdapter() |
943 |
|
- |
// { |
944 |
|
- |
// public void onMouseDown( Widget sender, int x, int y ) |
945 |
|
- |
// { |
946 |
|
- |
// startDecreaseHeightTimer(); |
947 |
|
- |
// } |
948 |
|
- |
// |
949 |
|
- |
// public void onMouseUp( Widget sender, int x, int y ) |
950 |
|
- |
// { |
951 |
|
- |
// stopTimer(); |
952 |
|
- |
// } |
953 |
|
- |
// } ); |
954 |
|
- |
return null; // todo: translate: imageButton; |
955 |
|
- |
} |
956 |
|
- |
|
957 |
|
- |
private Widget createSizeDiagonalPlusButton() { |
958 |
|
- |
// BGImageButton imageButton = new BGImageButton( "FloaterSizeDiagonalPlus", |
959 |
|
- |
// "Click to Increase Width & Height;\nAlt-Click to Resize Width & Height Bottom Right Window Corner;", |
960 |
|
- |
// new ClickListener() |
961 |
|
- |
// { |
962 |
|
- |
// public void onClick( Widget sender ) |
963 |
|
- |
// { |
964 |
|
- |
// if ( mAltDown ) |
965 |
|
- |
// { |
966 |
|
- |
// mFloater.expandToMaxWidth(); |
967 |
|
- |
// mFloater.expandToMaxHeight(); |
968 |
|
- |
// } |
969 |
|
- |
// else |
970 |
|
- |
// { |
971 |
|
- |
// int zBy = mSizeTextbox.getTextboxValue(); |
972 |
|
- |
// mFloater.increaseWidthBy( zBy ); |
973 |
|
- |
// mFloater.increaseHeightBy( zBy ); |
974 |
|
- |
// } |
975 |
|
- |
// updateStatus(); |
976 |
|
- |
// } |
977 |
|
- |
// } ); |
978 |
|
- |
// imageButton.addMouseListener( new MouseListenerAdapter() |
979 |
|
- |
// { |
980 |
|
- |
// public void onMouseDown( Widget sender, int x, int y ) |
981 |
|
- |
// { |
982 |
|
- |
// startIncreaseDiagonalTimer(); |
983 |
|
- |
// } |
984 |
|
- |
// |
985 |
|
- |
// public void onMouseUp( Widget sender, int x, int y ) |
986 |
|
- |
// { |
987 |
|
- |
// stopTimer(); |
988 |
|
- |
// } |
989 |
|
- |
// } ); |
990 |
|
- |
return null; // todo: translate: imageButton; |
991 |
|
- |
} |
992 |
|
- |
|
993 |
|
- |
private Widget createSizeDiagonalMinusButton() { |
994 |
|
- |
// BGImageButton imageButton = new BGImageButton( "FloaterSizeDiagonalMinus", |
995 |
|
- |
// "Click to Decrease Width & Height;\nAlt-Click to Set Exact Width & Height;", |
996 |
|
- |
// new ClickListener() |
997 |
|
- |
// { |
998 |
|
- |
// public void onClick( Widget sender ) |
999 |
|
- |
// { |
1000 |
|
- |
// int zBy = mSizeTextbox.getTextboxValue(); |
1001 |
|
- |
// if ( mAltDown ) |
1002 |
|
- |
// { |
1003 |
|
- |
// mFloater.setWidth( zBy ); |
1004 |
|
- |
// mFloater.setHeight( zBy ); |
1005 |
|
- |
// } |
1006 |
|
- |
// else |
1007 |
|
- |
// { |
1008 |
|
- |
// mFloater.decreaseWidthBy( zBy ); |
1009 |
|
- |
// mFloater.decreaseHeightBy( zBy ); |
1010 |
|
- |
// } |
1011 |
|
- |
// updateStatus(); |
1012 |
|
- |
// } |
1013 |
|
- |
// } ); |
1014 |
|
- |
// imageButton.addMouseListener( new MouseListenerAdapter() |
1015 |
|
- |
// { |
1016 |
|
- |
// public void onMouseDown( Widget sender, int x, int y ) |
1017 |
|
- |
// { |
1018 |
|
- |
// startDecreaseDiagonalTimer(); |
1019 |
|
- |
// } |
1020 |
|
- |
// |
1021 |
|
- |
// public void onMouseUp( Widget sender, int x, int y ) |
1022 |
|
- |
// { |
1023 |
|
- |
// stopTimer(); |
1024 |
|
- |
// } |
1025 |
|
- |
// } ); |
1026 |
|
- |
return null; // todo: translate: imageButton; |
1027 |
|
- |
} |
1028 |
|
- |
|
1029 |
|
- |
private static class TextBoxHelper implements ChangeListener, |
1030 |
|
- |
FocusListener { |
1031 |
|
- |
public static final String FIELD_STATE_REGULAR = "FMSD-Field-NotChanged"; |
1032 |
|
- |
public static final String FIELD_STATE_CHANGED = "FMSD-Field-Changed"; |
1033 |
|
- |
|
1034 |
|
- |
public static final String[] WRAPPER_STATES = new String[] // |
1035 |
|
- |
{ // |
1036 |
|
- |
"FMSD-Wrapper-NotFocused-NotErrored", // 0 |
1037 |
|
- |
"FMSD-Wrapper-Focused-NotErrored", // 1 |
1038 |
|
- |
"FMSD-Wrapper-NotFocused-Errored", // 2 |
1039 |
|
- |
"FMSD-Wrapper-Focused-Errored", // 3 |
1040 |
|
- |
}; |
1041 |
|
- |
|
1042 |
|
- |
private boolean mFocused, mErrored, mChanged; // = false; |
1043 |
|
- |
|
1044 |
|
- |
private SimplePanel mWrapper = new SimplePanel(); |
1045 |
|
- |
private TextBoxChangeListenable mTextBox = new TextBoxChangeListenable(); |
1046 |
|
- |
private String mLastWrapperState = null; |
1047 |
|
- |
|
1048 |
|
- |
private void updateState() { |
1049 |
|
- |
String zNewWrapperState = WRAPPER_STATES[(mErrored ? 2 : 0) + (mFocused ? 1 : 0)]; |
1050 |
|
- |
if ( !zNewWrapperState.equals( mLastWrapperState ) ) { |
1051 |
|
- |
if ( mLastWrapperState != null ) { |
1052 |
|
- |
mWrapper.removeStyleName( mLastWrapperState ); |
1053 |
|
- |
} |
1054 |
|
- |
mWrapper.addStyleName( mLastWrapperState = zNewWrapperState ); |
1055 |
|
- |
} |
1056 |
|
- |
BackDoorToWidget.manageStyle( mTextBox, mChanged, FIELD_STATE_CHANGED, FIELD_STATE_REGULAR ); |
1057 |
|
- |
} |
1058 |
|
- |
|
1059 |
|
- |
private void setFocused( boolean pFocused ) { |
1060 |
|
- |
if ( mFocused != pFocused ) { |
1061 |
|
- |
mFocused = pFocused; |
1062 |
|
- |
updateState(); |
1063 |
|
- |
} |
1064 |
|
- |
} |
1065 |
|
- |
|
1066 |
|
- |
private void setErrored( boolean pErrored ) { |
1067 |
|
- |
if ( mErrored != pErrored ) { |
1068 |
|
- |
mErrored = pErrored; |
1069 |
|
- |
updateState(); |
1070 |
|
- |
} |
1071 |
|
- |
} |
1072 |
|
- |
|
1073 |
|
- |
private void setChanged( boolean pChanged ) { |
1074 |
|
- |
if ( mChanged != pChanged ) { |
1075 |
|
- |
mChanged = pChanged; |
1076 |
|
- |
updateState(); |
1077 |
|
- |
} |
1078 |
|
- |
} |
1079 |
|
- |
|
1080 |
|
- |
public TextBoxHelper( String pStyle ) { |
1081 |
|
- |
mWrapper.setWidget( mTextBox ); |
1082 |
|
- |
|
1083 |
|
- |
mTextBox.addStyleName( pStyle ); |
1084 |
|
- |
mTextBox.setText( "1" ); |
1085 |
|
- |
mTextBox.setTextAlignment( TextBoxBase.ALIGN_RIGHT ); |
1086 |
|
- |
|
1087 |
|
- |
mTextBox.addChangeListener( this ); |
1088 |
|
- |
mTextBox.addFocusListener( this ); |
1089 |
|
- |
|
1090 |
|
- |
updateState(); |
1091 |
|
- |
} |
1092 |
|
- |
|
1093 |
|
- |
public Widget getWidget() { |
1094 |
|
- |
return mWrapper; |
1095 |
|
- |
} |
1096 |
|
- |
|
1097 |
|
- |
public int getTextboxValue() { |
1098 |
|
- |
String zCurValue = getFilteredTextValue(); |
1099 |
|
- |
if ( zCurValue != null ) { |
1100 |
|
- |
try { |
1101 |
|
- |
return Integer.parseInt( zCurValue ); |
1102 |
|
- |
} |
1103 |
|
- |
catch ( NumberFormatException e ) { |
1104 |
|
- |
// Expected on Bad input |
1105 |
|
- |
} |
1106 |
|
- |
} |
1107 |
|
- |
return -1; |
1108 |
|
- |
} |
1109 |
|
- |
|
1110 |
|
- |
private String getFilteredTextValue() { |
1111 |
|
- |
String zOrig = Strings.deNull( mTextBox.getText() ); |
1112 |
|
- |
StringBuilder zStr = new StringBuilder( zOrig ); |
1113 |
|
- |
if ( zStr.length() == 0 ) { |
1114 |
|
- |
zStr.append( '1' ); |
1115 |
|
- |
} else { |
1116 |
|
- |
for ( int i = 0; i < zStr.length(); i++ ) { |
1117 |
|
- |
if ( !Characters.isNumeric( zStr.charAt( i ) ) ) { |
1118 |
|
- |
zStr.setCharAt( i, '?' ); |
1119 |
|
- |
} |
1120 |
|
- |
} |
1121 |
|
- |
} |
1122 |
|
- |
String zFiltered = zStr.toString(); |
1123 |
|
- |
if ( !zFiltered.equals( zOrig ) ) { |
1124 |
|
- |
mTextBox.setText( zFiltered ); |
1125 |
|
- |
} |
1126 |
|
- |
return zFiltered; |
1127 |
|
- |
} |
1128 |
|
- |
|
1129 |
|
- |
public void onChange( Widget sender ) { |
1130 |
|
- |
int zValue = getTextboxValue(); |
1131 |
|
- |
setChanged( zValue != 1 ); |
1132 |
|
- |
setErrored( zValue < 1 ); |
1133 |
|
- |
} |
1134 |
|
- |
|
1135 |
|
- |
public void onFocus( Widget sender ) { |
1136 |
|
- |
setFocused( true ); |
1137 |
|
- |
} |
1138 |
|
- |
|
1139 |
|
- |
public void onLostFocus( Widget sender ) { |
1140 |
|
- |
setFocused( false ); |
1141 |
|
- |
} |
1142 |
|
- |
} |
1143 |
|
- |
} |
|
1 |
+ |
// This Source Code is in the Public Domain per: http://unlicense.org |
|
2 |
+ |
package org.litesoft.GWT.client.nonpublic; |
|
3 |
+ |
|
|
4 |
+ |
import org.litesoft.GWT.client.widgets.*; |
|
5 |
+ |
import org.litesoft.commonfoundation.base.*; |
|
6 |
+ |
import org.litesoft.commonfoundation.typeutils.*; |
|
7 |
+ |
import org.litesoft.configuration.*; |
|
8 |
+ |
|
|
9 |
+ |
import com.google.gwt.user.client.*; |
|
10 |
+ |
import com.google.gwt.user.client.ui.*; |
|
11 |
+ |
import com.google.gwt.user.client.ui.Button; |
|
12 |
+ |
|
|
13 |
+ |
public class FloaterMoveSizeDialog extends AbstractDialog { |
|
14 |
+ |
// vvvvvvvvvv These can only be static cause there is only expected to be one at any one time vvvvvvvv // |
|
15 |
+ |
|
|
16 |
+ |
private static final String PINNED_ID = "PinnedID"; |
|
17 |
+ |
private static final String ANCHOR_RIGHT_ID = "AnchorRightID"; |
|
18 |
+ |
private static final String ANCHOR_BOTTOM_ID = "AnchorBottomID"; |
|
19 |
+ |
|
|
20 |
+ |
private static final String MOVE_UP_ID = "MoveUpID"; |
|
21 |
+ |
private static final String MOVE_DOWN_ID = "MoveDownID"; |
|
22 |
+ |
private static final String MOVE_LEFT_ID = "MoveLeftID"; |
|
23 |
+ |
private static final String MOVE_RIGHT_ID = "MoveRightID"; |
|
24 |
+ |
private static final String MOVE_LEFT_UP_ID = "MoveLeftUpID"; |
|
25 |
+ |
private static final String MOVE_RIGHT_UP_ID = "MoveRightUpID"; |
|
26 |
+ |
private static final String MOVE_LEFT_DOWN_ID = "MoveLeftDownID"; |
|
27 |
+ |
private static final String MOVE_RIGHT_DOWN_ID = "MoveRightDownID"; |
|
28 |
+ |
private static final String MOVE_TEXTBOX_ID = "MoveTextboxID"; |
|
29 |
+ |
|
|
30 |
+ |
private static final String MOVE_CONTROL_INNER_HTML_ID = "MoveControlInnerHtmlID"; |
|
31 |
+ |
|
|
32 |
+ |
private static final String MOVE_CONTROL_INNER_HTML = // |
|
33 |
+ |
"<table cellpadding='0' cellspacing='0' border='0'><tr><td id=" + MOVE_LEFT_UP_ID + |
|
34 |
+ |
" align='center'></td><td id=" + MOVE_UP_ID + " align='center'></td><td id=" + MOVE_RIGHT_UP_ID + |
|
35 |
+ |
" align='center'></td></tr><tr><td id=" + MOVE_LEFT_ID + " align='center'></td><td id=" + |
|
36 |
+ |
MOVE_TEXTBOX_ID + "></td><td id=" + MOVE_RIGHT_ID + " align='center'></td></tr><tr><td id=" + |
|
37 |
+ |
MOVE_LEFT_DOWN_ID + " align='center'></td><td id=" + MOVE_DOWN_ID + |
|
38 |
+ |
" align='center'></td><td id=" + MOVE_RIGHT_DOWN_ID + " align='center'></td></tr></table>"; |
|
39 |
+ |
|
|
40 |
+ |
private static final String MOVE_CONTROL_HTML = // |
|
41 |
+ |
"<table cellpadding='0' cellspacing='0' border='0'><tr><td id=" + PINNED_ID + "></td>" + |
|
42 |
+ |
"<td></td><td></td></tr><tr><td></td><td>" + |
|
43 |
+ |
"<table cellpadding='0' cellspacing='0' border='0'><tr><td id=" + MOVE_CONTROL_INNER_HTML_ID + |
|
44 |
+ |
"></td></tr></table></td><td id=" + ANCHOR_RIGHT_ID + "></td></tr><tr><td></td><td id=" + |
|
45 |
+ |
ANCHOR_BOTTOM_ID + " align='center'></td><td></td></tr></table>"; |
|
46 |
+ |
|
|
47 |
+ |
private static final String SIZE_HORIZONTAL_PLUS_ID = "SizeHorizontalPlusID"; |
|
48 |
+ |
private static final String SIZE_HORIZONTAL_MINUS_ID = "SizeHorizontalMinusID"; |
|
49 |
+ |
private static final String SIZE_VERTICAL_PLUS_ID = "SizeVerticalPlusID"; |
|
50 |
+ |
private static final String SIZE_VERTICAL_MINUS_ID = "SizeVerticalMinusID"; |
|
51 |
+ |
private static final String SIZE_DIAGONAL_PLUS_ID = "SizeDiagonalPlusID"; |
|
52 |
+ |
private static final String SIZE_DIAGONAL_MINUS_ID = "SizeDiagonalMinusID"; |
|
53 |
+ |
private static final String SIZE_TEXTBOX_ID = "SizeTextboxID"; |
|
54 |
+ |
|
|
55 |
+ |
private static final String SIZE_CONTROL_HTML = // |
|
56 |
+ |
"<table cellpadding='0' cellspacing='0' border='0'><tr><td id=" + SIZE_TEXTBOX_ID + |
|
57 |
+ |
"></td><td id=" + SIZE_HORIZONTAL_MINUS_ID + " style='padding-left:1px;'></td><td id=" + |
|
58 |
+ |
SIZE_HORIZONTAL_PLUS_ID + " style='padding-left:2px;'></td></tr><tr><td id=" + |
|
59 |
+ |
SIZE_VERTICAL_MINUS_ID + " style='padding-bottom:0px;'></td>" + |
|
60 |
+ |
"<td colspan='2' rowspan='2' style='padding-left:0px;' valign='top'>" + |
|
61 |
+ |
"<table cellpadding='0' cellspacing='0' border='0'><tr><td id=" + SIZE_DIAGONAL_MINUS_ID + |
|
62 |
+ |
"></td><td></td></tr><tr><td></td><td id=" + SIZE_DIAGONAL_PLUS_ID + "></td></tr></table>" + |
|
63 |
+ |
"</td><td></td></tr><tr><td id=" + SIZE_VERTICAL_PLUS_ID + " style='padding-top:2px;'></td>" + |
|
64 |
+ |
"<td></td><td></td></tr></table>"; |
|
65 |
+ |
|
|
66 |
+ |
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ // |
|
67 |
+ |
|
|
68 |
+ |
private SimpleLabel mCurPosition = new SimpleLabel().style( "simpleLabel" ); |
|
69 |
+ |
private SimpleLabel mCurSize = new SimpleLabel().style( "simpleLabel" ); |
|
70 |
+ |
private SimpleLabel mContentSize = new SimpleLabel().style( "simpleLabel" ); |
|
71 |
+ |
|
|
72 |
+ |
private CheckBox mChromeCheckbox; |
|
73 |
+ |
|
|
74 |
+ |
private TextBoxHelper mSizeTextbox = new TextBoxHelper( "SizeTextbox" ); |
|
75 |
+ |
private TextBoxHelper mMoveTextbox = new TextBoxHelper( "MoveTextbox" ); |
|
76 |
+ |
|
|
77 |
+ |
private SimplePanel mMoveControlInnerHtmlPanel = new SimplePanel(); |
|
78 |
+ |
|
|
79 |
+ |
private SizeableHorizontalPanel mControlsPanel = new SizeableHorizontalPanel( true ).style( "reg" ); |
|
80 |
+ |
|
|
81 |
+ |
IFloaterPanelMoveAndSize mFloater; |
|
82 |
+ |
|
|
83 |
+ |
private boolean mNoChromeOrPinning = SimpleMapConfiguration.getBoolean( "TurnOffChromeAndPinning", false ); |
|
84 |
+ |
|
|
85 |
+ |
public FloaterMoveSizeDialog( String pDefaultTitle, IFloaterPanelMoveAndSize pFloater ) { |
|
86 |
+ |
super( pDefaultTitle, Opaqueness.None ); |
|
87 |
+ |
|
|
88 |
+ |
mFloater = pFloater; |
|
89 |
+ |
|
|
90 |
+ |
mChromeCheckbox = new CheckBox( "Chrome" ); |
|
91 |
+ |
mChromeCheckbox.setChecked( mFloater.isChromed() ); |
|
92 |
+ |
mChromeCheckbox.addClickListener( new ClickListener() { |
|
93 |
+ |
public void onClick( Widget sender ) { |
|
94 |
+ |
mFloater.setChromed( !mFloater.isChromed() ); |
|
95 |
+ |
|
|
96 |
+ |
updateChromeBorderIndicator(); |
|
97 |
+ |
} |
|
98 |
+ |
} ); |
|
99 |
+ |
|
|
100 |
+ |
updateStatus(); |
|
101 |
+ |
} |
|
102 |
+ |
|
|
103 |
+ |
private void updateChromeBorderIndicator() { |
|
104 |
+ |
BackDoorToWidget.manageStyle( mMoveControlInnerHtmlPanel, mFloater.isChromed(), |
|
105 |
+ |
"MoveControlInnerPanelBorder", "MoveControlInnerPanelNoBorder" ); |
|
106 |
+ |
} |
|
107 |
+ |
|
|
108 |
+ |
private void updateBottomAnchor() { |
|
109 |
+ |
BackDoorToWidget.manageStyle( mControlsPanel, mFloater.isBottomAnchor(), // |
|
110 |
+ |
"bottomAnchored", "bottomUnanchored" ); |
|
111 |
+ |
} |
|
112 |
+ |
|
|
113 |
+ |
private void updateRightAnchor() { |
|
114 |
+ |
BackDoorToWidget.manageStyle( mControlsPanel, mFloater.isRightAnchor(), // |
|
115 |
+ |
"rightAnchored", "rightUnanchored" ); |
|
116 |
+ |
} |
|
117 |
+ |
|
|
118 |
+ |
private void updatePinButton() { |
|
119 |
+ |
BackDoorToWidget.manageStyle( mControlsPanel, mFloater.isPinned(), "pinned", "unpinned" ); |
|
120 |
+ |
} |
|
121 |
+ |
|
|
122 |
+ |
private void updateAltState() { |
|
123 |
+ |
BackDoorToWidget.manageStyle( mControlsPanel, mAltDown, "alt", "reg" ); |
|
124 |
+ |
} |
|
125 |
+ |
|
|
126 |
+ |
private boolean mAltDown = false; |
|
127 |
+ |
|
|
128 |
+ |
private void setAltState( boolean pAltDown ) { |
|
129 |
+ |
if ( mAltDown != pAltDown ) { |
|
130 |
+ |
mAltDown = pAltDown; |
|
131 |
+ |
|
|
132 |
+ |
updateAltState(); |
|
133 |
+ |
} |
|
134 |
+ |
} |
|
135 |
+ |
|
|
136 |
+ |
public boolean onKeyDownPreview( char key, int modifiers ) { |
|
137 |
+ |
if ( 0 != (modifiers & KeyboardListener.MODIFIER_ALT) ) { |
|
138 |
+ |
setAltState( true ); |
|
139 |
+ |
} |
|
140 |
+ |
return super.onKeyDownPreview( key, modifiers ); |
|
141 |
+ |
} |
|
142 |
+ |
|
|
143 |
+ |
public boolean onKeyUpPreview( char key, int modifiers ) { |
|
144 |
+ |
if ( 0 == (modifiers & KeyboardListener.MODIFIER_ALT) ) { |
|
145 |
+ |
setAltState( false ); |
|
146 |
+ |
} |
|
147 |
+ |
return super.onKeyUpPreview( key, modifiers ); |
|
148 |
+ |
} |
|
149 |
+ |
|
|
150 |
+ |
protected Widget createBodyPanel() { |
|
151 |
+ |
SizeableVerticalPanel zPanel = new SizeableVerticalPanel( true ).stretchable(); |
|
152 |
+ |
|
|
153 |
+ |
SizeableTitledBorderedSimplePanel zStatusFieldset = |
|
154 |
+ |
new SizeableTitledBorderedSimplePanel( true, "Status" ).stretchableHorizontally(); |
|
155 |
+ |
zStatusFieldset.add( createStatusGrid() ); |
|
156 |
+ |
|
|
157 |
+ |
zPanel.add( zStatusFieldset ); |
|
158 |
+ |
zPanel.add( createControlsPanel() ); |
|
159 |
+ |
|
|
160 |
+ |
zPanel.setHorizontalAlignment( HasHorizontalAlignment.ALIGN_CENTER ); |
|
161 |
+ |
zPanel.add( new Button( "Close", new ClickListener() { |
|
162 |
+ |
public void onClick( Widget sender ) { |
|
163 |
+ |
hide(); |
|
164 |
+ |
} |
|
165 |
+ |
} ) ); |
|
166 |
+ |
|
|
167 |
+ |
return zPanel; |
|
168 |
+ |
} |
|
169 |
+ |
|
|
170 |
+ |
private Grid createStatusGrid() { |
|
171 |
+ |
final IFloaterPanelMoveAndSize[] zFloaters = mFloater.getAllFloaters(); |
|
172 |
+ |
final ListBox zBox = new ListBox(); |
|
173 |
+ |
zBox.setWidth( "120" ); |
|
174 |
+ |
|
|
175 |
+ |
for ( int i = 0; i < zFloaters.length; i++ ) { |
|
176 |
+ |
IFloaterPanelMoveAndSize zFloater = zFloaters[i]; |
|
177 |
+ |
zBox.addItem( zFloater.getCurrentTitle(), "" + i ); |
|
178 |
+ |
} |
|
179 |
+ |
|
|
180 |
+ |
zBox.addChangeListener( new ChangeListener() { |
|
181 |
+ |
public void onChange( Widget sender ) { |
|
182 |
+ |
setActiveAndUpdateStatus( zBox, zFloaters ); |
|
183 |
+ |
} |
|
184 |
+ |
} ); |
|
185 |
+ |
|
|
186 |
+ |
Grid zStatusGrid = new Grid( 5, 2 ); |
|
187 |
+ |
zStatusGrid.setWidget( 0, 0, new SimpleLabel( "Title:" ).style( "simpleLabel" ) ); |
|
188 |
+ |
zStatusGrid.setWidget( 0, 1, zBox ); |
|
189 |
+ |
zStatusGrid.setWidget( 1, 0, new SimpleLabel( "Current Position:" ).style( "simpleLabel" ) ); |
|
190 |
+ |
zStatusGrid.setWidget( 1, 1, mCurPosition ); |
|
191 |
+ |
zStatusGrid.setWidget( 2, 0, new SimpleLabel( "Current Size:" ).style( "simpleLabel" ) ); |
|
192 |
+ |
zStatusGrid.setWidget( 2, 1, mCurSize ); |
|
193 |
+ |
zStatusGrid.setWidget( 3, 0, new SimpleLabel( "Content Size:" ).style( "simpleLabel" ) ); |
|
194 |
+ |
zStatusGrid.setWidget( 3, 1, mContentSize ); |
|
195 |
+ |
if ( mNoChromeOrPinning ) { |
|
196 |
+ |
zStatusGrid.setWidget( 4, 0, new Spacer( 5 ) ); |
|
197 |
+ |
} else { |
|
198 |
+ |
zStatusGrid.setWidget( 4, 0, mChromeCheckbox ); |
|
199 |
+ |
} |
|
200 |
+ |
|
|
201 |
+ |
int zIndexForValue = getIndexForValue( zFloaters, mFloater.getCurrentTitle() ); |
|
202 |
+ |
if ( zIndexForValue >= 0 ) { |
|
203 |
+ |
zBox.setSelectedIndex( zIndexForValue ); |
|
204 |
+ |
} |
|
205 |
+ |
|
|
206 |
+ |
return zStatusGrid; |
|
207 |
+ |
} |
|
208 |
+ |
|
|
209 |
+ |
private void setActiveAndUpdateStatus( ListBox pBox, IFloaterPanelMoveAndSize[] pFloaters ) { |
|
210 |
+ |
String zIndxValue = pBox.getValue( pBox.getSelectedIndex() ); |
|
211 |
+ |
int zIntIndx = Integer.parseInt( zIndxValue ); |
|
212 |
+ |
mFloater = pFloaters[zIntIndx]; |
|
213 |
+ |
mFloater.setActive(); |
|
214 |
+ |
updateStatus(); |
|
215 |
+ |
setTitle( mFloater.getCurrentTitle() ); |
|
216 |
+ |
} |
|
217 |
+ |
|
|
218 |
+ |
private int getIndexForValue( IFloaterPanelMoveAndSize[] pFloaters, String pValue ) { |
|
219 |
+ |
int rv = -1; |
|
220 |
+ |
for ( int i = 0; i < pFloaters.length; i++ ) { |
|
221 |
+ |
IFloaterPanelMoveAndSize myFloater = pFloaters[i]; |
|
222 |
+ |
if ( pValue.equals( myFloater.getCurrentTitle() ) ) { |
|
223 |
+ |
rv = i; |
|
224 |
+ |
} |
|
225 |
+ |
} |
|
226 |
+ |
return rv; |
|
227 |
+ |
} |
|
228 |
+ |
|
|
229 |
+ |
private SizeableHorizontalPanel createControlsPanel() { |
|
230 |
+ |
mControlsPanel.add( createFieldset( "Move", createMoveControl() ) ); |
|
231 |
+ |
mControlsPanel.add( createFieldset( "Size", createSizeControl() ) ); |
|
232 |
+ |
|
|
233 |
+ |
return mControlsPanel.stretchable(); |
|
234 |
+ |
} |
|
235 |
+ |
|
|
236 |
+ |
private SizeableTitledBorderedVerticalPanel createFieldset( String pTitle, HTMLPanel pPanel ) { |
|
237 |
+ |
SizeableTitledBorderedVerticalPanel fieldset = |
|
238 |
+ |
new SizeableTitledBorderedVerticalPanel( true, pTitle ).style( |
|
239 |
+ |
"MoveSizeFieldset" ).stretchable(); |
|
240 |
+ |
|
|
241 |
+ |
DOM.setStyleAttribute( fieldset.getElement(), "textAlign", "center" ); |
|
242 |
+ |
fieldset.add( new SizeableSpacer().stretchableVertically() ); |
|
243 |
+ |
fieldset.add( pPanel ); |
|
244 |
+ |
fieldset.add( new SizeableSpacer().stretchableVertically() ); |
|
245 |
+ |
|
|
246 |
+ |
return fieldset; |
|
247 |
+ |
} |
|
248 |
+ |
|
|
249 |
+ |
private void updateStatus() { |
|
250 |
+ |
mCurPosition.setText( "x:" + mFloater.getPosLeft() + "; y:" + mFloater.getPosTop() ); |
|
251 |
+ |
mCurSize.setText( "w:" + mFloater.getOffsetWidth() + "; h:" + mFloater.getOffsetHeight() ); |
|
252 |
+ |
mContentSize.setText( "w:" + (mFloater.getContentSize()).getIntWidth() + "; h:" + |
|
253 |
+ |
(mFloater.getContentSize()).getIntHeight() ); |
|
254 |
+ |
updatePinButton(); |
|
255 |
+ |
updateRightAnchor(); |
|
256 |
+ |
updateBottomAnchor(); |
|
257 |
+ |
updateChromeBorderIndicator(); |
|
258 |
+ |
} |
|
259 |
+ |
|
|
260 |
+ |
private HTMLPanel createMoveControl() { |
|
261 |
+ |
HTMLPanel innerHTMLPanel = new HTMLPanel( MOVE_CONTROL_INNER_HTML ); |
|
262 |
+ |
|
|
263 |
+ |
innerHTMLPanel.add( mMoveTextbox.getWidget(), MOVE_TEXTBOX_ID ); |
|
264 |
+ |
|
|
265 |
+ |
innerHTMLPanel.add( createMoveUpButton(), MOVE_UP_ID ); |
|
266 |
+ |
innerHTMLPanel.add( createMoveDownButton(), MOVE_DOWN_ID ); |
|
267 |
+ |
innerHTMLPanel.add( createMoveLeftButton(), MOVE_LEFT_ID ); |
|
268 |
+ |
innerHTMLPanel.add( createMoveRightButton(), MOVE_RIGHT_ID ); |
|
269 |
+ |
|
|
270 |
+ |
innerHTMLPanel.add( createMoveLeftUpButton(), MOVE_LEFT_UP_ID ); |
|
271 |
+ |
innerHTMLPanel.add( createMoveRightUpButton(), MOVE_RIGHT_UP_ID ); |
|
272 |
+ |
innerHTMLPanel.add( createMoveLeftDownButton(), MOVE_LEFT_DOWN_ID ); |
|
273 |
+ |
innerHTMLPanel.add( createMoveRightDownButton(), MOVE_RIGHT_DOWN_ID ); |
|
274 |
+ |
|
|
275 |
+ |
mMoveControlInnerHtmlPanel.add( innerHTMLPanel ); |
|
276 |
+ |
|
|
277 |
+ |
HTMLPanel panel = new HTMLPanel( MOVE_CONTROL_HTML ); |
|
278 |
+ |
|
|
279 |
+ |
if ( mNoChromeOrPinning ) { |
|
280 |
+ |
panel.add( new Spacer( 5 ), PINNED_ID ); |
|
281 |
+ |
panel.add( mMoveControlInnerHtmlPanel, MOVE_CONTROL_INNER_HTML_ID ); |
|
282 |
+ |
panel.add( new Spacer( 5 ), ANCHOR_RIGHT_ID ); |
|
283 |
+ |
panel.add( new Spacer( 5 ), ANCHOR_BOTTOM_ID ); |
|
284 |
+ |
} else { |
|
285 |
+ |
panel.add( createPinnedButton(), PINNED_ID ); |
|
286 |
+ |
panel.add( mMoveControlInnerHtmlPanel, MOVE_CONTROL_INNER_HTML_ID ); |
|
287 |
+ |
panel.add( createAnchorRightButton(), ANCHOR_RIGHT_ID ); |
|
288 |
+ |
panel.add( createAnchorBottomButton(), ANCHOR_BOTTOM_ID ); |
|
289 |
+ |
} |
|
290 |
+ |
return panel; |
|
291 |
+ |
} |
|
292 |
+ |
|
|
293 |
+ |
private Widget createPinnedButton() { |
|
294 |
+ |
return null; // todo: translate: |
|
295 |
+ |
// new BGImageButton( "FloaterPushPin", "Pin to This Position;", new ClickListener() |
|
296 |
+ |
// { |
|
297 |
+ |
// public void onClick( Widget sender ) |
|
298 |
+ |
// { |
|
299 |
+ |
// mFloater.setPinned( !mFloater.isPinned() ); |
|
300 |
+ |
// |
|
301 |
+ |
// updatePinButton(); |
|
302 |
+ |
// } |
|
303 |
+ |
// } ); |
|
304 |
+ |
} |
|
305 |
+ |
|
|
306 |
+ |
private Widget createAnchorRightButton() { |
|
307 |
+ |
return null; // todo: translate: |
|
308 |
+ |
// new BGImageButton( "FloaterAnchorRight", "Anchor to Right Window Border;", new ClickListener() |
|
309 |
+ |
// { |
|
310 |
+ |
// public void onClick( Widget sender ) |
|
311 |
+ |
// { |
|
312 |
+ |
// mFloater.setRightAnchor( !mFloater.isRightAnchor() ); |
|
313 |
+ |
// |
|
314 |
+ |
// updateRightAnchor(); |
|
315 |
+ |
// } |
|
316 |
+ |
// } ); |
|
317 |
+ |
} |
|
318 |
+ |
|
|
319 |
+ |
private Widget createAnchorBottomButton() { |
|
320 |
+ |
return null; // todo: translate: |
|
321 |
+ |
// new BGImageButton( "FloaterAnchorBottom", "Anchor to Bottom Window Border;", |
|
322 |
+ |
// new ClickListener() |
|
323 |
+ |
// { |
|
324 |
+ |
// public void onClick( Widget sender ) |
|
325 |
+ |
// { |
|
326 |
+ |
// mFloater.setBottomAnchor( !mFloater.isBottomAnchor() ); |
|
327 |
+ |
// |
|
328 |
+ |
// updateBottomAnchor(); |
|
329 |
+ |
// } |
|
330 |
+ |
// } ); |
|
331 |
+ |
} |
|
332 |
+ |
|
|
333 |
+ |
private MyTimer mTimer = null; |
|
334 |
+ |
|
|
335 |
+ |
private void start_N_Timer() { |
|
336 |
+ |
mTimer = new MoveNorthTimer(); |
|
337 |
+ |
mTimer.init(); |
|
338 |
+ |
} |
|
339 |
+ |
|
|
340 |
+ |
private void start_S_Timer() { |
|
341 |
+ |
mTimer = new MoveSouthTimer(); |
|
342 |
+ |
mTimer.init(); |
|
343 |
+ |
} |
|
344 |
+ |
|
|
345 |
+ |
private void start_W_Timer() { |
|
346 |
+ |
mTimer = new MoveWestTimer(); |
|
347 |
+ |
mTimer.init(); |
|
348 |
+ |
} |
|
349 |
+ |
|
|
350 |
+ |
private void start_E_Timer() { |
|
351 |
+ |
mTimer = new MoveEastTimer(); |
|
352 |
+ |
mTimer.init(); |
|
353 |
+ |
} |
|
354 |
+ |
|
|
355 |
+ |
private void start_NW_Timer() { |
|
356 |
+ |
mTimer = new MoveNorthWestTimer(); |
|
357 |
+ |
mTimer.init(); |
|
358 |
+ |
} |
|
359 |
+ |
|
|
360 |
+ |
private void start_NE_Timer() { |
|
361 |
+ |
mTimer = new MoveNorthEastTimer(); |
|
362 |
+ |
mTimer.init(); |
|
363 |
+ |
} |
|
364 |
+ |
|
|
365 |
+ |
private void start_SW_Timer() { |
|
366 |
+ |
mTimer = new MoveSouthWestTimer(); |
|
367 |
+ |
mTimer.init(); |
|
368 |
+ |
} |
|
369 |
+ |
|
|
370 |
+ |
private void start_SE_Timer() { |
|
371 |
+ |
mTimer = new MoveSouthEastTimer(); |
|
372 |
+ |
mTimer.init(); |
|
373 |
+ |
} |
|
374 |
+ |
|
|
375 |
+ |
private void startIncreaseWidthTimer() { |
|
376 |
+ |
mTimer = new IncreaseWidthTimer(); |
|
377 |
+ |
mTimer.init(); |
|
378 |
+ |
} |
|
379 |
+ |
|
|
380 |
+ |
private void startDecreaseWidthTimer() { |
|
381 |
+ |
mTimer = new DecreaseWidthTimer(); |
|
382 |
+ |
mTimer.init(); |
|
383 |
+ |
} |
|
384 |
+ |
|
|
385 |
+ |
private void startIncreaseHeightTimer() { |
|
386 |
+ |
mTimer = new IncreaseHeightTimer(); |
|
387 |
+ |
mTimer.init(); |
|
388 |
+ |
} |
|
389 |
+ |
|
|
390 |
+ |
private void startDecreaseHeightTimer() { |
|
391 |
+ |
mTimer = new DecreaseHeightTimer(); |
|
392 |
+ |
mTimer.init(); |
|
393 |
+ |
} |
|
394 |
+ |
|
|
395 |
+ |
private void startIncreaseDiagonalTimer() { |
|
396 |
+ |
mTimer = new IncreaseDiagonalTimer(); |
|
397 |
+ |
mTimer.init(); |
|
398 |
+ |
} |
|
399 |
+ |
|
|
400 |
+ |
private void startDecreaseDiagonalTimer() { |
|
401 |
+ |
mTimer = new DecreaseDiagonalTimer(); |
|
402 |
+ |
mTimer.init(); |
|
403 |
+ |
} |
|
404 |
+ |
|
|
405 |
+ |
private void stopTimer() { |
|
406 |
+ |
if ( mTimer != null ) { |
|
407 |
+ |
mTimer.cancel(); |
|
408 |
+ |
} |
|
409 |
+ |
} |
|
410 |
+ |
|
|
411 |
+ |
private abstract class MyTimer extends Timer { |
|
412 |
+ |
public static final int MIN_DELAY = 25; |
|
413 |
+ |
public static final int DELAY_ADJUST = 10; |
|
414 |
+ |
|
|
415 |
+ |
private int mDelay; |
|
416 |
+ |
|
|
417 |
+ |
public void init() { |
|
418 |
+ |
schedule( mDelay = 200 ); |
|
419 |
+ |
} |
|
420 |
+ |
|
|
421 |
+ |
public void run() { |
|
422 |
+ |
adjustValue(); |
|
423 |
+ |
if ( (mDelay -= DELAY_ADJUST) < MIN_DELAY ) { |
|
424 |
+ |
mDelay = MIN_DELAY; |
|
425 |
+ |
} |
|
426 |
+ |
schedule( mDelay ); |
|
427 |
+ |
} |
|
428 |
+ |
|
|
429 |
+ |
public abstract void adjustValue(); |
|
430 |
+ |
} |
|
431 |
+ |
|
|
432 |
+ |
private class MoveNorthTimer extends MyTimer { |
|
433 |
+ |
public void adjustValue() { |
|
434 |
+ |
mFloater.moveN( mMoveTextbox.getTextboxValue() ); |
|
435 |
+ |
updateStatus(); |
|
436 |
+ |
} |
|
437 |
+ |
} |
|
438 |
+ |
|
|
439 |
+ |
private class MoveSouthTimer extends MyTimer { |
|
440 |
+ |
public void adjustValue() { |
|
441 |
+ |
mFloater.moveS( mMoveTextbox.getTextboxValue() ); |
|
442 |
+ |
updateStatus(); |
|
443 |
+ |
} |
|
444 |
+ |
} |
|
445 |
+ |
|
|
446 |
+ |
private class MoveWestTimer extends MyTimer { |
|
447 |
+ |
public void adjustValue() { |
|
448 |
+ |
mFloater.moveW( mMoveTextbox.getTextboxValue() ); |
|
449 |
+ |
updateStatus(); |
|
450 |
+ |
} |
|
451 |
+ |
} |
|
452 |
+ |
|
|
453 |
+ |
private class MoveEastTimer extends MyTimer { |
|
454 |
+ |
public void adjustValue() { |
|
455 |
+ |
mFloater.moveE( mMoveTextbox.getTextboxValue() ); |
|
456 |
+ |
updateStatus(); |
|
457 |
+ |
} |
|
458 |
+ |
} |
|
459 |
+ |
|
|
460 |
+ |
private class MoveNorthWestTimer extends MyTimer { |
|
461 |
+ |
public void adjustValue() { |
|
462 |
+ |
mFloater.moveNW( mMoveTextbox.getTextboxValue() ); |
|
463 |
+ |
updateStatus(); |
|
464 |
+ |
} |
|
465 |
+ |
} |
|
466 |
+ |
|
|
467 |
+ |
private class MoveNorthEastTimer extends MyTimer { |
|
468 |
+ |
public void adjustValue() { |
|
469 |
+ |
mFloater.moveNE( mMoveTextbox.getTextboxValue() ); |
|
470 |
+ |
updateStatus(); |
|
471 |
+ |
} |
|
472 |
+ |
} |
|
473 |
+ |
|
|
474 |
+ |
private class MoveSouthWestTimer extends MyTimer { |
|
475 |
+ |
public void adjustValue() { |
|
476 |
+ |
mFloater.moveSW( mMoveTextbox.getTextboxValue() ); |
|
477 |
+ |
updateStatus(); |
|
478 |
+ |
} |
|
479 |
+ |
} |
|
480 |
+ |
|
|
481 |
+ |
private class MoveSouthEastTimer extends MyTimer { |
|
482 |
+ |
public void adjustValue() { |
|
483 |
+ |
mFloater.moveSE( mMoveTextbox.getTextboxValue() ); |
|
484 |
+ |
updateStatus(); |
|
485 |
+ |
} |
|
486 |
+ |
} |
|
487 |
+ |
|
|
488 |
+ |
private class IncreaseWidthTimer extends MyTimer { |
|
489 |
+ |
public void adjustValue() { |
|
490 |
+ |
mFloater.increaseWidthBy( mSizeTextbox.getTextboxValue() ); |
|
491 |
+ |
updateStatus(); |
|
492 |
+ |
} |
|
493 |
+ |
} |
|
494 |
+ |
|
|
495 |
+ |
private class DecreaseWidthTimer extends MyTimer { |
|
496 |
+ |
public void adjustValue() { |
|
497 |
+ |
mFloater.decreaseWidthBy( mSizeTextbox.getTextboxValue() ); |
|
498 |
+ |
updateStatus(); |
|
499 |
+ |
} |
|
500 |
+ |
} |
|
501 |
+ |
|
|
502 |
+ |
private class IncreaseHeightTimer extends MyTimer { |
|
503 |
+ |
public void adjustValue() { |
|
504 |
+ |
mFloater.increaseHeightBy( mSizeTextbox.getTextboxValue() ); |
|
505 |
+ |
updateStatus(); |
|
506 |
+ |
} |
|
507 |
+ |
} |
|
508 |
+ |
|
|
509 |
+ |
private class DecreaseHeightTimer extends MyTimer { |
|
510 |
+ |
public void adjustValue() { |
|
511 |
+ |
mFloater.decreaseHeightBy( mSizeTextbox.getTextboxValue() ); |
|
512 |
+ |
updateStatus(); |
|
513 |
+ |
} |
|
514 |
+ |
} |
|
515 |
+ |
|
|
516 |
+ |
private class IncreaseDiagonalTimer extends MyTimer { |
|
517 |
+ |
public void adjustValue() { |
|
518 |
+ |
mFloater.increaseWidthBy( mSizeTextbox.getTextboxValue() ); |
|
519 |
+ |
mFloater.increaseHeightBy( mSizeTextbox.getTextboxValue() ); |
|
520 |
+ |
updateStatus(); |
|
521 |
+ |
} |
|
522 |
+ |
} |
|
523 |
+ |
|
|
524 |
+ |
private class DecreaseDiagonalTimer extends MyTimer { |
|
525 |
+ |
public void adjustValue() { |
|
526 |
+ |
mFloater.decreaseWidthBy( mSizeTextbox.getTextboxValue() ); |
|
527 |
+ |
mFloater.decreaseHeightBy( mSizeTextbox.getTextboxValue() ); |
|
528 |
+ |
updateStatus(); |
|
529 |
+ |
} |
|
530 |
+ |
} |
|
531 |
+ |
|
|
532 |
+ |
private Widget createMoveUpButton() { |
|
533 |
+ |
// BGImageButton imageButton = new BGImageButton( "FloaterMoveUp", |
|
534 |
+ |
// "Click to Move Up;\nAlt-Click to Move to Top Window Border;", |
|
535 |
+ |
// new ClickListener() |
|
536 |
+ |
// { |
|
537 |
+ |
// public void onClick( Widget sender ) |
|
538 |
+ |
// { |
|
539 |
+ |
// if ( mAltDown ) |
|
540 |
+ |
// { |
|
541 |
+ |
// mFloater.moveToMaxN(); |
|
542 |
+ |
// } |
|
543 |
+ |
// else |
|
544 |
+ |
// { |
|
545 |
+ |
// mFloater.moveN( |
|
546 |
+ |
// mMoveTextbox.getTextboxValue() ); |
|
547 |
+ |
// } |
|
548 |
+ |
// updateStatus(); |
|
549 |
+ |
// } |
|
550 |
+ |
// } ); |
|
551 |
+ |
// imageButton.addMouseListener( new MouseListenerAdapter() |
|
552 |
+ |
// { |
|
553 |
+ |
// public void onMouseDown( Widget sender, int x, int y ) |
|
554 |
+ |
// { |
|
555 |
+ |
// start_N_Timer(); |
|
556 |
+ |
// } |
|
557 |
+ |
// |
|
558 |
+ |
// public void onMouseUp( Widget sender, int x, int y ) |
|
559 |
+ |
// { |
|
560 |
+ |
// stopTimer(); |
|
561 |
+ |
// } |
|
562 |
+ |
// } ); |
|
563 |
+ |
// |
|
564 |
+ |
return null; // todo: translate: imageButton; |
|
565 |
+ |
} |
|
566 |
+ |
|
|
567 |
+ |
private Widget createMoveDownButton() { |
|
568 |
+ |
// BGImageButton imageButton = new BGImageButton( "FloaterMoveDown", |
|
569 |
+ |
// "Click to Move Down;\nAlt-Click to Move to Bottom Window Border;", |
|
570 |
+ |
// new ClickListener() |
|
571 |
+ |
// { |
|
572 |
+ |
// public void onClick( Widget sender ) |
|
573 |
+ |
// { |
|
574 |
+ |
// if ( mAltDown ) |
|
575 |
+ |
// { |
|
576 |
+ |
// mFloater.moveToMaxS(); |
|
577 |
+ |
// } |
|
578 |
+ |
// else |
|
579 |
+ |
// { |
|
580 |
+ |
// mFloater.moveS( |
|
581 |
+ |
// mMoveTextbox.getTextboxValue() ); |
|
582 |
+ |
// } |
|
583 |
+ |
// updateStatus(); |
|
584 |
+ |
// } |
|
585 |
+ |
// } ); |
|
586 |
+ |
// imageButton.addMouseListener( new MouseListenerAdapter() |
|
587 |
+ |
// { |
|
588 |
+ |
// public void onMouseDown( Widget sender, int x, int y ) |
|
589 |
+ |
// { |
|
590 |
+ |
// start_S_Timer(); |
|
591 |
+ |
// } |
|
592 |
+ |
// |
|
593 |
+ |
// public void onMouseUp( Widget sender, int x, int y ) |
|
594 |
+ |
// { |
|
595 |
+ |
// stopTimer(); |
|
596 |
+ |
// } |
|
597 |
+ |
// } ); |
|
598 |
+ |
return null; // todo: translate: imageButton; |
|
599 |
+ |
} |
|
600 |
+ |
|
|
601 |
+ |
private Widget createMoveLeftButton() { |
|
602 |
+ |
// BGImageButton imageButton = new BGImageButton( "FloaterMoveLeft", |
|
603 |
+ |
// "Click to Move Left;\nAlt-Click to Move to Left Window Border;", |
|
604 |
+ |
// new ClickListener() |
|
605 |
+ |
// { |
|
606 |
+ |
// public void onClick( Widget sender ) |
|
607 |
+ |
// { |
|
608 |
+ |
// if ( mAltDown ) |
|
609 |
+ |
// { |
|
610 |
+ |
// mFloater.moveToMaxW(); |
|
611 |
+ |
// } |
|
612 |
+ |
// else |
|
613 |
+ |
// { |
|
614 |
+ |
// mFloater.moveW( |
|
615 |
+ |
// mMoveTextbox.getTextboxValue() ); |
|
616 |
+ |
// } |
|
617 |
+ |
// updateStatus(); |
|
618 |
+ |
// } |
|
619 |
+ |
// } ); |
|
620 |
+ |
// imageButton.addMouseListener( new MouseListenerAdapter() |
|
621 |
+ |
// { |
|
622 |
+ |
// public void onMouseDown( Widget sender, int x, int y ) |
|
623 |
+ |
// { |
|
624 |
+ |
// start_W_Timer(); |
|
625 |
+ |
// } |
|
626 |
+ |
// |
|
627 |
+ |
// public void onMouseUp( Widget sender, int x, int y ) |
|
628 |
+ |
// { |
|
629 |
+ |
// stopTimer(); |
|
630 |
+ |
// } |
|
631 |
+ |
// } ); |
|
632 |
+ |
return null; // todo: translate: imageButton; |
|
633 |
+ |
} |
|
634 |
+ |
|
|
635 |
+ |
private Widget createMoveRightButton() { |
|
636 |
+ |
// BGImageButton imageButton = new BGImageButton( "FloaterMoveRight", |
|
637 |
+ |
// "Click to Move Right;\nAlt-Click to Move to Right Window Border;", |
|
638 |
+ |
// new ClickListener() |
|
639 |
+ |
// { |
|
640 |
+ |
// public void onClick( Widget sender ) |
|
641 |
+ |
// { |
|
642 |
+ |
// if ( mAltDown ) |
|
643 |
+ |
// { |
|
644 |
+ |
// mFloater.moveToMaxE(); |
|
645 |
+ |
// } |
|
646 |
+ |
// else |
|
647 |
+ |
// { |
|
648 |
+ |
// mFloater.moveE( |
|
649 |
+ |
// mMoveTextbox.getTextboxValue() ); |
|
650 |
+ |
// } |
|
651 |
+ |
// updateStatus(); |
|
652 |
+ |
// } |
|
653 |
+ |
// } ); |
|
654 |
+ |
// imageButton.addMouseListener( new MouseListenerAdapter() |
|
655 |
+ |
// { |
|
656 |
+ |
// public void onMouseDown( Widget sender, int x, int y ) |
|
657 |
+ |
// { |
|
658 |
+ |
// start_E_Timer(); |
|
659 |
+ |
// } |
|
660 |
+ |
// |
|
661 |
+ |
// public void onMouseUp( Widget sender, int x, int y ) |
|
662 |
+ |
// { |
|
663 |
+ |
// stopTimer(); |
|
664 |
+ |
// } |
|
665 |
+ |
// } ); |
|
666 |
+ |
return null; // todo: translate: imageButton; |
|
667 |
+ |
} |
|
668 |
+ |
|
|
669 |
+ |
private Widget createMoveLeftUpButton() { |
|
670 |
+ |
// BGImageButton imageButton = new BGImageButton( "FloaterMoveLeftUp", |
|
671 |
+ |
// "Click to Move Top Left;\nAlt-Click to Move to Top Left Corner of Window;", |
|
672 |
+ |
// new ClickListener() |
|
673 |
+ |
// { |
|
674 |
+ |
// public void onClick( Widget sender ) |
|
675 |
+ |
// { |
|
676 |
+ |
// if ( mAltDown ) |
|
677 |
+ |
// { |
|
678 |
+ |
// mFloater.moveToMaxNW(); |
|
679 |
+ |
// } |
|
680 |
+ |
// else |
|
681 |
+ |
// { |
|
682 |
+ |
// mFloater.moveNW( |
|
683 |
+ |
// mMoveTextbox.getTextboxValue() ); |
|
684 |
+ |
// } |
|
685 |
+ |
// updateStatus(); |
|
686 |
+ |
// } |
|
687 |
+ |
// } ); |
|
688 |
+ |
// imageButton.addMouseListener( new MouseListenerAdapter() |
|
689 |
+ |
// { |
|
690 |
+ |
// public void onMouseDown( Widget sender, int x, int y ) |
|
691 |
+ |
// { |
|
692 |
+ |
// start_NW_Timer(); |
|
693 |
+ |
// } |
|
694 |
+ |
// |
|
695 |
+ |
// public void onMouseUp( Widget sender, int x, int y ) |
|
696 |
+ |
// { |
|
697 |
+ |
// stopTimer(); |
|
698 |
+ |
// } |
|
699 |
+ |
// } ); |
|
700 |
+ |
return null; // todo: translate: imageButton; |
|
701 |
+ |
} |
|
702 |
+ |
|
|
703 |
+ |
private Widget createMoveRightUpButton() { |
|
704 |
+ |
// BGImageButton imageButton = new BGImageButton( "FloaterMoveRightUp", |
|
705 |
+ |
// "Click to Move Top Right;\nAlt-Click to Move to Top Right Corner of Window;", |
|
706 |
+ |
// new ClickListener() |
|
707 |
+ |
// { |
|
708 |
+ |
// public void onClick( Widget sender ) |
|
709 |
+ |
// { |
|
710 |
+ |
// if ( mAltDown ) |
|
711 |
+ |
// { |
|
712 |
+ |
// mFloater.moveToMaxNE(); |
|
713 |
+ |
// } |
|
714 |
+ |
// else |
|
715 |
+ |
// { |
|
716 |
+ |
// mFloater.moveNE( |
|
717 |
+ |
// mMoveTextbox.getTextboxValue() ); |
|
718 |
+ |
// } |
|
719 |
+ |
// updateStatus(); |
|
720 |
+ |
// } |
|
721 |
+ |
// } ); |
|
722 |
+ |
// imageButton.addMouseListener( new MouseListenerAdapter() |
|
723 |
+ |
// { |
|
724 |
+ |
// public void onMouseDown( Widget sender, int x, int y ) |
|
725 |
+ |
// { |
|
726 |
+ |
// start_NE_Timer(); |
|
727 |
+ |
// } |
|
728 |
+ |
// |
|
729 |
+ |
// public void onMouseUp( Widget sender, int x, int y ) |
|
730 |
+ |
// { |
|
731 |
+ |
// stopTimer(); |
|
732 |
+ |
// } |
|
733 |
+ |
// } ); |
|
734 |
+ |
return null; // todo: translate: imageButton; |
|
735 |
+ |
} |
|
736 |
+ |
|
|
737 |
+ |
private Widget createMoveLeftDownButton() { |
|
738 |
+ |
// BGImageButton imageButton = new BGImageButton( "FloaterMoveLeftDown", |
|
739 |
+ |
// "Click to Move Bottom Left;\nAlt-Click to Move to Bottom Left Corner of Window;", |
|
740 |
+ |
// new ClickListener() |
|
741 |
+ |
// { |
|
742 |
+ |
// public void onClick( Widget sender ) |
|
743 |
+ |
// { |
|
744 |
+ |
// if ( mAltDown ) |
|
745 |
+ |
// { |
|
746 |
+ |
// mFloater.moveToMaxSW(); |
|
747 |
+ |
// } |
|
748 |
+ |
// else |
|
749 |
+ |
// { |
|
750 |
+ |
// mFloater.moveSW( |
|
751 |
+ |
// mMoveTextbox.getTextboxValue() ); |
|
752 |
+ |
// } |
|
753 |
+ |
// updateStatus(); |
|
754 |
+ |
// } |
|
755 |
+ |
// } ); |
|
756 |
+ |
// imageButton.addMouseListener( new MouseListenerAdapter() |
|
757 |
+ |
// { |
|
758 |
+ |
// public void onMouseDown( Widget sender, int x, int y ) |
|
759 |
+ |
// { |
|
760 |
+ |
// start_SW_Timer(); |
|
761 |
+ |
// } |
|
762 |
+ |
// |
|
763 |
+ |
// public void onMouseUp( Widget sender, int x, int y ) |
|
764 |
+ |
// { |
|
765 |
+ |
// stopTimer(); |
|
766 |
+ |
// } |
|
767 |
+ |
// } ); |
|
768 |
+ |
return null; // todo: translate: imageButton; |
|
769 |
+ |
} |
|
770 |
+ |
|
|
771 |
+ |
private Widget createMoveRightDownButton() { |
|
772 |
+ |
// BGImageButton imageButton = new BGImageButton( "FloaterMoveRightDown", |
|
773 |
+ |
// "Click to Move Bottom Right;\nAlt-Click to Move to Bottom Right Corner of Window;", |
|
774 |
+ |
// new ClickListener() |
|
775 |
+ |
// { |
|
776 |
+ |
// public void onClick( Widget sender ) |
|
777 |
+ |
// { |
|
778 |
+ |
// if ( mAltDown ) |
|
779 |
+ |
// { |
|
780 |
+ |
// mFloater.moveToMaxSE(); |
|
781 |
+ |
// } |
|
782 |
+ |
// else |
|
783 |
+ |
// { |
|
784 |
+ |
// mFloater.moveSE( |
|
785 |
+ |
// mMoveTextbox.getTextboxValue() ); |
|
786 |
+ |
// } |
|
787 |
+ |
// updateStatus(); |
|
788 |
+ |
// } |
|
789 |
+ |
// } ); |
|
790 |
+ |
// imageButton.addMouseListener( new MouseListenerAdapter() |
|
791 |
+ |
// { |
|
792 |
+ |
// public void onMouseDown( Widget sender, int x, int y ) |
|
793 |
+ |
// { |
|
794 |
+ |
// start_SE_Timer(); |
|
795 |
+ |
// } |
|
796 |
+ |
// |
|
797 |
+ |
// public void onMouseUp( Widget sender, int x, int y ) |
|
798 |
+ |
// { |
|
799 |
+ |
// stopTimer(); |
|
800 |
+ |
// } |
|
801 |
+ |
// } ); |
|
802 |
+ |
return null; // todo: translate: imageButton; |
|
803 |
+ |
} |
|
804 |
+ |
|
|
805 |
+ |
private HTMLPanel createSizeControl() { |
|
806 |
+ |
HTMLPanel panel = new HTMLPanel( SIZE_CONTROL_HTML ); |
|
807 |
+ |
|
|
808 |
+ |
panel.add( mSizeTextbox.getWidget(), SIZE_TEXTBOX_ID ); |
|
809 |
+ |
|
|
810 |
+ |
panel.add( createSizeHorizontalPlusButton(), SIZE_HORIZONTAL_PLUS_ID ); |
|
811 |
+ |
panel.add( createSizeHorizontalMinusButton(), SIZE_HORIZONTAL_MINUS_ID ); |
|
812 |
+ |
panel.add( createSizeVerticalPlusButton(), SIZE_VERTICAL_PLUS_ID ); |
|
813 |
+ |
panel.add( createSizeVerticalMinusButton(), SIZE_VERTICAL_MINUS_ID ); |
|
814 |
+ |
panel.add( createSizeDiagonalPlusButton(), SIZE_DIAGONAL_PLUS_ID ); |
|
815 |
+ |
panel.add( createSizeDiagonalMinusButton(), SIZE_DIAGONAL_MINUS_ID ); |
|
816 |
+ |
|
|
817 |
+ |
return panel; |
|
818 |
+ |
} |
|
819 |
+ |
|
|
820 |
+ |
private Widget createSizeHorizontalPlusButton() { |
|
821 |
+ |
// BGImageButton imageButton = new BGImageButton( "FloaterSizeHorizontalPlus", |
|
822 |
+ |
// "Click to Increase Width;\nAlt-Click to Resize Width to Right Window Border;", |
|
823 |
+ |
// new ClickListener() |
|
824 |
+ |
// { |
|
825 |
+ |
// public void onClick( Widget sender ) |
|
826 |
+ |
// { |
|
827 |
+ |
// if ( mAltDown ) |
|
828 |
+ |
// { |
|
829 |
+ |
// mFloater.expandToMaxWidth(); |
|
830 |
+ |
// } |
|
831 |
+ |
// else |
|
832 |
+ |
// { |
|
833 |
+ |
// mFloater.increaseWidthBy( |
|
834 |
+ |
// mSizeTextbox.getTextboxValue() ); |
|
835 |
+ |
// } |
|
836 |
+ |
// updateStatus(); |
|
837 |
+ |
// } |
|
838 |
+ |
// } ); |
|
839 |
+ |
// imageButton.addMouseListener( new MouseListenerAdapter() |
|
840 |
+ |
// { |
|
841 |
+ |
// public void onMouseDown( Widget sender, int x, int y ) |
|
842 |
+ |
// { |
|
843 |
+ |
// startIncreaseWidthTimer(); |
|
844 |
+ |
// } |
|
845 |
+ |
// |
|
846 |
+ |
// public void onMouseUp( Widget sender, int x, int y ) |
|
847 |
+ |
// { |
|
848 |
+ |
// stopTimer(); |
|
849 |
+ |
// } |
|
850 |
+ |
// } ); |
|
851 |
+ |
return null; // todo: translate: imageButton; |
|
852 |
+ |
} |
|
853 |
+ |
|
|
854 |
+ |
private Widget createSizeHorizontalMinusButton() { |
|
855 |
+ |
// BGImageButton imageButton = new BGImageButton( "FloaterSizeHorizontalMinus", |
|
856 |
+ |
// "Click to Decrease Width;\nAlt-Click to Set Exact Width;", |
|
857 |
+ |
// new ClickListener() |
|
858 |
+ |
// { |
|
859 |
+ |
// public void onClick( Widget sender ) |
|
860 |
+ |
// { |
|
861 |
+ |
// if ( mAltDown ) |
|
862 |
+ |
// { |
|
863 |
+ |
// mFloater.setWidth( |
|
864 |
+ |
// mSizeTextbox.getTextboxValue() ); |
|
865 |
+ |
// } |
|
866 |
+ |
// else |
|
867 |
+ |
// { |
|
868 |
+ |
// mFloater.decreaseWidthBy( |
|
869 |
+ |
// mSizeTextbox.getTextboxValue() ); |
|
870 |
+ |
// } |
|
871 |
+ |
// updateStatus(); |
|
872 |
+ |
// } |
|
873 |
+ |
// } ); |
|
874 |
+ |
// imageButton.addMouseListener( new MouseListenerAdapter() |
|
875 |
+ |
// { |
|
876 |
+ |
// public void onMouseDown( Widget sender, int x, int y ) |
|
877 |
+ |
// { |
|
878 |
+ |
// startDecreaseWidthTimer(); |
|
879 |
+ |
// } |
|
880 |
+ |
// |
|
881 |
+ |
// public void onMouseUp( Widget sender, int x, int y ) |
|
882 |
+ |
// { |
|
883 |
+ |
// stopTimer(); |
|
884 |
+ |
// } |
|
885 |
+ |
// } ); |
|
886 |
+ |
return null; // todo: translate: imageButton; |
|
887 |
+ |
} |
|
888 |
+ |
|
|
889 |
+ |
private Widget createSizeVerticalPlusButton() { |
|
890 |
+ |
// BGImageButton imageButton = new BGImageButton( "FloaterSizeVerticalPlus", |
|
891 |
+ |
// "Click to Increase Height;\nAlt-Click to Resize Height to Bottom Window Border;", |
|
892 |
+ |
// new ClickListener() |
|
893 |
+ |
// { |
|
894 |
+ |
// public void onClick( Widget sender ) |
|
895 |
+ |
// { |
|
896 |
+ |
// if ( mAltDown ) |
|
897 |
+ |
// { |
|
898 |
+ |
// mFloater.expandToMaxHeight(); |
|
899 |
+ |
// } |
|
900 |
+ |
// else |
|
901 |
+ |
// { |
|
902 |
+ |
// mFloater.increaseHeightBy( |
|
903 |
+ |
// mSizeTextbox.getTextboxValue() ); |
|
904 |
+ |
// } |
|
905 |
+ |
// updateStatus(); |
|
906 |
+ |
// } |
|
907 |
+ |
// } ); |
|
908 |
+ |
// imageButton.addMouseListener( new MouseListenerAdapter() |
|
909 |
+ |
// { |
|
910 |
+ |
// public void onMouseDown( Widget sender, int x, int y ) |
|
911 |
+ |
// { |
|
912 |
+ |
// startIncreaseHeightTimer(); |
|
913 |
+ |
// } |
|
914 |
+ |
// |
|
915 |
+ |
// public void onMouseUp( Widget sender, int x, int y ) |
|
916 |
+ |
// { |
|
917 |
+ |
// stopTimer(); |
|
918 |
+ |
// } |
|
919 |
+ |
// } ); |
|
920 |
+ |
return null; // todo: translate: imageButton; |
|
921 |
+ |
} |
|
922 |
+ |
|
|
923 |
+ |
private Widget createSizeVerticalMinusButton() { |
|
924 |
+ |
// BGImageButton imageButton = new BGImageButton( "FloaterSizeVerticalMinus", |
|
925 |
+ |
// "Click to Decrease Height;\nAlt-Click to Set Exact Height;", |
|
926 |
+ |
// new ClickListener() |
|
927 |
+ |
// { |
|
928 |
+ |
// public void onClick( Widget sender ) |
|
929 |
+ |
// { |
|
930 |
+ |
// if ( mAltDown ) |
|
931 |
+ |
// { |
|
932 |
+ |
// mFloater.setHeight( |
|
933 |
+ |
// mSizeTextbox.getTextboxValue() ); |
|
934 |
+ |
// } |
|
935 |
+ |
// else |
|
936 |
+ |
// { |
|
937 |
+ |
// mFloater.decreaseHeightBy( |
|
938 |
+ |
// mSizeTextbox.getTextboxValue() ); |
|
939 |
+ |
// } |
|
940 |
+ |
// updateStatus(); |
|
941 |
+ |
// } |
|
942 |
+ |
// } ); |
|
943 |
+ |
// imageButton.addMouseListener( new MouseListenerAdapter() |
|
944 |
+ |
// { |
|
945 |
+ |
// public void onMouseDown( Widget sender, int x, int y ) |
|
946 |
+ |
// { |
|
947 |
+ |
// startDecreaseHeightTimer(); |
|
948 |
+ |
// } |
|
949 |
+ |
// |
|
950 |
+ |
// public void onMouseUp( Widget sender, int x, int y ) |
|
951 |
+ |
// { |
|
952 |
+ |
// stopTimer(); |
|
953 |
+ |
// } |
|
954 |
+ |
// } ); |
|
955 |
+ |
return null; // todo: translate: imageButton; |
|
956 |
+ |
} |
|
957 |
+ |
|
|
958 |
+ |
private Widget createSizeDiagonalPlusButton() { |
|
959 |
+ |
// BGImageButton imageButton = new BGImageButton( "FloaterSizeDiagonalPlus", |
|
960 |
+ |
// "Click to Increase Width & Height;\nAlt-Click to Resize Width & Height Bottom Right Window Corner;", |
|
961 |
+ |
// new ClickListener() |
|
962 |
+ |
// { |
|
963 |
+ |
// public void onClick( Widget sender ) |
|
964 |
+ |
// { |
|
965 |
+ |
// if ( mAltDown ) |
|
966 |
+ |
// { |
|
967 |
+ |
// mFloater.expandToMaxWidth(); |
|
968 |
+ |
// mFloater.expandToMaxHeight(); |
|
969 |
+ |
// } |
|
970 |
+ |
// else |
|
971 |
+ |
// { |
|
972 |
+ |
// int zBy = mSizeTextbox.getTextboxValue(); |
|
973 |
+ |
// mFloater.increaseWidthBy( zBy ); |
|
974 |
+ |
// mFloater.increaseHeightBy( zBy ); |
|
975 |
+ |
// } |
|
976 |
+ |
// updateStatus(); |
|
977 |
+ |
// } |
|
978 |
+ |
// } ); |
|
979 |
+ |
// imageButton.addMouseListener( new MouseListenerAdapter() |
|
980 |
+ |
// { |
|
981 |
+ |
// public void onMouseDown( Widget sender, int x, int y ) |
|
982 |
+ |
// { |
|
983 |
+ |
// startIncreaseDiagonalTimer(); |
|
984 |
+ |
// } |
|
985 |
+ |
// |
|
986 |
+ |
// public void onMouseUp( Widget sender, int x, int y ) |
|
987 |
+ |
// { |
|
988 |
+ |
// stopTimer(); |
|
989 |
+ |
// } |
|
990 |
+ |
// } ); |
|
991 |
+ |
return null; // todo: translate: imageButton; |
|
992 |
+ |
} |
|
993 |
+ |
|
|
994 |
+ |
private Widget createSizeDiagonalMinusButton() { |
|
995 |
+ |
// BGImageButton imageButton = new BGImageButton( "FloaterSizeDiagonalMinus", |
|
996 |
+ |
// "Click to Decrease Width & Height;\nAlt-Click to Set Exact Width & Height;", |
|
997 |
+ |
// new ClickListener() |
|
998 |
+ |
// { |
|
999 |
+ |
// public void onClick( Widget sender ) |
|
1000 |
+ |
// { |
|
1001 |
+ |
// int zBy = mSizeTextbox.getTextboxValue(); |
|
1002 |
+ |
// if ( mAltDown ) |
|
1003 |
+ |
// { |
|
1004 |
+ |
// mFloater.setWidth( zBy ); |
|
1005 |
+ |
// mFloater.setHeight( zBy ); |
|
1006 |
+ |
// } |
|
1007 |
+ |
// else |
|
1008 |
+ |
// { |
|
1009 |
+ |
// mFloater.decreaseWidthBy( zBy ); |
|
1010 |
+ |
// mFloater.decreaseHeightBy( zBy ); |
|
1011 |
+ |
// } |
|
1012 |
+ |
// updateStatus(); |
|
1013 |
+ |
// } |
|
1014 |
+ |
// } ); |
|
1015 |
+ |
// imageButton.addMouseListener( new MouseListenerAdapter() |
|
1016 |
+ |
// { |
|
1017 |
+ |
// public void onMouseDown( Widget sender, int x, int y ) |
|
1018 |
+ |
// { |
|
1019 |
+ |
// startDecreaseDiagonalTimer(); |
|
1020 |
+ |
// } |
|
1021 |
+ |
// |
|
1022 |
+ |
// public void onMouseUp( Widget sender, int x, int y ) |
|
1023 |
+ |
// { |
|
1024 |
+ |
// stopTimer(); |
|
1025 |
+ |
// } |
|
1026 |
+ |
// } ); |
|
1027 |
+ |
return null; // todo: translate: imageButton; |
|
1028 |
+ |
} |
|
1029 |
+ |
|
|
1030 |
+ |
private static class TextBoxHelper implements ChangeListener, |
|
1031 |
+ |
FocusListener { |
|
1032 |
+ |
public static final String FIELD_STATE_REGULAR = "FMSD-Field-NotChanged"; |
|
1033 |
+ |
public static final String FIELD_STATE_CHANGED = "FMSD-Field-Changed"; |
|
1034 |
+ |
|
|
1035 |
+ |
public static final String[] WRAPPER_STATES = new String[] // |
|
1036 |
+ |
{ // |
|
1037 |
+ |
"FMSD-Wrapper-NotFocused-NotErrored", // 0 |
|
1038 |
+ |
"FMSD-Wrapper-Focused-NotErrored", // 1 |
|
1039 |
+ |
"FMSD-Wrapper-NotFocused-Errored", // 2 |
|
1040 |
+ |
"FMSD-Wrapper-Focused-Errored", // 3 |
|
1041 |
+ |
}; |
|
1042 |
+ |
|
|
1043 |
+ |
private boolean mFocused, mErrored, mChanged; // = false; |
|
1044 |
+ |
|
|
1045 |
+ |
private SimplePanel mWrapper = new SimplePanel(); |
|
1046 |
+ |
private TextBoxChangeListenable mTextBox = new TextBoxChangeListenable(); |
|
1047 |
+ |
private String mLastWrapperState = null; |
|
1048 |
+ |
|
|
1049 |
+ |
private void updateState() { |
|
1050 |
+ |
String zNewWrapperState = WRAPPER_STATES[(mErrored ? 2 : 0) + (mFocused ? 1 : 0)]; |
|
1051 |
+ |
if ( !zNewWrapperState.equals( mLastWrapperState ) ) { |
|
1052 |
+ |
if ( mLastWrapperState != null ) { |
|
1053 |
+ |
mWrapper.removeStyleName( mLastWrapperState ); |
|
1054 |
+ |
} |
|
1055 |
+ |
mWrapper.addStyleName( mLastWrapperState = zNewWrapperState ); |
|
1056 |
+ |
} |
|
1057 |
+ |
BackDoorToWidget.manageStyle( mTextBox, mChanged, FIELD_STATE_CHANGED, FIELD_STATE_REGULAR ); |
|
1058 |
+ |
} |
|
1059 |
+ |
|
|
1060 |
+ |
private void setFocused( boolean pFocused ) { |
|
1061 |
+ |
if ( mFocused != pFocused ) { |
|
1062 |
+ |
mFocused = pFocused; |
|
1063 |
+ |
updateState(); |
|
1064 |
+ |
} |
|
1065 |
+ |
} |
|
1066 |
+ |
|
|
1067 |
+ |
private void setErrored( boolean pErrored ) { |
|
1068 |
+ |
if ( mErrored != pErrored ) { |
|
1069 |
+ |
mErrored = pErrored; |
|
1070 |
+ |
updateState(); |
|
1071 |
+ |
} |
|
1072 |
+ |
} |
|
1073 |
+ |
|
|
1074 |
+ |
private void setChanged( boolean pChanged ) { |
|
1075 |
+ |
if ( mChanged != pChanged ) { |
|
1076 |
+ |
mChanged = pChanged; |
|
1077 |
+ |
updateState(); |
|
1078 |
+ |
} |
|
1079 |
+ |
} |
|
1080 |
+ |
|
|
1081 |
+ |
public TextBoxHelper( String pStyle ) { |
|
1082 |
+ |
mWrapper.setWidget( mTextBox ); |
|
1083 |
+ |
|
|
1084 |
+ |
mTextBox.addStyleName( pStyle ); |
|
1085 |
+ |
mTextBox.setText( "1" ); |
|
1086 |
+ |
mTextBox.setTextAlignment( TextBoxBase.ALIGN_RIGHT ); |
|
1087 |
+ |
|
|
1088 |
+ |
mTextBox.addChangeListener( this ); |
|
1089 |
+ |
mTextBox.addFocusListener( this ); |
|
1090 |
+ |
|
|
1091 |
+ |
updateState(); |
|
1092 |
+ |
} |
|
1093 |
+ |
|
|
1094 |
+ |
public Widget getWidget() { |
|
1095 |
+ |
return mWrapper; |
|
1096 |
+ |
} |
|
1097 |
+ |
|
|
1098 |
+ |
public int getTextboxValue() { |
|
1099 |
+ |
String zCurValue = getFilteredTextValue(); |
|
1100 |
+ |
if ( zCurValue != null ) { |
|
1101 |
+ |
try { |
|
1102 |
+ |
return Integer.parseInt( zCurValue ); |
|
1103 |
+ |
} |
|
1104 |
+ |
catch ( NumberFormatException e ) { |
|
1105 |
+ |
// Expected on Bad input |
|
1106 |
+ |
} |
|
1107 |
+ |
} |
|
1108 |
+ |
return -1; |
|
1109 |
+ |
} |
|
1110 |
+ |
|
|
1111 |
+ |
private String getFilteredTextValue() { |
|
1112 |
+ |
String zOrig = ConstrainTo.notNull( mTextBox.getText() ); |
|
1113 |
+ |
StringBuilder zStr = new StringBuilder( zOrig ); |
|
1114 |
+ |
if ( zStr.length() == 0 ) { |
|
1115 |
+ |
zStr.append( '1' ); |
|
1116 |
+ |
} else { |
|
1117 |
+ |
for ( int i = 0; i < zStr.length(); i++ ) { |
|
1118 |
+ |
if ( !Characters.isNumeric( zStr.charAt( i ) ) ) { |
|
1119 |
+ |
zStr.setCharAt( i, '?' ); |
|
1120 |
+ |
} |
|
1121 |
+ |
} |
|
1122 |
+ |
} |
|
1123 |
+ |
String zFiltered = zStr.toString(); |
|
1124 |
+ |
if ( !zFiltered.equals( zOrig ) ) { |
|
1125 |
+ |
mTextBox.setText( zFiltered ); |
|
1126 |
+ |
} |
|
1127 |
+ |
return zFiltered; |
|
1128 |
+ |
} |
|
1129 |
+ |
|
|
1130 |
+ |
public void onChange( Widget sender ) { |
|
1131 |
+ |
int zValue = getTextboxValue(); |
|
1132 |
+ |
setChanged( zValue != 1 ); |
|
1133 |
+ |
setErrored( zValue < 1 ); |
|
1134 |
+ |
} |
|
1135 |
+ |
|
|
1136 |
+ |
public void onFocus( Widget sender ) { |
|
1137 |
+ |
setFocused( true ); |
|
1138 |
+ |
} |
|
1139 |
+ |
|
|
1140 |
+ |
public void onLostFocus( Widget sender ) { |
|
1141 |
+ |
setFocused( false ); |
|
1142 |
+ |
} |
|
1143 |
+ |
} |
|
1144 |
+ |
} |