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 extern const struct ITextHostVtbl itextHostStdcallVtbl DECLSPEC_HIDDEN
;
28 typedef struct tagME_String
32 void (*free
)(struct tagME_String
*);
35 typedef struct tagME_FontCacheItem
43 #define HFONT_CACHE_SIZE 10
45 typedef struct tagME_Style
49 ME_FontCacheItem
*font_cache
; /* cached font for the style */
50 TEXTMETRICW tm
; /* cached font metrics for the style */
51 int nRefs
; /* reference count */
52 SCRIPT_CACHE script_cache
;
58 diTextStart
, /* start of the text buffer */
59 diParagraph
, /* paragraph start */
60 diCell
, /* cell start */
61 diRun
, /* run (sequence of chars with the same character format) */
62 diStartRow
, /* start of the row (line of text on the screen) */
63 diTextEnd
, /* end of the text buffer */
65 /********************* these below are meant for finding only *********************/
66 diStartRowOrParagraph
, /* 7 */
67 diStartRowOrParagraphOrEnd
,
71 diRunOrParagraphOrEnd
, /* 12 */
74 #define SELECTIONBAR_WIDTH 8
76 /******************************** run flags *************************/
77 #define MERF_STYLEFLAGS 0x0FFF
78 /* run contains non-text content, which has its own rules for wrapping, sizing etc */
79 #define MERF_GRAPHICS 0x001
80 /* run is a tab (or, in future, any kind of content whose size is dependent on run position) */
81 #define MERF_TAB 0x002
82 /* run is a cell boundary */
83 #define MERF_ENDCELL 0x004 /* v4.1 */
85 #define MERF_NONTEXT (MERF_GRAPHICS | MERF_TAB | MERF_ENDCELL)
87 /* run is splittable (contains white spaces in the middle or end) */
88 #define MERF_SPLITTABLE 0x001000
89 /* run starts with whitespaces */
90 #define MERF_STARTWHITE 0x002000
91 /* run ends with whitespaces */
92 #define MERF_ENDWHITE 0x004000
93 /* run is completely made of whitespaces */
94 #define MERF_WHITESPACE 0x008000
95 /* the "end of paragraph" run, contains 1 character */
96 #define MERF_ENDPARA 0x100000
97 /* forcing the "end of row" run, contains 1 character */
98 #define MERF_ENDROW 0x200000
100 #define MERF_HIDDEN 0x400000
101 /* start of a table row has an empty paragraph that should be skipped over. */
102 #define MERF_TABLESTART 0x800000 /* v4.1 */
104 /* runs with any of these flags set cannot be joined */
105 #define MERF_NOJOIN (MERF_GRAPHICS|MERF_TAB|MERF_ENDPARA|MERF_ENDROW)
106 /* runs that don't contain real text */
107 #define MERF_NOTEXT (MERF_GRAPHICS|MERF_TAB|MERF_ENDPARA|MERF_ENDROW)
109 /* those flags are kept when the row is split */
110 #define MERF_SPLITMASK (~(0))
112 /******************************** para flags *************************/
114 /* this paragraph was already wrapped and hasn't changed, every change resets that flag */
115 #define MEPF_REWRAP 0x01
117 #define MEPF_CELL 0x04 /* The paragraph is nested in a cell */
118 #define MEPF_ROWSTART 0x08 /* Hidden empty paragraph at the start of the row */
119 #define MEPF_ROWEND 0x10 /* Visible empty paragraph at the end of the row */
120 #define MEPF_COMPLEX 0x20 /* Use uniscribe */
122 /******************************** structures *************************/
124 struct tagME_DisplayItem
;
126 typedef struct tagME_Run
129 struct tagME_Paragraph
*para
; /* ptr to the run's paragraph */
130 int nCharOfs
; /* relative to para's offset */
131 int len
; /* length of run's text */
132 int nWidth
; /* width of full run, width of leading&trailing ws */
134 int nAscent
, nDescent
; /* pixels above/below baseline */
135 POINT pt
; /* relative to para's position */
136 REOBJECT
*ole_obj
; /* FIXME: should be a union with strText (at least) */
138 SCRIPT_ANALYSIS script_analysis
;
139 int num_glyphs
, max_glyphs
;
141 SCRIPT_VISATTR
*vis_attrs
;
148 typedef struct tagME_Border
154 typedef struct tagME_BorderRect
170 typedef struct tagME_Paragraph
175 struct tagME_DisplayItem
*pCell
; /* v4.1 */
176 ME_BorderRect border
;
183 struct para_num para_num
;
184 ME_Run
*eop_run
; /* ptr to the end-of-para run */
185 struct tagME_DisplayItem
*prev_para
, *next_para
;
188 typedef struct tagME_Cell
/* v4.1 */
190 int nNestingLevel
; /* 0 for normal cells, and greater for nested cells */
192 ME_BorderRect border
;
195 int yTextOffset
; /* The text offset is caused by the largest top border. */
196 struct tagME_DisplayItem
*prev_cell
, *next_cell
, *parent_cell
;
199 typedef struct tagME_Row
209 /* the display item list layout is like this:
210 * - the document consists of paragraphs
211 * - each paragraph contains at least one run, the last run in the paragraph
212 * is an end-of-paragraph run
213 * - each formatted paragraph contains at least one row, which corresponds
214 * to a screen line (that's why there are no rows in an unformatted
216 * - the paragraphs contain "shortcut" pointers to the previous and the next
217 * paragraph, that makes iteration over paragraphs faster
218 * - the list starts with diTextStart and ends with diTextEnd
221 typedef struct tagME_DisplayItem
224 struct tagME_DisplayItem
*prev
, *next
;
233 typedef struct tagME_TextBuffer
235 ME_DisplayItem
*pFirst
, *pLast
;
236 ME_Style
*pCharStyle
;
237 ME_Style
*pDefaultStyle
;
240 typedef struct tagME_Cursor
242 ME_DisplayItem
*pPara
;
243 ME_DisplayItem
*pRun
;
262 undo_end_transaction
, /* marks the end of a group of changes for undo */
263 undo_potential_end_transaction
/* allows grouping typed chars for undo */
266 struct insert_run_item
274 struct delete_run_item
279 struct join_paras_item
284 struct split_para_item
288 ME_BorderRect border
;
291 ME_BorderRect cell_border
;
292 int cell_right_boundary
;
295 struct set_para_fmt_item
299 ME_BorderRect border
;
302 struct set_char_fmt_item
314 struct insert_run_item insert_run
;
315 struct delete_run_item delete_run
;
316 struct join_paras_item join_paras
;
317 struct split_para_item split_para
;
318 struct set_para_fmt_item set_para_fmt
;
319 struct set_char_fmt_item set_char_fmt
;
331 typedef struct tagME_FontTableItem
{
337 #define STREAMIN_BUFFER_SIZE 4096 /* M$ compatibility */
339 struct tagME_InStream
{
340 EDITSTREAM
*editstream
;
343 char buffer
[STREAMIN_BUFFER_SIZE
];
345 typedef struct tagME_InStream ME_InStream
;
347 typedef struct tagME_TextEditor
349 HWND hWnd
, hwndParent
;
352 BOOL bEmulateVersion10
;
353 ME_TextBuffer
*pBuffer
;
359 int nTotalLength
, nLastTotalLength
;
360 int nTotalWidth
, nLastTotalWidth
;
361 int nAvailWidth
; /* 0 = wrap to client area, else wrap width in twips */
363 COLORREF rgbBackColor
;
364 HBRUSH hbrBackground
;
368 struct list undo_stack
;
369 struct list redo_stack
;
372 ME_UndoMode nUndoMode
;
374 int nLastSelStart
, nLastSelEnd
;
375 ME_DisplayItem
*pLastSelStartPara
, *pLastSelEndPara
;
376 ME_FontCacheItem pFontCache
[HFONT_CACHE_SIZE
];
377 int nZoomNumerator
, nZoomDenominator
;
380 BOOL bDefaultFormatRect
;
383 EDITWORDBREAKPROCW pfnWordBreak
;
384 LPRICHEDITOLECALLBACK lpOleCallback
;
385 /*TEXTMODE variable; contains only one of each of the following options:
386 *TM_RICHTEXT or TM_PLAINTEXT
387 *TM_SINGLELEVELUNDO or TM_MULTILEVELUNDO
388 *TM_SINGLECODEPAGE or TM_MULTICODEPAGE*/
391 BOOL AutoURLDetect_bEnable
;
394 BOOL bDialogMode
; /* Indicates that we are inside a dialog window */
397 DWORD selofs
; /* The size of the selection bar on the left side of control */
398 ME_SelectionType nSelectionType
;
400 /* Track previous notified selection */
401 CHARRANGE notified_cr
;
403 /* Cache previously set scrollbar info */
404 SCROLLINFO vert_si
, horz_si
;
408 struct list style_list
;
411 typedef struct tagME_Context
419 /* those are valid inside ME_WrapTextParagraph and related */
420 ME_TextEditor
*editor
;