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
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 */
67 diTextStart
, /* start of the text buffer */
68 diParagraph
, /* paragraph start */
69 diRun
, /* run (sequence of chars with the same character format) */
70 diStartRow
, /* start of the row (line of text on the screen) */
71 diTextEnd
, /* end of the text buffer */
73 /********************* these below are meant for finding only *********************/
74 diStartRowOrParagraph
, /* 5 */
75 diStartRowOrParagraphOrEnd
,
79 diRunOrParagraphOrEnd
, /* 10 */
81 diUndoInsertRun
, /* 11 */
82 diUndoDeleteRun
, /* 12 */
83 diUndoJoinParagraphs
, /* 13 */
84 diUndoSplitParagraph
, /* 14 */
85 diUndoSetParagraphFormat
, /* 15 */
86 diUndoSetCharFormat
, /* 16 */
87 diUndoEndTransaction
, /* 17 */
88 diUndoSetDefaultCharFormat
, /* 18 */
91 /******************************** run flags *************************/
92 #define MERF_STYLEFLAGS 0x0FFF
93 /* run contains non-text content, which has its own rules for wrapping, sizing etc */
94 #define MERF_GRAPHICS 1
95 /* run is a tab (or, in future, any kind of content whose size is dependent on run position) */
97 /* run is a cell boundary */
100 #define MERF_NONTEXT (MERF_GRAPHICS | MERF_TAB | MERF_CELL)
102 /* run is splittable (contains white spaces in the middle or end) */
103 #define MERF_SPLITTABLE 0x001000
104 /* run starts with whitespaces */
105 #define MERF_STARTWHITE 0x002000
106 /* run ends with whitespaces */
107 #define MERF_ENDWHITE 0x004000
108 /* run is completely made of whitespaces */
109 #define MERF_WHITESPACE 0x008000
110 /* run is a last (dummy) run in the paragraph */
111 #define MERF_SKIPPED 0x010000
112 /* flags that are calculated during text wrapping */
113 #define MERF_CALCBYWRAP 0x0F0000
114 /* the "end of paragraph" run, contains 1 character */
115 #define MERF_ENDPARA 0x100000
117 #define MERF_HIDDEN 0x200000
119 /* runs with any of these flags set cannot be joined */
120 #define MERF_NOJOIN (MERF_GRAPHICS|MERF_TAB|MERF_ENDPARA)
121 /* runs that don't contain real text */
122 #define MERF_NOTEXT (MERF_GRAPHICS|MERF_TAB|MERF_ENDPARA)
124 /* those flags are kept when the row is split */
125 #define MERF_SPLITMASK (~(0))
127 /******************************** para flags *************************/
129 /* this paragraph was already wrapped and hasn't changed, every change resets that flag */
130 #define MEPF_REWRAP 1
131 #define MEPF_REPAINT 2
133 /******************************** structures *************************/
135 struct tagME_DisplayItem
;
137 typedef struct tagME_Run
141 int nCharOfs
; /* relative to para's offset */
142 int nWidth
; /* width of full run, width of leading&trailing ws */
144 int nAscent
, nDescent
; /* pixels above/below baseline */
145 POINT pt
; /* relative to para's position */
146 struct tagME_TableCell
*pCell
; /* for MERF_CELL: points to respective cell in ME_Paragraph */
149 typedef struct tagME_Document
{
150 struct tagME_DisplayItem
*def_char_style
;
151 struct tagME_DisplayItem
*def_para_style
;
152 int last_wrapped_line
;
155 typedef struct tagME_TableCell
158 struct tagME_TableCell
*next
;
161 typedef struct tagME_Paragraph
165 BOOL bTable
; /* this paragraph is a table row */
166 struct tagME_TableCell
*pCells
; /* list of cells and their properties */
167 struct tagME_TableCell
*pLastCell
; /* points to the last cell in the list */
169 int nLeftMargin
, nRightMargin
, nFirstMargin
;
173 int nLastPaintYPos
, nLastPaintHeight
;
175 struct tagME_DisplayItem
*prev_para
, *next_para
, *document
;
178 typedef struct tagME_Row
188 /* the display item list layout is like this:
189 * - the document consists of paragraphs
190 * - each paragraph contains at least one run, the last run in the paragraph
191 * is an end-of-paragraph run
192 * - each formatted paragraph contains at least one row, which corresponds
193 * to a screen line (that's why there are no rows in an unformatted
195 * - the paragraphs contain "shortcut" pointers to the previous and the next
196 * paragraph, that makes iteration over paragraphs faster
197 * - the list starts with diTextStart and ends with diTextEnd
200 typedef struct tagME_DisplayItem
203 struct tagME_DisplayItem
*prev
, *next
;
208 ME_Document doc
; /* not used */
209 ME_Style
*ustyle
; /* used by diUndoSetCharFormat */
213 typedef struct tagME_UndoItem
219 typedef struct tagME_TextBuffer
221 ME_DisplayItem
*pFirst
, *pLast
;
222 ME_Style
*pCharStyle
;
223 ME_Style
*pDefaultStyle
;
226 typedef struct tagME_Cursor
228 ME_DisplayItem
*pRun
;
239 typedef struct tagME_FontTableItem
{
245 #define STREAMIN_BUFFER_SIZE 4096 /* M$ compatibility */
247 struct tagME_InStream
{
248 EDITSTREAM
*editstream
;
251 char buffer
[STREAMIN_BUFFER_SIZE
];
253 typedef struct tagME_InStream ME_InStream
;
256 #define STREAMOUT_BUFFER_SIZE 4096
257 #define STREAMOUT_FONTTBL_SIZE 8192
258 #define STREAMOUT_COLORTBL_SIZE 1024
260 typedef struct tagME_OutStream
{
262 char buffer
[STREAMOUT_BUFFER_SIZE
];
266 ME_FontTableItem fonttbl
[STREAMOUT_FONTTBL_SIZE
];
268 COLORREF colortbl
[STREAMOUT_COLORTBL_SIZE
];
270 UINT nDefaultCodePage
;
273 typedef struct tagME_FontCacheItem
281 #define HFONT_CACHE_SIZE 10
283 typedef struct tagME_TextEditor
286 BOOL bEmulateVersion10
;
288 ME_TextBuffer
*pBuffer
;
292 int nTotalLength
, nLastTotalLength
;
295 int nOldSelFrom
, nOldSelTo
;
296 COLORREF rgbBackColor
;
297 HBRUSH hbrBackground
;
301 ME_DisplayItem
*pUndoStack
, *pRedoStack
, *pUndoStackBottom
;
304 ME_UndoMode nUndoMode
;
306 int nLastSelStart
, nLastSelEnd
;
307 ME_FontCacheItem pFontCache
[HFONT_CACHE_SIZE
];
308 BOOL bScrollX
, bScrollY
;
310 int nZoomNumerator
, nZoomDenominator
;
314 EDITWORDBREAKPROCW pfnWordBreak
;
315 LPRICHEDITOLECALLBACK lpOleCallback
;
316 /*TEXTMODE variable; contains only one of each of the following options:
317 *TM_RICHTEXT or TM_PLAINTEXT
318 *TM_SINGLELEVELUNDO or TM_MULTILEVELUNDO
319 *TM_SINGLECODEPAGE or TM_MULTICODEPAGE*/
322 BOOL AutoURLDetect_bEnable
;
325 typedef struct tagME_Context
333 /* those are valid inside ME_WrapTextParagraph and related */
335 ME_TextEditor
*editor
;
339 typedef struct tagME_WrapContext
343 int nLeftMargin
, nRightMargin
, nFirstMargin
;
344 int nTotalWidth
, nAvailWidth
;
348 ME_DisplayItem
*pRowStart
;
350 ME_DisplayItem
*pLastSplittableRun
;
351 POINT ptLastSplittableRun
;