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 diRun
, /* run (sequence of chars with the same character format) */
71 diStartRow
, /* start of the row (line of text on the screen) */
72 diTextEnd
, /* end of the text buffer */
74 /********************* these below are meant for finding only *********************/
75 diStartRowOrParagraph
, /* 5 */
76 diStartRowOrParagraphOrEnd
,
80 diRunOrParagraphOrEnd
, /* 10 */
82 diUndoInsertRun
, /* 11 */
83 diUndoDeleteRun
, /* 12 */
84 diUndoJoinParagraphs
, /* 13 */
85 diUndoSplitParagraph
, /* 14 */
86 diUndoSetParagraphFormat
, /* 15 */
87 diUndoSetCharFormat
, /* 16 */
88 diUndoEndTransaction
, /* 17 - marks the end of a group of changes for undo */
89 diUndoPotentialEndTransaction
, /* 18 - allows grouping typed chars for undo */
92 #define SELECTIONBAR_WIDTH 9
94 /******************************** run flags *************************/
95 #define MERF_STYLEFLAGS 0x0FFF
96 /* run contains non-text content, which has its own rules for wrapping, sizing etc */
97 #define MERF_GRAPHICS 0x001
98 /* run is a tab (or, in future, any kind of content whose size is dependent on run position) */
99 #define MERF_TAB 0x002
100 /* run is a cell boundary */
101 #define MERF_CELL 0x004
103 #define MERF_NONTEXT (MERF_GRAPHICS | MERF_TAB | MERF_CELL)
105 /* run is splittable (contains white spaces in the middle or end) */
106 #define MERF_SPLITTABLE 0x001000
107 /* run starts with whitespaces */
108 #define MERF_STARTWHITE 0x002000
109 /* run ends with whitespaces */
110 #define MERF_ENDWHITE 0x004000
111 /* run is completely made of whitespaces */
112 #define MERF_WHITESPACE 0x008000
113 /* run is a last (dummy) run in the paragraph */
114 #define MERF_SKIPPED 0x010000
115 /* flags that are calculated during text wrapping */
116 #define MERF_CALCBYWRAP 0x0F0000
117 /* the "end of paragraph" run, contains 1 character */
118 #define MERF_ENDPARA 0x100000
119 /* forcing the "end of row" run, contains 1 character */
120 #define MERF_ENDROW 0x200000
122 #define MERF_HIDDEN 0x400000
124 /* runs with any of these flags set cannot be joined */
125 #define MERF_NOJOIN (MERF_GRAPHICS|MERF_TAB|MERF_ENDPARA|MERF_ENDROW)
126 /* runs that don't contain real text */
127 #define MERF_NOTEXT (MERF_GRAPHICS|MERF_TAB|MERF_ENDPARA|MERF_ENDROW)
129 /* those flags are kept when the row is split */
130 #define MERF_SPLITMASK (~(0))
132 /******************************** para flags *************************/
134 /* this paragraph was already wrapped and hasn't changed, every change resets that flag */
135 #define MEPF_REWRAP 1
136 #define MEPF_REPAINT 2
138 /******************************** structures *************************/
140 struct tagME_DisplayItem
;
142 typedef struct tagME_Run
146 int nCharOfs
; /* relative to para's offset */
147 int nWidth
; /* width of full run, width of leading&trailing ws */
149 int nAscent
, nDescent
; /* pixels above/below baseline */
150 POINT pt
; /* relative to para's position */
151 struct tagME_TableCell
*pCell
; /* for MERF_CELL: points to respective cell in ME_Paragraph */
152 REOBJECT
*ole_obj
; /* FIXME: should be a union with strText (at least) */
153 int nCR
; int nLF
; /* for MERF_ENDPARA: number of \r and \n characters encoded by run */
156 typedef struct tagME_Document
{
157 struct tagME_DisplayItem
*def_char_style
;
158 struct tagME_DisplayItem
*def_para_style
;
159 int last_wrapped_line
;
162 typedef struct tagME_TableCell
165 struct tagME_TableCell
*next
;
168 typedef struct tagME_Paragraph
172 struct tagME_TableCell
*pCells
; /* list of cells and their properties */
173 struct tagME_TableCell
*pLastCell
; /* points to the last cell in the list */
178 int nLastPaintYPos
, nLastPaintHeight
;
180 struct tagME_DisplayItem
*prev_para
, *next_para
, *document
;
183 typedef struct tagME_Row
193 /* the display item list layout is like this:
194 * - the document consists of paragraphs
195 * - each paragraph contains at least one run, the last run in the paragraph
196 * is an end-of-paragraph run
197 * - each formatted paragraph contains at least one row, which corresponds
198 * to a screen line (that's why there are no rows in an unformatted
200 * - the paragraphs contain "shortcut" pointers to the previous and the next
201 * paragraph, that makes iteration over paragraphs faster
202 * - the list starts with diTextStart and ends with diTextEnd
205 typedef struct tagME_DisplayItem
208 struct tagME_DisplayItem
*prev
, *next
;
213 ME_Document doc
; /* not used */
214 ME_Style
*ustyle
; /* used by diUndoSetCharFormat */
218 typedef struct tagME_UndoItem
222 int nCR
, nLF
; /* used by diUndoSplitParagraph */
225 typedef struct tagME_TextBuffer
227 ME_DisplayItem
*pFirst
, *pLast
;
228 ME_Style
*pCharStyle
;
229 ME_Style
*pDefaultStyle
;
232 typedef struct tagME_Cursor
234 ME_DisplayItem
*pRun
;
253 typedef struct tagME_FontTableItem
{
259 #define STREAMIN_BUFFER_SIZE 4096 /* M$ compatibility */
261 struct tagME_InStream
{
262 EDITSTREAM
*editstream
;
265 char buffer
[STREAMIN_BUFFER_SIZE
];
267 typedef struct tagME_InStream ME_InStream
;
270 #define STREAMOUT_BUFFER_SIZE 4096
271 #define STREAMOUT_FONTTBL_SIZE 8192
272 #define STREAMOUT_COLORTBL_SIZE 1024
274 typedef struct tagME_OutStream
{
276 char buffer
[STREAMOUT_BUFFER_SIZE
];
280 ME_FontTableItem fonttbl
[STREAMOUT_FONTTBL_SIZE
];
282 COLORREF colortbl
[STREAMOUT_COLORTBL_SIZE
];
284 UINT nDefaultCodePage
;
287 typedef struct tagME_FontCacheItem
295 #define HFONT_CACHE_SIZE 10
297 typedef struct tagME_TextEditor
300 BOOL bEmulateVersion10
;
301 ME_TextBuffer
*pBuffer
;
305 int nTotalLength
, nLastTotalLength
;
309 COLORREF rgbBackColor
;
310 HBRUSH hbrBackground
;
314 ME_DisplayItem
*pUndoStack
, *pRedoStack
, *pUndoStackBottom
;
317 ME_UndoMode nUndoMode
;
319 int nLastSelStart
, nLastSelEnd
;
320 ME_DisplayItem
*pLastSelStartPara
, *pLastSelEndPara
;
321 ME_FontCacheItem pFontCache
[HFONT_CACHE_SIZE
];
322 int nZoomNumerator
, nZoomDenominator
;
328 EDITWORDBREAKPROCW pfnWordBreak
;
329 LPRICHEDITOLECALLBACK lpOleCallback
;
330 /*TEXTMODE variable; contains only one of each of the following options:
331 *TM_RICHTEXT or TM_PLAINTEXT
332 *TM_SINGLELEVELUNDO or TM_MULTILEVELUNDO
333 *TM_SINGLECODEPAGE or TM_MULTICODEPAGE*/
336 BOOL AutoURLDetect_bEnable
;
341 DWORD selofs
; /* The size of the selection bar on the left side of control */
342 ME_SelectionType nSelectionType
;
344 /* Track previous notified selection */
345 CHARRANGE notified_cr
;
347 /* Cache previously set vertical scrollbar info */
351 typedef struct tagME_Context
360 /* those are valid inside ME_WrapTextParagraph and related */
362 ME_TextEditor
*editor
;
366 typedef struct tagME_WrapContext
370 int nLeftMargin
, nRightMargin
, nFirstMargin
;
375 ME_DisplayItem
*pRowStart
;
377 ME_DisplayItem
*pLastSplittableRun
;
378 POINT ptLastSplittableRun
;