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 */
45 diTextStart
, /* start of the text buffer */
46 diParagraph
, /* paragraph start */
47 diCell
, /* cell start */
48 diRun
, /* run (sequence of chars with the same character format) */
49 diStartRow
, /* start of the row (line of text on the screen) */
50 diTextEnd
, /* end of the text buffer */
52 /********************* these below are meant for finding only *********************/
53 diStartRowOrParagraph
, /* 7 */
54 diStartRowOrParagraphOrEnd
,
58 diRunOrParagraphOrEnd
, /* 12 */
61 #define SELECTIONBAR_WIDTH 8
63 /******************************** run flags *************************/
64 #define MERF_STYLEFLAGS 0x0FFF
65 /* run contains non-text content, which has its own rules for wrapping, sizing etc */
66 #define MERF_GRAPHICS 0x001
67 /* run is a tab (or, in future, any kind of content whose size is dependent on run position) */
68 #define MERF_TAB 0x002
69 /* run is a cell boundary */
70 #define MERF_ENDCELL 0x004 /* v4.1 */
72 #define MERF_NONTEXT (MERF_GRAPHICS | MERF_TAB | MERF_ENDCELL)
74 /* run is splittable (contains white spaces in the middle or end) */
75 #define MERF_SPLITTABLE 0x001000
76 /* run starts with whitespaces */
77 #define MERF_STARTWHITE 0x002000
78 /* run ends with whitespaces */
79 #define MERF_ENDWHITE 0x004000
80 /* run is completely made of whitespaces */
81 #define MERF_WHITESPACE 0x008000
82 /* the "end of paragraph" run, contains 1 character */
83 #define MERF_ENDPARA 0x100000
84 /* forcing the "end of row" run, contains 1 character */
85 #define MERF_ENDROW 0x200000
87 #define MERF_HIDDEN 0x400000
88 /* start of a table row has an empty paragraph that should be skipped over. */
89 #define MERF_TABLESTART 0x800000 /* v4.1 */
91 /* runs with any of these flags set cannot be joined */
92 #define MERF_NOJOIN (MERF_GRAPHICS|MERF_TAB|MERF_ENDPARA|MERF_ENDROW)
93 /* runs that don't contain real text */
94 #define MERF_NOTEXT (MERF_GRAPHICS|MERF_TAB|MERF_ENDPARA|MERF_ENDROW)
96 /* those flags are kept when the row is split */
97 #define MERF_SPLITMASK (~(0))
99 /******************************** para flags *************************/
101 /* this paragraph was already wrapped and hasn't changed, every change resets that flag */
102 #define MEPF_REWRAP 0x01
104 #define MEPF_CELL 0x04 /* The paragraph is nested in a cell */
105 #define MEPF_ROWSTART 0x08 /* Hidden empty paragraph at the start of the row */
106 #define MEPF_ROWEND 0x10 /* Visible empty paragraph at the end of the row */
108 /******************************** structures *************************/
110 struct tagME_DisplayItem
;
112 typedef struct tagME_Run
115 struct tagME_Paragraph
*para
; /* ptr to the run's paragraph */
116 int nCharOfs
; /* relative to para's offset */
117 int len
; /* length of run's text */
118 int nWidth
; /* width of full run, width of leading&trailing ws */
120 int nAscent
, nDescent
; /* pixels above/below baseline */
121 POINT pt
; /* relative to para's position */
122 REOBJECT
*ole_obj
; /* FIXME: should be a union with strText (at least) */
125 typedef struct tagME_Border
131 typedef struct tagME_BorderRect
139 typedef struct tagME_Paragraph
144 struct tagME_DisplayItem
*pCell
; /* v4.1 */
145 ME_BorderRect border
;
152 struct tagME_DisplayItem
*prev_para
, *next_para
;
155 typedef struct tagME_Cell
/* v4.1 */
157 int nNestingLevel
; /* 0 for normal cells, and greater for nested cells */
159 ME_BorderRect border
;
162 int yTextOffset
; /* The text offset is caused by the largest top border. */
163 struct tagME_DisplayItem
*prev_cell
, *next_cell
, *parent_cell
;
166 typedef struct tagME_Row
176 /* the display item list layout is like this:
177 * - the document consists of paragraphs
178 * - each paragraph contains at least one run, the last run in the paragraph
179 * is an end-of-paragraph run
180 * - each formatted paragraph contains at least one row, which corresponds
181 * to a screen line (that's why there are no rows in an unformatted
183 * - the paragraphs contain "shortcut" pointers to the previous and the next
184 * paragraph, that makes iteration over paragraphs faster
185 * - the list starts with diTextStart and ends with diTextEnd
188 typedef struct tagME_DisplayItem
191 struct tagME_DisplayItem
*prev
, *next
;
200 typedef struct tagME_TextBuffer
202 ME_DisplayItem
*pFirst
, *pLast
;
203 ME_Style
*pCharStyle
;
204 ME_Style
*pDefaultStyle
;
207 typedef struct tagME_Cursor
209 ME_DisplayItem
*pPara
;
210 ME_DisplayItem
*pRun
;
229 undo_end_transaction
, /* marks the end of a group of changes for undo */
230 undo_potential_end_transaction
/* allows grouping typed chars for undo */
233 struct insert_run_item
241 struct delete_run_item
246 struct join_paras_item
251 struct split_para_item
255 ME_BorderRect border
;
258 ME_BorderRect cell_border
;
259 int cell_right_boundary
;
262 struct set_para_fmt_item
266 ME_BorderRect border
;
269 struct set_char_fmt_item
281 struct insert_run_item insert_run
;
282 struct delete_run_item delete_run
;
283 struct join_paras_item join_paras
;
284 struct split_para_item split_para
;
285 struct set_para_fmt_item set_para_fmt
;
286 struct set_char_fmt_item set_char_fmt
;
298 typedef struct tagME_FontTableItem
{
304 #define STREAMIN_BUFFER_SIZE 4096 /* M$ compatibility */
306 struct tagME_InStream
{
307 EDITSTREAM
*editstream
;
310 char buffer
[STREAMIN_BUFFER_SIZE
];
312 typedef struct tagME_InStream ME_InStream
;
315 #define STREAMOUT_BUFFER_SIZE 4096
316 #define STREAMOUT_FONTTBL_SIZE 8192
317 #define STREAMOUT_COLORTBL_SIZE 1024
319 typedef struct tagME_OutStream
{
321 char buffer
[STREAMOUT_BUFFER_SIZE
];
325 ME_FontTableItem fonttbl
[STREAMOUT_FONTTBL_SIZE
];
327 COLORREF colortbl
[STREAMOUT_COLORTBL_SIZE
];
329 UINT nDefaultCodePage
;
330 /* nNestingLevel = 0 means we aren't in a cell, 1 means we are in a cell,
331 * an greater numbers mean we are in a cell nested within a cell. */
335 typedef struct tagME_FontCacheItem
343 #define HFONT_CACHE_SIZE 10
345 typedef struct tagME_TextEditor
347 HWND hWnd
, hwndParent
;
349 BOOL bEmulateVersion10
;
350 ME_TextBuffer
*pBuffer
;
356 int nTotalLength
, nLastTotalLength
;
357 int nTotalWidth
, nLastTotalWidth
;
358 int nAvailWidth
; /* 0 = wrap to client area, else wrap width in twips */
360 COLORREF rgbBackColor
;
361 HBRUSH hbrBackground
;
365 struct list undo_stack
;
366 struct list redo_stack
;
369 ME_UndoMode nUndoMode
;
371 int nLastSelStart
, nLastSelEnd
;
372 ME_DisplayItem
*pLastSelStartPara
, *pLastSelEndPara
;
373 ME_FontCacheItem pFontCache
[HFONT_CACHE_SIZE
];
374 int nZoomNumerator
, nZoomDenominator
;
377 BOOL bDefaultFormatRect
;
380 EDITWORDBREAKPROCW pfnWordBreak
;
381 LPRICHEDITOLECALLBACK lpOleCallback
;
382 /*TEXTMODE variable; contains only one of each of the following options:
383 *TM_RICHTEXT or TM_PLAINTEXT
384 *TM_SINGLELEVELUNDO or TM_MULTILEVELUNDO
385 *TM_SINGLECODEPAGE or TM_MULTICODEPAGE*/
388 BOOL AutoURLDetect_bEnable
;
391 BOOL bDialogMode
; /* Indicates that we are inside a dialog window */
394 DWORD selofs
; /* The size of the selection bar on the left side of control */
395 ME_SelectionType nSelectionType
;
397 /* Track previous notified selection */
398 CHARRANGE notified_cr
;
400 /* Cache previously set scrollbar info */
401 SCROLLINFO vert_si
, horz_si
;
406 typedef struct tagME_Context
414 /* those are valid inside ME_WrapTextParagraph and related */
415 ME_TextEditor
*editor
;
418 typedef struct tagME_WrapContext
422 int nLeftMargin
, nRightMargin
, nFirstMargin
;
426 BOOL bOverflown
, bWordWrap
;
427 ME_DisplayItem
*pPara
;
428 ME_DisplayItem
*pRowStart
;
430 ME_DisplayItem
*pLastSplittableRun
;