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
50 #include "wine/debug.h"
51 #include "wine/heap.h"
52 #include "wine/list.h"
55 extern const struct ITextHostVtbl itextHostStdcallVtbl DECLSPEC_HIDDEN
;
58 typedef struct tagME_String
62 void (*free
)(struct tagME_String
*);
65 typedef struct tagME_FontCacheItem
73 #define HFONT_CACHE_SIZE 10
75 typedef struct tagME_Style
79 ME_FontCacheItem
*font_cache
; /* cached font for the style */
80 TEXTMETRICW tm
; /* cached font metrics for the style */
81 int nRefs
; /* reference count */
82 SCRIPT_CACHE script_cache
;
88 diTextStart
, /* start of the text buffer */
89 diParagraph
, /* paragraph start */
90 diCell
, /* cell start */
91 diRun
, /* run (sequence of chars with the same character format) */
92 diStartRow
, /* start of the row (line of text on the screen) */
93 diTextEnd
, /* end of the text buffer */
95 /********************* these below are meant for finding only *********************/
96 diStartRowOrParagraph
, /* 7 */
97 diStartRowOrParagraphOrEnd
,
101 diRunOrParagraphOrEnd
, /* 12 */
104 #define SELECTIONBAR_WIDTH 8
106 /******************************** run flags *************************/
107 #define MERF_STYLEFLAGS 0x0FFF
108 /* run contains non-text content, which has its own rules for wrapping, sizing etc */
109 #define MERF_GRAPHICS 0x001
110 /* run is a tab (or, in future, any kind of content whose size is dependent on run position) */
111 #define MERF_TAB 0x002
112 /* run is a cell boundary */
113 #define MERF_ENDCELL 0x004 /* v4.1 */
115 #define MERF_NONTEXT (MERF_GRAPHICS | MERF_TAB | MERF_ENDCELL)
117 /* run is splittable (contains white spaces in the middle or end) */
118 #define MERF_SPLITTABLE 0x001000
119 /* run starts with whitespaces */
120 #define MERF_STARTWHITE 0x002000
121 /* run ends with whitespaces */
122 #define MERF_ENDWHITE 0x004000
123 /* run is completely made of whitespaces */
124 #define MERF_WHITESPACE 0x008000
125 /* the "end of paragraph" run, contains 1 character */
126 #define MERF_ENDPARA 0x100000
127 /* forcing the "end of row" run, contains 1 character */
128 #define MERF_ENDROW 0x200000
130 #define MERF_HIDDEN 0x400000
131 /* start of a table row has an empty paragraph that should be skipped over. */
132 #define MERF_TABLESTART 0x800000 /* v4.1 */
134 /* runs with any of these flags set cannot be joined */
135 #define MERF_NOJOIN (MERF_GRAPHICS|MERF_TAB|MERF_ENDPARA|MERF_ENDROW)
136 /* runs that don't contain real text */
137 #define MERF_NOTEXT (MERF_GRAPHICS|MERF_TAB|MERF_ENDPARA|MERF_ENDROW)
139 /* those flags are kept when the row is split */
140 #define MERF_SPLITMASK (~(0))
142 /******************************** para flags *************************/
144 /* this paragraph was already wrapped and hasn't changed, every change resets that flag */
145 #define MEPF_REWRAP 0x01
147 #define MEPF_CELL 0x04 /* The paragraph is nested in a cell */
148 #define MEPF_ROWSTART 0x08 /* Hidden empty paragraph at the start of the row */
149 #define MEPF_ROWEND 0x10 /* Visible empty paragraph at the end of the row */
150 #define MEPF_COMPLEX 0x20 /* Use uniscribe */
152 /******************************** structures *************************/
154 struct tagME_DisplayItem
;
162 typedef struct tagME_Run
165 struct tagME_Paragraph
*para
; /* ptr to the run's paragraph */
166 int nCharOfs
; /* relative to para's offset */
167 int len
; /* length of run's text */
168 int nWidth
; /* width of full run, width of leading&trailing ws */
170 int nAscent
, nDescent
; /* pixels above/below baseline */
171 POINT pt
; /* relative to para's position */
172 struct re_object
*reobj
; /* FIXME: should be a union with strText (at least) */
174 SCRIPT_ANALYSIS script_analysis
;
175 int num_glyphs
, max_glyphs
;
177 SCRIPT_VISATTR
*vis_attrs
;
184 typedef struct tagME_Border
190 typedef struct tagME_BorderRect
206 typedef struct tagME_Paragraph
211 struct tagME_DisplayItem
*pCell
; /* v4.1 */
212 ME_BorderRect border
;
219 struct para_num para_num
;
220 ME_Run
*eop_run
; /* ptr to the end-of-para run */
221 struct tagME_DisplayItem
*prev_para
, *next_para
;
224 typedef struct tagME_Cell
/* v4.1 */
226 int nNestingLevel
; /* 0 for normal cells, and greater for nested cells */
228 ME_BorderRect border
;
231 int yTextOffset
; /* The text offset is caused by the largest top border. */
232 struct tagME_DisplayItem
*prev_cell
, *next_cell
, *parent_cell
;
235 typedef struct tagME_Row
245 /* the display item list layout is like this:
246 * - the document consists of paragraphs
247 * - each paragraph contains at least one run, the last run in the paragraph
248 * is an end-of-paragraph run
249 * - each formatted paragraph contains at least one row, which corresponds
250 * to a screen line (that's why there are no rows in an unformatted
252 * - the paragraphs contain "shortcut" pointers to the previous and the next
253 * paragraph, that makes iteration over paragraphs faster
254 * - the list starts with diTextStart and ends with diTextEnd
257 typedef struct tagME_DisplayItem
260 struct tagME_DisplayItem
*prev
, *next
;
269 typedef struct tagME_TextBuffer
271 ME_DisplayItem
*pFirst
, *pLast
;
272 ME_Style
*pCharStyle
;
273 ME_Style
*pDefaultStyle
;
276 typedef struct tagME_Cursor
278 ME_DisplayItem
*pPara
;
279 ME_DisplayItem
*pRun
;
298 undo_end_transaction
, /* marks the end of a group of changes for undo */
299 undo_potential_end_transaction
/* allows grouping typed chars for undo */
302 struct insert_run_item
310 struct delete_run_item
315 struct join_paras_item
320 struct split_para_item
324 ME_BorderRect border
;
327 ME_BorderRect cell_border
;
328 int cell_right_boundary
;
331 struct set_para_fmt_item
335 ME_BorderRect border
;
338 struct set_char_fmt_item
350 struct insert_run_item insert_run
;
351 struct delete_run_item delete_run
;
352 struct join_paras_item join_paras
;
353 struct split_para_item split_para
;
354 struct set_para_fmt_item set_para_fmt
;
355 struct set_char_fmt_item set_char_fmt
;
367 typedef struct tagME_FontTableItem
{
373 #define STREAMIN_BUFFER_SIZE 4096 /* M$ compatibility */
375 struct tagME_InStream
{
376 EDITSTREAM
*editstream
;
379 char buffer
[STREAMIN_BUFFER_SIZE
];
381 typedef struct tagME_InStream ME_InStream
;
383 typedef struct tagME_TextEditor
385 HWND hWnd
, hwndParent
;
388 BOOL bEmulateVersion10
;
389 ME_TextBuffer
*pBuffer
;
395 int nTotalLength
, nLastTotalLength
;
396 int nTotalWidth
, nLastTotalWidth
;
397 int nAvailWidth
; /* 0 = wrap to client area, else wrap width in twips */
399 COLORREF rgbBackColor
;
400 HBRUSH hbrBackground
;
404 struct list undo_stack
;
405 struct list redo_stack
;
408 ME_UndoMode nUndoMode
;
410 int nLastSelStart
, nLastSelEnd
;
411 ME_DisplayItem
*pLastSelStartPara
, *pLastSelEndPara
;
412 ME_FontCacheItem pFontCache
[HFONT_CACHE_SIZE
];
413 int nZoomNumerator
, nZoomDenominator
;
416 BOOL bDefaultFormatRect
;
419 EDITWORDBREAKPROCW pfnWordBreak
;
420 LPRICHEDITOLECALLBACK lpOleCallback
;
421 /*TEXTMODE variable; contains only one of each of the following options:
422 *TM_RICHTEXT or TM_PLAINTEXT
423 *TM_SINGLELEVELUNDO or TM_MULTILEVELUNDO
424 *TM_SINGLECODEPAGE or TM_MULTICODEPAGE*/
427 BOOL AutoURLDetect_bEnable
;
430 BOOL bDialogMode
; /* Indicates that we are inside a dialog window */
433 DWORD selofs
; /* The size of the selection bar on the left side of control */
434 ME_SelectionType nSelectionType
;
436 /* Track previous notified selection */
437 CHARRANGE notified_cr
;
439 /* Cache previously set scrollbar info */
440 SCROLLINFO vert_si
, horz_si
;
444 struct list style_list
;
445 struct list reobj_list
;
448 typedef struct tagME_Context
456 /* those are valid inside ME_WrapTextParagraph and related */
457 ME_TextEditor
*editor
;