mmledit.h

Go to the documentation of this file.
00001 
00019 #ifndef _MGUI_NCSCTRL_MLEDIT_H
00020 #define _MGUI_NCSCTRL_MLEDIT_H
00021 
00022 #ifdef __cplusplus
00023 extern "C" {
00024 #endif  /* __cplusplus */
00025 
00026 /* ------------------------------- text document/buffer ------------------------ */
00027 
00028 /* content type, reserved */
00029 typedef enum {
00030     CT_TEXT,
00031     CT_BMP,
00032     CT_ICON
00033 } ContentType;
00034 
00035 /* text format, reserved */
00036 typedef enum {
00037     TF_PLAINTEXT,
00038     TF_RICHTEXT,
00039     TF_MEDIATEXT
00040 } TextFormat;
00041 
00042 /* one text line (end with '\n') is a scrollview item */ 
00043 /* structure of text node/line */
00044 typedef struct _textnode
00045 {
00046     list_t    list;            /* list element */
00047     StrBuffer content;
00048     DWORD     addData;         /* for storing scrollview item handle */
00049 } TextNode;
00050 
00051 /* structure of a text mark, recording insert position or selection range */
00052 typedef struct _textmark
00053 {
00054     int       pos_lnOff;       /* mark offset in the text node*/
00055     TextNode  *curNode;        /* text node containing the mark*/
00056 } TextMark;
00057 
00058 /* structure of text document data */
00059 typedef struct _textdoc
00060 {
00061     list_t    queue;           /* text line/node head */
00062 
00063     /* setup field */
00064     unsigned char lnsep;       /* line seperator (default is "\n") */
00065     int       nDefLineSize;    /* default line buffer size*/
00066     int       nBlockSize;      /* line buffer block size */
00067 
00068     /* node init function executed when creating node */
00069     void      (*init_fn)     (struct _textdoc *, TextNode *, TextNode *);
00070     /* node change function executed when changing current insertion/selection node */
00071     void      (*change_fn)   (struct _textdoc *, BOOL bSel);
00072     /* node content change function executed when string content of a node is changed */
00073     void      (*change_cont) (struct _textdoc *, TextNode *node);
00074     /* node destroy function */
00075     void      (*del_fn)      (struct _textdoc *, TextNode *);
00076     void       *fn_data;       /* data passed to init_fn */
00077 
00078     /* status field */
00079     TextMark  insert;          /* cursor/insertion mark */
00080     TextMark  selection;       /* selection mark */
00081 
00082 } TextDoc;
00083 
00084 /* -------------------------------------------------------------------------- */
00085 
00086 /* backup data struct */
00087 typedef struct _status_data
00088 {
00089     DWORD     flags;        /* editor status */
00090 
00091     int       desCaretX;  /* the desired caret x position, changed by mouse and <- , -> */
00092 
00093     int       caretX;      /* caret x position in the virtual content window */
00094     int       caretY;      /* caret y position in the virtual content window */
00095     int       selX;        /* selection point x position in the virtual content window */
00096     int       selY;        /* selection point y position in the virtual content window */
00097 
00098     TextNode  *maxNode;     /* node with the max length */
00099     int       maxLen;       /* max line length */
00100     TextNode  *secNode;     /* node with the second max length */
00101     int       secLen;       /* seconde max line length */
00102 
00103     int       curItemY;     /* y position of the current insertion node */
00104     int       selItemY;     /* y position of the selection node */
00105 } STATDATA;
00106 typedef STATDATA* PSTATDATA;
00107 
00108 /* structure of backup text node/line */
00109 typedef struct _bk_textnode
00110 {
00111     list_t    list;         /* list element */
00112     StrBuffer content;      /* text content */
00113 } BkNode;
00114 
00115 typedef struct _backup_data
00116 {
00117     STATDATA  statData;
00118     TextMark  bkIns;        /* backup insertion point */
00119     TextMark  bkSel;        /* backup selection point */
00120     int       opType;       /* operation type */
00121     list_t    bkQueue;      /* backup text nodes */
00122 } BKDATA;
00123 typedef BKDATA* PBKDATA;
00124 
00130 /*
00131  * \def NCSCTRL_MLEDIT
00132  * \brief the name of mledit control
00133 */
00134 #define NCSCTRL_MLEDIT   NCSCLASSNAME("mledit")
00135 
00136 typedef struct _mMlEdit         mMlEdit;
00137 typedef struct _mMlEditClass    mMlEditClass;
00138 typedef struct _mMlEditRenderer mMlEditRenderer;
00139 
00140 
00141 #define mMlEditHeader(Class)        \
00142         mEditHeader(Class)          \
00143         TextDoc   txtDoc;           \
00144         StrBuffer teBuff;           \
00145         int       nrDiffLine;       \
00146         int       wNoChanged;       \
00147         int       wLastLine;        \
00148         int       hardLimit;        \
00149         int       curLen;           \
00150         int       nLineHeight;      \
00151         int       nLineAboveH;      \
00152         int       nLineBaseH;       \
00153         unsigned char lnChar;       \
00154         unsigned char caretShape;   \
00155         char      *title;           \
00156         int       titleIndent;      \
00157         DWORD     flags;            \
00158         DWORD     exFlags;          \
00159         BOOL      contDirty;        \
00160         int       desCaretX;        \
00161         int       caretX;           \
00162         int       caretY;           \
00163         int       selX;             \
00164         int       selY;             \
00165         TextNode  *maxNode;         \
00166         int       maxLen;           \
00167         TextNode  *secNode;         \
00168         int       secLen;           \
00169         int       curItemY;         \
00170         int       selItemY;         \
00171         TextCopyPaste *cp;
00172 
00238 struct _mMlEdit
00239 {
00240     mMlEditHeader(mMlEdit)
00241 };
00242 
00243 #define mMlEditClassHeader(clsName, parentClass)                   \
00244     mEditClassHeader (clsName, parentClass)                        \
00245     int (*setTitle)(clsName *self, const char *title, int len);    \
00246     int (*getTitle)(clsName *self, char *buffer, int len); 
00247 
00266 struct _mMlEditClass
00267 {
00268     mMlEditClassHeader(mMlEdit, mEdit)
00269 };
00270 
00277 MGNCS_EXPORT extern mMlEditClass g_stmMlEditCls;
00278 
00279 
00280 #define mMlEditRendererHeader(clsName, parentClass) \
00281         mEditRendererHeader(clsName, parentClass)       \
00282 
00283 
00289 struct _mMlEditRenderer
00290 {
00291         mMlEditRendererHeader(mMlEdit, mEdit)
00292 };
00293 
00298 #define NCSS_MLEDIT_AUTOWRAP   (0x0001<<NCSS_EDIT_SHIFT)
00299 
00304 #define NCSS_MLEDIT_TITLE      (0x0002<<NCSS_EDIT_SHIFT)
00305 
00306 #define NCSS_MLEDIT_SHIFT  (NCSS_EDIT_SHIFT+2)
00307 
00309 enum mMlEditProp 
00310 {
00311     NCSP_MLEDIT_LINECOUNT = NCSP_EDIT_MAX + 1,   
00312     NCSP_MLEDIT_LINEHEIGHT,                    
00313     NCSP_MLEDIT_LINEFEEDISPCHAR,               
00314     NCSP_MLEDIT_LINESEP,                       
00315     NCSP_MLEDIT_CARETSHAPE,                    
00316     NCSP_MLEDIT_NUMOFPARAGRAPHS,               
00317     NCSP_MLEDIT_MAX
00318 };
00319 
00320 enum mMlEditNotify
00321 {
00322     NCSN_MLEDIT_MAX = NCSN_EDIT_MAX + 1,
00323 };
00324 
00326 enum ncsCaretShape
00327 {
00328     NCS_CARETSHAPE_LINE = 0, 
00329     NCS_CARETSHAPE_BLOCK     
00330 };
00331 
00332 
00333 /* internal status flags */
00334 #define NCSF_MLEDIT_SELECT         0x0001
00335 #define NCSF_MLEDIT_FOCUSED        0x0002
00336 #define NCSF_MLEDIT_TMP            0x0004
00337 #define NCSF_MLEDIT_REPLACE        0x0008
00338 #define NCSF_MLEDIT_MOVE           0x0010
00339 #define NCSF_MLEDIT_NOCARET        0x0020
00340 #define NCSF_MLEDIT_EX_SETFOCUS    0x0040
00341 #define NCSF_MLEDIT_EX_KILLFOCUS   0x0080
00342 
00345 #ifdef __cplusplus
00346 }
00347 #endif  /* __cplusplus */
00348 
00349 #endif /* _MGUI_NCSCTRL_MLEDIT_H */
Generated on Fri Jun 10 11:18:06 2011 for New Control Set V1.0.0 API Reference by  doxygen 1.6.3