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