@@ -382,15 +382,6 @@ int defaultForeground () {
382382}
383383*/
384384
385- private void clearScaleDecoration () {
386- for (int i = 0 ; i < handle .childNodes .length ; i ++) {
387- //System.out.println(i + ":" + handle.childNodes[i].className);
388- if (handle .childNodes [i ].className .indexOf ("scale-line-decoration" ) != -1 ) {
389- //System.out.println(i);
390- handle .removeChild (handle .childNodes [i ]);
391- }
392- }
393- }
394385private void decorateScale () {
395386 int outerSize ;
396387 if ((style & SWT .HORIZONTAL ) != 0 ) {
@@ -517,7 +508,7 @@ public int getSelection () {
517508 selection = left * maximum / (getSize ().x - 12 );
518509 } else {
519510 int top = Integer .parseInt (thumbHandle .style .top );
520- selection = top * maximum / (getSize ().y - 12 );
511+ selection = maximum - top * maximum / (getSize ().y - 12 );
521512 }
522513 return selection ;
523514}
@@ -611,8 +602,9 @@ public void setMaximum (int value) {
611602 //OS.SendMessage (handle, OS.TBM_SETRANGEMAX, 1, value);
612603 if (maximum == value ) return ;
613604 maximum = value ;
614- clearScaleDecoration ();
605+ // clearScaleDecoration();
615606 decorateScale ();
607+ setSelection (selection );
616608 }
617609}
618610
@@ -636,8 +628,9 @@ public void setMinimum (int value) {
636628 //OS.SendMessage (handle, OS.TBM_SETRANGEMIN, 1, value);
637629 if (minimum == value ) return ;
638630 minimum = value ;
639- clearScaleDecoration ();
631+ // clearScaleDecoration();
640632 decorateScale ();
633+ setSelection (selection );
641634 }
642635}
643636
@@ -664,7 +657,7 @@ public void setPageIncrement (int pageIncrement) {
664657// OS.SendMessage (handle, OS.TBM_SETTICFREQ, pageIncrement, 0);
665658 if (this .pageIncrement == pageIncrement ) return ;
666659 this .pageIncrement = pageIncrement ;
667- clearScaleDecoration ();
660+ // clearScaleDecoration();
668661 decorateScale ();
669662}
670663
@@ -682,14 +675,22 @@ public void setPageIncrement (int pageIncrement) {
682675public void setSelection (int value ) {
683676 checkWidget ();
684677 //OS.SendMessage (handle, OS.TBM_SETPOS, 1, value);
685- if (selection == value ) return ;
686- if (minimum <= value && value < maximum ) {
678+ if (value < minimum ) {
679+ selection = minimum ;
680+ } else if (value > maximum ) {
681+ selection = maximum ;
682+ } else {
687683 selection = value ;
688- if ((style & SWT .HORIZONTAL ) != 0 ) {
689- thumbHandle .style .left = Math .round (selection * (getSize ().x - 12 ) / maximum ) + "px" ;
690- } else {
691- thumbHandle .style .top = Math .round (selection * (getSize ().y - 12 ) / maximum ) + "px" ;
692- }
684+ }
685+
686+ // if (selection == value) return;
687+ // if (minimum <= value && value < maximum) {
688+ // selection = value;
689+ // }
690+ if ((style & SWT .HORIZONTAL ) != 0 ) {
691+ thumbHandle .style .left = Math .round (selection * (getSize ().x - 12 ) / maximum ) + "px" ;
692+ } else {
693+ thumbHandle .style .top = Math .round ((maximum - selection ) * (getSize ().y - 12 ) / maximum ) + "px" ;
693694 }
694695}
695696
@@ -703,6 +704,7 @@ boolean SetWindowPos(Object hWnd, Object hWndInsertAfter, int X, int Y, int cx,
703704 el .style .top = Y + "px" ;
704705 el .style .width = (cx > 0 ? cx : 0 ) + "px" ;
705706 el .style .height = (cy > 0 ? cy : 0 ) + "px" ;
707+ setSelection (selection );
706708 return true ;
707709// return super.SetWindowPos(hWnd, hWndInsertAfter, X, Y, cx, cy, uFlags);
708710}
0 commit comments