Changeset 155 for trunk/src


Ignore:
Timestamp:
Jun 17, 2009, 3:52:31 AM (16 years ago)
Author:
lpino
Message:
  • Scale implementation is complete
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/plugins/org.eclipse.swt/Eclipse SWT/pm/org/eclipse/swt/widgets/Scale.java

    r154 r155  
    3838
    3939public class Scale extends Control {
    40         int MAX_RANGE;
    41         int MIN_RANGE;
    42         int INCREMENT;
     40        int maxRange;
     41        int minRange;
     42        int increment;
    4343        int pixelRange;
    4444        static final int TrackBarProc;
     
    8383    this.parent = parent;
    8484    this.style = style;
    85     MAX_RANGE = 100;
    86     MIN_RANGE = 0;
    87     INCREMENT = 10;
     85    maxRange = 100;
     86    minRange = 0;
     87    increment = 10;
    8888
    8989    SLDCDATA sldcData = new SLDCDATA();
     
    156156        int border = getBorderWidth ();
    157157        int width = border * 2, height = border * 2;
    158 //      RECT rect = new RECT ();
    159 //      OS.SendMessage (handle, OS.TBM_GETTHUMBRECT, 0, rect);
    160         OS.WinSendMsg(handle, OS.SLM_QUERYSLIDERINFO, OS.MPFROM2SHORT((short)OS.SMA_SHAFTDIMENSIONS, (short)OS.SMA_RANGEVALUE), 0);
    161         OS.WinSendMsg(handle, OS.SLM_QUERYSLIDERINFO, OS.MPFROM2SHORT((short)OS.SMA_SLIDERARMDIMENSIONS, (short)OS.SMA_RANGEVALUE), 0);
    162         OS.WinSendMsg(handle, OS.SLM_QUERYTICKSIZE, 1, 0);
    163 //      if ((style & SWT.HORIZONTAL) != 0) {
    164 //              width += OS.GetSystemMetrics (OS.SM_CXHSCROLL) * 10;
    165 //              int scrollY = OS.GetSystemMetrics (OS.SM_CYHSCROLL);
    166 //              height += (rect.top * 2) + scrollY + (scrollY / 3);
    167 //      } else {
    168 //              int scrollX = OS.GetSystemMetrics (OS.SM_CXVSCROLL);
    169 //              width += (rect.left * 2) + scrollX + (scrollX / 3);
    170 //              height += OS.GetSystemMetrics (OS.SM_CYVSCROLL) * 10;
    171 //      }
    172 //      if (wHint != SWT.DEFAULT) width = wHint + (border * 2);
    173 //      if (hHint != SWT.DEFAULT) height = hHint + (border * 2);
     158        int shaftLength = OS.WinSendMsg(handle, OS.SLM_QUERYSLIDERINFO, OS.MPFROM2SHORT((short)OS.SMA_SHAFTDIMENSIONS, (short)OS.SMA_RANGEVALUE), 0);
     159        int arm = OS.WinSendMsg(handle, OS.SLM_QUERYSLIDERINFO, OS.MPFROM2SHORT((short)OS.SMA_SLIDERARMDIMENSIONS, (short)OS.SMA_RANGEVALUE), 0);
     160        int tick = OS.WinSendMsg(handle, OS.SLM_QUERYTICKSIZE, 1, 0);
     161        if ((style & SWT.HORIZONTAL) != 0) {
     162                width += OS.SHORT1FROMMP(shaftLength) + 10;
     163                height += OS.SHORT2FROMMP(arm) + tick;
     164        } else {
     165                width += OS.SHORT2FROMMP(arm) + tick;
     166                height += OS.SHORT1FROMMP(shaftLength) + 10;
     167        }
     168        if (wHint != SWT.DEFAULT) width = wHint + (border * 2);
     169        if (hHint != SWT.DEFAULT) height = hHint + (border * 2);
    174170        return new Point (width, height);
    175171}
     
    180176
    181177int defaultForeground () {
    182         return OS.WinQuerySysColor(handle, OS.SYSCLR_SCROLLBAR, 0);
     178        return OS.WinQuerySysColor(handle, OS.SYSCLR_WINDOWTEXT, 0);
    183179}
    184180
     
    198194        checkWidget ();
    199195        return 1;
    200 //      return OS.SendMessage (handle, OS.TBM_GETLINESIZE, 0, 0);
    201196}
    202197
     
    213208public int getMaximum () {
    214209        checkWidget ();
    215         return MAX_RANGE;
    216 //      return OS.SendMessage (handle, OS.TBM_GETRANGEMAX, 0, 0);
     210        return maxRange;
    217211}
    218212
     
    229223public int getMinimum () {
    230224        checkWidget ();
    231         return MIN_RANGE;
     225        return minRange;
    232226}
    233227
     
    246240public int getPageIncrement () {
    247241        checkWidget ();
    248         return INCREMENT;
     242        return increment;
    249243//      return OS.SendMessage (handle, OS.TBM_GETPAGESIZE, 0, 0);
    250244}
     
    264258        int pixelInfo = OS.WinSendMsg(handle, OS.SLM_QUERYSLIDERINFO, OS.MPFROM2SHORT((short)OS.SMA_SLIDERARMPOSITION, (short)OS.SMA_RANGEVALUE ), 0);
    265259        int posPixels = OS.SHORT1FROMMP(pixelInfo);
    266         int totalPixels = ((pixelInfo & 0xFFFF0000)>>16) & 0xFFFF;
    267         int pos = ((MAX_RANGE*posPixels)/totalPixels);
     260        int totalPixels = OS.SHORT2FROMMP(pixelInfo) - 1;
     261        int pos = ((maxRange*posPixels)/totalPixels);
    268262        return pos;
    269263}
     
    310304        checkWidget ();
    311305        if (increment < 1) return;
    312         int minimum = MIN_RANGE;
    313         int maximum = MAX_RANGE;
     306        int minimum = minRange;
     307        int maximum = maxRange;
    314308        if (increment > maximum - minimum) return;
    315         INCREMENT = increment;
     309        increment = increment;
    316310}
    317311
     
    331325        checkWidget ();
    332326//      int minimum = OS.SendMessage (handle, OS.TBM_GETRANGEMIN, 0, 0);
    333         if (0 <= MIN_RANGE && MIN_RANGE < value) {
    334                 MAX_RANGE = value;
     327        if (0 <= minRange && minRange < value) {
     328                maxRange = value;
    335329        }
    336330}
     
    351345        checkWidget ();
    352346//      int maximum = OS.SendMessage (handle, OS.TBM_GETRANGEMAX, 0, 0);
    353         if (0 <= value && value < MAX_RANGE) {
    354                 MAX_RANGE = value;
     347        if (0 <= value && value < maxRange) {
     348                maxRange = value;
    355349        }
    356350}
     
    372366        checkWidget ();
    373367        if (pageIncrement < 1) return;
    374         int minimum = MIN_RANGE;
    375         int maximum = MAX_RANGE;
     368        int minimum = minRange;
     369        int maximum = maxRange;
    376370        if (pageIncrement > maximum - minimum) return;
    377         INCREMENT = pageIncrement;
    378 //      OS.SendMessage (handle, OS.TBM_SETPAGESIZE, 0, pageIncrement);
    379 //      OS.SendMessage (handle, OS.TBM_SETTICFREQ, pageIncrement, 0);
     371        increment = pageIncrement;
    380372}
    381373
     
    396388        if (value < 0) return;
    397389        int pixels = OS.WinSendMsg(handle, OS.SLM_QUERYSLIDERINFO, OS.MPFROM2SHORT((short)OS.SMA_SLIDERARMPOSITION, (short)OS.SMA_RANGEVALUE ), 0);
    398         int totalPixels = ((pixels & 0xFFFF0000)>>16) & 0xFFFF;
    399         int pixelPos = ((value*totalPixels)/MAX_RANGE);
     390        int totalPixels = OS.SHORT2FROMMP(pixels) -1;
     391        int pixelPos = ((value*totalPixels)/maxRange);
    400392        OS.WinSendMsg(handle, OS.SLM_SETSLIDERINFO, OS.MPFROM2SHORT((short)OS.SMA_SLIDERARMPOSITION, (short)OS.SMA_RANGEVALUE), pixelPos);
    401393}
Note: See TracChangeset for help on using the changeset viewer.