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 #define _WIN32_IE 0x0400
50 #include "wine/debug.h"
51 #include "wine/list.h"
54 extern const struct ITextHostVtbl itextHostStdcallVtbl DECLSPEC_HIDDEN
;
57 typedef struct tagME_String
61 void (*free
)(struct tagME_String
*);
64 typedef struct tagME_FontCacheItem
72 #define HFONT_CACHE_SIZE 10
74 typedef struct tagME_Style
78 ME_FontCacheItem
*font_cache
; /* cached font for the style */
79 TEXTMETRICW tm
; /* cached font metrics for the style */
80 int nRefs
; /* reference count */
81 SCRIPT_CACHE script_cache
;
87 diTextStart
, /* start of the text buffer */
88 diParagraph
, /* paragraph start */
89 diCell
, /* cell start */
90 diRun
, /* run (sequence of chars with the same character format) */
91 diStartRow
, /* start of the row (line of text on the screen) */
92 diTextEnd
, /* end of the text buffer */
94 /********************* these below are meant for finding only *********************/
95 diStartRowOrParagraph
, /* 7 */
96 diStartRowOrParagraphOrEnd
,
100 diRunOrParagraphOrEnd
, /* 12 */
103 #define SELECTIONBAR_WIDTH 8
105 /******************************** run flags *************************/
106 #define MERF_STYLEFLAGS 0x0FFF
107 /* run contains non-text content, which has its own rules for wrapping, sizing etc */
108 #define MERF_GRAPHICS 0x001
109 /* run is a tab (or, in future, any kind of content whose size is dependent on run position) */
110 #define MERF_TAB 0x002
111 /* run is a cell boundary */
112 #define MERF_ENDCELL 0x004 /* v4.1 */
114 #define MERF_NONTEXT (MERF_GRAPHICS | MERF_TAB | MERF_ENDCELL)
116 /* run is splittable (contains white spaces in the middle or end) */
117 #define MERF_SPLITTABLE 0x001000
118 /* run starts with whitespaces */
119 #define MERF_STARTWHITE 0x002000
120 /* run ends with whitespaces */
121 #define MERF_ENDWHITE 0x004000
122 /* run is completely made of whitespaces */
123 #define MERF_WHITESPACE 0x008000
124 /* the "end of paragraph" run, contains 1 character */
125 #define MERF_ENDPARA 0x100000
126 /* forcing the "end of row" run, contains 1 character */
127 #define MERF_ENDROW 0x200000
129 #define MERF_HIDDEN 0x400000
130 /* start of a table row has an empty paragraph that should be skipped over. */
131 #define MERF_TABLESTART 0x800000 /* v4.1 */
133 /* runs with any of these flags set cannot be joined */
134 #define MERF_NOJOIN (MERF_GRAPHICS|MERF_TAB|MERF_ENDPARA|MERF_ENDROW)
135 /* runs that don't contain real text */
136 #define MERF_NOTEXT (MERF_GRAPHICS|MERF_TAB|MERF_ENDPARA|MERF_ENDROW)
138 /* those flags are kept when the row is split */
139 #define MERF_SPLITMASK (~(0))
141 /******************************** para flags *************************/
143 /* this paragraph was already wrapped and hasn't changed, every change resets that flag */
144 #define MEPF_REWRAP 0x01
146 #define MEPF_CELL 0x04 /* The paragraph is nested in a cell */
147 #define MEPF_ROWSTART 0x08 /* Hidden empty paragraph at the start of the row */
148 #define MEPF_ROWEND 0x10 /* Visible empty paragraph at the end of the row */
149 #define MEPF_COMPLEX 0x20 /* Use uniscribe */
151 /******************************** structures *************************/
153 struct tagME_DisplayItem
;
155 typedef struct tagME_Run
158 struct tagME_Paragraph
*para
; /* ptr to the run's paragraph */
159 int nCharOfs
; /* relative to para's offset */
160 int len
; /* length of run's text */
161 int nWidth
; /* width of full run, width of leading&trailing ws */
163 int nAscent
, nDescent
; /* pixels above/below baseline */
164 POINT pt
; /* relative to para's position */
165 REOBJECT
*ole_obj
; /* FIXME: should be a union with strText (at least) */
167 SCRIPT_ANALYSIS script_analysis
;
168 int num_glyphs
, max_glyphs
;
170 SCRIPT_VISATTR
*vis_attrs
;
177 typedef struct tagME_Border
183 typedef struct tagME_BorderRect
199 typedef struct tagME_Paragraph
204 struct tagME_DisplayItem
*pCell
; /* v4.1 */
205 ME_BorderRect border
;
212 struct para_num para_num
;
213 ME_Run
*eop_run
; /* ptr to the end-of-para run */
214 struct tagME_DisplayItem
*prev_para
, *next_para
;
217 typedef struct tagME_Cell
/* v4.1 */
219 int nNestingLevel
; /* 0 for normal cells, and greater for nested cells */
221 ME_BorderRect border
;
224 int yTextOffset
; /* The text offset is caused by the largest top border. */
225 struct tagME_DisplayItem
*prev_cell
, *next_cell
, *parent_cell
;
228 typedef struct tagME_Row
238 /* the display item list layout is like this:
239 * - the document consists of paragraphs
240 * - each paragraph contains at least one run, the last run in the paragraph
241 * is an end-of-paragraph run
242 * - each formatted paragraph contains at least one row, which corresponds
243 * to a screen line (that's why there are no rows in an unformatted
245 * - the paragraphs contain "shortcut" pointers to the previous and the next
246 * paragraph, that makes iteration over paragraphs faster
247 * - the list starts with diTextStart and ends with diTextEnd
250 typedef struct tagME_DisplayItem
253 struct tagME_DisplayItem
*prev
, *next
;
262 typedef struct tagME_TextBuffer
264 ME_DisplayItem
*pFirst
, *pLast
;
265 ME_Style
*pCharStyle
;
266 ME_Style
*pDefaultStyle
;
269 typedef struct tagME_Cursor
271 ME_DisplayItem
*pPara
;
272 ME_DisplayItem
*pRun
;
291 undo_end_transaction
, /* marks the end of a group of changes for undo */
292 undo_potential_end_transaction
/* allows grouping typed chars for undo */
295 struct insert_run_item
303 struct delete_run_item
308 struct join_paras_item
313 struct split_para_item
317 ME_BorderRect border
;
320 ME_BorderRect cell_border
;
321 int cell_right_boundary
;
324 struct set_para_fmt_item
328 ME_BorderRect border
;
331 struct set_char_fmt_item
343 struct insert_run_item insert_run
;
344 struct delete_run_item delete_run
;
345 struct join_paras_item join_paras
;
346 struct split_para_item split_para
;
347 struct set_para_fmt_item set_para_fmt
;
348 struct set_char_fmt_item set_char_fmt
;
360 typedef struct tagME_FontTableItem
{
366 #define STREAMIN_BUFFER_SIZE 4096 /* M$ compatibility */
368 struct tagME_InStream
{
369 EDITSTREAM
*editstream
;
372 char buffer
[STREAMIN_BUFFER_SIZE
];
374 typedef struct tagME_InStream ME_InStream
;
376 typedef struct tagME_TextEditor
378 HWND hWnd
, hwndParent
;
381 BOOL bEmulateVersion10
;
382 ME_TextBuffer
*pBuffer
;
388 int nTotalLength
, nLastTotalLength
;
389 int nTotalWidth
, nLastTotalWidth
;
390 int nAvailWidth
; /* 0 = wrap to client area, else wrap width in twips */
392 COLORREF rgbBackColor
;
393 HBRUSH hbrBackground
;
397 struct list undo_stack
;
398 struct list redo_stack
;
401 ME_UndoMode nUndoMode
;
403 int nLastSelStart
, nLastSelEnd
;
404 ME_DisplayItem
*pLastSelStartPara
, *pLastSelEndPara
;
405 ME_FontCacheItem pFontCache
[HFONT_CACHE_SIZE
];
406 int nZoomNumerator
, nZoomDenominator
;
409 BOOL bDefaultFormatRect
;
412 EDITWORDBREAKPROCW pfnWordBreak
;
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
;
423 BOOL bDialogMode
; /* Indicates that we are inside a dialog window */
426 DWORD selofs
; /* The size of the selection bar on the left side of control */
427 ME_SelectionType nSelectionType
;
429 /* Track previous notified selection */
430 CHARRANGE notified_cr
;
432 /* Cache previously set scrollbar info */
433 SCROLLINFO vert_si
, horz_si
;
437 struct list style_list
;
440 typedef struct tagME_Context
448 /* those are valid inside ME_WrapTextParagraph and related */
449 ME_TextEditor
*editor
;