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
48 #include "wine/debug.h"
49 #include "wine/heap.h"
50 #include "wine/list.h"
51 #include "wine/rbtree.h"
53 typedef struct tagME_String
57 void (*free
)(struct tagME_String
*);
60 typedef struct tagME_FontCacheItem
68 #define HFONT_CACHE_SIZE 10
70 typedef struct tagME_Style
74 ME_FontCacheItem
*font_cache
; /* cached font for the style */
75 TEXTMETRICW tm
; /* cached font metrics for the style */
76 int nRefs
; /* reference count */
77 SCRIPT_CACHE script_cache
;
83 diTextStart
, /* start of the text buffer */
84 diParagraph
, /* paragraph start */
85 diCell
, /* cell start */
86 diRun
, /* run (sequence of chars with the same character format) */
87 diStartRow
, /* start of the row (line of text on the screen) */
88 diTextEnd
, /* end of the text buffer */
90 /********************* these below are meant for finding only *********************/
91 diStartRowOrParagraph
, /* 7 */
92 diStartRowOrParagraphOrEnd
,
96 diRunOrParagraphOrEnd
, /* 12 */
99 #define SELECTIONBAR_WIDTH 8
101 /******************************** run flags *************************/
102 #define MERF_STYLEFLAGS 0x0FFF
103 /* run contains non-text content, which has its own rules for wrapping, sizing etc */
104 #define MERF_GRAPHICS 0x001
105 /* run is a tab (or, in future, any kind of content whose size is dependent on run position) */
106 #define MERF_TAB 0x002
107 /* run is a cell boundary */
108 #define MERF_ENDCELL 0x004 /* v4.1 */
110 #define MERF_NONTEXT (MERF_GRAPHICS | MERF_TAB | MERF_ENDCELL)
112 /* run is splittable (contains white spaces in the middle or end) */
113 #define MERF_SPLITTABLE 0x001000
114 /* run starts with whitespaces */
115 #define MERF_STARTWHITE 0x002000
116 /* run ends with whitespaces */
117 #define MERF_ENDWHITE 0x004000
118 /* run is completely made of whitespaces */
119 #define MERF_WHITESPACE 0x008000
120 /* the "end of paragraph" run, contains 1 character */
121 #define MERF_ENDPARA 0x100000
122 /* forcing the "end of row" run, contains 1 character */
123 #define MERF_ENDROW 0x200000
125 #define MERF_HIDDEN 0x400000
126 /* start of a table row has an empty paragraph that should be skipped over. */
127 #define MERF_TABLESTART 0x800000 /* v4.1 */
129 /* runs with any of these flags set cannot be joined */
130 #define MERF_NOJOIN (MERF_GRAPHICS|MERF_TAB|MERF_ENDPARA|MERF_ENDROW)
131 /* runs that don't contain real text */
132 #define MERF_NOTEXT (MERF_GRAPHICS|MERF_TAB|MERF_ENDPARA|MERF_ENDROW)
134 /* those flags are kept when the row is split */
135 #define MERF_SPLITMASK (~(0))
137 /******************************** para flags *************************/
139 /* this paragraph was already wrapped and hasn't changed, every change resets that flag */
140 #define MEPF_REWRAP 0x01
142 #define MEPF_CELL 0x04 /* The paragraph is nested in a cell */
143 #define MEPF_ROWSTART 0x08 /* Hidden empty paragraph at the start of the row */
144 #define MEPF_ROWEND 0x10 /* Visible empty paragraph at the end of the row */
145 #define MEPF_COMPLEX 0x20 /* Use uniscribe */
147 /******************************** structures *************************/
149 struct tagME_DisplayItem
;
157 typedef struct tagME_Run
160 struct tagME_Paragraph
*para
; /* ptr to the run's paragraph */
161 int nCharOfs
; /* relative to para's offset */
162 int len
; /* length of run's text */
163 int nWidth
; /* width of full run, width of leading&trailing ws */
165 int nAscent
, nDescent
; /* pixels above/below baseline */
166 POINT pt
; /* relative to para's position */
167 struct re_object
*reobj
; /* FIXME: should be a union with strText (at least) */
169 SCRIPT_ANALYSIS script_analysis
;
170 int num_glyphs
, max_glyphs
;
172 SCRIPT_VISATTR
*vis_attrs
;
179 typedef struct tagME_Border
185 typedef struct tagME_BorderRect
201 typedef struct tagME_Paragraph
206 struct tagME_Cell
*cell
; /* v4.1 */
207 ME_BorderRect border
;
214 struct para_num para_num
;
215 ME_Run
*eop_run
; /* ptr to the end-of-para run */
216 struct tagME_DisplayItem
*prev_para
, *next_para
;
217 struct wine_rb_entry marked_entry
;
220 typedef struct tagME_Cell
/* v4.1 */
222 int nNestingLevel
; /* 0 for normal cells, and greater for nested cells */
224 ME_BorderRect border
;
227 int yTextOffset
; /* The text offset is caused by the largest top border. */
228 struct tagME_Cell
*prev_cell
, *next_cell
, *parent_cell
;
231 typedef struct tagME_Row
241 /* the display item list layout is like this:
242 * - the document consists of paragraphs
243 * - each paragraph contains at least one run, the last run in the paragraph
244 * is an end-of-paragraph run
245 * - each formatted paragraph contains at least one row, which corresponds
246 * to a screen line (that's why there are no rows in an unformatted
248 * - the paragraphs contain "shortcut" pointers to the previous and the next
249 * paragraph, that makes iteration over paragraphs faster
250 * - the list starts with diTextStart and ends with diTextEnd
253 typedef struct tagME_DisplayItem
256 struct tagME_DisplayItem
*prev
, *next
;
265 typedef struct tagME_TextBuffer
267 ME_DisplayItem
*pFirst
, *pLast
;
268 ME_Style
*pCharStyle
;
269 ME_Style
*pDefaultStyle
;
272 typedef struct tagME_Cursor
294 undo_end_transaction
, /* marks the end of a group of changes for undo */
295 undo_potential_end_transaction
/* allows grouping typed chars for undo */
298 struct insert_run_item
306 struct delete_run_item
311 struct join_paras_item
316 struct split_para_item
320 ME_BorderRect border
;
323 ME_BorderRect cell_border
;
324 int cell_right_boundary
;
327 struct set_para_fmt_item
331 ME_BorderRect border
;
334 struct set_char_fmt_item
346 struct insert_run_item insert_run
;
347 struct delete_run_item delete_run
;
348 struct join_paras_item join_paras
;
349 struct split_para_item split_para
;
350 struct set_para_fmt_item set_para_fmt
;
351 struct set_char_fmt_item set_char_fmt
;
363 typedef struct tagME_FontTableItem
{
369 #define STREAMIN_BUFFER_SIZE 4096 /* M$ compatibility */
371 struct tagME_InStream
{
372 EDITSTREAM
*editstream
;
375 char buffer
[STREAMIN_BUFFER_SIZE
];
377 typedef struct tagME_InStream ME_InStream
;
379 typedef struct tagME_TextEditor
381 ITextHost2
*texthost
;
382 unsigned int bEmulateVersion10
: 1;
383 unsigned int in_place_active
: 1;
384 unsigned int have_texthost2
: 1;
385 ME_TextBuffer
*pBuffer
;
391 int nTotalLength
, nLastTotalLength
;
392 int nTotalWidth
, nLastTotalWidth
;
393 int nAvailWidth
; /* 0 = wrap to client area, else wrap width in twips */
398 struct list undo_stack
;
399 struct list redo_stack
;
402 ME_UndoMode nUndoMode
;
404 int nLastSelStart
, nLastSelEnd
;
405 ME_Paragraph
*last_sel_start_para
, *last_sel_end_para
;
406 ME_FontCacheItem pFontCache
[HFONT_CACHE_SIZE
];
407 int nZoomNumerator
, nZoomDenominator
;
411 EDITWORDBREAKPROCW pfnWordBreak
;
412 IRichEditOle
*richole
;
413 LPRICHEDITOLECALLBACK lpOleCallback
;
414 /*TEXTMODE variable; contains only one of each of the following options:
415 *TM_RICHTEXT or TM_PLAINTEXT
416 *TM_SINGLELEVELUNDO or TM_MULTILEVELUNDO
417 *TM_SINGLECODEPAGE or TM_MULTICODEPAGE*/
420 BOOL AutoURLDetect_bEnable
;
425 DWORD selofs
; /* The size of the selection bar on the left side of control */
426 ME_SelectionType nSelectionType
;
428 /* Track previous notified selection */
429 CHARRANGE notified_cr
;
431 /* Cache previously set scrollbar info */
432 SCROLLINFO vert_si
, horz_si
;
433 unsigned int vert_sb_enabled
: 1;
434 unsigned int horz_sb_enabled
: 1;
440 TXTBACKSTYLE back_style
;
441 struct list style_list
;
442 struct list reobj_list
;
443 struct wine_rb_tree marked_paras
;
446 typedef struct tagME_Context
453 ME_Style
*current_style
;
456 /* those are valid inside ME_WrapTextParagraph and related */
457 ME_TextEditor
*editor
;
460 struct text_selection
462 ITextSelection ITextSelection_iface
;
465 struct text_services
*services
;
470 IUnknown IUnknown_inner
;
471 ITextServices ITextServices_iface
;
472 IRichEditOle IRichEditOle_iface
;
473 ITextDocument2Old ITextDocument2Old_iface
;
476 ME_TextEditor
*editor
;
477 struct text_selection
*text_selection
;
478 struct list rangelist
;
479 struct list clientsites
;
480 char spare
[256]; /* for bug #12179 */