示例#1
0
 void updateBar(int selection, int minimum, int maximum, int thumb) {
   NSScroller widget = (NSScroller) view;
   selection = Math.max(minimum, Math.min(maximum - thumb, selection));
   float fraction =
       minimum == maximum ? 1 : (float) (selection - minimum) / (maximum - thumb - minimum);
   float knob = minimum == maximum ? 1 : (float) (thumb - minimum) / (maximum - minimum);
   widget.setFloatValue(fraction, knob);
 }
示例#2
0
 public Point computeSize(int wHint, int hHint, boolean changed) {
   checkWidget();
   int width = 0, height = 0;
   if ((style & SWT.HORIZONTAL) != 0) {
     height = (int) NSScroller.scrollerWidth();
     width = height * 10;
   } else {
     width = (int) NSScroller.scrollerWidth();
     height = width * 10;
   }
   if (wHint != SWT.DEFAULT) width = wHint;
   if (hHint != SWT.DEFAULT) height = hHint;
   return new Point(width, height);
 }
示例#3
0
 void createHandle() {
   NSScroller widget = (NSScroller) new SWTScroller().alloc();
   NSRect rect = new NSRect();
   if ((style & SWT.HORIZONTAL) != 0) {
     rect.width = 1;
   } else {
     rect.height = 1;
   }
   widget.initWithFrame(rect);
   widget.setEnabled(true);
   widget.setTarget(widget);
   widget.setAction(OS.sel_sendSelection);
   widget.setTag(jniRef);
   view = widget;
   parent.contentView().addSubview_(widget);
   updateBar(0, minimum, maximum, thumb);
 }
示例#4
0
 /**
  * Returns the 'selection', which is the receiver's value.
  *
  * @return the selection
  * @exception SWTException
  *     <ul>
  *       <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  *       <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  *     </ul>
  */
 public int getSelection() {
   checkWidget();
   NSScroller widget = (NSScroller) view;
   float value = widget.floatValue();
   return (int) ((maximum - thumb - minimum) * value + minimum);
 }