00001
00028 #ifndef _MGUI_TEXT_EDIT_H
00029 #define _MGUI_TEXT_EDIT_H
00030
00031 #if defined(_MGNCSCTRL_TEXTEDITOR) || (defined(_MGCTRL_TEXTEDIT) && defined(_MGCTRL_TEXTEDIT_USE_NEW_IMPL))
00032
00033 #ifdef __cplusplus
00034 extern "C" {
00035 #endif
00036
00037
00038 #define _MGHAVE_TEXTEDITTITLE 0
00039
00040 DECLARE_OBJECT(mTextBuffer)
00041 DECLARE_OBJECT(mTextIterator)
00042 DECLARE_OBJECT(mTextLayout)
00043 DECLARE_OBJECT(mTextLayoutNode)
00044 DECLARE_OBJECT(mTextRender)
00045
00047
00048 typedef struct _TextBufferObserverNode {
00049 ITextBufferObserver* observer;
00050 struct _TextBufferObserverNode* next;
00051 }mTextBufferObserverNode;
00052
00053 #define mTextBufferHeader(Clss) \
00054 mObjectHeader(Clss) \
00055 INTERFACE(ITextBuffer) \
00056 char * buffer; \
00057 int max_size; \
00058 int char_len; \
00059 mTextBufferObserverNode* observers;
00060
00061 #define mTextBufferClassHeader(Clss, Super) \
00062 mObjectClassHeader(Clss, Super) \
00063 ITextBufferHeader(ITextBuffer, Clss)
00064
00065
00066
00067 DEFINE_OBJECT(mTextBuffer, mObject)
00068
00069
00070
00071 #define mTextIteratorHeader(Clss) \
00072 mObjectHeader(Clss) \
00073 INTERFACE(ITextIterator) \
00074 mTextBuffer* buffer; \
00075 int index;
00076
00077 #define mTextIteratorClassHeader(Clss, Super) \
00078 mObjectClassHeader(Clss, Super) \
00079 ITextIteratorHeader(ITextIterator, Clss)
00080
00081
00082
00083 DEFINE_OBJECT(mTextIterator, mObject)
00084
00085
00086
00087 #define mTextLayoutHeader(Clss) \
00088 mCommBTreeHeader(Clss) \
00089 INTERFACE(ITextLayout) \
00090 ITextBuffer * text_buffer; \
00091 int cursor; \
00092 int cursor_x, cursor_y; \
00093 int cursor_height; \
00094 int text_cursor; \
00095 int sel_begin; \
00096 int sel_begin_x, sel_begin_y;\
00097 int sel_begin_height; \
00098 int text_sel_begin; \
00099 ITextLayoutContext* context; \
00100 PCLIPRGN dirty_area; \
00101 int old_height, new_height; //height changed include
00102
00103 #define mTextLayoutClassHeader(Clss, Super) \
00104 mCommBTreeClassHeader(Clss, Super) \
00105 ITextLayoutHeader(ITextLayout, Clss)
00106
00107 DEFINE_OBJECT(mTextLayout, mCommBTree)
00108
00109
00110
00111 #define mTextLayoutNodeHeader(Clss) \
00112 mCommBTreeNodeHeader(Clss) \
00113 int str_count; \
00114 int text_count; \
00115 int width, height;
00116
00117 #define mTextLayoutNodeClassHeader(Clss, Super) \
00118 mCommBTreeNodeClassHeader(Clss, Super)
00119
00120 DEFINE_OBJECT(mTextLayoutNode,mCommBTreeNode)
00121
00122
00123
00124
00125 #define mTextRenderHeader(Clss) \
00126 mObjectHeader(Clss) \
00127 INTERFACE(ITextRender)
00128
00129 #define mTextRenderClassHeader(Clss, Super) \
00130 mObjectClassHeader(Clss, Super) \
00131 ITextRenderHeader(ITextRender, Clss)
00132
00133 DEFINE_OBJECT(mTextRender,mObject)
00134
00135 enum {
00136 NCS_TXTRDR_TEXT = 0
00137 };
00138
00139 ITextRender* GetTextRender(int type);
00140
00141
00142 DECLARE_OBJECT(mTextEditor)
00143
00144
00149 #ifndef __MINIGUI_LIB__
00150
00154 #define NCSCTRL_TEXTEDITOR NCSCLASSNAME("texteditor")
00155 #endif
00156
00157
00158 #define NCS_TEF_REPLACE_MODE 0x010000
00159 #define NCS_TEF_HAS_PAINTED 0x020000
00160 #define mTextEditor_isReplaceMode(self) \
00161 ((self)->flags&NCS_TEF_REPLACE_MODE)
00162 #define mTextEditor_hasPainted(self) \
00163 ((self)->flags&NCS_TEF_HAS_PAINTED)
00164
00165
00166 #ifdef _MGHAVE_TEXTEDITTITLE
00167 #define TITLE_HEADER \
00168 int title_idx, title_text_idx; \
00169 int title_x, title_y, title_last_height; \
00170 int title_paracount; \
00171 int title_last_para_text_index; \
00172 int title_linecount; \
00173 int title_last_line_text_index;
00174
00175 #define TITLE_CLASS_HEADER(Clss) \
00176 void (*setTitle)(Clss*, const char* buff, int len); \
00177 int (*getTitle)(Clss*, char* buff, int max);
00178
00179
00180 #else
00181 #define TITLE_HEADER
00182 #define TITLE_CLASS_HEADER(Clss)
00183 #endif
00184
00185
00214 #define mTextEditorHeader(Clss) \
00215 mWidgetHeader(Clss) \
00216 INTERFACE(ITextLayoutContext) \
00217 mTextBuffer *textBuffer; \
00218 mTextLayout *textLayout; \
00219 int visWidth, visHeight;\
00220 int offX, offY; \
00221 int hardLimit; \
00222 unsigned int flags; \
00223 int caretWidth; \
00224 int caretHeight; \
00225 unsigned short scrollBarMode; \
00226 unsigned int scrollHStep; \
00227 unsigned int scrollVStep; \
00228 RECT margins; \
00229 int oldOffX, oldOffY; \
00230 TITLE_HEADER
00231
00232
00318 #define mTextEditorClassHeader(Clss, Super) \
00319 mWidgetClassHeader(Clss, Super) \
00320 ITextLayoutContextHeader(ITextLayoutContext, Clss) \
00321 int (*onChar)(Clss*, int asciiCode, DWORD keyFlags); \
00322 BOOL (*onFontChanged)(Clss*); \
00323 int (*getInvalidBkgnd)(Clss*, RECT *prc); \
00324 int (*onLButtonDBClk)(Clss*, int x, int y, DWORD keyFlags); \
00325 void (*onCSizeChanged)(Clss*, int cliWidth, int cliHeight); \
00326 void (*onSetFocus)(Clss*, HWND oldActiveWnd, int lParam); \
00327 void (*onKillFocus)(Clss*, HWND newActiveWnd, int lParam); \
00328 void (*onHScroll)(Clss*, int code, int mouseX); \
00329 void (*onVScroll)(Clss*, int code, int mouseY); \
00330 \
00331 int (*getParaText)(Clss*, int index, int start, int len, char* buffer); \
00332 int (*getLineText)(Clss*, int index, int start, int len, char* buffer); \
00333 int (*getParaLength)(Clss*, int index, int *startPos); \
00334 int (*getParaLengthInMChar)(Clss*, int paraNo, int *startPos); \
00335 int (*getLineLength)(Clss*, int lineNo, int *startPos, BOOL bMChar); \
00336 int (*getParaNum)(Clss*); \
00337 int (*setText)(Clss*, const char* text); \
00338 int (*insertText)(Clss*, const char* text, int len); \
00339 int (*getText)(Clss*, char* text, int len); \
00340 int (*getTextLen)(Clss*); \
00341 BOOL (*enableCaret)(Clss*, BOOL enable); \
00342 int (*setCaretPosByPara)(Clss*, unsigned int paraIdx, unsigned int offChar, \
00343 BOOL isSel); \
00344 int (*getCaretPosByPara)(Clss*, int *paraIdx, int *offChar, \
00345 int *height, BOOL isSel); \
00346 int (*setCaretPosByLine)(Clss*, unsigned int lineIdx, unsigned int offChar, \
00347 BOOL isSel); \
00348 int (*getCaretPosByLine)(Clss*, int *lineIdx, int *offChar, \
00349 int *height, BOOL isSel); \
00350 int (*getLineCount)(Clss*); \
00351 void (*selectAll)(Clss*); \
00352 int (*setSel)(Clss*, unsigned int startParaIdx, unsigned int startOffChar, \
00353 unsigned int endParaIdx, unsigned int endOffChar); \
00354 int (*getSel)(Clss*, char *buffer, int len); \
00355 BOOL (*needLineDecorative)(Clss*); \
00356 void (*lineDecorative)(Clss*, int x, int y, int w, int h, \
00357 int lineNo, HDC hdc); \
00358 TITLE_CLASS_HEADER(Clss)
00359
00360 #ifndef __MINIGUI_LIB__
00361
00366 #define NCSS_TE_READONLY (1<<NCSS_WIDGET_SHIFT)
00367
00372 #define NCSS_TE_UPPERCASE (2<<NCSS_WIDGET_SHIFT)
00373
00378 #define NCSS_TE_LOWERCASE (4<<NCSS_WIDGET_SHIFT)
00379
00384 #define NCSS_TE_NOHIDESEL (8<<NCSS_WIDGET_SHIFT)
00385
00390 #define NCSS_TE_AUTOWRAP (0x10<<NCSS_WIDGET_SHIFT)
00391
00396 #define NCSS_TE_BASELINE (0x20<<NCSS_WIDGET_SHIFT)
00397
00402 #define NCSS_TE_OWNERBKGND (0x40<<NCSS_WIDGET_SHIFT)
00403
00404
00405
00406
00407
00408 #define NCSS_TE_TITLE (0x80<<NCSS_WIDGET_SHIFT)
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418 #define NCSS_TE_AUTOVSCROLL (0x100<<NCSS_WIDGET_SHIFT)
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428 #define NCSS_TE_AUTOHSCROLL (0x200<<NCSS_WIDGET_SHIFT)
00429
00430 #define NCSS_TE_SHIFT (NCSS_WIDGET_SHIFT + 10)
00431
00432 #endif
00433
00438 enum ncsTEScrollMode
00439 {
00443 NCS_TEF_SCROLLBAR_NEVER = 0,
00444
00448 NCS_TEF_SCROLLBAR_AUTO,
00449
00453 NCS_TEF_SCROLLBAR_ALWAYS,
00454 };
00455
00460 enum mTextEditorProp
00461 {
00465 NCSP_TE_READONLY = NCSP_WIDGET_MAX + 1,
00466
00470 NCSP_TE_SCROLL_MODE,
00471
00475 NCSP_TE_SCROLL_HSTEP,
00476
00480 NCSP_TE_SCROLL_VSTEP,
00481
00485 NCSP_TE_TEXTLIMIT,
00486
00490 NCSP_TE_LINECOUNT,
00491
00495 NCSP_TE_PARAGRAPHCOUNT,
00496
00500 NCSP_TE_MARGINRECT,
00501
00505 NCSP_TE_MAX,
00506 };
00507 #define NCSP_TE_NUMOFPARAGRAPHS NCSP_TE_PARAGRAPHCOUNT
00508
00509 #ifndef __MINIGUI_LIB__
00510
00514 enum mTextEditorNotify
00515 {
00519 NCSN_TE_CONTENTCHANGED = NCSN_WIDGET_MAX + 1,
00520
00524 NCSN_TE_SETFOCUS,
00525
00529 NCSN_TE_KILLFOCUS,
00530
00534 NCSN_TE_MAXTEXT,
00535
00539 NCSN_TE_CHANGE,
00540
00545 NCSN_TE_UPDATE,
00546
00550 NCSN_TE_SELCHANGED,
00551
00555 NCSN_TE_MAX
00556 };
00557
00558 typedef struct _mTextEditorRenderer mTextEditorRenderer;
00559 #endif
00560
00561
00562 DEFINE_OBJECT(mTextEditor, mWidget)
00563
00564 #ifdef __MINIGUI_LIB__
00565 void TextEditorDrawLinesDecorative(mTextEditor * self, HDC hdc, int x, int y, int w, int h);
00566 #define mTextEditor_drawLinesDecorative TextEditorDrawLinesDecorative
00567 #else
00568 void mTextEditor_drawLinesDecorative(mTextEditor * self, HDC hdc, int x, int y, int w, int h);
00569 #endif
00570
00572 #ifdef __cplusplus
00573 }
00574 #endif
00575
00576 #endif
00577
00578 #endif
00579
00580