42 #ifndef TEXTEDITBASE_H 43 #define TEXTEDITBASE_H 49 DECLARE_INTERFACE(ITextBufferObserver)
50 DECLARE_INTERFACE(ITextIterator)
51 DECLARE_INTERFACE(ITextBuffer)
52 DECLARE_INTERFACE(ITextRender)
53 DECLARE_INTERFACE(ITextLayoutContext)
54 DECLARE_INTERFACE(ITextLayout)
57 #define ITextBufferObserverHeader(Interface,ClassImpl) \ 58 IInterfaceHeader(Interface, ClassImpl) \ 59 void (*onTextChanged)(ClassImpl*, int changedBegin, int delCount, int insertCount); 61 DEFINE_INTERFACE(ITextBufferObserver)
66 #define ITextBufferHeader(Interface, ClassImpl) \ 67 IInterfaceHeader(Interface, ClassImpl) \ 69 int (*replace)(ClassImpl *self, \ 73 int (*getText)(ClassImpl* self, \ 77 int (*getCount)(ClassImpl* self); \ 78 ITextIterator* (*getAt)(ClassImpl* self, \ 80 BOOL (*addObserver)(ClassImpl*, ITextBufferObserver* observer); \ 81 BOOL (*removeObserver)(ClassImpl*, ITextBufferObserver* observer); \ 82 int (*find)(ClassImpl*self, int start, const char* str, int str_count); \ 83 int (*setCase)(ClassImpl *self, int start, int len, BOOL bupper); 85 DEFINE_INTERFACE(ITextBuffer)
89 #define ITextIteratorHeader(Interface, ClassImpl) \ 90 IInterfaceHeader(Interface, ClassImpl) \ 91 void (*nextChar)(ClassImpl* self); \ 92 void (*prevChar)(ClassImpl* self); \ 94 int (*index)(ClassImpl* self); \ 96 int (*reset)(ClassImpl* self, int charIndex); \ 98 BOOL (*isEnd)(ClassImpl* self); \ 100 BOOL (*isHead)(ClassImpl* self); \ 102 const char* (*getMore)(ClassImpl*,int *pTextLen, \ 103 int *pVisibleTextLen, BOOL bAutoSkip); \ 105 ITextIterator* (*reference)(ClassImpl* self); \ 107 int (*diff)(ClassImpl*, const ITextIterator* another); \ 109 int (*inRange)(ClassImpl*, const ITextIterator* left, \ 110 const ITextIterator* right); \ 112 void (*releaseIterator)(ClassImpl* self); \ 114 ITextRender* (*getTextRender)(ClassImpl* self); \ 116 int (*getCharType)(ClassImpl* self, int offset); 120 TI_VISIBILE_CHAR = 0,
126 DEFINE_INTERFACE(ITextIterator)
130 TXTITER_RANGE_INVALID = -1,
131 TXTITER_RANGE_IN = 0,
132 TXTITER_RANGE_LEFTEDGE ,
133 TXTITER_RANGE_RIGHTEDGE ,
134 TXTITER_RANGE_LEFTOUT ,
135 TXTITER_RANGE_RIGHTOUT
141 #define ITextRenderHeader(Interface, ClassImpl) \ 142 IInterfaceHeader(Interface, ClassImpl) \ 143 int (*calc)(ClassImpl* self, HDC hdc, \ 144 ITextIterator* begin, \ 145 int str_count, int* ptext_count, \ 146 const RECT* maxBound, RECT *bounds); \ 147 int (*draw)(ClassImpl* self, HDC hdc, int x, int y, \ 148 ITextIterator* begin, int str_count); \ 149 int (*getTextByteLen)(ClassImpl* self, HDC hdc, \ 150 ITextIterator* it, int *ptext_index); \ 151 int (*getTextCount)(ClassImpl* self, HDC hdc, \ 152 ITextIterator* it, int* pstr_len);\ 153 int (*getCaretSize)(ClassImpl* self, HDC hdc, \ 154 ITextIterator* it, int *pWidth, int *pHeight); 156 DEFINE_INTERFACE(ITextRender)
162 #define ITextLayoutContextHeader(Interface, ClassImpl) \ 163 IInterfaceHeader(Interface, ClassImpl) \ 164 int (*getMetrics)(ClassImpl*,int type); \ 165 void (*setupDC)(ClassImpl*, HDC hdc); \ 166 void (*beginSelection)(ClassImpl*,HDC hdc); \ 167 void (*endSelection)(ClassImpl*, HDC hdc); \ 168 HDC (*getDC)(ClassImpl*); \ 169 void (*contentPosToDCPos)(ClassImpl*, HDC hdc, \ 171 void (*releaseDC)(ClassImpl*, HDC hdc); \ 172 void (*updateCaret)(ClassImpl*); \ 173 void (*update)(ClassImpl*, BOOL); 176 TEXTMETRICS_MAXWIDTH,
177 TEXTMETRICS_MAXHEIGHT,
178 TEXTMETRICS_LINESPACE,
179 TEXTMETRICS_DEFLINEHEIGHT
182 DEFINE_INTERFACE(ITextLayoutContext)
185 typedef
void (*CB_LINE_PROC)(
mObject* self,
int x,
int y,
int width,
int height,
int lineNo,
void* user_param);
186 typedef BOOL (*CB_NODE_PROC)(
mObject* self,
mObject* cur_node,
void* user_param);
188 #define ITextLayoutHeader(Interface, ClassImpl) \ 189 ITextBufferObserverHeader(Interface, ClassImpl) \ 191 int (*getCharIndex)(ClassImpl*, int *px, int *py, \ 192 int *plineHeight, int *ptext_index); \ 194 int (*getCharPos)(ClassImpl*, int index, int *px, \ 195 int *py, int *plineHeight, BOOL bAsText); \ 197 BOOL (*getTextBoundSize)(ClassImpl* self, int *cx, int *cy); \ 198 BOOL (*setCursor)(ClassImpl* self, int index, BOOL isSel); \ 199 int (*setCursorPos)(ClassImpl* self, int x, int y, BOOL isSel); \ 200 int (*getCursor)(ClassImpl*, int *px, int *py, int *cursor_h, BOOL isSel); \ 201 void (*draw)(ClassImpl* self, HDC hdc, int x, int y, int width, int height);\ 202 int (*getLineHeight)(ClassImpl* self, int index); \ 203 void (*reset)(ClassImpl *self); \ 204 int (*textCount2Len)(ClassImpl*, int text_index, int text_count, int *plen);\ 205 int (*textLen2Count)(ClassImpl*, int str_index, int str_len, int*text_count,\ 206 int *poutstr_index, int *poutstr_count); \ 207 void (*foreachLine)(ClassImpl*, int x, int y, int maxWidth, int maxHeight, \ 208 CB_LINE_PROC proc, mObject* proc_owner, void* user_param); \ 209 void (*travelNode)(ClassImpl*, CB_NODE_PROC proc, mObject* proc_owner, void* user_param); \ 210 PLOGFONT (*getReleatedFont)(ClassImpl*, int idx, BOOL isText); \ 211 int (*getParaByIndex)(ClassImpl* self, int index, int *pcol, BOOL bText); \ 212 int (*getLineByIndex)(ClassImpl* self, int index, int* pcol, BOOL bText); \ 213 int (*getIndexByPara)(ClassImpl* self, int paraNo, int col, BOOL* outOfRange, BOOL bText); \ 214 int (*getIndexByLine)(ClassImpl* self, int lineIdx, int col, BOOL* outOfRange, BOOL bText); 216 DEFINE_INTERFACE(ITextLayout)