ntdll: Implement NtCreateDebugObject().
[wine.git] / dlls / riched20 / editstr.h
blob204e078c986796dd00366340abbcd8fc6544a2d3
1 /*
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
21 #ifndef __EDITSTR_H
22 #define __EDITSTR_H
24 #include <assert.h>
25 #include <stdarg.h>
26 #include <stdio.h>
27 #include <stdlib.h>
28 #include <limits.h>
30 #define COBJMACROS
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"
46 #include "wine/asm.h"
47 #include "wine/debug.h"
48 #include "wine/heap.h"
49 #include "wine/list.h"
50 #include "wine/rbtree.h"
52 #ifdef __ASM_USE_THISCALL_WRAPPER
53 extern const struct ITextHostVtbl itextHostStdcallVtbl DECLSPEC_HIDDEN;
54 #endif /* __i386__ */
56 typedef struct tagME_String
58 WCHAR *szData;
59 int nLen, nBuffer;
60 void (*free)(struct tagME_String *);
61 } ME_String;
63 typedef struct tagME_FontCacheItem
65 LOGFONTW lfSpecs;
66 HFONT hFont;
67 int nRefs;
68 int nAge;
69 } ME_FontCacheItem;
71 #define HFONT_CACHE_SIZE 10
73 typedef struct tagME_Style
75 CHARFORMAT2W fmt;
77 ME_FontCacheItem *font_cache; /* cached font for the style */
78 TEXTMETRICW tm; /* cached font metrics for the style */
79 int nRefs; /* reference count */
80 SCRIPT_CACHE script_cache;
81 struct list entry;
82 } ME_Style;
84 typedef enum {
85 diInvalid,
86 diTextStart, /* start of the text buffer */
87 diParagraph, /* paragraph start */
88 diCell, /* cell start */
89 diRun, /* run (sequence of chars with the same character format) */
90 diStartRow, /* start of the row (line of text on the screen) */
91 diTextEnd, /* end of the text buffer */
93 /********************* these below are meant for finding only *********************/
94 diStartRowOrParagraph, /* 7 */
95 diStartRowOrParagraphOrEnd,
96 diRunOrParagraph,
97 diRunOrStartRow,
98 diParagraphOrEnd,
99 diRunOrParagraphOrEnd, /* 12 */
100 } ME_DIType;
102 #define SELECTIONBAR_WIDTH 8
104 /******************************** run flags *************************/
105 #define MERF_STYLEFLAGS 0x0FFF
106 /* run contains non-text content, which has its own rules for wrapping, sizing etc */
107 #define MERF_GRAPHICS 0x001
108 /* run is a tab (or, in future, any kind of content whose size is dependent on run position) */
109 #define MERF_TAB 0x002
110 /* run is a cell boundary */
111 #define MERF_ENDCELL 0x004 /* v4.1 */
113 #define MERF_NONTEXT (MERF_GRAPHICS | MERF_TAB | MERF_ENDCELL)
115 /* run is splittable (contains white spaces in the middle or end) */
116 #define MERF_SPLITTABLE 0x001000
117 /* run starts with whitespaces */
118 #define MERF_STARTWHITE 0x002000
119 /* run ends with whitespaces */
120 #define MERF_ENDWHITE 0x004000
121 /* run is completely made of whitespaces */
122 #define MERF_WHITESPACE 0x008000
123 /* the "end of paragraph" run, contains 1 character */
124 #define MERF_ENDPARA 0x100000
125 /* forcing the "end of row" run, contains 1 character */
126 #define MERF_ENDROW 0x200000
127 /* run is hidden */
128 #define MERF_HIDDEN 0x400000
129 /* start of a table row has an empty paragraph that should be skipped over. */
130 #define MERF_TABLESTART 0x800000 /* v4.1 */
132 /* runs with any of these flags set cannot be joined */
133 #define MERF_NOJOIN (MERF_GRAPHICS|MERF_TAB|MERF_ENDPARA|MERF_ENDROW)
134 /* runs that don't contain real text */
135 #define MERF_NOTEXT (MERF_GRAPHICS|MERF_TAB|MERF_ENDPARA|MERF_ENDROW)
137 /* those flags are kept when the row is split */
138 #define MERF_SPLITMASK (~(0))
140 /******************************** para flags *************************/
142 /* this paragraph was already wrapped and hasn't changed, every change resets that flag */
143 #define MEPF_REWRAP 0x01
144 /* v4.1 */
145 #define MEPF_CELL 0x04 /* The paragraph is nested in a cell */
146 #define MEPF_ROWSTART 0x08 /* Hidden empty paragraph at the start of the row */
147 #define MEPF_ROWEND 0x10 /* Visible empty paragraph at the end of the row */
148 #define MEPF_COMPLEX 0x20 /* Use uniscribe */
150 /******************************** structures *************************/
152 struct tagME_DisplayItem;
154 struct re_object
156 struct list entry;
157 REOBJECT obj;
160 typedef struct tagME_Run
162 ME_Style *style;
163 struct tagME_Paragraph *para; /* ptr to the run's paragraph */
164 int nCharOfs; /* relative to para's offset */
165 int len; /* length of run's text */
166 int nWidth; /* width of full run, width of leading&trailing ws */
167 int nFlags;
168 int nAscent, nDescent; /* pixels above/below baseline */
169 POINT pt; /* relative to para's position */
170 struct re_object *reobj; /* FIXME: should be a union with strText (at least) */
172 SCRIPT_ANALYSIS script_analysis;
173 int num_glyphs, max_glyphs;
174 WORD *glyphs;
175 SCRIPT_VISATTR *vis_attrs;
176 int *advances;
177 GOFFSET *offsets;
178 int max_clusters;
179 WORD *clusters;
180 } ME_Run;
182 typedef struct tagME_Border
184 int width;
185 COLORREF colorRef;
186 } ME_Border;
188 typedef struct tagME_BorderRect
190 ME_Border top;
191 ME_Border left;
192 ME_Border bottom;
193 ME_Border right;
194 } ME_BorderRect;
196 struct para_num
198 ME_Style *style;
199 ME_String *text;
200 INT width;
201 POINT pt;
204 typedef struct tagME_Paragraph
206 PARAFORMAT2 fmt;
207 ME_String *text;
209 struct tagME_Cell *cell; /* v4.1 */
210 ME_BorderRect border;
212 int nCharOfs;
213 int nFlags;
214 POINT pt;
215 int nHeight, nWidth;
216 int nRows;
217 struct para_num para_num;
218 ME_Run *eop_run; /* ptr to the end-of-para run */
219 struct tagME_DisplayItem *prev_para, *next_para;
220 struct wine_rb_entry marked_entry;
221 } ME_Paragraph;
223 typedef struct tagME_Cell /* v4.1 */
225 int nNestingLevel; /* 0 for normal cells, and greater for nested cells */
226 int nRightBoundary;
227 ME_BorderRect border;
228 POINT pt;
229 int nHeight, nWidth;
230 int yTextOffset; /* The text offset is caused by the largest top border. */
231 struct tagME_Cell *prev_cell, *next_cell, *parent_cell;
232 } ME_Cell;
234 typedef struct tagME_Row
236 int nHeight;
237 int nBaseline;
238 int nWidth;
239 int nLMargin;
240 int nRMargin;
241 POINT pt;
242 } ME_Row;
244 /* the display item list layout is like this:
245 * - the document consists of paragraphs
246 * - each paragraph contains at least one run, the last run in the paragraph
247 * is an end-of-paragraph run
248 * - each formatted paragraph contains at least one row, which corresponds
249 * to a screen line (that's why there are no rows in an unformatted
250 * paragraph
251 * - the paragraphs contain "shortcut" pointers to the previous and the next
252 * paragraph, that makes iteration over paragraphs faster
253 * - the list starts with diTextStart and ends with diTextEnd
256 typedef struct tagME_DisplayItem
258 ME_DIType type;
259 struct tagME_DisplayItem *prev, *next;
260 union {
261 ME_Run run;
262 ME_Row row;
263 ME_Cell cell;
264 ME_Paragraph para;
265 } member;
266 } ME_DisplayItem;
268 typedef struct tagME_TextBuffer
270 ME_DisplayItem *pFirst, *pLast;
271 ME_Style *pCharStyle;
272 ME_Style *pDefaultStyle;
273 } ME_TextBuffer;
275 typedef struct tagME_Cursor
277 ME_Paragraph *para;
278 ME_Run *run;
279 int nOffset;
280 } ME_Cursor;
282 typedef enum {
283 umAddToUndo,
284 umAddToRedo,
285 umIgnore,
286 umAddBackToUndo
287 } ME_UndoMode;
289 enum undo_type
291 undo_insert_run,
292 undo_delete_run,
293 undo_join_paras,
294 undo_split_para,
295 undo_set_para_fmt,
296 undo_set_char_fmt,
297 undo_end_transaction, /* marks the end of a group of changes for undo */
298 undo_potential_end_transaction /* allows grouping typed chars for undo */
301 struct insert_run_item
303 int pos, len;
304 WCHAR *str;
305 ME_Style *style;
306 DWORD flags;
309 struct delete_run_item
311 int pos, len;
314 struct join_paras_item
316 int pos;
319 struct split_para_item
321 int pos;
322 PARAFORMAT2 fmt;
323 ME_BorderRect border;
324 ME_String *eol_str;
325 DWORD flags;
326 ME_BorderRect cell_border;
327 int cell_right_boundary;
330 struct set_para_fmt_item
332 int pos;
333 PARAFORMAT2 fmt;
334 ME_BorderRect border;
337 struct set_char_fmt_item
339 int pos, len;
340 CHARFORMAT2W fmt;
343 struct undo_item
345 struct list entry;
346 enum undo_type type;
347 union
349 struct insert_run_item insert_run;
350 struct delete_run_item delete_run;
351 struct join_paras_item join_paras;
352 struct split_para_item split_para;
353 struct set_para_fmt_item set_para_fmt;
354 struct set_char_fmt_item set_char_fmt;
355 } u;
358 typedef enum {
359 stPosition = 0,
360 stWord,
361 stLine,
362 stParagraph,
363 stDocument
364 } ME_SelectionType;
366 typedef struct tagME_FontTableItem {
367 BYTE bCharSet;
368 WCHAR *szFaceName;
369 } ME_FontTableItem;
372 #define STREAMIN_BUFFER_SIZE 4096 /* M$ compatibility */
374 struct tagME_InStream {
375 EDITSTREAM *editstream;
376 DWORD dwSize;
377 DWORD dwUsed;
378 char buffer[STREAMIN_BUFFER_SIZE];
380 typedef struct tagME_InStream ME_InStream;
382 typedef struct tagME_TextEditor
384 HWND hWnd, hwndParent;
385 ITextHost *texthost;
386 IUnknown *reOle;
387 BOOL bEmulateVersion10;
388 ME_TextBuffer *pBuffer;
389 ME_Cursor *pCursors;
390 DWORD styleFlags;
391 DWORD exStyleFlags;
392 int nCursors;
393 SIZE sizeWindow;
394 int nTotalLength, nLastTotalLength;
395 int nTotalWidth, nLastTotalWidth;
396 int nAvailWidth; /* 0 = wrap to client area, else wrap width in twips */
397 int nUDArrowX;
398 int total_rows;
399 COLORREF rgbBackColor;
400 HBRUSH hbrBackground;
401 int nEventMask;
402 int nModifyStep;
403 struct list undo_stack;
404 struct list redo_stack;
405 int nUndoStackSize;
406 int nUndoLimit;
407 ME_UndoMode nUndoMode;
408 int nParagraphs;
409 int nLastSelStart, nLastSelEnd;
410 ME_Paragraph *last_sel_start_para, *last_sel_end_para;
411 ME_FontCacheItem pFontCache[HFONT_CACHE_SIZE];
412 int nZoomNumerator, nZoomDenominator;
413 RECT prevClientRect;
414 RECT rcFormat;
415 BOOL bDefaultFormatRect;
416 BOOL bWordWrap;
417 int nTextLimit;
418 EDITWORDBREAKPROCW pfnWordBreak;
419 LPRICHEDITOLECALLBACK lpOleCallback;
420 /*TEXTMODE variable; contains only one of each of the following options:
421 *TM_RICHTEXT or TM_PLAINTEXT
422 *TM_SINGLELEVELUNDO or TM_MULTILEVELUNDO
423 *TM_SINGLECODEPAGE or TM_MULTICODEPAGE*/
424 int mode;
425 BOOL bHideSelection;
426 BOOL AutoURLDetect_bEnable;
427 WCHAR cPasswordMask;
428 BOOL bHaveFocus;
429 BOOL bDialogMode; /* Indicates that we are inside a dialog window */
430 /*for IME */
431 int imeStartIndex;
432 DWORD selofs; /* The size of the selection bar on the left side of control */
433 ME_SelectionType nSelectionType;
435 /* Track previous notified selection */
436 CHARRANGE notified_cr;
438 /* Cache previously set scrollbar info */
439 SCROLLINFO vert_si, horz_si;
441 int caret_height;
442 BOOL caret_hidden;
443 BOOL bMouseCaptured;
444 int wheel_remain;
445 struct list style_list;
446 struct list reobj_list;
447 struct wine_rb_tree marked_paras;
448 } ME_TextEditor;
450 typedef struct tagME_Context
452 HDC hDC;
453 POINT pt;
454 RECT rcView;
455 SIZE dpi;
456 int nAvailWidth;
457 ME_Style *current_style;
458 HFONT orig_font;
460 /* those are valid inside ME_WrapTextParagraph and related */
461 ME_TextEditor *editor;
462 } ME_Context;
464 #endif