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
46 #include "wine/debug.h"
47 #include "wine/heap.h"
48 #include "wine/list.h"
50 #if defined(__i386__) && !defined(__MINGW32__)
51 extern const struct ITextHostVtbl itextHostStdcallVtbl DECLSPEC_HIDDEN
;
54 typedef struct tagME_String
58 void (*free
)(struct tagME_String
*);
61 typedef struct tagME_FontCacheItem
69 #define HFONT_CACHE_SIZE 10
71 typedef struct tagME_Style
75 ME_FontCacheItem
*font_cache
; /* cached font for the style */
76 TEXTMETRICW tm
; /* cached font metrics for the style */
77 int nRefs
; /* reference count */
78 SCRIPT_CACHE script_cache
;
84 diTextStart
, /* start of the text buffer */
85 diParagraph
, /* paragraph start */
86 diCell
, /* cell start */
87 diRun
, /* run (sequence of chars with the same character format) */
88 diStartRow
, /* start of the row (line of text on the screen) */
89 diTextEnd
, /* end of the text buffer */
91 /********************* these below are meant for finding only *********************/
92 diStartRowOrParagraph
, /* 7 */
93 diStartRowOrParagraphOrEnd
,
97 diRunOrParagraphOrEnd
, /* 12 */
100 #define SELECTIONBAR_WIDTH 8
102 /******************************** run flags *************************/
103 #define MERF_STYLEFLAGS 0x0FFF
104 /* run contains non-text content, which has its own rules for wrapping, sizing etc */
105 #define MERF_GRAPHICS 0x001
106 /* run is a tab (or, in future, any kind of content whose size is dependent on run position) */
107 #define MERF_TAB 0x002
108 /* run is a cell boundary */
109 #define MERF_ENDCELL 0x004 /* v4.1 */
111 #define MERF_NONTEXT (MERF_GRAPHICS | MERF_TAB | MERF_ENDCELL)
113 /* run is splittable (contains white spaces in the middle or end) */
114 #define MERF_SPLITTABLE 0x001000
115 /* run starts with whitespaces */
116 #define MERF_STARTWHITE 0x002000
117 /* run ends with whitespaces */
118 #define MERF_ENDWHITE 0x004000
119 /* run is completely made of whitespaces */
120 #define MERF_WHITESPACE 0x008000
121 /* the "end of paragraph" run, contains 1 character */
122 #define MERF_ENDPARA 0x100000
123 /* forcing the "end of row" run, contains 1 character */
124 #define MERF_ENDROW 0x200000
126 #define MERF_HIDDEN 0x400000
127 /* start of a table row has an empty paragraph that should be skipped over. */
128 #define MERF_TABLESTART 0x800000 /* v4.1 */
130 /* runs with any of these flags set cannot be joined */
131 #define MERF_NOJOIN (MERF_GRAPHICS|MERF_TAB|MERF_ENDPARA|MERF_ENDROW)
132 /* runs that don't contain real text */
133 #define MERF_NOTEXT (MERF_GRAPHICS|MERF_TAB|MERF_ENDPARA|MERF_ENDROW)
135 /* those flags are kept when the row is split */
136 #define MERF_SPLITMASK (~(0))
138 /******************************** para flags *************************/
140 /* this paragraph was already wrapped and hasn't changed, every change resets that flag */
141 #define MEPF_REWRAP 0x01
143 #define MEPF_CELL 0x04 /* The paragraph is nested in a cell */
144 #define MEPF_ROWSTART 0x08 /* Hidden empty paragraph at the start of the row */
145 #define MEPF_ROWEND 0x10 /* Visible empty paragraph at the end of the row */
146 #define MEPF_COMPLEX 0x20 /* Use uniscribe */
148 /******************************** structures *************************/
150 struct tagME_DisplayItem
;
158 typedef struct tagME_Run
161 struct tagME_Paragraph
*para
; /* ptr to the run's paragraph */
162 int nCharOfs
; /* relative to para's offset */
163 int len
; /* length of run's text */
164 int nWidth
; /* width of full run, width of leading&trailing ws */
166 int nAscent
, nDescent
; /* pixels above/below baseline */
167 POINT pt
; /* relative to para's position */
168 struct re_object
*reobj
; /* FIXME: should be a union with strText (at least) */
170 SCRIPT_ANALYSIS script_analysis
;
171 int num_glyphs
, max_glyphs
;
173 SCRIPT_VISATTR
*vis_attrs
;
180 typedef struct tagME_Border
186 typedef struct tagME_BorderRect
202 typedef struct tagME_Paragraph
207 struct tagME_DisplayItem
*pCell
; /* v4.1 */
208 ME_BorderRect border
;
215 struct para_num para_num
;
216 ME_Run
*eop_run
; /* ptr to the end-of-para run */
217 struct tagME_DisplayItem
*prev_para
, *next_para
;
218 struct tagME_DisplayItem
*prev_marked
, *next_marked
;
221 typedef struct tagME_Cell
/* v4.1 */
223 int nNestingLevel
; /* 0 for normal cells, and greater for nested cells */
225 ME_BorderRect border
;
228 int yTextOffset
; /* The text offset is caused by the largest top border. */
229 struct tagME_DisplayItem
*prev_cell
, *next_cell
, *parent_cell
;
232 typedef struct tagME_Row
242 /* the display item list layout is like this:
243 * - the document consists of paragraphs
244 * - each paragraph contains at least one run, the last run in the paragraph
245 * is an end-of-paragraph run
246 * - each formatted paragraph contains at least one row, which corresponds
247 * to a screen line (that's why there are no rows in an unformatted
249 * - the paragraphs contain "shortcut" pointers to the previous and the next
250 * paragraph, that makes iteration over paragraphs faster
251 * - the list starts with diTextStart and ends with diTextEnd
254 typedef struct tagME_DisplayItem
257 struct tagME_DisplayItem
*prev
, *next
;
266 typedef struct tagME_TextBuffer
268 ME_DisplayItem
*pFirst
, *pLast
;
269 ME_Style
*pCharStyle
;
270 ME_Style
*pDefaultStyle
;
273 typedef struct tagME_Cursor
275 ME_DisplayItem
*pPara
;
276 ME_DisplayItem
*pRun
;
295 undo_end_transaction
, /* marks the end of a group of changes for undo */
296 undo_potential_end_transaction
/* allows grouping typed chars for undo */
299 struct insert_run_item
307 struct delete_run_item
312 struct join_paras_item
317 struct split_para_item
321 ME_BorderRect border
;
324 ME_BorderRect cell_border
;
325 int cell_right_boundary
;
328 struct set_para_fmt_item
332 ME_BorderRect border
;
335 struct set_char_fmt_item
347 struct insert_run_item insert_run
;
348 struct delete_run_item delete_run
;
349 struct join_paras_item join_paras
;
350 struct split_para_item split_para
;
351 struct set_para_fmt_item set_para_fmt
;
352 struct set_char_fmt_item set_char_fmt
;
364 typedef struct tagME_FontTableItem
{
370 #define STREAMIN_BUFFER_SIZE 4096 /* M$ compatibility */
372 struct tagME_InStream
{
373 EDITSTREAM
*editstream
;
376 char buffer
[STREAMIN_BUFFER_SIZE
];
378 typedef struct tagME_InStream ME_InStream
;
380 typedef struct tagME_TextEditor
382 HWND hWnd
, hwndParent
;
385 BOOL bEmulateVersion10
;
386 ME_TextBuffer
*pBuffer
;
392 int nTotalLength
, nLastTotalLength
;
393 int nTotalWidth
, nLastTotalWidth
;
394 int nAvailWidth
; /* 0 = wrap to client area, else wrap width in twips */
397 COLORREF rgbBackColor
;
398 HBRUSH hbrBackground
;
402 struct list undo_stack
;
403 struct list redo_stack
;
406 ME_UndoMode nUndoMode
;
408 int nLastSelStart
, nLastSelEnd
;
409 ME_DisplayItem
*pLastSelStartPara
, *pLastSelEndPara
;
410 ME_FontCacheItem pFontCache
[HFONT_CACHE_SIZE
];
411 int nZoomNumerator
, nZoomDenominator
;
414 BOOL bDefaultFormatRect
;
417 EDITWORDBREAKPROCW pfnWordBreak
;
418 LPRICHEDITOLECALLBACK lpOleCallback
;
419 /*TEXTMODE variable; contains only one of each of the following options:
420 *TM_RICHTEXT or TM_PLAINTEXT
421 *TM_SINGLELEVELUNDO or TM_MULTILEVELUNDO
422 *TM_SINGLECODEPAGE or TM_MULTICODEPAGE*/
425 BOOL AutoURLDetect_bEnable
;
428 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
;
435 ME_DisplayItem
*first_marked_para
;
437 /* Track previous notified selection */
438 CHARRANGE notified_cr
;
440 /* Cache previously set scrollbar info */
441 SCROLLINFO vert_si
, horz_si
;
447 struct list style_list
;
448 struct list reobj_list
;
451 typedef struct tagME_Context
458 ME_Style
*current_style
;
461 /* those are valid inside ME_WrapTextParagraph and related */
462 ME_TextEditor
*editor
;