winegstreamer: Unblock waits in sink_chain_cb() when disabling a stream.
[wine.git] / dlls / riched20 / editstr.h
blob3b166234f2388bbbac5a26b117a23929a88f187b
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 <tom.h>
45 #include "usp10.h"
47 #include "wine/asm.h"
48 #include "wine/debug.h"
49 #include "wine/heap.h"
50 #include "wine/list.h"
51 #include "wine/rbtree.h"
53 typedef struct tagME_String
55 WCHAR *szData;
56 int nLen, nBuffer;
57 void (*free)(struct tagME_String *);
58 } ME_String;
60 typedef struct tagME_FontCacheItem
62 LOGFONTW lfSpecs;
63 HFONT hFont;
64 int nRefs;
65 int nAge;
66 } ME_FontCacheItem;
68 #define HFONT_CACHE_SIZE 10
70 typedef struct tagME_Style
72 CHARFORMAT2W fmt;
74 ME_FontCacheItem *font_cache; /* cached font for the style */
75 TEXTMETRICW tm; /* cached font metrics for the style */
76 int nRefs; /* reference count */
77 SCRIPT_CACHE script_cache;
78 struct list entry;
79 } ME_Style;
81 typedef enum {
82 diInvalid,
83 diTextStart, /* start of the text buffer */
84 diParagraph, /* paragraph start */
85 diCell, /* cell start */
86 diRun, /* run (sequence of chars with the same character format) */
87 diStartRow, /* start of the row (line of text on the screen) */
88 diTextEnd, /* end of the text buffer */
90 /********************* these below are meant for finding only *********************/
91 diStartRowOrParagraph, /* 7 */
92 diStartRowOrParagraphOrEnd,
93 diRunOrParagraph,
94 diRunOrStartRow,
95 diParagraphOrEnd,
96 diRunOrParagraphOrEnd, /* 12 */
97 } ME_DIType;
99 #define SELECTIONBAR_WIDTH 8
101 /******************************** run flags *************************/
102 #define MERF_STYLEFLAGS 0x0FFF
103 /* run contains non-text content, which has its own rules for wrapping, sizing etc */
104 #define MERF_GRAPHICS 0x001
105 /* run is a tab (or, in future, any kind of content whose size is dependent on run position) */
106 #define MERF_TAB 0x002
107 /* run is a cell boundary */
108 #define MERF_ENDCELL 0x004 /* v4.1 */
110 #define MERF_NONTEXT (MERF_GRAPHICS | MERF_TAB | MERF_ENDCELL)
112 /* run is splittable (contains white spaces in the middle or end) */
113 #define MERF_SPLITTABLE 0x001000
114 /* run starts with whitespaces */
115 #define MERF_STARTWHITE 0x002000
116 /* run ends with whitespaces */
117 #define MERF_ENDWHITE 0x004000
118 /* run is completely made of whitespaces */
119 #define MERF_WHITESPACE 0x008000
120 /* the "end of paragraph" run, contains 1 character */
121 #define MERF_ENDPARA 0x100000
122 /* forcing the "end of row" run, contains 1 character */
123 #define MERF_ENDROW 0x200000
124 /* run is hidden */
125 #define MERF_HIDDEN 0x400000
126 /* start of a table row has an empty paragraph that should be skipped over. */
127 #define MERF_TABLESTART 0x800000 /* v4.1 */
129 /* runs with any of these flags set cannot be joined */
130 #define MERF_NOJOIN (MERF_GRAPHICS|MERF_TAB|MERF_ENDPARA|MERF_ENDROW)
131 /* runs that don't contain real text */
132 #define MERF_NOTEXT (MERF_GRAPHICS|MERF_TAB|MERF_ENDPARA|MERF_ENDROW)
134 /* those flags are kept when the row is split */
135 #define MERF_SPLITMASK (~(0))
137 /******************************** para flags *************************/
139 /* this paragraph was already wrapped and hasn't changed, every change resets that flag */
140 #define MEPF_REWRAP 0x01
141 /* v4.1 */
142 #define MEPF_CELL 0x04 /* The paragraph is nested in a cell */
143 #define MEPF_ROWSTART 0x08 /* Hidden empty paragraph at the start of the row */
144 #define MEPF_ROWEND 0x10 /* Visible empty paragraph at the end of the row */
145 #define MEPF_COMPLEX 0x20 /* Use uniscribe */
147 /******************************** structures *************************/
149 struct tagME_DisplayItem;
150 struct tagME_Run;
152 struct re_object
154 struct list entry;
155 REOBJECT obj;
156 struct tagME_Run *run; /* ptr to the reobj's run */
159 typedef struct tagME_Run
161 ME_Style *style;
162 struct tagME_Paragraph *para; /* ptr to the run's paragraph */
163 int nCharOfs; /* relative to para's offset */
164 int len; /* length of run's text */
165 int nWidth; /* width of full run, width of leading&trailing ws */
166 int nFlags;
167 int nAscent, nDescent; /* pixels above/below baseline */
168 POINT pt; /* relative to para's position */
169 struct re_object *reobj; /* FIXME: should be a union with strText (at least) */
171 SCRIPT_ANALYSIS script_analysis;
172 int num_glyphs, max_glyphs;
173 WORD *glyphs;
174 SCRIPT_VISATTR *vis_attrs;
175 int *advances;
176 GOFFSET *offsets;
177 int max_clusters;
178 WORD *clusters;
179 } ME_Run;
181 typedef struct tagME_Border
183 int width;
184 COLORREF colorRef;
185 } ME_Border;
187 typedef struct tagME_BorderRect
189 ME_Border top;
190 ME_Border left;
191 ME_Border bottom;
192 ME_Border right;
193 } ME_BorderRect;
195 struct para_num
197 ME_Style *style;
198 ME_String *text;
199 INT width;
200 POINT pt;
203 typedef struct tagME_Paragraph
205 PARAFORMAT2 fmt;
206 ME_String *text;
208 struct tagME_Cell *cell; /* v4.1 */
209 ME_BorderRect border;
211 int nCharOfs;
212 int nFlags;
213 POINT pt;
214 int nHeight, nWidth;
215 int nRows;
216 struct para_num para_num;
217 ME_Run *eop_run; /* ptr to the end-of-para run */
218 struct tagME_DisplayItem *prev_para, *next_para;
219 struct wine_rb_entry marked_entry;
220 } ME_Paragraph;
222 typedef struct tagME_Cell /* v4.1 */
224 int nNestingLevel; /* 0 for normal cells, and greater for nested cells */
225 int nRightBoundary;
226 ME_BorderRect border;
227 POINT pt;
228 int nHeight, nWidth;
229 int yTextOffset; /* The text offset is caused by the largest top border. */
230 struct tagME_Cell *prev_cell, *next_cell, *parent_cell;
231 } ME_Cell;
233 typedef struct tagME_Row
235 int nHeight;
236 int nBaseline;
237 int nWidth;
238 int nLMargin;
239 int nRMargin;
240 POINT pt;
241 } ME_Row;
243 /* the display item list layout is like this:
244 * - the document consists of paragraphs
245 * - each paragraph contains at least one run, the last run in the paragraph
246 * is an end-of-paragraph run
247 * - each formatted paragraph contains at least one row, which corresponds
248 * to a screen line (that's why there are no rows in an unformatted
249 * paragraph
250 * - the paragraphs contain "shortcut" pointers to the previous and the next
251 * paragraph, that makes iteration over paragraphs faster
252 * - the list starts with diTextStart and ends with diTextEnd
255 typedef struct tagME_DisplayItem
257 ME_DIType type;
258 struct tagME_DisplayItem *prev, *next;
259 union {
260 ME_Run run;
261 ME_Row row;
262 ME_Cell cell;
263 ME_Paragraph para;
264 } member;
265 } ME_DisplayItem;
267 typedef struct tagME_TextBuffer
269 ME_DisplayItem *pFirst, *pLast;
270 ME_Style *pCharStyle;
271 ME_Style *pDefaultStyle;
272 } ME_TextBuffer;
274 typedef struct tagME_Cursor
276 ME_Paragraph *para;
277 ME_Run *run;
278 int nOffset;
279 } ME_Cursor;
281 typedef enum {
282 umAddToUndo,
283 umAddToRedo,
284 umIgnore,
285 umAddBackToUndo
286 } ME_UndoMode;
288 enum undo_type
290 undo_insert_run,
291 undo_delete_run,
292 undo_join_paras,
293 undo_split_para,
294 undo_set_para_fmt,
295 undo_set_char_fmt,
296 undo_end_transaction, /* marks the end of a group of changes for undo */
297 undo_potential_end_transaction /* allows grouping typed chars for undo */
300 struct insert_run_item
302 int pos, len;
303 WCHAR *str;
304 ME_Style *style;
305 DWORD flags;
308 struct delete_run_item
310 int pos, len;
313 struct join_paras_item
315 int pos;
318 struct split_para_item
320 int pos;
321 PARAFORMAT2 fmt;
322 ME_BorderRect border;
323 ME_String *eol_str;
324 DWORD flags;
325 ME_BorderRect cell_border;
326 int cell_right_boundary;
329 struct set_para_fmt_item
331 int pos;
332 PARAFORMAT2 fmt;
333 ME_BorderRect border;
336 struct set_char_fmt_item
338 int pos, len;
339 CHARFORMAT2W fmt;
342 struct undo_item
344 struct list entry;
345 enum undo_type type;
346 union
348 struct insert_run_item insert_run;
349 struct delete_run_item delete_run;
350 struct join_paras_item join_paras;
351 struct split_para_item split_para;
352 struct set_para_fmt_item set_para_fmt;
353 struct set_char_fmt_item set_char_fmt;
354 } u;
357 typedef enum {
358 stPosition = 0,
359 stWord,
360 stLine,
361 stParagraph,
362 stDocument
363 } ME_SelectionType;
365 typedef struct tagME_FontTableItem {
366 BYTE bCharSet;
367 WCHAR *szFaceName;
368 } ME_FontTableItem;
371 #define STREAMIN_BUFFER_SIZE 4096 /* M$ compatibility */
373 struct tagME_InStream {
374 EDITSTREAM *editstream;
375 DWORD dwSize;
376 DWORD dwUsed;
377 char buffer[STREAMIN_BUFFER_SIZE];
379 typedef struct tagME_InStream ME_InStream;
381 typedef struct tagME_TextEditor
383 ITextHost2 *texthost;
384 unsigned int bEmulateVersion10 : 1;
385 unsigned int in_place_active : 1;
386 unsigned int have_texthost2 : 1;
387 ME_TextBuffer *pBuffer;
388 ME_Cursor *pCursors;
389 DWORD props;
390 DWORD scrollbars;
391 int nCursors;
392 SIZE sizeWindow;
393 int nTotalLength, nLastTotalLength;
394 int nTotalWidth, nLastTotalWidth;
395 int nAvailWidth; /* 0 = wrap to client area, else wrap width in twips */
396 int nUDArrowX;
397 int total_rows;
398 int nEventMask;
399 int nModifyStep;
400 struct list undo_stack;
401 struct list redo_stack;
402 int nUndoStackSize;
403 int nUndoLimit;
404 ME_UndoMode nUndoMode;
405 int nParagraphs;
406 LONG nLastSelStart, nLastSelEnd;
407 ME_Paragraph *last_sel_start_para, *last_sel_end_para;
408 ME_FontCacheItem pFontCache[HFONT_CACHE_SIZE];
409 int nZoomNumerator, nZoomDenominator;
410 RECT rcFormat;
411 BOOL bWordWrap;
412 int nTextLimit;
413 EDITWORDBREAKPROCW pfnWordBreak;
414 IRichEditOle *richole;
415 LPRICHEDITOLECALLBACK lpOleCallback;
416 /*TEXTMODE variable; contains only one of each of the following options:
417 *TM_RICHTEXT or TM_PLAINTEXT
418 *TM_SINGLELEVELUNDO or TM_MULTILEVELUNDO
419 *TM_SINGLECODEPAGE or TM_MULTICODEPAGE*/
420 int mode;
421 BOOL bHideSelection;
422 BOOL AutoURLDetect_bEnable;
423 WCHAR password_char;
424 BOOL bHaveFocus;
425 /*for IME */
426 int imeStartIndex;
427 DWORD selofs; /* The size of the selection bar on the left side of control */
428 ME_SelectionType nSelectionType;
430 /* Track previous notified selection */
431 CHARRANGE notified_cr;
433 /* Cache previously set scrollbar info */
434 SCROLLINFO vert_si, horz_si;
435 unsigned int vert_sb_enabled : 1;
436 unsigned int horz_sb_enabled : 1;
438 int caret_height;
439 BOOL caret_hidden;
440 BOOL bMouseCaptured;
441 int wheel_remain;
442 TXTBACKSTYLE back_style;
443 struct list style_list;
444 struct list reobj_list;
445 struct wine_rb_tree marked_paras;
446 } ME_TextEditor;
448 typedef struct tagME_Context
450 HDC hDC;
451 POINT pt;
452 RECT rcView;
453 SIZE dpi;
454 int nAvailWidth;
455 ME_Style *current_style;
456 HFONT orig_font;
458 /* those are valid inside ME_WrapTextParagraph and related */
459 ME_TextEditor *editor;
460 } ME_Context;
462 struct text_selection
464 ITextSelection ITextSelection_iface;
465 LONG ref;
467 struct text_services *services;
470 struct text_services
472 IUnknown IUnknown_inner;
473 ITextServices ITextServices_iface;
474 IRichEditOle IRichEditOle_iface;
475 ITextDocument2Old ITextDocument2Old_iface;
476 IUnknown *outer_unk;
477 LONG ref;
478 ME_TextEditor *editor;
479 struct text_selection *text_selection;
480 struct list rangelist;
481 struct list clientsites;
482 char spare[256]; /* for bug #12179 */
485 #endif