View Javadoc

1   /**
2    * 
3    */
4   package org.sirius.server.win32.classes.controls;
5   
6   import java.rmi.RemoteException;
7   
8   import org.sirius.server.win32.classes.Common;
9   import org.sirius.server.win32lib.controls.Win32LibControlsClient;
10  
11  /**
12   * @author Myk Kolisnyk
13   *
14   */
15  public class Spin  extends Common {
16  
17      Win32LibControlsClient win32lib;    
18      
19      /**
20       * 
21       */
22      public Spin() {
23          win32lib = new Win32LibControlsClient();        
24      }
25  
26      /**
27       * @param hwnd
28       * @return
29       * @throws RemoteException
30       * @see org.sirius.server.win32lib.controls.spin.ISpinContractProxy#getLowerBound(java.lang.Integer)
31       */
32      public Double getLowerBound(Integer hwnd) throws RemoteException {
33          return win32lib.spin().getLowerBound(hwnd);
34      }
35  
36      /**
37       * @param hwnd
38       * @return
39       * @throws RemoteException
40       * @see org.sirius.server.win32lib.controls.spin.ISpinContractProxy#getPosition(java.lang.Integer)
41       */
42      public Double getPosition(Integer hwnd) throws RemoteException {
43          return win32lib.spin().getPosition(hwnd);
44      }
45  
46      /**
47       * @param hwnd
48       * @return
49       * @throws RemoteException
50       * @see org.sirius.server.win32lib.controls.spin.ISpinContractProxy#getText(java.lang.Integer)
51       */
52      public String getText(Integer hwnd) throws RemoteException {
53          return String.valueOf(win32lib.spin().getValue(hwnd));
54      }
55  
56      /**
57       * @param hwnd
58       * @return
59       * @throws RemoteException
60       * @see org.sirius.server.win32lib.controls.spin.ISpinContractProxy#getUpperBound(java.lang.Integer)
61       */
62      public Double getUpperBound(Integer hwnd) throws RemoteException {
63          return win32lib.spin().getUpperBound(hwnd);
64      }
65  
66      /**
67       * @param hwnd
68       * @param pos
69       * @throws RemoteException
70       * @see org.sirius.server.win32lib.controls.spin.ISpinContractProxy#setPosition(java.lang.Integer, java.lang.Double)
71       */
72      public void setPosition(Integer hwnd, Double pos) throws RemoteException {
73          win32lib.spin().setPosition(hwnd, pos);
74      }
75  
76      /**
77       * @param hwnd
78       * @param text
79       * @throws RemoteException
80       * @see org.sirius.server.win32lib.controls.spin.ISpinContractProxy#setText(java.lang.Integer, java.lang.String)
81       */
82      public void setText(Integer hwnd, String text) throws RemoteException {
83          win32lib.spin().setValue(hwnd, new Double(text));
84      }
85      
86      public Double getSmallStep(Integer hwnd) throws RemoteException{
87          return win32lib.spin().getSmallStep(hwnd);
88      }
89  
90      public Double getLargeStep(Integer hwnd) throws RemoteException{
91          return win32lib.spin().getLargeStep(hwnd);
92      }
93      
94      public void increment(Integer hwnd) throws RemoteException{
95          double position = this.getPosition(hwnd);
96          double step = this.getSmallStep(hwnd);
97          double min = this.getLowerBound(hwnd);
98          double max = this.getUpperBound(hwnd);
99          
100         if(position + step > max ){
101             this.setPosition(hwnd, min);
102         }
103         else {
104             this.setPosition(hwnd, position + step);
105         }
106     }
107     
108     public void decrement(Integer hwnd) throws RemoteException{
109         double position = this.getPosition(hwnd);
110         double step = this.getSmallStep(hwnd);
111         double min = this.getLowerBound(hwnd);
112         double max = this.getUpperBound(hwnd);
113         
114         if(position - step < min ){
115             this.setPosition(hwnd, max);
116         }
117         else {
118             this.setPosition(hwnd, position - step);
119         }
120     }
121 }