diff dwt/widgets/ProgressBar.d @ 45:d8635bb48c7c

Merge with SWT 3.5
author Jacob Carlborg <doob@me.com>
date Mon, 01 Dec 2008 17:07:00 +0100
parents e831403a80a9
children cfa563df4fdd
line wrap: on
line diff
--- a/dwt/widgets/ProgressBar.d	Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/widgets/ProgressBar.d	Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -36,6 +36,10 @@
  * IMPORTANT: This class is intended to be subclassed <em>only</em>
  * within the DWT implementation.
  * </p>
+ *
+ * @see <a href="http://www.eclipse.org/swt/snippets/#progressbar">ProgressBar snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/examples.php">DWT Example: ControlExample</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
  */
 public class ProgressBar : Control {
     
@@ -100,14 +104,12 @@
 }
 
 void createHandle () {
-    SWTProgressIndicator widget = cast(SWTProgressIndicator)new SWTProgressIndicator().alloc();
+    NSProgressIndicator widget = cast(NSProgressIndicator)new SWTProgressIndicator().alloc();
     widget.initWithFrame(new NSRect());
     widget.setUsesThreadedAnimation(false);
     widget.setIndeterminate((style & DWT.INDETERMINATE) !is 0);
     if ((style & DWT.INDETERMINATE) !is 0) widget.startAnimation(null);
-    widget.setTag(jniRef);
     view = widget;
-    parent.contentView().addSubview_(widget);
 }
 
 /**
@@ -155,6 +157,23 @@
     return cast(int)(cast(NSProgressIndicator)view).doubleValue();
 }
 
+/**
+ * Returns the state of the receiver. The value will be one of:
+ * <ul>
+ *  <li>{@link DWT#NORMAL}</li>
+ *  <li>{@link DWT#ERROR}</li>
+ *  <li>{@link DWT#PAUSED}</li>
+ * </ul>
+ *
+ * @return the state 
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.4
+ */
 public int getState () {
     checkWidget ();
     return DWT.NORMAL;
@@ -175,8 +194,13 @@
  */
 public void setMaximum (int value) {
     checkWidget();
-    if (value < 0) return;
-    (cast(NSProgressIndicator)view).setMaxValue(value);
+    int minimum = (int)((NSProgressIndicator)view).minValue();
+    if (value <= minimum) return;
+    int selection = (int)((NSProgressIndicator)view).doubleValue();
+    int newSelection = Math.min (selection, value);
+    if (selection !is newSelection) {
+        ((NSProgressIndicator)view).setDoubleValue(newSelection);
+    }
 }
 
 /**
@@ -194,8 +218,13 @@
  */
 public void setMinimum (int value) {
     checkWidget();
-    if (value < 0) return;
-    (cast(NSProgressIndicator)view).setMinValue(value);
+    int maximum =  (int)((NSProgressIndicator)view).maxValue();
+    if (!(0 <= value && value < maximum)) return;
+    int selection = (int)((NSProgressIndicator)view).doubleValue();
+    int newSelection = Math.max (selection, value);
+    if (selection !is newSelection) {
+        ((NSProgressIndicator)view).setDoubleValue(newSelection);
+    }
 }
 
 /**
@@ -215,6 +244,23 @@
    (cast(NSProgressIndicator)view).setDoubleValue(value);
 }
 
+/**
+ * Sets the state of the receiver. The state must be one of these values:
+ * <ul>
+ *  <li>{@link DWT#NORMAL}</li>
+ *  <li>{@link DWT#ERROR}</li>
+ *  <li>{@link DWT#PAUSED}</li>
+ * </ul>
+ *
+ * @param state the new state
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.4
+ */
 public void setState (int state) {
     checkWidget ();
     //NOT IMPLEMENTED