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
42 #include "wine/debug.h"
44 typedef struct tagME_String
50 typedef struct tagME_Style
54 HFONT hFont
; /* cached font for the style */
55 TEXTMETRICW tm
; /* cached font metrics for the style */
56 int nRefs
; /* reference count */
57 int nSequence
; /* incremented when cache needs to be rebuilt, ie. every screen redraw */
61 diTextStart
, /* start of the text buffer */
62 diParagraph
, /* paragraph start */
63 diRun
, /* run (sequence of chars with the same character format) */
64 diStartRow
, /* start of the row (line of text on the screen) */
65 diTextEnd
, /* end of the text buffer */
67 /********************* these below are meant for finding only *********************/
68 diStartRowOrParagraph
, /* 5 */
69 diStartRowOrParagraphOrEnd
,
73 diRunOrParagraphOrEnd
, /* 10 */
75 diUndoInsertRun
, /* 11 */
76 diUndoDeleteRun
, /* 12 */
77 diUndoJoinParagraphs
, /* 13 */
78 diUndoSplitParagraph
, /* 14 */
79 diUndoSetParagraphFormat
, /* 15 */
80 diUndoSetCharFormat
, /* 16 */
81 diUndoEndTransaction
, /* 17 */
82 diUndoSetDefaultCharFormat
, /* 18 */
85 /******************************** run flags *************************/
86 #define MERF_STYLEFLAGS 0x0FFF
87 /* run contains non-text content, which has its own rules for wrapping, sizing etc */
88 #define MERF_GRAPHICS 1
89 /* run is a tab (or, in future, any kind of content whose size is dependent on run position) */
92 /* run is splittable (contains white spaces in the middle or end) */
93 #define MERF_SPLITTABLE 0x001000
94 /* run starts with whitespaces */
95 #define MERF_STARTWHITE 0x002000
96 /* run ends with whitespaces */
97 #define MERF_ENDWHITE 0x004000
98 /* run is completely made of whitespaces */
99 #define MERF_WHITESPACE 0x008000
100 /* run is a last (dummy) run in the paragraph */
101 #define MERF_SKIPPED 0x010000
102 /* flags that are calculated during text wrapping */
103 #define MERF_CALCBYWRAP 0x0F0000
104 /* the "end of paragraph" run, contains 1 character */
105 #define MERF_ENDPARA 0x100000
107 /* runs with any of these flags set cannot be joined */
108 #define MERF_NOJOIN (MERF_GRAPHICS|MERF_TAB|MERF_ENDPARA)
109 /* runs that don't contain real text */
110 #define MERF_NOTEXT (MERF_GRAPHICS|MERF_TAB|MERF_ENDPARA)
112 /* those flags are kept when the row is split */
113 #define MERF_SPLITMASK (~(0))
115 /******************************** para flags *************************/
117 /* this paragraph was already wrapped and hasn't changed, every change resets that flag */
118 #define MEPF_REWRAP 1
119 #define MEPF_REPAINT 2
121 /******************************** structures *************************/
123 struct tagME_DisplayItem
;
125 typedef struct tagME_Run
129 int nCharOfs
; /* relative to para's offset */
130 int nWidth
; /* width of full run, width of leading&trailing ws */
132 int nAscent
, nDescent
; /* pixels above/below baseline */
133 POINT pt
; /* relative to para's position */
136 typedef struct tagME_Document
{
137 struct tagME_DisplayItem
*def_char_style
;
138 struct tagME_DisplayItem
*def_para_style
;
139 int last_wrapped_line
;
142 typedef struct tagME_Paragraph
145 int nLeftMargin
, nRightMargin
, nFirstMargin
;
149 int nLastPaintYPos
, nLastPaintHeight
;
150 struct tagME_DisplayItem
*prev_para
, *next_para
, *document
;
153 typedef struct tagME_Row
163 typedef struct tagME_DisplayItem
166 struct tagME_DisplayItem
*prev
, *next
;
171 ME_Document doc
; /* not used */
172 ME_Style
*ustyle
; /* used by diUndoSetCharFormat */
176 typedef struct tagME_UndoItem
182 typedef struct tagME_TextBuffer
184 ME_DisplayItem
*pFirst
, *pLast
;
185 ME_Style
*pCharStyle
;
186 ME_Style
*pDefaultStyle
;
189 typedef struct tagME_Cursor
191 ME_DisplayItem
*pRun
;
202 typedef struct tagME_FontTableItem
{
208 #define STREAMIN_BUFFER_SIZE 4096 /* M$ compatibility */
210 struct tagME_InStream
{
211 EDITSTREAM
*editstream
;
214 BYTE buffer
[STREAMIN_BUFFER_SIZE
];
216 typedef struct tagME_InStream ME_InStream
;
219 #define STREAMOUT_BUFFER_SIZE 4096
220 #define STREAMOUT_FONTTBL_SIZE 8192
221 #define STREAMOUT_COLORTBL_SIZE 1024
223 typedef struct tagME_OutStream
{
225 char buffer
[STREAMOUT_BUFFER_SIZE
];
229 ME_FontTableItem fonttbl
[STREAMOUT_FONTTBL_SIZE
];
231 COLORREF colortbl
[STREAMOUT_COLORTBL_SIZE
];
233 UINT nDefaultCodePage
;
236 typedef struct tagME_FontCacheItem
244 #define HFONT_CACHE_SIZE 10
246 typedef struct tagME_TextEditor
250 ME_TextBuffer
*pBuffer
;
254 int nTotalLength
, nLastTotalLength
;
257 int nOldSelFrom
, nOldSelTo
;
258 COLORREF rgbBackColor
;
262 ME_DisplayItem
*pUndoStack
, *pRedoStack
;
263 ME_UndoMode nUndoMode
;
265 int nLastSelStart
, nLastSelEnd
;
266 ME_FontCacheItem pFontCache
[HFONT_CACHE_SIZE
];
267 ME_OutStream
*pStream
;
268 BOOL bScrollX
, bScrollY
;
272 typedef struct tagME_Context
280 /* those are valid inside ME_WrapTextParagraph and related */
282 ME_TextEditor
*editor
;
286 typedef struct tagME_WrapContext
290 int nLeftMargin
, nRightMargin
, nFirstMargin
;
291 int nTotalWidth
, nAvailWidth
;
295 ME_DisplayItem
*pRowStart
;
297 ME_DisplayItem
*pLastSplittableRun
;
298 POINT ptLastSplittableRun
;