ReactOS  0.4.15-dev-1392-g3014417
editstr.h
Go to the documentation of this file.
1 /*
2  * RichEdit - structures and constant
3  *
4  * Copyright 2004 by Krzysztof Foltman
5  *
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.
10  *
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.
15  *
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
19  */
20 
21 #ifndef __EDITSTR_H
22 #define __EDITSTR_H
23 
24 #include <assert.h>
25 #include <stdarg.h>
26 #include <stdio.h>
27 #include <stdlib.h>
28 #include <limits.h>
29 
30 #define COBJMACROS
31 
32 #include <windef.h>
33 #include <winbase.h>
34 #include <winnls.h>
35 #include <winnt.h>
36 #include <wingdi.h>
37 #include <winuser.h>
38 #include <richedit.h>
39 #include <commctrl.h>
40 #include <ole2.h>
41 #include <richole.h>
42 #include "imm.h"
43 #include <textserv.h>
44 #include "usp10.h"
45 
46 #include "wine/debug.h"
47 #include "wine/heap.h"
48 #include "wine/list.h"
49 
50 #if defined(__i386__) && !defined(__MINGW32__)
51 extern const struct ITextHostVtbl itextHostStdcallVtbl DECLSPEC_HIDDEN;
52 #endif /* __i386__ */
53 
54 typedef struct tagME_String
55 {
57  int nLen, nBuffer;
58  void (*free)(struct tagME_String *);
59 } ME_String;
60 
61 typedef struct tagME_FontCacheItem
62 {
65  int nRefs;
66  int nAge;
68 
69 #define HFONT_CACHE_SIZE 10
70 
71 typedef struct tagME_Style
72 {
74 
75  ME_FontCacheItem *font_cache; /* cached font for the style */
76  TEXTMETRICW tm; /* cached font metrics for the style */
77  int nRefs; /* reference count */
79  struct list entry;
80 } ME_Style;
81 
82 typedef enum {
84  diTextStart, /* start of the text buffer */
85  diParagraph, /* paragraph start */
86  diCell, /* cell start */
87  diRun, /* run (sequence of chars with the same character format) */
88  diStartRow, /* start of the row (line of text on the screen) */
89  diTextEnd, /* end of the text buffer */
90 
91  /********************* these below are meant for finding only *********************/
98 } ME_DIType;
99 
100 #define SELECTIONBAR_WIDTH 8
101 
102 /******************************** run flags *************************/
103 #define MERF_STYLEFLAGS 0x0FFF
104 /* run contains non-text content, which has its own rules for wrapping, sizing etc */
105 #define MERF_GRAPHICS 0x001
106 /* run is a tab (or, in future, any kind of content whose size is dependent on run position) */
107 #define MERF_TAB 0x002
108 /* run is a cell boundary */
109 #define MERF_ENDCELL 0x004 /* v4.1 */
110 
111 #define MERF_NONTEXT (MERF_GRAPHICS | MERF_TAB | MERF_ENDCELL)
112 
113 /* run is splittable (contains white spaces in the middle or end) */
114 #define MERF_SPLITTABLE 0x001000
115 /* run starts with whitespaces */
116 #define MERF_STARTWHITE 0x002000
117 /* run ends with whitespaces */
118 #define MERF_ENDWHITE 0x004000
119 /* run is completely made of whitespaces */
120 #define MERF_WHITESPACE 0x008000
121 /* the "end of paragraph" run, contains 1 character */
122 #define MERF_ENDPARA 0x100000
123 /* forcing the "end of row" run, contains 1 character */
124 #define MERF_ENDROW 0x200000
125 /* run is hidden */
126 #define MERF_HIDDEN 0x400000
127 /* start of a table row has an empty paragraph that should be skipped over. */
128 #define MERF_TABLESTART 0x800000 /* v4.1 */
129 
130 /* runs with any of these flags set cannot be joined */
131 #define MERF_NOJOIN (MERF_GRAPHICS|MERF_TAB|MERF_ENDPARA|MERF_ENDROW)
132 /* runs that don't contain real text */
133 #define MERF_NOTEXT (MERF_GRAPHICS|MERF_TAB|MERF_ENDPARA|MERF_ENDROW)
134 
135 /* those flags are kept when the row is split */
136 #define MERF_SPLITMASK (~(0))
137 
138 /******************************** para flags *************************/
139 
140 /* this paragraph was already wrapped and hasn't changed, every change resets that flag */
141 #define MEPF_REWRAP 0x01
142 /* v4.1 */
143 #define MEPF_CELL 0x04 /* The paragraph is nested in a cell */
144 #define MEPF_ROWSTART 0x08 /* Hidden empty paragraph at the start of the row */
145 #define MEPF_ROWEND 0x10 /* Visible empty paragraph at the end of the row */
146 #define MEPF_COMPLEX 0x20 /* Use uniscribe */
147 
148 /******************************** structures *************************/
149 
150 struct tagME_DisplayItem;
151 
152 struct re_object
153 {
154  struct list entry;
156 };
157 
158 typedef struct tagME_Run
159 {
161  struct tagME_Paragraph *para; /* ptr to the run's paragraph */
162  int nCharOfs; /* relative to para's offset */
163  int len; /* length of run's text */
164  int nWidth; /* width of full run, width of leading&trailing ws */
165  int nFlags;
166  int nAscent, nDescent; /* pixels above/below baseline */
167  POINT pt; /* relative to para's position */
168  struct re_object *reobj; /* FIXME: should be a union with strText (at least) */
169 
174  int *advances;
178 } ME_Run;
179 
180 typedef struct tagME_Border
181 {
182  int width;
184 } ME_Border;
185 
186 typedef struct tagME_BorderRect
187 {
192 } ME_BorderRect;
193 
194 struct para_num
195 {
200 };
201 
202 typedef struct tagME_Paragraph
203 {
206 
207  struct tagME_DisplayItem *pCell; /* v4.1 */
209 
210  int nCharOfs;
211  int nFlags;
214  int nRows;
216  ME_Run *eop_run; /* ptr to the end-of-para run */
219 } ME_Paragraph;
220 
221 typedef struct tagME_Cell /* v4.1 */
222 {
223  int nNestingLevel; /* 0 for normal cells, and greater for nested cells */
228  int yTextOffset; /* The text offset is caused by the largest top border. */
230 } ME_Cell;
231 
232 typedef struct tagME_Row
233 {
234  int nHeight;
236  int nWidth;
237  int nLMargin;
238  int nRMargin;
240 } ME_Row;
241 
242 /* the display item list layout is like this:
243  * - the document consists of paragraphs
244  * - each paragraph contains at least one run, the last run in the paragraph
245  * is an end-of-paragraph run
246  * - each formatted paragraph contains at least one row, which corresponds
247  * to a screen line (that's why there are no rows in an unformatted
248  * paragraph
249  * - the paragraphs contain "shortcut" pointers to the previous and the next
250  * paragraph, that makes iteration over paragraphs faster
251  * - the list starts with diTextStart and ends with diTextEnd
252  */
253 
254 typedef struct tagME_DisplayItem
255 {
258  union {
263  } member;
265 
266 typedef struct tagME_TextBuffer
267 {
271 } ME_TextBuffer;
272 
273 typedef struct tagME_Cursor
274 {
277  int nOffset;
278 } ME_Cursor;
279 
280 typedef enum {
285 } ME_UndoMode;
286 
288 {
295  undo_end_transaction, /* marks the end of a group of changes for undo */
296  undo_potential_end_transaction /* allows grouping typed chars for undo */
297 };
298 
300 {
301  int pos, len;
305 };
306 
308 {
309  int pos, len;
310 };
311 
313 {
314  int pos;
315 };
316 
318 {
319  int pos;
326 };
327 
329 {
330  int pos;
333 };
334 
336 {
337  int pos, len;
339 };
340 
341 struct undo_item
342 {
343  struct list entry;
345  union
346  {
353  } u;
354 };
355 
356 typedef enum {
363 
364 typedef struct tagME_FontTableItem {
368 
369 
370 #define STREAMIN_BUFFER_SIZE 4096 /* M$ compatibility */
371 
377 };
379 
380 typedef struct tagME_TextEditor
381 {
383  ITextHost *texthost;
390  int nCursors;
394  int nAvailWidth; /* 0 = wrap to client area, else wrap width in twips */
402  struct list undo_stack;
403  struct list redo_stack;
418  LPRICHEDITOLECALLBACK lpOleCallback;
419  /*TEXTMODE variable; contains only one of each of the following options:
420  *TM_RICHTEXT or TM_PLAINTEXT
421  *TM_SINGLELEVELUNDO or TM_MULTILEVELUNDO
422  *TM_SINGLECODEPAGE or TM_MULTICODEPAGE*/
423  int mode;
428  BOOL bDialogMode; /* Indicates that we are inside a dialog window */
429  /*for IME */
431  DWORD selofs; /* The size of the selection bar on the left side of control */
434 
435  /* Track previous notified selection */
437 
438  /* Cache previously set scrollbar info */
440 
445  struct list style_list;
446  struct list reobj_list;
447 } ME_TextEditor;
448 
449 typedef struct tagME_Context
450 {
458 
459  /* those are valid inside ME_WrapTextParagraph and related */
461 } ME_Context;
462 
463 #endif
ME_DIType type
Definition: editstr.h:256
struct tagME_FontTableItem ME_FontTableItem
int nRefs
Definition: editstr.h:77
struct join_paras_item join_paras
Definition: editstr.h:349
ME_Style * style
Definition: editstr.h:196
struct list style_list
Definition: editstr.h:445
struct tagME_FontCacheItem ME_FontCacheItem
BOOL bHideSelection
Definition: editstr.h:424
ME_BorderRect cell_border
Definition: editstr.h:324
ME_DIType
Definition: editstr.h:82
struct set_char_fmt_item set_char_fmt
Definition: editstr.h:352
IUnknown * reOle
Definition: editstr.h:384
ME_Paragraph para
Definition: editstr.h:262
struct tagME_Cell ME_Cell
int nBuffer
Definition: editstr.h:57
BOOL AutoURLDetect_bEnable
Definition: editstr.h:425
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
ME_Border top
Definition: editstr.h:188
WCHAR * szData
Definition: editstr.h:56
int nZoomNumerator
Definition: editstr.h:411
REOBJECT obj
Definition: editstr.h:155
ME_Style * current_style
Definition: editstr.h:456
DWORD styleFlags
Definition: editstr.h:388
RECO_DRAG struct _reobject REOBJECT
ME_Style * pCharStyle
Definition: editstr.h:269
struct tagME_Context ME_Context
INT width
Definition: editstr.h:198
struct re_object * reobj
Definition: editstr.h:168
ME_TextEditor * editor
Definition: editstr.h:460
struct tagME_DisplayItem * pCell
Definition: editstr.h:207
static HDC
Definition: imagelist.c:92
#define DECLSPEC_HIDDEN
Definition: precomp.h:8
struct tagME_Paragraph * para
Definition: editstr.h:161
HFONT orig_font
Definition: editstr.h:457
BOOL caret_hidden
Definition: editstr.h:442
CHARRANGE notified_cr
Definition: editstr.h:436
ME_String * eol_str
Definition: editstr.h:322
BOOL bDefaultFormatRect
Definition: editstr.h:414
struct list reobj_list
Definition: editstr.h:446
GLuint buffer
Definition: glext.h:5915
BOOL bMouseCaptured
Definition: editstr.h:443
struct tagME_DisplayItem * prev_para
Definition: editstr.h:217
WORD * clusters
Definition: editstr.h:177
TEXTMETRICW tm
Definition: editstr.h:76
POINT pt
Definition: editstr.h:226
WCHAR * szFaceName
Definition: editstr.h:366
int cell_right_boundary
Definition: editstr.h:325
int nCharOfs
Definition: editstr.h:162
struct split_para_item split_para
Definition: editstr.h:350
ME_Style * style
Definition: editstr.h:160
int32_t INT
Definition: typedefs.h:58
ME_String * text
Definition: editstr.h:197
ME_DisplayItem * pLastSelStartPara
Definition: editstr.h:409
#define STREAMIN_BUFFER_SIZE
Definition: editstr.h:370
struct delete_run_item delete_run
Definition: editstr.h:348
SCROLLINFO vert_si
Definition: editstr.h:439
int nNestingLevel
Definition: editstr.h:223
struct tagME_DisplayItem * prev_marked
Definition: editstr.h:218
ME_String * text
Definition: editstr.h:205
POINT pt
Definition: editstr.h:452
ME_DisplayItem * pFirst
Definition: editstr.h:268
struct insert_run_item insert_run
Definition: editstr.h:347
int nLMargin
Definition: editstr.h:237
struct tagME_BorderRect ME_BorderRect
struct tagME_DisplayItem * next
Definition: editstr.h:257
struct tagME_DisplayItem * parent_cell
Definition: editstr.h:229
unsigned int BOOL
Definition: ntddk_ex.h:94
struct tagME_DisplayItem * next_marked
Definition: editstr.h:218
struct set_para_fmt_item set_para_fmt
Definition: editstr.h:351
HBRUSH hbrBackground
Definition: editstr.h:398
POINT pt
Definition: editstr.h:239
int nUndoStackSize
Definition: editstr.h:404
ME_TextBuffer * pBuffer
Definition: editstr.h:386
int nDescent
Definition: editstr.h:166
Definition: editstr.h:87
BOOL bCaretAtEnd
Definition: editstr.h:399
int len
Definition: editstr.h:163
DWORD dwSize
Definition: editstr.h:374
ME_UndoMode
Definition: editstr.h:280
struct list entry
Definition: editstr.h:79
int nAvailWidth
Definition: editstr.h:455
struct tagME_TextBuffer ME_TextBuffer
int nLen
Definition: editstr.h:57
PARAFORMAT2 fmt
Definition: editstr.h:320
struct tagME_String ME_String
ME_FontCacheItem pFontCache[HFONT_CACHE_SIZE]
Definition: editstr.h:410
ME_DisplayItem * pLastSelEndPara
Definition: editstr.h:409
ME_BorderRect border
Definition: editstr.h:208
LOGFONTW lfSpecs
Definition: editstr.h:63
struct list undo_stack
Definition: editstr.h:402
ME_SelectionType nSelectionType
Definition: editstr.h:432
PARAFORMAT2 fmt
Definition: editstr.h:331
int nWidth
Definition: editstr.h:236
ME_Style * pDefaultStyle
Definition: editstr.h:270
int nRMargin
Definition: editstr.h:238
CHARFORMAT2W fmt
Definition: editstr.h:338
__wchar_t WCHAR
Definition: xmlstorage.h:180
GOFFSET * offsets
Definition: editstr.h:175
DWORD COLORREF
Definition: windef.h:300
ME_FontCacheItem * font_cache
Definition: editstr.h:75
int nBaseline
Definition: editstr.h:235
BOOL bDialogMode
Definition: editstr.h:428
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
struct tagME_Row ME_Row
ME_DisplayItem * pPara
Definition: editstr.h:275
union tagME_DisplayItem::@526 member
ME_Run * eop_run
Definition: editstr.h:216
struct tagME_TextEditor ME_TextEditor
int nFlags
Definition: editstr.h:165
ME_BorderRect border
Definition: editstr.h:225
undo_type
Definition: editstr.h:287
WCHAR * str
Definition: editstr.h:302
ITextHost * texthost
Definition: editstr.h:383
EDITSTREAM * editstream
Definition: editstr.h:373
int nRightBoundary
Definition: editstr.h:224
int nWidth
Definition: editstr.h:164
void(* free)(struct tagME_String *)
Definition: editstr.h:58
int nOffset
Definition: editstr.h:277
COLORREF rgbBackColor
Definition: editstr.h:397
ME_BorderRect border
Definition: editstr.h:332
ME_SelectionType
Definition: editstr.h:356
Definition: editstr.h:86
POINT pt
Definition: editstr.h:199
Definition: _list.h:228
ME_DisplayItem * pLast
Definition: editstr.h:268
int(CALLBACK * EDITWORDBREAKPROCW)(LPWSTR, int, int, int)
Definition: winuser.h:2880
POINT pt
Definition: editstr.h:167
union undo_item::@527 u
SCRIPT_CACHE script_cache
Definition: editstr.h:78
LPRICHEDITOLECALLBACK lpOleCallback
Definition: editstr.h:418
ME_Cell cell
Definition: editstr.h:261
unsigned char BYTE
Definition: xxhash.c:193
int * advances
Definition: editstr.h:174
COLORREF colorRef
Definition: editstr.h:183
ME_Border right
Definition: editstr.h:191
enum undo_type type
Definition: editstr.h:344
ME_Border bottom
Definition: editstr.h:190
struct list entry
Definition: editstr.h:343
BOOL bEmulateVersion10
Definition: editstr.h:385
ME_Style * style
Definition: editstr.h:303
struct tagME_Style ME_Style
ME_Cursor * pCursors
Definition: editstr.h:387
struct tagME_Border ME_Border
PARAFORMAT2 fmt
Definition: editstr.h:204
SCROLLINFO horz_si
Definition: editstr.h:439
int num_glyphs
Definition: editstr.h:171
int nHeight
Definition: editstr.h:227
int nLastTotalLength
Definition: editstr.h:392
int yTextOffset
Definition: editstr.h:228
struct tagME_DisplayItem * next_para
Definition: editstr.h:217
ME_UndoMode nUndoMode
Definition: editstr.h:406
ME_DisplayItem * pRun
Definition: editstr.h:276
RECT prevClientRect
Definition: editstr.h:412
SCRIPT_ANALYSIS script_analysis
Definition: editstr.h:170
int max_clusters
Definition: editstr.h:176
DWORD dwUsed
Definition: editstr.h:375
WORD * glyphs
Definition: editstr.h:172
#define HFONT_CACHE_SIZE
Definition: editstr.h:69
struct tagME_Cursor ME_Cursor
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
ME_DisplayItem * first_marked_para
Definition: editstr.h:433
struct tagME_DisplayItem * next_cell
Definition: editstr.h:229
ME_Border left
Definition: editstr.h:189
DWORD exStyleFlags
Definition: editstr.h:389
int nWidth
Definition: editstr.h:227
RECT rcView
Definition: editstr.h:453
struct tagME_Paragraph ME_Paragraph
ME_BorderRect border
Definition: editstr.h:321
struct tagME_DisplayItem ME_DisplayItem
WCHAR cPasswordMask
Definition: editstr.h:426
struct list redo_stack
Definition: editstr.h:403
int nLastTotalWidth
Definition: editstr.h:393
SCRIPT_VISATTR * vis_attrs
Definition: editstr.h:173
CHARFORMAT2W fmt
Definition: editstr.h:73
struct tagME_DisplayItem * prev
Definition: editstr.h:257
struct tagME_Run ME_Run
int nZoomDenominator
Definition: editstr.h:411
int nAscent
Definition: editstr.h:166
EDITWORDBREAKPROCW pfnWordBreak
Definition: editstr.h:417
struct list entry
Definition: editstr.h:154
int nHeight
Definition: editstr.h:234
int max_glyphs
Definition: editstr.h:171
struct tagME_DisplayItem * prev_cell
Definition: editstr.h:229