- Timestamp:
- Jun 15, 2009, 11:36:17 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/plugins/org.eclipse.swt/Eclipse SWT/pm/org/eclipse/swt/widgets/Scale.java
r150 r151 38 38 39 39 public class Scale extends Control { 40 int MAX_RANGE; 41 int MIN_RANGE; 42 int INCREMENT; 43 int pixelRange; 40 44 static final int TrackBarProc; 41 45 static final PSZ TrackBarClass = PSZ.getAtom (OS.WC_SLIDER); … … 79 83 this.parent = parent; 80 84 this.style = style; 85 MAX_RANGE = 100; 86 MIN_RANGE = 0; 87 INCREMENT = 10; 88 81 89 SLDCDATA sldcData = new SLDCDATA(); 82 90 sldcData.usScale1Increments = 10; 83 //sldcData.usScale2Increments = 10;84 91 sldcData.usScale1Spacing = 0; 85 //sldcData.usScale2Spacing = 0; 92 86 93 handle = OS.WinCreateWindow ( 87 94 parent.handle, … … 91 98 0, parent.getHeight (), 0, 0, 92 99 parent.handle, 93 // to mimic the Windows behavior 94 OS.HWND_BOTTOM, //OS.HWND_TOP, 100 OS.HWND_BOTTOM, 95 101 0, 96 102 sldcData, … … 98 104 ); 99 105 if (handle == 0) error (SWT.ERROR_NO_HANDLES); 106 100 107 OS.WinSetWindowUShort (handle, OS.QWS_ID, (short)(handle & 0xFFFF)); 101 102 108 OS.WinSendMsg(handle, OS.SLM_SETTICKSIZE, OS.MPFROM2SHORT((short)OS.SMA_SETALLTICKS, (short)6), 0); 103 System.out.println ("Scale:createHandle " + Integer.toHexString (OS.MPFROM2SHORT((short)OS.SMA_SETALLTICKS, (short)6)));109 // OS.WinSendMsg(handle, OS.SLM_SETSLIDERINFO, OS.MPFROM2SHORT((short)OS.SMA_SLIDERARMPOSITION, (short)OS.SMA_INCREMENTVALUE), 1); 104 110 super.register (); 105 111 super.subclass (); … … 167 173 168 174 void createHandle () { 169 System.out.println ("Scale:createHandle");170 175 super.createHandle (); 171 // OS.WinSendMsg(handle, OS.SLM_SETTICKSIZE, OS.MPFROM2SHORT((short)OS.SMA_SETALLTICKS, (short)10), 0);172 // OS.SendMessage (handle, OS.TBM_SETRANGEMAX, 0, 100);173 // OS.SendMessage (handle, OS.TBM_SETPAGESIZE, 0, 10);174 // OS.SendMessage (handle, OS.TBM_SETTICFREQ, 10, 0);175 176 } 176 177 … … 193 194 public int getIncrement () { 194 195 checkWidget (); 195 return OS.WinSendMsg(handle, OS.SLM_QUERYSLIDERINFO, OS.MPFROM2SHORT((short)OS.SMA_SLIDERARMPOSITION, (short)OS.SMA_INCREMENTVALUE), 0); 196 return 1; 197 // return OS.WinSendMsg(handle, OS.SLM_QUERYSLIDERINFO, OS.MPFROM2SHORT((short)OS.SMA_SLIDERARMPOSITION, (short)OS.SMA_INCREMENTVALUE), 0); 196 198 // return OS.SendMessage (handle, OS.TBM_GETLINESIZE, 0, 0); 197 199 } … … 207 209 // * </ul> 208 210 // */ 209 //public int getMaximum () { 210 // checkWidget (); 211 public int getMaximum () { 212 checkWidget (); 213 return MAX_RANGE; 211 214 // return OS.SendMessage (handle, OS.TBM_GETRANGEMAX, 0, 0); 212 //}213 // 215 } 216 214 217 ///** 215 218 // * Returns the minimum value which the receiver will allow. … … 222 225 // * </ul> 223 226 // */ 224 //public int getMinimum () {225 //checkWidget ();226 // return OS.SendMessage (handle, OS.TBM_GETRANGEMIN, 0, 0);227 //}228 // 227 public int getMinimum () { 228 checkWidget (); 229 return MIN_RANGE; 230 } 231 229 232 ///** 230 233 // * Returns the amount that the receiver's value will be … … 239 242 // * </ul> 240 243 // */ 241 //public int getPageIncrement () { 242 // checkWidget (); 244 public int getPageIncrement () { 245 checkWidget (); 246 return INCREMENT; 243 247 // return OS.SendMessage (handle, OS.TBM_GETPAGESIZE, 0, 0); 244 //}245 // 248 } 249 246 250 ///** 247 251 // * Returns the single <em>selection</em> that is the receiver's position. … … 254 258 // * </ul> 255 259 // */ 256 //public int getSelection () { 257 // checkWidget (); 258 // return OS.SendMessage (handle, OS.TBM_GETPOS, 0, 0); 259 //} 260 // 260 public int getSelection () { 261 checkWidget (); 262 int pixelInfo = OS.WinSendMsg(handle, OS.SLM_QUERYSLIDERINFO, OS.MPFROM2SHORT((short)OS.SMA_SLIDERARMPOSITION, (short)OS.SMA_RANGEVALUE ), 0); 263 int posPixels = OS.SHORT1FROMMP(pixelInfo); 264 int totalPixels = ((pixelInfo & 0xFFFF0000)>>16) & 0xFFFF; 265 int pos = ((MAX_RANGE*posPixels)/totalPixels)+1; 266 return pos; 267 } 268 261 269 ///** 262 270 // * Removes the listener from the collection of listeners who will … … 297 305 // * </ul> 298 306 // */ 299 //public void setIncrement (int increment) {300 //checkWidget ();301 //if (increment < 1) return;302 // int minimum = OS.SendMessage (handle, OS.TBM_GETRANGEMIN, 0, 0);303 // int maximum = OS.SendMessage (handle, OS.TBM_GETRANGEMAX, 0, 0);304 //if (increment > maximum - minimum) return;305 // OS.SendMessage (handle, OS.TBM_SETLINESIZE, 0, increment);306 //}307 // 307 public void setIncrement (int increment) { 308 checkWidget (); 309 if (increment < 1) return; 310 int minimum = MIN_RANGE; 311 int maximum = MAX_RANGE; 312 if (increment > maximum - minimum) return; 313 INCREMENT = increment; 314 } 315 308 316 ///** 309 317 // * Sets the maximum value which the receiver will allow … … 318 326 // * </ul> 319 327 // */ 320 //public void setMaximum (int value) {321 //checkWidget ();328 public void setMaximum (int value) { 329 checkWidget (); 322 330 // int minimum = OS.SendMessage (handle, OS.TBM_GETRANGEMIN, 0, 0); 323 // if (0 <= minimum && minimum< value) {324 // OS.SendMessage (handle, OS.TBM_SETRANGEMAX, 1, value);325 //}326 //}327 // 331 if (0 <= MIN_RANGE && MIN_RANGE < value) { 332 MAX_RANGE = value; 333 } 334 } 335 328 336 ///** 329 337 // * Sets the minimum value which the receiver will allow … … 338 346 // * </ul> 339 347 // */ 340 //public void setMinimum (int value) {341 //checkWidget ();348 public void setMinimum (int value) { 349 checkWidget (); 342 350 // int maximum = OS.SendMessage (handle, OS.TBM_GETRANGEMAX, 0, 0); 343 // if (0 <= value && value < maximum) {344 // OS.SendMessage (handle, OS.TBM_SETRANGEMIN, 1, value);345 //}346 //}347 // 351 if (0 <= value && value < MAX_RANGE) { 352 MAX_RANGE = value; 353 } 354 } 355 348 356 ///** 349 357 // * Sets the amount that the receiver's value will be … … 359 367 // * </ul> 360 368 // */ 361 //public void setPageIncrement (int pageIncrement) { 362 // checkWidget (); 363 // if (pageIncrement < 1) return; 364 // int minimum = OS.SendMessage (handle, OS.TBM_GETRANGEMIN, 0, 0); 365 // int maximum = OS.SendMessage (handle, OS.TBM_GETRANGEMAX, 0, 0); 366 // if (pageIncrement > maximum - minimum) return; 369 public void setPageIncrement (int pageIncrement) { 370 checkWidget (); 371 if (pageIncrement < 1) return; 372 int minimum = MIN_RANGE; 373 int maximum = MAX_RANGE; 374 if (pageIncrement > maximum - minimum) return; 375 INCREMENT = pageIncrement; 367 376 // OS.SendMessage (handle, OS.TBM_SETPAGESIZE, 0, pageIncrement); 368 377 // OS.SendMessage (handle, OS.TBM_SETTICFREQ, pageIncrement, 0); 369 //}370 // 378 } 379 371 380 ///** 372 381 // * Sets the single <em>selection</em> that is the receiver's … … 381 390 // * </ul> 382 391 // */ 383 //public void setSelection (int value) { 384 // checkWidget (); 385 // if (value < 0) return; 386 // OS.SendMessage (handle, OS.TBM_SETPOS, 1, value); 387 //} 388 // 392 public void setSelection (int value) { 393 checkWidget (); 394 if (value < 0) return; 395 int pixels = OS.WinSendMsg(handle, OS.SLM_QUERYSLIDERINFO, OS.MPFROM2SHORT((short)OS.SMA_SLIDERARMPOSITION, (short)OS.SMA_RANGEVALUE ), 0); 396 int totalPixels = ((pixels & 0xFFFF0000)>>16) & 0xFFFF; 397 int pixelPos = (value*totalPixels)/MAX_RANGE; 398 OS.WinSendMsg(handle, OS.SLM_SETSLIDERINFO, OS.MPFROM2SHORT((short)OS.SMA_SLIDERARMPOSITION, (short)OS.SMA_RANGEVALUE), pixelPos); 399 } 400 389 401 int widgetStyle () { 390 402 int bits = super.widgetStyle () | OS.SLS_CENTER | OS.SLS_HOMELEFT | OS.SLS_PRIMARYSCALE1;
Note:
See TracChangeset
for help on using the changeset viewer.