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
;
28 typedef struct tagME_String
34 typedef struct tagME_Style
38 HFONT hFont
; /* cached font for the style */
39 TEXTMETRICW tm
; /* cached font metrics for the style */
40 int nRefs
; /* reference count */
41 SCRIPT_CACHE script_cache
;
46 diTextStart
, /* start of the text buffer */
47 diParagraph
, /* paragraph start */
48 diCell
, /* cell start */
49 diRun
, /* run (sequence of chars with the same character format) */
50 diStartRow
, /* start of the row (line of text on the screen) */
51 diTextEnd
, /* end of the text buffer */
53 /********************* these below are meant for finding only *********************/
54 diStartRowOrParagraph
, /* 7 */
55 diStartRowOrParagraphOrEnd
,
59 diRunOrParagraphOrEnd
, /* 12 */
62 #define SELECTIONBAR_WIDTH 8
64 /******************************** run flags *************************/
65 #define MERF_STYLEFLAGS 0x0FFF
66 /* run contains non-text content, which has its own rules for wrapping, sizing etc */
67 #define MERF_GRAPHICS 0x001
68 /* run is a tab (or, in future, any kind of content whose size is dependent on run position) */
69 #define MERF_TAB 0x002
70 /* run is a cell boundary */
71 #define MERF_ENDCELL 0x004 /* v4.1 */
73 #define MERF_NONTEXT (MERF_GRAPHICS | MERF_TAB | MERF_ENDCELL)
75 /* run is splittable (contains white spaces in the middle or end) */
76 #define MERF_SPLITTABLE 0x001000
77 /* run starts with whitespaces */
78 #define MERF_STARTWHITE 0x002000
79 /* run ends with whitespaces */
80 #define MERF_ENDWHITE 0x004000
81 /* run is completely made of whitespaces */
82 #define MERF_WHITESPACE 0x008000
83 /* the "end of paragraph" run, contains 1 character */
84 #define MERF_ENDPARA 0x100000
85 /* forcing the "end of row" run, contains 1 character */
86 #define MERF_ENDROW 0x200000
88 #define MERF_HIDDEN 0x400000
89 /* start of a table row has an empty paragraph that should be skipped over. */
90 #define MERF_TABLESTART 0x800000 /* v4.1 */
92 /* runs with any of these flags set cannot be joined */
93 #define MERF_NOJOIN (MERF_GRAPHICS|MERF_TAB|MERF_ENDPARA|MERF_ENDROW)
94 /* runs that don't contain real text */
95 #define MERF_NOTEXT (MERF_GRAPHICS|MERF_TAB|MERF_ENDPARA|MERF_ENDROW)
97 /* those flags are kept when the row is split */
98 #define MERF_SPLITMASK (~(0))
100 /******************************** para flags *************************/
102 /* this paragraph was already wrapped and hasn't changed, every change resets that flag */
103 #define MEPF_REWRAP 0x01
105 #define MEPF_CELL 0x04 /* The paragraph is nested in a cell */
106 #define MEPF_ROWSTART 0x08 /* Hidden empty paragraph at the start of the row */
107 #define MEPF_ROWEND 0x10 /* Visible empty paragraph at the end of the row */
108 #define MEPF_COMPLEX 0x20 /* Use uniscribe */
110 /******************************** structures *************************/
112 struct tagME_DisplayItem
;
114 typedef struct tagME_Run
117 struct tagME_Paragraph
*para
; /* ptr to the run's paragraph */
118 int nCharOfs
; /* relative to para's offset */
119 int len
; /* length of run's text */
120 int nWidth
; /* width of full run, width of leading&trailing ws */
122 int nAscent
, nDescent
; /* pixels above/below baseline */
123 POINT pt
; /* relative to para's position */
124 REOBJECT
*ole_obj
; /* FIXME: should be a union with strText (at least) */
126 SCRIPT_ANALYSIS script_analysis
;
127 int num_glyphs
, max_glyphs
;
129 SCRIPT_VISATTR
*vis_attrs
;
136 typedef struct tagME_Border
142 typedef struct tagME_BorderRect
150 typedef struct tagME_Paragraph
155 struct tagME_DisplayItem
*pCell
; /* v4.1 */
156 ME_BorderRect border
;
163 struct tagME_DisplayItem
*prev_para
, *next_para
;
166 typedef struct tagME_Cell
/* v4.1 */
168 int nNestingLevel
; /* 0 for normal cells, and greater for nested cells */
170 ME_BorderRect border
;
173 int yTextOffset
; /* The text offset is caused by the largest top border. */
174 struct tagME_DisplayItem
*prev_cell
, *next_cell
, *parent_cell
;
177 typedef struct tagME_Row
187 /* the display item list layout is like this:
188 * - the document consists of paragraphs
189 * - each paragraph contains at least one run, the last run in the paragraph
190 * is an end-of-paragraph run
191 * - each formatted paragraph contains at least one row, which corresponds
192 * to a screen line (that's why there are no rows in an unformatted
194 * - the paragraphs contain "shortcut" pointers to the previous and the next
195 * paragraph, that makes iteration over paragraphs faster
196 * - the list starts with diTextStart and ends with diTextEnd
199 typedef struct tagME_DisplayItem
202 struct tagME_DisplayItem
*prev
, *next
;
211 typedef struct tagME_TextBuffer
213 ME_DisplayItem
*pFirst
, *pLast
;
214 ME_Style
*pCharStyle
;
215 ME_Style
*pDefaultStyle
;
218 typedef struct tagME_Cursor
220 ME_DisplayItem
*pPara
;
221 ME_DisplayItem
*pRun
;
240 undo_end_transaction
, /* marks the end of a group of changes for undo */
241 undo_potential_end_transaction
/* allows grouping typed chars for undo */
244 struct insert_run_item
252 struct delete_run_item
257 struct join_paras_item
262 struct split_para_item
266 ME_BorderRect border
;
269 ME_BorderRect cell_border
;
270 int cell_right_boundary
;
273 struct set_para_fmt_item
277 ME_BorderRect border
;
280 struct set_char_fmt_item
292 struct insert_run_item insert_run
;
293 struct delete_run_item delete_run
;
294 struct join_paras_item join_paras
;
295 struct split_para_item split_para
;
296 struct set_para_fmt_item set_para_fmt
;
297 struct set_char_fmt_item set_char_fmt
;
309 typedef struct tagME_FontTableItem
{
315 #define STREAMIN_BUFFER_SIZE 4096 /* M$ compatibility */
317 struct tagME_InStream
{
318 EDITSTREAM
*editstream
;
321 char buffer
[STREAMIN_BUFFER_SIZE
];
323 typedef struct tagME_InStream ME_InStream
;
326 #define STREAMOUT_BUFFER_SIZE 4096
327 #define STREAMOUT_FONTTBL_SIZE 8192
328 #define STREAMOUT_COLORTBL_SIZE 1024
330 typedef struct tagME_OutStream
{
332 char buffer
[STREAMOUT_BUFFER_SIZE
];
336 ME_FontTableItem fonttbl
[STREAMOUT_FONTTBL_SIZE
];
338 COLORREF colortbl
[STREAMOUT_COLORTBL_SIZE
];
340 UINT nDefaultCodePage
;
341 /* nNestingLevel = 0 means we aren't in a cell, 1 means we are in a cell,
342 * an greater numbers mean we are in a cell nested within a cell. */
346 typedef struct tagME_FontCacheItem
354 #define HFONT_CACHE_SIZE 10
356 typedef struct tagME_TextEditor
358 HWND hWnd
, hwndParent
;
360 BOOL bEmulateVersion10
;
361 ME_TextBuffer
*pBuffer
;
367 int nTotalLength
, nLastTotalLength
;
368 int nTotalWidth
, nLastTotalWidth
;
369 int nAvailWidth
; /* 0 = wrap to client area, else wrap width in twips */
371 COLORREF rgbBackColor
;
372 HBRUSH hbrBackground
;
376 struct list undo_stack
;
377 struct list redo_stack
;
380 ME_UndoMode nUndoMode
;
382 int nLastSelStart
, nLastSelEnd
;
383 ME_DisplayItem
*pLastSelStartPara
, *pLastSelEndPara
;
384 ME_FontCacheItem pFontCache
[HFONT_CACHE_SIZE
];
385 int nZoomNumerator
, nZoomDenominator
;
388 BOOL bDefaultFormatRect
;
391 EDITWORDBREAKPROCW pfnWordBreak
;
392 LPRICHEDITOLECALLBACK lpOleCallback
;
393 /*TEXTMODE variable; contains only one of each of the following options:
394 *TM_RICHTEXT or TM_PLAINTEXT
395 *TM_SINGLELEVELUNDO or TM_MULTILEVELUNDO
396 *TM_SINGLECODEPAGE or TM_MULTICODEPAGE*/
399 BOOL AutoURLDetect_bEnable
;
402 BOOL bDialogMode
; /* Indicates that we are inside a dialog window */
405 DWORD selofs
; /* The size of the selection bar on the left side of control */
406 ME_SelectionType nSelectionType
;
408 /* Track previous notified selection */
409 CHARRANGE notified_cr
;
411 /* Cache previously set scrollbar info */
412 SCROLLINFO vert_si
, horz_si
;
418 typedef struct tagME_Context
426 /* those are valid inside ME_WrapTextParagraph and related */
427 ME_TextEditor
*editor
;
430 typedef struct tagME_WrapContext
434 int nLeftMargin
, nRightMargin
, nFirstMargin
;
438 BOOL bOverflown
, bWordWrap
;
439 ME_DisplayItem
*pPara
;
440 ME_DisplayItem
*pRowStart
;
442 ME_DisplayItem
*pLastSplittableRun
;