mGNCS API Reference  v1.5.0
A new control set and a new framework for MiniGUI apps
mmledit.h
Go to the documentation of this file.
1 //
3 // IMPORTANT NOTICE
4 //
5 // The following open source license statement does not apply to any
6 // entity in the Exception List published by FMSoft.
7 //
8 // For more information, please visit:
9 //
10 // https://www.fmsoft.cn/exception-list
11 //
13 
55 #ifndef _MGUI_NCSCTRL_MLEDIT_H
56 #define _MGUI_NCSCTRL_MLEDIT_H
57 
58 #ifdef __cplusplus
59 extern "C" {
60 #endif /* __cplusplus */
61 
62 /* ------------------------------- text document/buffer ------------------------ */
63 
64 /* content type, reserved */
65 typedef enum {
66  CT_TEXT,
67  CT_BMP,
68  CT_ICON
69 } ContentType;
70 
71 /* text format, reserved */
72 typedef enum {
73  TF_PLAINTEXT,
74  TF_RICHTEXT,
75  TF_MEDIATEXT
76 } TextFormat;
77 
78 /* one text line (end with '\n') is a scrollview item */
79 /* structure of text node/line */
80 typedef struct _textnode
81 {
82  list_t list; /* list element */
83  StrBuffer content;
84  DWORD addData; /* for storing scrollview item handle */
85 } TextNode;
86 
87 /* structure of a text mark, recording insert position or selection range */
88 typedef struct _textmark
89 {
90  int pos_lnOff; /* mark offset in the text node*/
91  TextNode *curNode; /* text node containing the mark*/
92 } TextMark;
93 
94 /* structure of text document data */
95 typedef struct _textdoc
96 {
97  list_t queue; /* text line/node head */
98 
99  /* setup field */
100  unsigned char lnsep; /* line seperator (default is "\n") */
101  int nDefLineSize; /* default line buffer size*/
102  int nBlockSize; /* line buffer block size */
103 
104  /* node init function executed when creating node */
105  void (*init_fn) (struct _textdoc *, TextNode *, TextNode *);
106  /* node change function executed when changing current insertion/selection node */
107  void (*change_fn) (struct _textdoc *, BOOL bSel);
108  /* node content change function executed when string content of a node is changed */
109  void (*change_cont) (struct _textdoc *, TextNode *node);
110  /* node destroy function */
111  void (*del_fn) (struct _textdoc *, TextNode *);
112  void *fn_data; /* data passed to init_fn */
113 
114  /* status field */
115  TextMark insert; /* cursor/insertion mark */
116  TextMark selection; /* selection mark */
117 
118 } TextDoc;
119 
120 /* -------------------------------------------------------------------------- */
121 
122 /* backup data struct */
123 typedef struct _status_data
124 {
125  DWORD flags; /* editor status */
126 
127  int desCaretX; /* the desired caret x position, changed by mouse and <- , -> */
128 
129  int caretX; /* caret x position in the virtual content window */
130  int caretY; /* caret y position in the virtual content window */
131  int selX; /* selection point x position in the virtual content window */
132  int selY; /* selection point y position in the virtual content window */
133 
134  TextNode *maxNode; /* node with the max length */
135  int maxLen; /* max line length */
136  TextNode *secNode; /* node with the second max length */
137  int secLen; /* seconde max line length */
138 
139  int curItemY; /* y position of the current insertion node */
140  int selItemY; /* y position of the selection node */
141 } STATDATA;
142 typedef STATDATA* PSTATDATA;
143 
144 /* structure of backup text node/line */
145 typedef struct _bk_textnode
146 {
147  list_t list; /* list element */
148  StrBuffer content; /* text content */
149 } BkNode;
150 
151 typedef struct _backup_data
152 {
153  STATDATA statData;
154  TextMark bkIns; /* backup insertion point */
155  TextMark bkSel; /* backup selection point */
156  int opType; /* operation type */
157  list_t bkQueue; /* backup text nodes */
158 } BKDATA;
159 typedef BKDATA* PBKDATA;
160 
166 /*
167  * \def NCSCTRL_MLEDIT
168  * \brief the name of mledit control
169 */
170 #define NCSCTRL_MLEDIT NCSCLASSNAME("mledit")
171 
172 typedef struct _mMlEdit mMlEdit;
173 typedef struct _mMlEditClass mMlEditClass;
174 typedef struct _mMlEditRenderer mMlEditRenderer;
175 
176 
177 #define mMlEditHeader(Class) \
178  mEditHeader(Class) \
179  TextDoc txtDoc; \
180  StrBuffer teBuff; \
181  int nrDiffLine; \
182  int wNoChanged; \
183  int wLastLine; \
184  int hardLimit; \
185  int curLen; \
186  int nLineHeight; \
187  int nLineAboveH; \
188  int nLineBaseH; \
189  unsigned char lnChar; \
190  unsigned char caretShape; \
191  char *title; \
192  int titleIndent; \
193  DWORD flags; \
194  DWORD exFlags; \
195  BOOL contDirty; \
196  int desCaretX; \
197  int caretX; \
198  int caretY; \
199  int selX; \
200  int selY; \
201  TextNode *maxNode; \
202  int maxLen; \
203  TextNode *secNode; \
204  int secLen; \
205  int curItemY; \
206  int selItemY; \
207  TextCopyPaste *cp;
208 
274 struct _mMlEdit
275 {
276  mMlEditHeader(mMlEdit)
277 };
278 
279 #define mMlEditClassHeader(clsName, parentClass) \
280  mEditClassHeader (clsName, parentClass) \
281  int (*setTitle)(clsName *self, const char *title, int len); \
282  int (*getTitle)(clsName *self, char *buffer, int len);
283 
302 struct _mMlEditClass
303 {
304  mMlEditClassHeader(mMlEdit, mEdit)
305 };
306 
313 MGNCS_EXPORT extern mMlEditClass g_stmMlEditCls;
314 
315 
316 #define mMlEditRendererHeader(clsName, parentClass) \
317  mEditRendererHeader(clsName, parentClass) \
318 
319 
325 struct _mMlEditRenderer
326 {
327  mMlEditRendererHeader(mMlEdit, mEdit)
328 };
329 
334 #define NCSS_MLEDIT_AUTOWRAP (0x0001<<NCSS_EDIT_SHIFT)
335 
340 #define NCSS_MLEDIT_TITLE (0x0002<<NCSS_EDIT_SHIFT)
341 
342 #define NCSS_MLEDIT_SHIFT (NCSS_EDIT_SHIFT+2)
343 
346 {
347  NCSP_MLEDIT_LINECOUNT = NCSP_EDIT_MAX + 1,
353  NCSP_MLEDIT_MAX
354 };
355 
356 enum mMlEditNotify
357 {
358  NCSN_MLEDIT_MAX = NCSN_EDIT_MAX + 1,
359 };
360 
363 {
366 };
367 
368 
369 /* internal status flags */
370 #define NCSF_MLEDIT_SELECT 0x0001
371 #define NCSF_MLEDIT_FOCUSED 0x0002
372 #define NCSF_MLEDIT_TMP 0x0004
373 #define NCSF_MLEDIT_REPLACE 0x0008
374 #define NCSF_MLEDIT_MOVE 0x0010
375 #define NCSF_MLEDIT_NOCARET 0x0020
376 #define NCSF_MLEDIT_EX_SETFOCUS 0x0040
377 #define NCSF_MLEDIT_EX_KILLFOCUS 0x0080
378 
381 #ifdef __cplusplus
382 }
383 #endif /* __cplusplus */
384 
385 #endif /* _MGUI_NCSCTRL_MLEDIT_H */
NCSP_MLEDIT_LINESEP
@ NCSP_MLEDIT_LINESEP
Definition: mmledit.h:350
NCS_CARETSHAPE_BLOCK
@ NCS_CARETSHAPE_BLOCK
Definition: mmledit.h:365
NCSP_MLEDIT_NUMOFPARAGRAPHS
@ NCSP_MLEDIT_NUMOFPARAGRAPHS
Definition: mmledit.h:352
g_stmMlEditCls
MGNCS_EXPORT mMlEditClass g_stmMlEditCls
the instance of mMlEditClass
NCSP_MLEDIT_CARETSHAPE
@ NCSP_MLEDIT_CARETSHAPE
Definition: mmledit.h:351
mMlEditProp
mMlEditProp
Definition: mmledit.h:345
NCSP_MLEDIT_LINEHEIGHT
@ NCSP_MLEDIT_LINEHEIGHT
Definition: mmledit.h:348
list_head
The structure of double linked list.
Definition: mdblist.h:71
NCS_CARETSHAPE_LINE
@ NCS_CARETSHAPE_LINE
Definition: mmledit.h:364
mMlEditRenderer
MlEdit class's Renderer interface, derived from mEditRenderer.
NCSP_MLEDIT_LINEFEEDISPCHAR
@ NCSP_MLEDIT_LINEFEEDISPCHAR
Definition: mmledit.h:349
NCSP_MLEDIT_LINECOUNT
@ NCSP_MLEDIT_LINECOUNT
Definition: mmledit.h:347
ncsCaretShape
ncsCaretShape
Definition: mmledit.h:362
mMlEdit
the multiline edit control, derived from mEdit.
mMlEditClass
the VTable of mMlEdit, derived from mEditClass.
mEdit
the edit struct of edit control, derived from mScrollView.