2 * RichEdit - structures and constant
4 * Copyright 2004 by Krzysztof Foltman
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #define _WIN32_IE 0x0400
45 #include "wine/debug.h"
47 typedef struct tagME_String
53 typedef struct tagME_Style
57 HFONT hFont; /* cached font for the style */
58 TEXTMETRICW tm; /* cached font metrics for the style */
59 int nRefs; /* reference count */
60 int nSequence; /* incremented when cache needs to be rebuilt, ie. every screen redraw */
64 diTextStart, /* start of the text buffer */
65 diParagraph, /* paragraph start */
66 diRun, /* run (sequence of chars with the same character format) */
67 diStartRow, /* start of the row (line of text on the screen) */
68 diTextEnd, /* end of the text buffer */
70 /********************* these below are meant for finding only *********************/
71 diStartRowOrParagraph, /* 5 */
72 diStartRowOrParagraphOrEnd,
76 diRunOrParagraphOrEnd, /* 10 */
78 diUndoInsertRun, /* 11 */
79 diUndoDeleteRun, /* 12 */
80 diUndoJoinParagraphs, /* 13 */
81 diUndoSplitParagraph, /* 14 */
82 diUndoSetParagraphFormat, /* 15 */
83 diUndoSetCharFormat, /* 16 */
84 diUndoEndTransaction, /* 17 */
85 diUndoSetDefaultCharFormat, /* 18 */
88 /******************************** run flags *************************/
89 #define MERF_STYLEFLAGS 0x0FFF
90 /* run contains non-text content, which has its own rules for wrapping, sizing etc */
91 #define MERF_GRAPHICS 1
92 /* run is a tab (or, in future, any kind of content whose size is dependent on run position) */
94 /* run is a cell boundary */
97 #define MERF_NONTEXT (MERF_GRAPHICS | MERF_TAB | MERF_CELL)
99 /* run is splittable (contains white spaces in the middle or end) */
100 #define MERF_SPLITTABLE 0x001000
101 /* run starts with whitespaces */
102 #define MERF_STARTWHITE 0x002000
103 /* run ends with whitespaces */
104 #define MERF_ENDWHITE 0x004000
105 /* run is completely made of whitespaces */
106 #define MERF_WHITESPACE 0x008000
107 /* run is a last (dummy) run in the paragraph */
108 #define MERF_SKIPPED 0x010000
109 /* flags that are calculated during text wrapping */
110 #define MERF_CALCBYWRAP 0x0F0000
111 /* the "end of paragraph" run, contains 1 character */
112 #define MERF_ENDPARA 0x100000
114 #define MERF_HIDDEN 0x200000
116 /* runs with any of these flags set cannot be joined */
117 #define MERF_NOJOIN (MERF_GRAPHICS|MERF_TAB|MERF_ENDPARA)
118 /* runs that don't contain real text */
119 #define MERF_NOTEXT (MERF_GRAPHICS|MERF_TAB|MERF_ENDPARA)
121 /* those flags are kept when the row is split */
122 #define MERF_SPLITMASK (~(0))
124 /******************************** para flags *************************/
126 /* this paragraph was already wrapped and hasn't changed, every change resets that flag */
127 #define MEPF_REWRAP 1
128 #define MEPF_REPAINT 2
130 /******************************** structures *************************/
132 struct tagME_DisplayItem;
134 typedef struct tagME_Run
138 int nCharOfs; /* relative to para's offset */
139 int nWidth; /* width of full run, width of leading&trailing ws */
141 int nAscent, nDescent; /* pixels above/below baseline */
142 POINT pt; /* relative to para's position */
143 struct tagME_TableCell *pCell; /* for MERF_CELL: points to respective cell in ME_Paragraph */
146 typedef struct tagME_Document {
147 struct tagME_DisplayItem *def_char_style;
148 struct tagME_DisplayItem *def_para_style;
149 int last_wrapped_line;
152 typedef struct tagME_TableCell
155 struct tagME_TableCell *next;
158 typedef struct tagME_Paragraph
162 BOOL bTable; /* this paragraph is a table row */
163 struct tagME_TableCell *pCells; /* list of cells and their properties */
164 struct tagME_TableCell *pLastCell; /* points to the last cell in the list */
166 int nLeftMargin, nRightMargin, nFirstMargin;
170 int nLastPaintYPos, nLastPaintHeight;
172 struct tagME_DisplayItem *prev_para, *next_para, *document;
175 typedef struct tagME_Row
185 /* the display item list layout is like this:
186 * - the document consists of paragraphs
187 * - each paragraph contains at least one run, the last run in the paragraph
188 * is an end-of-paragraph run
189 * - each formatted paragraph contains at least one row, which corresponds
190 * to a screen line (that's why there are no rows in an unformatted
192 * - the paragraphs contain "shortcut" pointers to the previous and the next
193 * paragraph, that makes iteration over paragraphs faster
194 * - the list starts with diTextStart and ends with diTextEnd
197 typedef struct tagME_DisplayItem
200 struct tagME_DisplayItem *prev, *next;
205 ME_Document doc; /* not used */
206 ME_Style *ustyle; /* used by diUndoSetCharFormat */
210 typedef struct tagME_UndoItem
216 typedef struct tagME_TextBuffer
218 ME_DisplayItem *pFirst, *pLast;
219 ME_Style *pCharStyle;
220 ME_Style *pDefaultStyle;
223 typedef struct tagME_Cursor
225 ME_DisplayItem *pRun;
236 typedef struct tagME_FontTableItem {
242 #define STREAMIN_BUFFER_SIZE 4096 /* M$ compatibility */
244 struct tagME_InStream {
245 EDITSTREAM *editstream;
248 char buffer[STREAMIN_BUFFER_SIZE];
250 typedef struct tagME_InStream ME_InStream;
253 #define STREAMOUT_BUFFER_SIZE 4096
254 #define STREAMOUT_FONTTBL_SIZE 8192
255 #define STREAMOUT_COLORTBL_SIZE 1024
257 typedef struct tagME_OutStream {
259 char buffer[STREAMOUT_BUFFER_SIZE];
263 ME_FontTableItem fonttbl[STREAMOUT_FONTTBL_SIZE];
265 COLORREF colortbl[STREAMOUT_COLORTBL_SIZE];
267 UINT nDefaultCodePage;
270 typedef struct tagME_FontCacheItem
278 #define HFONT_CACHE_SIZE 10
280 typedef struct tagME_TextEditor
283 BOOL bEmulateVersion10;
285 ME_TextBuffer *pBuffer;
289 int nTotalLength, nLastTotalLength;
292 int nOldSelFrom, nOldSelTo;
293 COLORREF rgbBackColor;
294 HBRUSH hbrBackground;
298 ME_DisplayItem *pUndoStack, *pRedoStack;
299 ME_UndoMode nUndoMode;
301 int nLastSelStart, nLastSelEnd;
302 ME_FontCacheItem pFontCache[HFONT_CACHE_SIZE];
303 BOOL bScrollX, bScrollY;
305 int nZoomNumerator, nZoomDenominator;
309 EDITWORDBREAKPROCW pfnWordBreak;
310 LPRICHEDITOLECALLBACK lpOleCallback;
313 typedef struct tagME_Context
321 /* those are valid inside ME_WrapTextParagraph and related */
323 ME_TextEditor *editor;
327 typedef struct tagME_WrapContext
331 int nLeftMargin, nRightMargin, nFirstMargin;
332 int nTotalWidth, nAvailWidth;
336 ME_DisplayItem *pRowStart;
338 ME_DisplayItem *pLastSplittableRun;
339 POINT ptLastSplittableRun;