mGNCS API Reference  v1.2.0
A new control set and a new framework for MiniGUI apps
mmledit.h
Go to the documentation of this file.
1 
43 #ifndef _MGUI_NCSCTRL_MLEDIT_H
44 #define _MGUI_NCSCTRL_MLEDIT_H
45 
46 #ifdef __cplusplus
47 extern "C" {
48 #endif /* __cplusplus */
49 
50 /* ------------------------------- text document/buffer ------------------------ */
51 
52 /* content type, reserved */
53 typedef enum {
54  CT_TEXT,
55  CT_BMP,
56  CT_ICON
57 } ContentType;
58 
59 /* text format, reserved */
60 typedef enum {
61  TF_PLAINTEXT,
62  TF_RICHTEXT,
63  TF_MEDIATEXT
64 } TextFormat;
65 
66 /* one text line (end with '\n') is a scrollview item */
67 /* structure of text node/line */
68 typedef struct _textnode
69 {
70  list_t list; /* list element */
71  StrBuffer content;
72  DWORD addData; /* for storing scrollview item handle */
73 } TextNode;
74 
75 /* structure of a text mark, recording insert position or selection range */
76 typedef struct _textmark
77 {
78  int pos_lnOff; /* mark offset in the text node*/
79  TextNode *curNode; /* text node containing the mark*/
80 } TextMark;
81 
82 /* structure of text document data */
83 typedef struct _textdoc
84 {
85  list_t queue; /* text line/node head */
86 
87  /* setup field */
88  unsigned char lnsep; /* line seperator (default is "\n") */
89  int nDefLineSize; /* default line buffer size*/
90  int nBlockSize; /* line buffer block size */
91 
92  /* node init function executed when creating node */
93  void (*init_fn) (struct _textdoc *, TextNode *, TextNode *);
94  /* node change function executed when changing current insertion/selection node */
95  void (*change_fn) (struct _textdoc *, BOOL bSel);
96  /* node content change function executed when string content of a node is changed */
97  void (*change_cont) (struct _textdoc *, TextNode *node);
98  /* node destroy function */
99  void (*del_fn) (struct _textdoc *, TextNode *);
100  void *fn_data; /* data passed to init_fn */
101 
102  /* status field */
103  TextMark insert; /* cursor/insertion mark */
104  TextMark selection; /* selection mark */
105 
106 } TextDoc;
107 
108 /* -------------------------------------------------------------------------- */
109 
110 /* backup data struct */
111 typedef struct _status_data
112 {
113  DWORD flags; /* editor status */
114 
115  int desCaretX; /* the desired caret x position, changed by mouse and <- , -> */
116 
117  int caretX; /* caret x position in the virtual content window */
118  int caretY; /* caret y position in the virtual content window */
119  int selX; /* selection point x position in the virtual content window */
120  int selY; /* selection point y position in the virtual content window */
121 
122  TextNode *maxNode; /* node with the max length */
123  int maxLen; /* max line length */
124  TextNode *secNode; /* node with the second max length */
125  int secLen; /* seconde max line length */
126 
127  int curItemY; /* y position of the current insertion node */
128  int selItemY; /* y position of the selection node */
129 } STATDATA;
130 typedef STATDATA* PSTATDATA;
131 
132 /* structure of backup text node/line */
133 typedef struct _bk_textnode
134 {
135  list_t list; /* list element */
136  StrBuffer content; /* text content */
137 } BkNode;
138 
139 typedef struct _backup_data
140 {
141  STATDATA statData;
142  TextMark bkIns; /* backup insertion point */
143  TextMark bkSel; /* backup selection point */
144  int opType; /* operation type */
145  list_t bkQueue; /* backup text nodes */
146 } BKDATA;
147 typedef BKDATA* PBKDATA;
148 
154 /*
155  * \def NCSCTRL_MLEDIT
156  * \brief the name of mledit control
157 */
158 #define NCSCTRL_MLEDIT NCSCLASSNAME("mledit")
159 
160 typedef struct _mMlEdit mMlEdit;
161 typedef struct _mMlEditClass mMlEditClass;
162 typedef struct _mMlEditRenderer mMlEditRenderer;
163 
164 
165 #define mMlEditHeader(Class) \
166  mEditHeader(Class) \
167  TextDoc txtDoc; \
168  StrBuffer teBuff; \
169  int nrDiffLine; \
170  int wNoChanged; \
171  int wLastLine; \
172  int hardLimit; \
173  int curLen; \
174  int nLineHeight; \
175  int nLineAboveH; \
176  int nLineBaseH; \
177  unsigned char lnChar; \
178  unsigned char caretShape; \
179  char *title; \
180  int titleIndent; \
181  DWORD flags; \
182  DWORD exFlags; \
183  BOOL contDirty; \
184  int desCaretX; \
185  int caretX; \
186  int caretY; \
187  int selX; \
188  int selY; \
189  TextNode *maxNode; \
190  int maxLen; \
191  TextNode *secNode; \
192  int secLen; \
193  int curItemY; \
194  int selItemY; \
195  TextCopyPaste *cp;
196 
262 struct _mMlEdit
263 {
264  mMlEditHeader(mMlEdit)
265 };
266 
267 #define mMlEditClassHeader(clsName, parentClass) \
268  mEditClassHeader (clsName, parentClass) \
269  int (*setTitle)(clsName *self, const char *title, int len); \
270  int (*getTitle)(clsName *self, char *buffer, int len);
271 
290 struct _mMlEditClass
291 {
292  mMlEditClassHeader(mMlEdit, mEdit)
293 };
294 
301 MGNCS_EXPORT extern mMlEditClass g_stmMlEditCls;
302 
303 
304 #define mMlEditRendererHeader(clsName, parentClass) \
305  mEditRendererHeader(clsName, parentClass) \
306 
307 
313 struct _mMlEditRenderer
314 {
315  mMlEditRendererHeader(mMlEdit, mEdit)
316 };
317 
322 #define NCSS_MLEDIT_AUTOWRAP (0x0001<<NCSS_EDIT_SHIFT)
323 
328 #define NCSS_MLEDIT_TITLE (0x0002<<NCSS_EDIT_SHIFT)
329 
330 #define NCSS_MLEDIT_SHIFT (NCSS_EDIT_SHIFT+2)
331 
334 {
335  NCSP_MLEDIT_LINECOUNT = NCSP_EDIT_MAX + 1,
341  NCSP_MLEDIT_MAX
342 };
343 
344 enum mMlEditNotify
345 {
346  NCSN_MLEDIT_MAX = NCSN_EDIT_MAX + 1,
347 };
348 
351 {
354 };
355 
356 
357 /* internal status flags */
358 #define NCSF_MLEDIT_SELECT 0x0001
359 #define NCSF_MLEDIT_FOCUSED 0x0002
360 #define NCSF_MLEDIT_TMP 0x0004
361 #define NCSF_MLEDIT_REPLACE 0x0008
362 #define NCSF_MLEDIT_MOVE 0x0010
363 #define NCSF_MLEDIT_NOCARET 0x0020
364 #define NCSF_MLEDIT_EX_SETFOCUS 0x0040
365 #define NCSF_MLEDIT_EX_KILLFOCUS 0x0080
366 
369 #ifdef __cplusplus
370 }
371 #endif /* __cplusplus */
372 
373 #endif /* _MGUI_NCSCTRL_MLEDIT_H */
the edit struct of edit control, derived from mScrollView.
MGNCS_EXPORT mMlEditClass g_stmMlEditCls
the instance of mMlEditClass
The structure of double linked list.
Definition: mdblist.h:59
ncsCaretShape
Definition: mmledit.h:350
MlEdit class&#39;s Renderer interface, derived from mEditRenderer.
mMlEditProp
Definition: mmledit.h:333
the multiline edit control, derived from mEdit.
the VTable of mMlEdit, derived from mEditClass.