Open-Source-Software-Entwicklung und Downloads

Browse Subversion Repository

Diff of /trunk/TTProxy/YCL/include/YCL/EditBoxCtrl.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3226 by maya, Tue Mar 24 09:37:20 2009 UTC revision 3227 by maya, Tue Mar 24 15:10:33 2009 UTC
# Line 1  Line 1 
1  /*  /*
2   * $Id: EditBoxCtrl.h,v 1.4 2007-08-18 08:52:18 maya Exp $   * $Id: EditBoxCtrl.h,v 1.4 2007-08-18 08:52:18 maya Exp $
3   */   */
4    
5  #ifndef _YCL_EDITBOXCTRL_H_  #ifndef _YCL_EDITBOXCTRL_H_
6  #define _YCL_EDITBOXCTRL_H_  #define _YCL_EDITBOXCTRL_H_
7    
8  #if _MSC_VER >= 1000  #if _MSC_VER >= 1000
9  #pragma once  #pragma once
10  #endif // _MSC_VER >= 1000  #endif // _MSC_VER >= 1000
11    
12  #include <YCL/Window.h>  #include <YCL/Window.h>
13    
14  namespace yebisuya {  namespace yebisuya {
15    
16  class EditBoxCtrl : virtual public Window {  class EditBoxCtrl : virtual public Window {
17  public:  public:
18          void limitText(int limit) {          void limitText(int limit) {
19                  SendMessage(EM_LIMITTEXT, limit);                  SendMessage(EM_LIMITTEXT, limit);
20          }          }
21          int getLineCount()const {          int getLineCount()const {
22                  return SendMessage(EM_GETLINECOUNT);                  return SendMessage(EM_GETLINECOUNT);
23          }          }
24          int getLine(int line, char* buffer, int length)const {          int getLine(int line, char* buffer, int length)const {
25                  *((int*) buffer) = length;                  *((int*) buffer) = length;
26                  return SendMessage(EM_GETLINE, line, (LPARAM) buffer);                  return SendMessage(EM_GETLINE, line, (LPARAM) buffer);
27          }          }
28          String getLine(int line)const {          String getLine(int line)const {
29                  int length = lineLength(line);                  int length = lineLength(line);
30                  char* buffer = (char*) alloca(length + 1);                  char* buffer = (char*) alloca(length + 1);
31                  getLine(line, buffer, length + 1);                  getLine(line, buffer, length + 1);
32                  return buffer;                  return buffer;
33          }          }
34          void getRect(RECT& rect)const {          void getRect(RECT& rect)const {
35                  SendMessage(EM_GETRECT, 0, (LPARAM) &rect);                  SendMessage(EM_GETRECT, 0, (LPARAM) &rect);
36          }          }
37          void setRect(const RECT& rect) {          void setRect(const RECT& rect) {
38                  SendMessage(EM_SETRECT, 0, (LPARAM) &rect);                  SendMessage(EM_SETRECT, 0, (LPARAM) &rect);
39          }          }
40          void setRectNoPaint(const RECT& rect) {          void setRectNoPaint(const RECT& rect) {
41                  SendMessage(EM_SETRECTNP, 0, (LPARAM) &rect);                  SendMessage(EM_SETRECTNP, 0, (LPARAM) &rect);
42          }          }
43          long getSel()const {          long getSel()const {
44                  return SendMessage(EM_GETSEL);                  return SendMessage(EM_GETSEL);
45          }          }
46          bool getSel(int& start, int& end)const {          bool getSel(int& start, int& end)const {
47                  return SendMessage(EM_GETSEL, (WPARAM) &start, (LPARAM) &end) != -1;                  return SendMessage(EM_GETSEL, (WPARAM) &start, (LPARAM) &end) != -1;
48          }          }
49          void setSel(int start, int end) {          void setSel(int start, int end) {
50                  SendMessage(EM_SETSEL, start, end);                  SendMessage(EM_SETSEL, start, end);
51          }          }
52          void replaceSel(const char* string) {          void replaceSel(const char* string) {
53                  SendMessage(EM_REPLACESEL, 0, (LPARAM) string);                  SendMessage(EM_REPLACESEL, 0, (LPARAM) string);
54          }          }
55          bool getModify()const {          bool getModify()const {
56                  return SendMessage(EM_GETMODIFY) != FALSE;                  return SendMessage(EM_GETMODIFY) != FALSE;
57          }          }
58          void setModify(bool modified) {          void setModify(bool modified) {
59                  SendMessage(EM_SETMODIFY, modified);                  SendMessage(EM_SETMODIFY, modified);
60          }          }
61          bool scrollCaret() {          bool scrollCaret() {
62                  return SendMessage(EM_SCROLLCARET) != FALSE;                  return SendMessage(EM_SCROLLCARET) != FALSE;
63          }          }
64          int lineFromChar(int index) {          int lineFromChar(int index) {
65                  return SendMessage(EM_LINEFROMCHAR, index);                  return SendMessage(EM_LINEFROMCHAR, index);
66          }          }
67          int lineIndex(int line) {          int lineIndex(int line) {
68                  return SendMessage(EM_LINEINDEX, line);                  return SendMessage(EM_LINEINDEX, line);
69          }          }
70          int lineLength(int line)const {          int lineLength(int line)const {
71                  return SendMessage(EM_LINELENGTH, line);                  return SendMessage(EM_LINELENGTH, line);
72          }          }
73          void scroll(int cx, int cy) {          void scroll(int cx, int cy) {
74                  SendMessage(EM_LINESCROLL, cx, cy);                  SendMessage(EM_LINESCROLL, cx, cy);
75          }          }
76          bool canUndo()const {          bool canUndo()const {
77                  return SendMessage(EM_CANUNDO) != FALSE;                  return SendMessage(EM_CANUNDO) != FALSE;
78          }          }
79          bool undo() {          bool undo() {
80                  return SendMessage(EM_UNDO) != FALSE;                  return SendMessage(EM_UNDO) != FALSE;
81          }          }
82          void emptyUndoBuffer() {          void emptyUndoBuffer() {
83                  SendMessage(EM_EMPTYUNDOBUFFER);                  SendMessage(EM_EMPTYUNDOBUFFER);
84          }          }
85          void setPasswordChar(int ch) {          void setPasswordChar(int ch) {
86                  SendMessage(EM_SETPASSWORDCHAR, ch);                  SendMessage(EM_SETPASSWORDCHAR, ch);
87          }          }
88          void setTabStops(int count, const int tabs[]) {          void setTabStops(int count, const int tabs[]) {
89                  SendMessage(EM_SETTABSTOPS, count, (LPARAM) tabs);                  SendMessage(EM_SETTABSTOPS, count, (LPARAM) tabs);
90          }          }
91          bool fmtLines(bool addEOL) {          bool fmtLines(bool addEOL) {
92                  return SendMessage(EM_FMTLINES, addEOL) != FALSE;                  return SendMessage(EM_FMTLINES, addEOL) != FALSE;
93          }          }
94          HLOCAL getHandle()const {          HLOCAL getHandle()const {
95                  return (HLOCAL) SendMessage(EM_GETHANDLE);                  return (HLOCAL) SendMessage(EM_GETHANDLE);
96          }          }
97          void setHandle(HLOCAL buffer) {          void setHandle(HLOCAL buffer) {
98                  SendMessage(EM_SETHANDLE, (WPARAM) buffer);                  SendMessage(EM_SETHANDLE, (WPARAM) buffer);
99          }          }
100          int getFirstVisibleLine()const {          int getFirstVisibleLine()const {
101                  return SendMessage(EM_GETFIRSTVISIBLELINE);                  return SendMessage(EM_GETFIRSTVISIBLELINE);
102          }          }
103          bool setReadOnly(bool readOnly) {          bool setReadOnly(bool readOnly) {
104                  return SendMessage(EM_SETREADONLY, readOnly) != FALSE;                  return SendMessage(EM_SETREADONLY, readOnly) != FALSE;
105          }          }
106          int getPasswordChar()const {          int getPasswordChar()const {
107                  return (TCHAR) SendMessage(EM_GETPASSWORDCHAR);                  return (TCHAR) SendMessage(EM_GETPASSWORDCHAR);
108          }          }
109          void setWordBreakProc(EDITWORDBREAKPROC wordBreakProc) {          void setWordBreakProc(EDITWORDBREAKPROC wordBreakProc) {
110                  SendMessage(EM_SETWORDBREAKPROC, 0, (LPARAM) wordBreakProc);                  SendMessage(EM_SETWORDBREAKPROC, 0, (LPARAM) wordBreakProc);
111          }          }
112          EDITWORDBREAKPROC getWordBreakProc()const {          EDITWORDBREAKPROC getWordBreakProc()const {
113                  return (EDITWORDBREAKPROC) SendMessage(EM_GETWORDBREAKPROC);                  return (EDITWORDBREAKPROC) SendMessage(EM_GETWORDBREAKPROC);
114          }          }
115          void charFromPos(POINT point, int& charIndex, int& line)const {          void charFromPos(POINT point, int& charIndex, int& line)const {
116                  long result = SendMessage(EM_CHARFROMPOS, 0, MAKELONG(point.x, point.y));                  long result = SendMessage(EM_CHARFROMPOS, 0, MAKELONG(point.x, point.y));
117                  charIndex = LOWORD(result);                  charIndex = LOWORD(result);
118                  line = HIWORD(result);                  line = HIWORD(result);
119          }          }
120          void posFromChar(int charIndex, POINT& point)const {          void posFromChar(int charIndex, POINT& point)const {
121                  long result = SendMessage(EM_POSFROMCHAR, charIndex);                  long result = SendMessage(EM_POSFROMCHAR, charIndex);
122                  point.x = LOWORD(result);                  point.x = LOWORD(result);
123                  point.y = HIWORD(result);                  point.y = HIWORD(result);
124          }          }
125          bool lineScroll(int cx, int cy) {          bool lineScroll(int cx, int cy) {
126                  return SendMessage(EM_LINESCROLL, cx, cy) != FALSE;                  return SendMessage(EM_LINESCROLL, cx, cy) != FALSE;
127          }          }
128          long getThumb()const {          long getThumb()const {
129                  return SendMessage(EM_GETTHUMB);                  return SendMessage(EM_GETTHUMB);
130          }          }
131          int getLimitText()const {          int getLimitText()const {
132                  return SendMessage(EM_GETLIMITTEXT);                  return SendMessage(EM_GETLIMITTEXT);
133          }          }
134          void setLimitText(int limit) {          void setLimitText(int limit) {
135                  SendMessage(EM_SETLIMITTEXT, limit);                  SendMessage(EM_SETLIMITTEXT, limit);
136          }          }
137          void getMargins(int& leftMargin, int& rightMargin)const {          void getMargins(int& leftMargin, int& rightMargin)const {
138                  long result = SendMessage(EM_GETMARGINS);                  long result = SendMessage(EM_GETMARGINS);
139                  leftMargin = LOWORD(result);                  leftMargin = LOWORD(result);
140                  rightMargin = HIWORD(result);                  rightMargin = HIWORD(result);
141          }          }
142          void setMargins(int flags, int leftMargin, int rightMargin) {          void setMargins(int flags, int leftMargin, int rightMargin) {
143                  SendMessage(EM_SETMARGINS, flags, MAKELONG(leftMargin, rightMargin));                  SendMessage(EM_SETMARGINS, flags, MAKELONG(leftMargin, rightMargin));
144          }          }
145  #ifndef EM_GETIMESTATUS  #ifndef EM_GETIMESTATUS
146  #define EM_GETIMESTATUS 0x00D9  #define EM_GETIMESTATUS 0x00D9
147  #endif  #endif
148          long getImeStatus(int type)const {          long getImeStatus(int type)const {
149                  return SendMessage(EM_GETIMESTATUS, type);                  return SendMessage(EM_GETIMESTATUS, type);
150          }          }
151  #ifndef EM_SETIMESTATUS  #ifndef EM_SETIMESTATUS
152  #define EM_SETIMESTATUS 0x00D8  #define EM_SETIMESTATUS 0x00D8
153  #endif  #endif
154          long setImeStatus(int type, long status) {          long setImeStatus(int type, long status) {
155                  return SendMessage(EM_SETIMESTATUS, type, status);                  return SendMessage(EM_SETIMESTATUS, type, status);
156          }          }
157  };  };
158    
159  }  }
160    
161  #endif//_YCL_EDITBOXCTRL_H_  #endif//_YCL_EDITBOXCTRL_H_

Legend:
Removed from v.3226  
changed lines
  Added in v.3227

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26