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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
25 #define _WIN32_IE 0x0400
34 #define NONAMELESSUNION
35 #define NONAMELESSSTRUCT
48 #include "wine/debug.h"
50 typedef struct tagME_String
56 typedef struct tagME_Style
60 HFONT hFont; /* cached font for the style */
61 TEXTMETRICW tm; /* cached font metrics for the style */
62 int nRefs; /* reference count */
63 int nSequence; /* incremented when cache needs to be rebuilt, ie. every screen redraw */
68 diTextStart, /* start of the text buffer */
69 diParagraph, /* paragraph start */
70 diCell, /* cell start */
71 diRun, /* run (sequence of chars with the same character format) */
72 diStartRow, /* start of the row (line of text on the screen) */
73 diTextEnd, /* end of the text buffer */
75 /********************* these below are meant for finding only *********************/
76 diStartRowOrParagraph, /* 7 */
77 diStartRowOrParagraphOrEnd,
81 diRunOrParagraphOrEnd, /* 12 */
83 diUndoInsertRun, /* 13 */
84 diUndoDeleteRun, /* 14 */
85 diUndoJoinParagraphs, /* 15 */
86 diUndoSplitParagraph, /* 16 */
87 diUndoSetParagraphFormat, /* 17 */
88 diUndoSetCharFormat, /* 18 */
89 diUndoEndTransaction, /* 19 - marks the end of a group of changes for undo */
90 diUndoPotentialEndTransaction, /* 20 - allows grouping typed chars for undo */
93 #define SELECTIONBAR_WIDTH 8
95 /******************************** run flags *************************/
96 #define MERF_STYLEFLAGS 0x0FFF
97 /* run contains non-text content, which has its own rules for wrapping, sizing etc */
98 #define MERF_GRAPHICS 0x001
99 /* run is a tab (or, in future, any kind of content whose size is dependent on run position) */
100 #define MERF_TAB 0x002
101 /* run is a cell boundary */
102 #define MERF_ENDCELL 0x004 /* v4.1 */
104 #define MERF_NONTEXT (MERF_GRAPHICS | MERF_TAB | MERF_ENDCELL)
106 /* run is splittable (contains white spaces in the middle or end) */
107 #define MERF_SPLITTABLE 0x001000
108 /* run starts with whitespaces */
109 #define MERF_STARTWHITE 0x002000
110 /* run ends with whitespaces */
111 #define MERF_ENDWHITE 0x004000
112 /* run is completely made of whitespaces */
113 #define MERF_WHITESPACE 0x008000
114 /* run is a last (dummy) run in the paragraph */
115 #define MERF_SKIPPED 0x010000
116 /* flags that are calculated during text wrapping */
117 #define MERF_CALCBYWRAP 0x0F0000
118 /* the "end of paragraph" run, contains 1 character */
119 #define MERF_ENDPARA 0x100000
120 /* forcing the "end of row" run, contains 1 character */
121 #define MERF_ENDROW 0x200000
123 #define MERF_HIDDEN 0x400000
124 /* start of a table row has an empty paragraph that should be skipped over. */
125 #define MERF_TABLESTART 0x800000 /* v4.1 */
127 /* runs with any of these flags set cannot be joined */
128 #define MERF_NOJOIN (MERF_GRAPHICS|MERF_TAB|MERF_ENDPARA|MERF_ENDROW)
129 /* runs that don't contain real text */
130 #define MERF_NOTEXT (MERF_GRAPHICS|MERF_TAB|MERF_ENDPARA|MERF_ENDROW)
132 /* those flags are kept when the row is split */
133 #define MERF_SPLITMASK (~(0))
135 /******************************** para flags *************************/
137 /* this paragraph was already wrapped and hasn't changed, every change resets that flag */
138 #define MEPF_REWRAP 0x01
139 #define MEPF_REPAINT 0x02
141 #define MEPF_CELL 0x04 /* The paragraph is nested in a cell */
142 #define MEPF_ROWSTART 0x08 /* Hidden empty paragraph at the start of the row */
143 #define MEPF_ROWEND 0x10 /* Visible empty paragraph at the end of the row */
145 /******************************** structures *************************/
147 struct tagME_DisplayItem;
149 typedef struct tagME_Run
153 int nCharOfs; /* relative to para's offset */
154 int nWidth; /* width of full run, width of leading&trailing ws */
156 int nAscent, nDescent; /* pixels above/below baseline */
157 POINT pt; /* relative to para's position */
158 REOBJECT *ole_obj; /* FIXME: should be a union with strText (at least) */
159 int nCR; int nLF; /* for MERF_ENDPARA: number of \r and \n characters encoded by run */
162 typedef struct tagME_Document {
163 struct tagME_DisplayItem *def_char_style;
164 struct tagME_DisplayItem *def_para_style;
165 int last_wrapped_line;
168 typedef struct tagME_Border
174 typedef struct tagME_BorderRect
182 typedef struct tagME_Paragraph
186 struct tagME_DisplayItem *pCell; /* v4.1 */
187 ME_BorderRect border;
193 int nLastPaintYPos, nLastPaintHeight;
195 struct tagME_DisplayItem *prev_para, *next_para, *document;
198 typedef struct tagME_Cell /* v4.1 */
200 int nNestingLevel; /* 0 for normal cells, and greater for nested cells */
202 ME_BorderRect border;
205 int yTextOffset; /* The text offset is caused by the largest top border. */
206 struct tagME_DisplayItem *prev_cell, *next_cell, *parent_cell;
209 typedef struct tagME_Row
219 /* the display item list layout is like this:
220 * - the document consists of paragraphs
221 * - each paragraph contains at least one run, the last run in the paragraph
222 * is an end-of-paragraph run
223 * - each formatted paragraph contains at least one row, which corresponds
224 * to a screen line (that's why there are no rows in an unformatted
226 * - the paragraphs contain "shortcut" pointers to the previous and the next
227 * paragraph, that makes iteration over paragraphs faster
228 * - the list starts with diTextStart and ends with diTextEnd
231 typedef struct tagME_DisplayItem
234 struct tagME_DisplayItem *prev, *next;
240 ME_Document doc; /* not used */
241 ME_Style *ustyle; /* used by diUndoSetCharFormat */
245 typedef struct tagME_UndoItem
249 int nCR, nLF; /* used by diUndoSplitParagraph */
252 typedef struct tagME_TextBuffer
254 ME_DisplayItem *pFirst, *pLast;
255 ME_Style *pCharStyle;
256 ME_Style *pDefaultStyle;
259 typedef struct tagME_Cursor
261 ME_DisplayItem *pRun;
280 typedef struct tagME_FontTableItem {
286 #define STREAMIN_BUFFER_SIZE 4096 /* M$ compatibility */
288 struct tagME_InStream {
289 EDITSTREAM *editstream;
292 char buffer[STREAMIN_BUFFER_SIZE];
294 typedef struct tagME_InStream ME_InStream;
297 #define STREAMOUT_BUFFER_SIZE 4096
298 #define STREAMOUT_FONTTBL_SIZE 8192
299 #define STREAMOUT_COLORTBL_SIZE 1024
301 typedef struct tagME_OutStream {
303 char buffer[STREAMOUT_BUFFER_SIZE];
307 ME_FontTableItem fonttbl[STREAMOUT_FONTTBL_SIZE];
309 COLORREF colortbl[STREAMOUT_COLORTBL_SIZE];
311 UINT nDefaultCodePage;
312 /* nNestingLevel = 0 means we aren't in a cell, 1 means we are in a cell,
313 * an greater numbers mean we are in a cell nested within a cell. */
317 typedef struct tagME_FontCacheItem
325 #define HFONT_CACHE_SIZE 10
327 typedef struct tagME_TextEditor
330 BOOL bEmulateVersion10;
331 ME_TextBuffer *pBuffer;
335 int nTotalLength, nLastTotalLength;
338 COLORREF rgbBackColor;
339 HBRUSH hbrBackground;
343 ME_DisplayItem *pUndoStack, *pRedoStack, *pUndoStackBottom;
346 ME_UndoMode nUndoMode;
348 int nLastSelStart, nLastSelEnd;
349 ME_DisplayItem *pLastSelStartPara, *pLastSelEndPara;
350 ME_FontCacheItem pFontCache[HFONT_CACHE_SIZE];
351 int nZoomNumerator, nZoomDenominator;
354 BOOL bDefaultFormatRect;
358 EDITWORDBREAKPROCW pfnWordBreak;
359 LPRICHEDITOLECALLBACK lpOleCallback;
360 /*TEXTMODE variable; contains only one of each of the following options:
361 *TM_RICHTEXT or TM_PLAINTEXT
362 *TM_SINGLELEVELUNDO or TM_MULTILEVELUNDO
363 *TM_SINGLECODEPAGE or TM_MULTICODEPAGE*/
366 BOOL AutoURLDetect_bEnable;
371 DWORD selofs; /* The size of the selection bar on the left side of control */
372 ME_SelectionType nSelectionType;
374 /* Track previous notified selection */
375 CHARRANGE notified_cr;
377 /* Cache previously set vertical scrollbar info */
381 typedef struct tagME_Context
390 /* those are valid inside ME_WrapTextParagraph and related */
392 ME_TextEditor *editor;
396 typedef struct tagME_WrapContext
400 int nLeftMargin, nRightMargin, nFirstMargin;
404 BOOL bOverflown, bWordWrap;
405 ME_DisplayItem *pRowStart;
407 ME_DisplayItem *pLastSplittableRun;
408 POINT ptLastSplittableRun;