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
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
28
29
30
31
32 public Double getLowerBound(Integer hwnd) throws RemoteException {
33 return win32lib.spin().getLowerBound(hwnd);
34 }
35
36
37
38
39
40
41
42 public Double getPosition(Integer hwnd) throws RemoteException {
43 return win32lib.spin().getPosition(hwnd);
44 }
45
46
47
48
49
50
51
52 public String getText(Integer hwnd) throws RemoteException {
53 return String.valueOf(win32lib.spin().getValue(hwnd));
54 }
55
56
57
58
59
60
61
62 public Double getUpperBound(Integer hwnd) throws RemoteException {
63 return win32lib.spin().getUpperBound(hwnd);
64 }
65
66
67
68
69
70
71
72 public void setPosition(Integer hwnd, Double pos) throws RemoteException {
73 win32lib.spin().setPosition(hwnd, pos);
74 }
75
76
77
78
79
80
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 }