View Javadoc

1   /**
2    * 
3    */
4   package org.sirius.server.win32.classes.controls;
5   
6   import javax.jws.WebService;
7   
8   import org.sirius.server.win32.classes.Common;
9   import org.sirius.server.win32.classes.Window;
10  import org.sirius.server.win32.constants.IEditConsts;
11  
12  import com.sun.jna.Pointer;
13  import com.sun.jna.platform.win32.WinDef.HWND;
14  import com.sun.jna.platform.win32.WinDef.LPARAM;
15  import com.sun.jna.platform.win32.WinDef.WPARAM;
16  
17  /**
18   * @author Myk Kolisnyk
19   * .
20   */
21  @WebService
22  public class Edit extends Common implements IEditConsts {
23  
24      /**
25       * .
26       */
27      public Edit() {
28          // TODO Auto-generated constructor stub
29      }
30  
31      /**
32       * .
33       * @param hwndCtl .
34       * @return .
35       */
36      public final int canUndo(final long hwndCtl) {
37          HWND hWnd = longToHwnd(hwndCtl);
38          WPARAM wParam = new WPARAM(0);
39          LPARAM lParam = new LPARAM(0);
40          return getUser32().SendMessage(hWnd, EM_CANUNDO, wParam, lParam);
41      }
42  
43      /**
44       * .
45       * @param hwndCtl .
46       * @return .
47       */
48      public final int emptyUndoBuffer(final long hwndCtl) {
49          HWND hWnd = longToHwnd(hwndCtl);
50          WPARAM wParam = new WPARAM(0);
51          LPARAM lParam = new LPARAM(0);
52          return getUser32().SendMessage(
53                  hWnd,
54                  EM_EMPTYUNDOBUFFER,
55                  wParam,
56                  lParam);
57      }
58  
59      /**
60       * .
61       * @param hwndCtl .
62       * @return .
63       */
64      public final int getFirstVisibleLine(final long hwndCtl) {
65          HWND hWnd = longToHwnd(hwndCtl);
66          WPARAM wParam = new WPARAM(0);
67          LPARAM lParam = new LPARAM(0);
68          return getUser32().SendMessage(
69                  hWnd,
70                  EM_GETFIRSTVISIBLELINE,
71                  wParam,
72                  lParam);
73      }
74  
75      /**
76       * .
77       * @param hwndCtl .
78       * @return .
79       */
80      public final int getLineCount(final long hwndCtl) {
81          HWND hWnd = longToHwnd(hwndCtl);
82          WPARAM wParam = new WPARAM(0);
83          LPARAM lParam = new LPARAM(0);
84          return getUser32().SendMessage(hWnd, EM_GETLINECOUNT, wParam, lParam);
85      }
86  
87      /**
88       * .
89       * @param hwndCtl .
90       * @return .
91       */
92      public final int getModify(final long hwndCtl) {
93          HWND hWnd = longToHwnd(hwndCtl);
94          WPARAM wParam = new WPARAM(0);
95          LPARAM lParam = new LPARAM(0);
96          return getUser32().SendMessage(hWnd, EM_GETMODIFY, wParam, lParam);
97      }
98  
99      /**
100      * .
101      * @param hwndCtl .
102      * @return .
103      */
104     public final int getPasswordChar(final long hwndCtl) {
105         HWND hWnd = longToHwnd(hwndCtl);
106         WPARAM wParam = new WPARAM(0);
107         LPARAM lParam = new LPARAM(0);
108         return getUser32().SendMessage(
109                 hWnd,
110                 EM_GETPASSWORDCHAR,
111                 wParam,
112                 lParam);
113     }
114 
115     /**
116      * .
117      * @param hwndCtl .
118      * @return .
119      */
120     public final int getSel(final long hwndCtl) {
121         HWND hWnd = longToHwnd(hwndCtl);
122         WPARAM wParam = new WPARAM(0);
123         LPARAM lParam = new LPARAM(0);
124         return getUser32().SendMessage(hWnd, EM_GETSEL, wParam, lParam);
125     }
126 
127     public final String getText(final long hwndCtl){
128         Window win = new Window();
129         return win.getText(hwndCtl);
130     }
131     
132     /**
133      * .
134      * @param hwndCtl .
135      * @param ich .
136      * @return .
137      */
138     public final int lineFromChar(final long hwndCtl, final int ich) {
139         HWND hWnd = longToHwnd(hwndCtl);
140         WPARAM wParam = new WPARAM(ich);
141         LPARAM lParam = new LPARAM(0);
142         return getUser32().SendMessage(hWnd, EM_LINEFROMCHAR, wParam, lParam);
143     }
144 
145     /**
146      * .
147      * @param hwndCtl .
148      * @param line .
149      * @return .
150      */
151     public final int lineIndex(final long hwndCtl, final int line) {
152         HWND hWnd = longToHwnd(hwndCtl);
153         WPARAM wParam = new WPARAM(line);
154         LPARAM lParam = new LPARAM(0);
155         return getUser32().SendMessage(hWnd, EM_LINEINDEX, wParam, lParam);
156     }
157 
158     /**
159      * .
160      * @param hwndCtl .
161      * @param line .
162      * @return .
163      */
164     public final int lineLength(final long hwndCtl, final int line) {
165         HWND hWnd = longToHwnd(hwndCtl);
166         WPARAM wParam = new WPARAM(line);
167         LPARAM lParam = new LPARAM(0);
168         return getUser32().SendMessage(hWnd, EM_LINELENGTH, wParam, lParam);
169     }
170 
171     /**
172      * .
173      * @param hwndCtl .
174      * @param lpszReplace .
175      * @return .
176      */
177     public final int replaceSel(final long hwndCtl, final String lpszReplace) {
178         HWND hWnd = longToHwnd(hwndCtl);
179         WPARAM wParam = new WPARAM(0);
180         Pointer pt = new Pointer(0);
181         pt.setString(0, lpszReplace);
182         LPARAM lParam = new LPARAM(Pointer.nativeValue(pt));
183         return getUser32().SendMessage(hWnd, EM_REPLACESEL, wParam, lParam);
184     }
185 
186     /**
187      * .
188      * @param hwndCtl .
189      * @param dv .
190      * @param dh .
191      * @return .
192      */
193     public final int scroll(final long hwndCtl, final int dv, final int dh) {
194         HWND hWnd = longToHwnd(hwndCtl);
195         WPARAM wParam = new WPARAM(dh);
196         LPARAM lParam = new LPARAM(dv);
197         return getUser32().SendMessage(hWnd, EM_LINESCROLL, wParam, lParam);
198     }
199 
200     /**
201      * .
202      * @param hwndCtl .
203      * @return .
204      */
205     public final boolean scrollCaret(final long hwndCtl) {
206         HWND hWnd = longToHwnd(hwndCtl);
207         WPARAM wParam = new WPARAM(0);
208         LPARAM lParam = new LPARAM(0);
209         return (getUser32()
210                     .SendMessage(
211                             hWnd,
212                             EM_SCROLLCARET,
213                             wParam,
214                             lParam) != 0)
215                 ? true
216                 : false;
217     }
218 
219     /**
220      * .
221      * @param hwndCtl .
222      * @param ch .
223      * @return .
224      */
225     public final int setPasswordChar(final long hwndCtl, final int ch) {
226         HWND hWnd = longToHwnd(hwndCtl);
227         WPARAM wParam = new WPARAM(ch);
228         LPARAM lParam = new LPARAM(0);
229         return getUser32().SendMessage(
230                 hWnd,
231                 EM_SETPASSWORDCHAR,
232                 wParam,
233                 lParam);
234     }
235 
236     /**
237      * .
238      * @param hwndCtl .
239      * @param ichStart .
240      * @param ichEnd .
241      * @return .
242      */
243     public final int setSel(
244             final long hwndCtl,
245             final int ichStart,
246             final int ichEnd) {
247         HWND hWnd = longToHwnd(hwndCtl);
248         WPARAM wParam = new WPARAM(ichStart);
249         LPARAM lParam = new LPARAM(ichEnd);
250         return getUser32().SendMessage(hWnd, EM_SETSEL, wParam, lParam);
251     }
252 
253     /**
254      * .
255      * @param hwndCtl .
256      * @param lpsz .
257      * @return .
258      */
259     public final boolean setText(final long hwndCtl, final String lpsz) {
260         HWND hWnd = longToHwnd(hwndCtl);
261         return getUser32().SetWindowText(hWnd, lpsz.toCharArray());
262     }
263 
264     /**
265      * .
266      * @param hwndCtl .
267      * @return .
268      */
269     public final int undo(final long hwndCtl) {
270         HWND hWnd = longToHwnd(hwndCtl);
271         WPARAM wParam = new WPARAM(0);
272         LPARAM lParam = new LPARAM(0);
273         return getUser32().SendMessage(hWnd, EM_UNDO, wParam, lParam);
274     }
275 }