|
Added
Link Here
|
| 1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2008 Innoopract Informationssysteme GmbH. All rights reserved. |
| 3 |
* This program and the accompanying materials are made available under the |
| 4 |
* terms of the Eclipse Public License v1.0 which accompanies this distribution, |
| 5 |
* and is available at http://www.eclipse.org/legal/epl-v10.html |
| 6 |
* |
| 7 |
* Contributors: Innoopract Informationssysteme GmbH - initial API and |
| 8 |
* implementation |
| 9 |
******************************************************************************/ |
| 10 |
|
| 11 |
/** |
| 12 |
* This class provides the client-side counterpart for |
| 13 |
* org.eclipse.swt.widgets.Slider. |
| 14 |
*/ |
| 15 |
qx.Class.define( "org.eclipse.swt.widgets.Slider", { |
| 16 |
extend : qx.ui.layout.CanvasLayout, |
| 17 |
|
| 18 |
construct : function( style ) { |
| 19 |
this.base( arguments ); |
| 20 |
this.setAppearance( "slider" ); |
| 21 |
// Get styles |
| 22 |
this._horizontal = qx.lang.String.contains( style, "horizontal" ); |
| 23 |
// |
| 24 |
this._hasSelectionListener = false; |
| 25 |
// Flag indicating that the next request can be sent |
| 26 |
this._readyToSendChanges = true; |
| 27 |
// Default values |
| 28 |
this._selection = 0; |
| 29 |
this._minimum = 0; |
| 30 |
this._maximum = 100; |
| 31 |
this._increment = 1; |
| 32 |
this._pageIncrement = 10; |
| 33 |
this._thumbWidth = 10; |
| 34 |
this._pxStep = 1.38; |
| 35 |
this._thumbPressed = false; |
| 36 |
// _interactionId: Indicates what element is pressed - minButton, |
| 37 |
// maxButton or area behind the thumb (line) |
| 38 |
this._interactionId; |
| 39 |
// _mousePos: Stores the mouse position, needed when calculating the |
| 40 |
// thumb translation after click on the area behind the thumb (line) |
| 41 |
this._mousePos; |
| 42 |
// Timer: used for continuous scrolling |
| 43 |
this._scrollTimer = new qx.client.Timer( 100 ); |
| 44 |
this._scrollTimer.addEventListener( "interval", |
| 45 |
this._onScrollTimerInterval, |
| 46 |
this ); |
| 47 |
// _scrollReadyToStart: Flag for starting the scrollTimer |
| 48 |
this._scrollReadyToStart = false; |
| 49 |
// Line - the area behind the thumb |
| 50 |
this._line = new qx.ui.basic.Atom; |
| 51 |
if( this._horizontal ) { |
| 52 |
this._line.addState( org.eclipse.swt.widgets.Slider.STATE_HORIZONTAL ); |
| 53 |
} |
| 54 |
this._line.setAppearance( "slider-line" ); |
| 55 |
this._line.addEventListener( "mousedown", this._onLineMouseDown, this ); |
| 56 |
this._line.addEventListener( "mouseup", |
| 57 |
this._onInteractionMouseUpOut, |
| 58 |
this ); |
| 59 |
this._line.addEventListener( "mousemove", this._onLineMouseMove, this ); |
| 60 |
this._line.addEventListener( "mouseout", |
| 61 |
this._onInteractionMouseUpOut, |
| 62 |
this ); |
| 63 |
this.add( this._line ); |
| 64 |
// Thumb |
| 65 |
this._thumb = new qx.ui.basic.Atom; |
| 66 |
if( this._horizontal ) { |
| 67 |
this._thumb.addState( org.eclipse.swt.widgets.Slider.STATE_HORIZONTAL ); |
| 68 |
} |
| 69 |
this._thumb.setAppearance( "slider-thumb" ); |
| 70 |
this._thumb.addEventListener( "mousedown", this._onThumbMouseDown, this ); |
| 71 |
this._thumb.addEventListener( "mousemove", this._onThumbMouseMove, this ); |
| 72 |
this._thumb.addEventListener( "mouseup", this._onThumbMouseUp, this ); |
| 73 |
// Fix IE Styling issues |
| 74 |
org.eclipse.swt.WidgetUtil.fixIEBoxHeight( this._thumb ); |
| 75 |
this.add( this._thumb ); |
| 76 |
// Thumb offset |
| 77 |
this._thumbOffset = 0; |
| 78 |
// Min button |
| 79 |
this._minButton = new qx.ui.form.Button; |
| 80 |
if( this._horizontal ) { |
| 81 |
this._minButton.addState( org.eclipse.swt.widgets.Slider.STATE_HORIZONTAL ); |
| 82 |
} |
| 83 |
this._minButton.addState( "rwt_PUSH" ); |
| 84 |
this._minButton.setAppearance( "slider-min-button" ); |
| 85 |
this._minButton.addEventListener( "mousedown", |
| 86 |
this._onMinButtonMouseDown, |
| 87 |
this ); |
| 88 |
this._minButton.addEventListener( "mouseup", |
| 89 |
this._onInteractionMouseUpOut, |
| 90 |
this ); |
| 91 |
this._minButton.addEventListener( "mouseout", |
| 92 |
this._onInteractionMouseUpOut, |
| 93 |
this ); |
| 94 |
// Fix IE Styling issues |
| 95 |
org.eclipse.swt.WidgetUtil.fixIEBoxHeight( this._minButton ); |
| 96 |
this.add( this._minButton ); |
| 97 |
// Max button |
| 98 |
this._maxButton = new qx.ui.form.Button; |
| 99 |
if( this._horizontal ) { |
| 100 |
this._maxButton.addState( org.eclipse.swt.widgets.Slider.STATE_HORIZONTAL ); |
| 101 |
} |
| 102 |
this._maxButton.addState( "rwt_PUSH" ); |
| 103 |
this._maxButton.setAppearance( "slider-max-button" ); |
| 104 |
this._maxButton.addEventListener( "mousedown", |
| 105 |
this._onMaxButtonMouseDown, |
| 106 |
this ); |
| 107 |
this._maxButton.addEventListener( "mouseup", |
| 108 |
this._onInteractionMouseUpOut, |
| 109 |
this ); |
| 110 |
this._maxButton.addEventListener( "mouseout", |
| 111 |
this._onInteractionMouseUpOut, |
| 112 |
this ); |
| 113 |
// Fix IE Styling issues |
| 114 |
org.eclipse.swt.WidgetUtil.fixIEBoxHeight( this._maxButton ); |
| 115 |
this.add( this._maxButton ); |
| 116 |
// Add events listeners |
| 117 |
this.addEventListener( "changeWidth", this._onChangeSize, this ); |
| 118 |
this.addEventListener( "changeHeight", this._onChangeSize, this ); |
| 119 |
this.addEventListener( "contextmenu", this._onContextMenu, this ); |
| 120 |
this.addEventListener( "changeEnabled", this._onChangeEnabled, this ); |
| 121 |
}, |
| 122 |
|
| 123 |
destruct : function() { |
| 124 |
this._line.removeEventListener( "mousedown", this._onLineMouseDown, this ); |
| 125 |
this._line.removeEventListener( "mouseup", |
| 126 |
this._onInteractionMouseUpOut, |
| 127 |
this ); |
| 128 |
this._line.removeEventListener( "mousemove", this._onLineMouseMove, this ); |
| 129 |
this._line.removeEventListener( "mouseout", |
| 130 |
this._onInteractionMouseUpOut, |
| 131 |
this ); |
| 132 |
this._minButton.removeEventListener( "mousedown", |
| 133 |
this._onMinButtonMouseDown, |
| 134 |
this ); |
| 135 |
this._minButton.removeEventListener( "mouseup", |
| 136 |
this._onInteractionMouseUpOut, |
| 137 |
this ); |
| 138 |
this._minButton.removeEventListener( "mouseout", |
| 139 |
this._onInteractionMouseUpOut, |
| 140 |
this ); |
| 141 |
this._maxButton.removeEventListener( "mousedown", |
| 142 |
this._onMaxButtonMouseDown, |
| 143 |
this ); |
| 144 |
this._maxButton.removeEventListener( "mouseup", |
| 145 |
this._onInteractionMouseUpOut, |
| 146 |
this ); |
| 147 |
this._maxButton.removeEventListener( "mouseout", |
| 148 |
this._onInteractionMouseUpOut, |
| 149 |
this ); |
| 150 |
this._scrollTimer.removeEventListener( "interval", |
| 151 |
this._onScrollTimerInterval, |
| 152 |
this ); |
| 153 |
this._thumb.removeEventListener( "mousedown", this._onThumbMouseDown, this ); |
| 154 |
this._thumb.removeEventListener( "mousemove", this._onThumbMouseMove, this ); |
| 155 |
this._thumb.removeEventListener( "mouseup", this._onThumbMouseUp, this ); |
| 156 |
this.removeEventListener( "changeWidth", this._onChangeSize, this ); |
| 157 |
this.removeEventListener( "changeHeight", this._onChangeSize, this ); |
| 158 |
this.removeEventListener( "contextmenu", this._onContextMenu, this ); |
| 159 |
this.removeEventListener( "changeEnabled", this._onChangeEnabled, this ); |
| 160 |
if( this._scrollTimer != null ) { |
| 161 |
this._scrollTimer.stop(); |
| 162 |
this._scrollTimer.dispose(); |
| 163 |
} |
| 164 |
this._scrollTimer = null; |
| 165 |
// this._disposeObjects( "_line", "_thumb", "_minButton", "_maxButton" ); |
| 166 |
this._line.dispose(); |
| 167 |
this._thumb.dispose(); |
| 168 |
this._minButton.dispose(); |
| 169 |
this._maxButton.dispose(); |
| 170 |
}, |
| 171 |
|
| 172 |
statics : { |
| 173 |
STATE_HORIZONTAL : "horizontal", |
| 174 |
BUTTON_WIDTH : 16, |
| 175 |
STATE_PRESSED : "pressed" |
| 176 |
}, |
| 177 |
|
| 178 |
members : { |
| 179 |
_onChangeSize : function( evt ) { |
| 180 |
if( this._horizontal ) { |
| 181 |
var left = this.getWidth() |
| 182 |
- org.eclipse.swt.widgets.Slider.BUTTON_WIDTH; |
| 183 |
this._maxButton.setLeft( left ); |
| 184 |
} else { |
| 185 |
var top = this.getHeight() |
| 186 |
- org.eclipse.swt.widgets.Slider.BUTTON_WIDTH; |
| 187 |
this._maxButton.setTop( top ); |
| 188 |
} |
| 189 |
this._updateLineSize(); |
| 190 |
this._updateButtonsSize(); |
| 191 |
this._updateThumbSize(); |
| 192 |
}, |
| 193 |
|
| 194 |
_onContextMenu : function( evt ) { |
| 195 |
var menu = this.getContextMenu(); |
| 196 |
if( menu != null ) { |
| 197 |
menu.setLocation( evt.getPageX(), evt.getPageY() ); |
| 198 |
menu.setOpener( this ); |
| 199 |
menu.show(); |
| 200 |
evt.stopPropagation(); |
| 201 |
} |
| 202 |
}, |
| 203 |
|
| 204 |
_onChangeEnabled : function( evt ) { |
| 205 |
this._thumb.setVisibility( evt.getValue() ); |
| 206 |
}, |
| 207 |
|
| 208 |
_onLineMouseDown : function( evt ) { |
| 209 |
this._interactionId = "line"; |
| 210 |
var pxSel; |
| 211 |
var sel; |
| 212 |
var thumbMov; // Thumb movement after interaction |
| 213 |
if( evt.isLeftButtonPressed() ) { |
| 214 |
if( this._horizontal ) { |
| 215 |
pxSel = this._thumb.getLeft() + ( this._thumb.getWidth() ) / 2; |
| 216 |
this._mousePos = evt.getPageX() |
| 217 |
- qx.html.Location.getClientBoxLeft( this.getElement() ); |
| 218 |
thumbMov = this._pageIncrement * this._pxStep |
| 219 |
+ this._thumb.getWidth() / 2; |
| 220 |
} else { |
| 221 |
pxSel = this._thumb.getTop() + ( this._thumb.getHeight() ) / 2; |
| 222 |
this._mousePos = evt.getPageY() |
| 223 |
- qx.html.Location.getClientBoxTop( this.getElement() ); |
| 224 |
thumbMov = this._pageIncrement * this._pxStep |
| 225 |
+ this._thumb.getHeight() / 2; |
| 226 |
} |
| 227 |
if( this._mousePos > pxSel ) { |
| 228 |
sel = this._selection + this._pageIncrement; |
| 229 |
} else { |
| 230 |
sel = this._selection - this._pageIncrement; |
| 231 |
} |
| 232 |
// Check whether to start auto-repeat interaction |
| 233 |
if( Math.abs( this._mousePos - pxSel ) > thumbMov ) { |
| 234 |
this._scrollReadyToStart = true; |
| 235 |
} |
| 236 |
if( sel < this._minimum ) { |
| 237 |
sel = this._minimum; |
| 238 |
} |
| 239 |
if( sel > ( this._maximum - this._thumbWidth ) ) { |
| 240 |
sel = this._maximum - this._thumbWidth; |
| 241 |
} |
| 242 |
this.setSelection( sel ); |
| 243 |
} |
| 244 |
}, |
| 245 |
|
| 246 |
_onLineMouseMove : function( evt ) { |
| 247 |
if( this._horizontal ) { |
| 248 |
this._mousePos = evt.getPageX() |
| 249 |
- qx.html.Location.getClientBoxLeft( this.getElement() ); |
| 250 |
} else { |
| 251 |
this._mousePos = evt.getPageY() |
| 252 |
- qx.html.Location.getClientBoxTop( this.getElement() ); |
| 253 |
} |
| 254 |
}, |
| 255 |
|
| 256 |
_onMinButtonMouseDown : function( evt ) { |
| 257 |
this._interactionId = "minButton"; |
| 258 |
var sel; |
| 259 |
if( evt.isLeftButtonPressed() ) { |
| 260 |
this._scrollReadyToStart = true; |
| 261 |
sel = this._selection - this._increment; |
| 262 |
if( sel < this._minimum ) { |
| 263 |
sel = this._minimum; |
| 264 |
} |
| 265 |
if( sel > ( this._maximum - this._thumbWidth ) ) { |
| 266 |
sel = this._maximum - this._thumbWidth; |
| 267 |
} |
| 268 |
this.setSelection( sel ); |
| 269 |
} |
| 270 |
}, |
| 271 |
|
| 272 |
_onMaxButtonMouseDown : function( evt ) { |
| 273 |
this._interactionId = "maxButton"; |
| 274 |
var sel; |
| 275 |
if( evt.isLeftButtonPressed() ) { |
| 276 |
this._scrollReadyToStart = true; |
| 277 |
sel = this._selection + this._increment; |
| 278 |
if( sel < this._minimum ) { |
| 279 |
sel = this._minimum; |
| 280 |
} |
| 281 |
if( sel > ( this._maximum - this._thumbWidth ) ) { |
| 282 |
sel = this._maximum - this._thumbWidth; |
| 283 |
} |
| 284 |
this.setSelection( sel ); |
| 285 |
} |
| 286 |
}, |
| 287 |
|
| 288 |
_onInteractionMouseUpOut : function( evt ) { |
| 289 |
this._scrollReadyToStart = false; |
| 290 |
this._scrollTimer.stop(); |
| 291 |
}, |
| 292 |
|
| 293 |
_scrollTimerStart : function() { |
| 294 |
if( this._scrollReadyToStart ) { |
| 295 |
this._scrollTimer.start(); |
| 296 |
} |
| 297 |
}, |
| 298 |
|
| 299 |
_onScrollTimerInterval : function( evt ) { |
| 300 |
var sel; |
| 301 |
switch( this._interactionId ) { |
| 302 |
case "minButton": |
| 303 |
sel = this._selection - this._increment; |
| 304 |
break; |
| 305 |
case "maxButton": |
| 306 |
sel = this._selection + this._increment; |
| 307 |
break; |
| 308 |
case "line": |
| 309 |
var pxSel; |
| 310 |
var thumbMov; // Thumb movement after interaction |
| 311 |
if( this._horizontal ) { |
| 312 |
pxSel = this._thumb.getLeft() + this._thumb.getWidth() / 2; |
| 313 |
thumbMov = this._pageIncrement * this._pxStep |
| 314 |
+ this._thumb.getWidth() / 2; |
| 315 |
} else { |
| 316 |
pxSel = this._thumb.getTop() + this._thumb.getHeight() / 2; |
| 317 |
thumbMov = this._pageIncrement * this._pxStep |
| 318 |
+ this._thumb.getHeight() / 2; |
| 319 |
} |
| 320 |
if( this._mousePos > pxSel ) { |
| 321 |
sel = this._selection + this._pageIncrement; |
| 322 |
} else { |
| 323 |
sel = this._selection - this._pageIncrement; |
| 324 |
} |
| 325 |
// Check whether to stop auto-repeat interaction |
| 326 |
if( Math.abs( this._mousePos - pxSel ) <= thumbMov ) { |
| 327 |
this._scrollReadyToStart = false; |
| 328 |
this._scrollTimer.stop(); |
| 329 |
} |
| 330 |
break; |
| 331 |
} |
| 332 |
if( sel < this._minimum ) { |
| 333 |
sel = this._minimum; |
| 334 |
} |
| 335 |
if( sel > ( this._maximum - this._thumbWidth ) ) { |
| 336 |
sel = this._maximum - this._thumbWidth; |
| 337 |
} |
| 338 |
this.setSelection( sel ); |
| 339 |
|
| 340 |
if( this._readyToSendChanges ) { |
| 341 |
this._readyToSendChanges = false; |
| 342 |
// Send changes |
| 343 |
qx.client.Timer.once( this._sendChanges, this, 500 ); |
| 344 |
} |
| 345 |
}, |
| 346 |
|
| 347 |
_onThumbMouseDown : function( evt ) { |
| 348 |
var mousePos; |
| 349 |
this._thumb.addState( org.eclipse.swt.widgets.Slider.STATE_PRESSED ); |
| 350 |
this._thumbPressed = true; |
| 351 |
if( evt.isLeftButtonPressed() ) { |
| 352 |
if( this._horizontal ) { |
| 353 |
mousePos = evt.getPageX() |
| 354 |
- qx.html.Location.getClientBoxLeft( this.getElement() ); |
| 355 |
this._thumbOffset = mousePos - this._thumb.getLeft(); |
| 356 |
} else { |
| 357 |
mousePos = evt.getPageY() |
| 358 |
- qx.html.Location.getClientBoxTop( this.getElement() ); |
| 359 |
this._thumbOffset = mousePos - this._thumb.getTop(); |
| 360 |
} |
| 361 |
this._thumb.setCapture( true ); |
| 362 |
} |
| 363 |
}, |
| 364 |
|
| 365 |
_onThumbMouseMove : function( evt ) { |
| 366 |
var mousePos; |
| 367 |
if( this._thumb.getCapture() ) { |
| 368 |
if( this._horizontal ) { |
| 369 |
mousePos = evt.getPageX() |
| 370 |
- qx.html.Location.getClientBoxLeft( this.getElement() ); |
| 371 |
} else { |
| 372 |
mousePos = evt.getPageY() |
| 373 |
- qx.html.Location.getClientBoxTop( this.getElement() ); |
| 374 |
} |
| 375 |
var sel = this._getSelectionFromThumbPosition( mousePos |
| 376 |
- this._thumbOffset ); |
| 377 |
if( this._selection != sel ) { |
| 378 |
this.setSelection( sel ); |
| 379 |
if( this._readyToSendChanges ) { |
| 380 |
this._readyToSendChanges = false; |
| 381 |
// Send changes |
| 382 |
qx.client.Timer.once( this._sendChanges, this, 500 ); |
| 383 |
} |
| 384 |
} |
| 385 |
} |
| 386 |
}, |
| 387 |
|
| 388 |
_onThumbMouseUp : function( evt ) { |
| 389 |
this._scrollTimer.stop(); |
| 390 |
this._thumbPressed = false; |
| 391 |
this._thumb.setCapture( false ); |
| 392 |
this._thumb.removeState( org.eclipse.swt.widgets.Slider.STATE_PRESSED ); |
| 393 |
}, |
| 394 |
|
| 395 |
_updateThumbSize : function() { |
| 396 |
if( this._horizontal ) { |
| 397 |
this._thumb.setWidth( this._thumbWidth * this._line.getWidth() |
| 398 |
/ ( this._maximum - this._minimum ) ); |
| 399 |
this._thumb.setHeight( this.getHeight() ); |
| 400 |
} else { |
| 401 |
this._thumb.setWidth( this.getWidth() ); |
| 402 |
this._thumb.setHeight( this._thumbWidth * this._line.getHeight() |
| 403 |
/ ( this._maximum - this._minimum ) ); |
| 404 |
} |
| 405 |
this._updateStep(); |
| 406 |
}, |
| 407 |
|
| 408 |
_updateStep : function() { |
| 409 |
var padding; |
| 410 |
var numSteps = this._maximum - this._minimum - this._thumbWidth; |
| 411 |
if( numSteps != 0 ) { |
| 412 |
if( this._horizontal ) { |
| 413 |
padding = org.eclipse.swt.widgets.Slider.BUTTON_WIDTH |
| 414 |
+ ( this._thumb.getWidth() ) / 2; |
| 415 |
this._pxStep = ( this.getWidth() - 2 * padding ) / numSteps; |
| 416 |
} else { |
| 417 |
padding = org.eclipse.swt.widgets.Slider.BUTTON_WIDTH |
| 418 |
+ ( this._thumb.getHeight() ) / 2; |
| 419 |
this._pxStep = ( this.getHeight() - 2 * padding ) / numSteps; |
| 420 |
} |
| 421 |
} else { |
| 422 |
this._pxStep = 0; |
| 423 |
} |
| 424 |
this._updateThumbPosition(); |
| 425 |
}, |
| 426 |
|
| 427 |
_updateThumbPosition : function() { |
| 428 |
var pos; |
| 429 |
if( this._selection >= ( this._maximum - this._thumbWidth ) ) { |
| 430 |
pos = org.eclipse.swt.widgets.Slider.BUTTON_WIDTH + this._pxStep |
| 431 |
* ( this._maximum - this._minimum - this._thumbWidth ); |
| 432 |
this._selection = this._maximum - this._thumbWidth; |
| 433 |
} else if( this._selection <= this._minimum ) { |
| 434 |
pos = org.eclipse.swt.widgets.Slider.BUTTON_WIDTH; |
| 435 |
this._selection = this._minimum; |
| 436 |
} else { |
| 437 |
pos = org.eclipse.swt.widgets.Slider.BUTTON_WIDTH + this._pxStep |
| 438 |
* ( this._selection - this._minimum ); |
| 439 |
} |
| 440 |
if( this._horizontal ) { |
| 441 |
this._thumb.setLeft( pos ); |
| 442 |
} else { |
| 443 |
this._thumb.setTop( pos ); |
| 444 |
} |
| 445 |
if( this._readyToSendChanges ) { |
| 446 |
this._readyToSendChanges = false; |
| 447 |
// Send changes |
| 448 |
qx.client.Timer.once( this._sendChanges, this, 500 ); |
| 449 |
// Starting the auto repeat functionality after a 250 ms delay |
| 450 |
qx.client.Timer.once( this._scrollTimerStart, this, 250 ); |
| 451 |
} |
| 452 |
}, |
| 453 |
|
| 454 |
_updateLineSize : function() { |
| 455 |
if( this._horizontal ) { |
| 456 |
this._line.setWidth( this.getWidth() - 2 |
| 457 |
* org.eclipse.swt.widgets.Slider.BUTTON_WIDTH ); |
| 458 |
this._line.setHeight( this.getHeight() ); |
| 459 |
} else { |
| 460 |
this._line.setWidth( this.getWidth() ); |
| 461 |
this._line.setHeight( this.getHeight() - 2 |
| 462 |
* org.eclipse.swt.widgets.Slider.BUTTON_WIDTH ); |
| 463 |
} |
| 464 |
}, |
| 465 |
|
| 466 |
_updateButtonsSize : function() { |
| 467 |
if( this._horizontal ) { |
| 468 |
this._minButton.setHeight( this.getHeight() ); |
| 469 |
this._maxButton.setHeight( this.getHeight() ); |
| 470 |
} else { |
| 471 |
this._minButton.setWidth( this.getWidth() ); |
| 472 |
this._maxButton.setWidth( this.getWidth() ); |
| 473 |
} |
| 474 |
}, |
| 475 |
|
| 476 |
_getSelectionFromThumbPosition : function( position ) { |
| 477 |
var sel = ( position - org.eclipse.swt.widgets.Slider.BUTTON_WIDTH ) |
| 478 |
/ this._pxStep + this._minimum; |
| 479 |
sel = Math.round( sel ); |
| 480 |
var sel_final; |
| 481 |
if( sel < this._minimum ) { |
| 482 |
sel_final = this._minimum; |
| 483 |
} else if( sel > ( this._maximum - this._thumbWidth ) ) { |
| 484 |
sel_final = this._maximum - this._thumbWidth; |
| 485 |
} else { |
| 486 |
sel_final = sel; |
| 487 |
} |
| 488 |
return sel_final; |
| 489 |
}, |
| 490 |
|
| 491 |
_sendChanges : function() { |
| 492 |
if( !org_eclipse_rap_rwt_EventUtil_suspend ) { |
| 493 |
var widgetManager = org.eclipse.swt.WidgetManager.getInstance(); |
| 494 |
var req = org.eclipse.swt.Request.getInstance(); |
| 495 |
var id = widgetManager.findIdByWidget( this ); |
| 496 |
req.addParameter( id + ".selection", this._selection ); |
| 497 |
if( this._hasSelectionListener ) { |
| 498 |
req.addEvent( "org.eclipse.swt.events.widgetSelected", id ); |
| 499 |
req.send(); |
| 500 |
} |
| 501 |
this._readyToSendChanges = true; |
| 502 |
} |
| 503 |
}, |
| 504 |
|
| 505 |
setHasSelectionListener : function( value ) { |
| 506 |
this._hasSelectionListener = value; |
| 507 |
}, |
| 508 |
|
| 509 |
setSelection : function( value ) { |
| 510 |
this._selection = value; |
| 511 |
this._updateThumbPosition(); |
| 512 |
}, |
| 513 |
|
| 514 |
setMinimum : function( value ) { |
| 515 |
this._minimum = value; |
| 516 |
this._updateThumbSize(); |
| 517 |
}, |
| 518 |
|
| 519 |
setMaximum : function( value ) { |
| 520 |
this._maximum = value; |
| 521 |
this._updateThumbSize(); |
| 522 |
}, |
| 523 |
|
| 524 |
setIncrement : function( value ) { |
| 525 |
this._increment = value; |
| 526 |
}, |
| 527 |
|
| 528 |
setPageIncrement : function( value ) { |
| 529 |
this._pageIncrement = value; |
| 530 |
}, |
| 531 |
|
| 532 |
setThumb : function( value ) { |
| 533 |
this._thumbWidth = value; |
| 534 |
this._updateThumbSize(); |
| 535 |
} |
| 536 |
} |
| 537 |
} ); |