54 #ifndef TEXTEDITBASE_H
55 #define TEXTEDITBASE_H
61 DECLARE_INTERFACE(ITextBufferObserver)
62 DECLARE_INTERFACE(ITextIterator)
63 DECLARE_INTERFACE(ITextBuffer)
64 DECLARE_INTERFACE(ITextRender)
65 DECLARE_INTERFACE(ITextLayoutContext)
66 DECLARE_INTERFACE(ITextLayout)
69 #define ITextBufferObserverHeader(Interface,ClassImpl) \
70 IInterfaceHeader(Interface, ClassImpl) \
71 void (*onTextChanged)(ClassImpl*, int changedBegin, int delCount, int insertCount);
73 DEFINE_INTERFACE(ITextBufferObserver)
78 #define ITextBufferHeader(Interface, ClassImpl) \
79 IInterfaceHeader(Interface, ClassImpl) \
81 int (*replace)(ClassImpl *self, \
85 int (*getText)(ClassImpl* self, \
89 int (*getCount)(ClassImpl* self); \
90 ITextIterator* (*getAt)(ClassImpl* self, \
92 BOOL (*addObserver)(ClassImpl*, ITextBufferObserver* observer); \
93 BOOL (*removeObserver)(ClassImpl*, ITextBufferObserver* observer); \
94 int (*find)(ClassImpl*self, int start, const char* str, int str_count); \
95 int (*setCase)(ClassImpl *self, int start, int len, BOOL bupper);
97 DEFINE_INTERFACE(ITextBuffer)
101 #define ITextIteratorHeader(Interface, ClassImpl) \
102 IInterfaceHeader(Interface, ClassImpl) \
103 void (*nextChar)(ClassImpl* self); \
104 void (*prevChar)(ClassImpl* self); \
106 int (*index)(ClassImpl* self); \
108 int (*reset)(ClassImpl* self, int charIndex); \
110 BOOL (*isEnd)(ClassImpl* self); \
112 BOOL (*isHead)(ClassImpl* self); \
114 const char* (*getMore)(ClassImpl*,int *pTextLen, \
115 int *pVisibleTextLen, BOOL bAutoSkip); \
117 ITextIterator* (*reference)(ClassImpl* self); \
119 int (*diff)(ClassImpl*, const ITextIterator* another); \
121 int (*inRange)(ClassImpl*, const ITextIterator* left, \
122 const ITextIterator* right); \
124 void (*releaseIterator)(ClassImpl* self); \
126 ITextRender* (*getTextRender)(ClassImpl* self); \
128 int (*getCharType)(ClassImpl* self, int offset);
132 TI_VISIBILE_CHAR = 0,
138 DEFINE_INTERFACE(ITextIterator)
142 TXTITER_RANGE_INVALID = -1,
143 TXTITER_RANGE_IN = 0,
144 TXTITER_RANGE_LEFTEDGE ,
145 TXTITER_RANGE_RIGHTEDGE ,
146 TXTITER_RANGE_LEFTOUT ,
147 TXTITER_RANGE_RIGHTOUT
153 #define ITextRenderHeader(Interface, ClassImpl) \
154 IInterfaceHeader(Interface, ClassImpl) \
155 int (*calc)(ClassImpl* self, HDC hdc, \
156 ITextIterator* begin, \
157 int str_count, int* ptext_count, \
158 const RECT* maxBound, RECT *bounds); \
159 int (*draw)(ClassImpl* self, HDC hdc, int x, int y, \
160 ITextIterator* begin, int str_count); \
161 int (*getTextByteLen)(ClassImpl* self, HDC hdc, \
162 ITextIterator* it, int *ptext_index); \
163 int (*getTextCount)(ClassImpl* self, HDC hdc, \
164 ITextIterator* it, int* pstr_len);\
165 int (*getCaretSize)(ClassImpl* self, HDC hdc, \
166 ITextIterator* it, int *pWidth, int *pHeight);
168 DEFINE_INTERFACE(ITextRender)
174 #define ITextLayoutContextHeader(Interface, ClassImpl) \
175 IInterfaceHeader(Interface, ClassImpl) \
176 int (*getMetrics)(ClassImpl*,int type); \
177 void (*setupDC)(ClassImpl*, HDC hdc); \
178 void (*beginSelection)(ClassImpl*,HDC hdc); \
179 void (*endSelection)(ClassImpl*, HDC hdc); \
180 HDC (*getDC)(ClassImpl*); \
181 void (*contentPosToDCPos)(ClassImpl*, HDC hdc, \
183 void (*releaseDC)(ClassImpl*, HDC hdc); \
184 void (*updateCaret)(ClassImpl*); \
185 void (*update)(ClassImpl*, BOOL);
188 TEXTMETRICS_MAXWIDTH,
189 TEXTMETRICS_MAXHEIGHT,
190 TEXTMETRICS_LINESPACE,
191 TEXTMETRICS_DEFLINEHEIGHT
194 DEFINE_INTERFACE(ITextLayoutContext)
197 typedef void (*CB_LINE_PROC)(
mObject*
self,
int x,
int y,
int width,
int height,
int lineNo,
void* user_param);
198 typedef BOOL (*CB_NODE_PROC)(
mObject*
self,
mObject* cur_node,
void* user_param);
200 #define ITextLayoutHeader(Interface, ClassImpl) \
201 ITextBufferObserverHeader(Interface, ClassImpl) \
203 int (*getCharIndex)(ClassImpl*, int *px, int *py, \
204 int *plineHeight, int *ptext_index); \
206 int (*getCharPos)(ClassImpl*, int index, int *px, \
207 int *py, int *plineHeight, BOOL bAsText); \
209 BOOL (*getTextBoundSize)(ClassImpl* self, int *cx, int *cy); \
210 BOOL (*setCursor)(ClassImpl* self, int index, BOOL isSel); \
211 int (*setCursorPos)(ClassImpl* self, int x, int y, BOOL isSel); \
212 int (*getCursor)(ClassImpl*, int *px, int *py, int *cursor_h, BOOL isSel); \
213 void (*draw)(ClassImpl* self, HDC hdc, int x, int y, int width, int height);\
214 int (*getLineHeight)(ClassImpl* self, int index); \
215 void (*reset)(ClassImpl *self); \
216 int (*textCount2Len)(ClassImpl*, int text_index, int text_count, int *plen);\
217 int (*textLen2Count)(ClassImpl*, int str_index, int str_len, int*text_count,\
218 int *poutstr_index, int *poutstr_count); \
219 void (*foreachLine)(ClassImpl*, int x, int y, int maxWidth, int maxHeight, \
220 CB_LINE_PROC proc, mObject* proc_owner, void* user_param); \
221 void (*travelNode)(ClassImpl*, CB_NODE_PROC proc, mObject* proc_owner, void* user_param); \
222 PLOGFONT (*getReleatedFont)(ClassImpl*, int idx, BOOL isText); \
223 int (*getParaByIndex)(ClassImpl* self, int index, int *pcol, BOOL bText); \
224 int (*getLineByIndex)(ClassImpl* self, int index, int* pcol, BOOL bText); \
225 int (*getIndexByPara)(ClassImpl* self, int paraNo, int col, BOOL* outOfRange, BOOL bText); \
226 int (*getIndexByLine)(ClassImpl* self, int lineIdx, int col, BOOL* outOfRange, BOOL bText);
228 DEFINE_INTERFACE(ITextLayout)