mf/tests: Test AAC decoder MFT presence and media types.
[wine.git] / dlls / riched20 / editstr.h
blobdb219d7e4df6e8f2e5517572b68e31b5b1e07722
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 typedef enum {
289 undoActive,
290 undoSuspended,
291 undoDisabled
292 } ME_UndoControlState;
294 enum undo_type
296 undo_insert_run,
297 undo_delete_run,
298 undo_join_paras,
299 undo_split_para,
300 undo_set_para_fmt,
301 undo_set_char_fmt,
302 undo_end_transaction, /* marks the end of a group of changes for undo */
303 undo_potential_end_transaction /* allows grouping typed chars for undo */
306 struct insert_run_item
308 int pos, len;
309 WCHAR *str;
310 ME_Style *style;
311 DWORD flags;
314 struct delete_run_item
316 int pos, len;
319 struct join_paras_item
321 int pos;
324 struct split_para_item
326 int pos;
327 PARAFORMAT2 fmt;
328 ME_BorderRect border;
329 ME_String *eol_str;
330 DWORD flags;
331 ME_BorderRect cell_border;
332 int cell_right_boundary;
335 struct set_para_fmt_item
337 int pos;
338 PARAFORMAT2 fmt;
339 ME_BorderRect border;
342 struct set_char_fmt_item
344 int pos, len;
345 CHARFORMAT2W fmt;
348 struct undo_item
350 struct list entry;
351 enum undo_type type;
352 union
354 struct insert_run_item insert_run;
355 struct delete_run_item delete_run;
356 struct join_paras_item join_paras;
357 struct split_para_item split_para;
358 struct set_para_fmt_item set_para_fmt;
359 struct set_char_fmt_item set_char_fmt;
360 } u;
363 typedef enum {
364 stPosition = 0,
365 stWord,
366 stLine,
367 stParagraph,
368 stDocument
369 } ME_SelectionType;
371 typedef struct tagME_FontTableItem {
372 BYTE bCharSet;
373 WCHAR *szFaceName;
374 } ME_FontTableItem;
377 #define STREAMIN_BUFFER_SIZE 4096 /* M$ compatibility */
379 struct tagME_InStream {
380 EDITSTREAM *editstream;
381 DWORD dwSize;
382 DWORD dwUsed;
383 char buffer[STREAMIN_BUFFER_SIZE];
385 typedef struct tagME_InStream ME_InStream;
387 typedef struct tagME_TextEditor
389 ITextHost2 *texthost;
390 unsigned int bEmulateVersion10 : 1;
391 unsigned int in_place_active : 1;
392 unsigned int have_texthost2 : 1;
393 ME_TextBuffer *pBuffer;
394 ME_Cursor *pCursors;
395 DWORD props;
396 DWORD scrollbars;
397 int nCursors;
398 SIZE sizeWindow;
399 int nTotalLength, nLastTotalLength;
400 int nTotalWidth, nLastTotalWidth;
401 int nAvailWidth; /* 0 = wrap to client area, else wrap width in twips */
402 int nUDArrowX;
403 int total_rows;
404 int nEventMask;
405 int nModifyStep;
406 struct list undo_stack;
407 struct list redo_stack;
408 int nUndoStackSize;
409 int nUndoLimit;
410 ME_UndoMode nUndoMode;
411 ME_UndoControlState undo_ctl_state;
412 int nParagraphs;
413 LONG nLastSelStart, nLastSelEnd;
414 ME_Paragraph *last_sel_start_para, *last_sel_end_para;
415 ME_FontCacheItem pFontCache[HFONT_CACHE_SIZE];
416 int nZoomNumerator, nZoomDenominator;
417 RECT rcFormat;
418 BOOL bWordWrap;
419 int nTextLimit;
420 EDITWORDBREAKPROCW pfnWordBreak;
421 IRichEditOle *richole;
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;
428 BOOL bHideSelection;
429 BOOL AutoURLDetect_bEnable;
430 WCHAR password_char;
431 BOOL bHaveFocus;
432 /*for IME */
433 int imeStartIndex;
434 DWORD selofs; /* The size of the selection bar on the left side of control */
435 ME_SelectionType nSelectionType;
437 /* Track previous notified selection */
438 CHARRANGE notified_cr;
440 /* Cache previously set scrollbar info */
441 SCROLLINFO vert_si, horz_si;
442 unsigned int vert_sb_enabled : 1;
443 unsigned int horz_sb_enabled : 1;
445 int caret_height;
446 BOOL caret_hidden;
447 BOOL bMouseCaptured;
448 int wheel_remain;
449 TXTBACKSTYLE back_style;
450 struct list style_list;
451 struct list reobj_list;
452 struct wine_rb_tree marked_paras;
453 } ME_TextEditor;
455 typedef struct tagME_Context
457 HDC hDC;
458 POINT pt;
459 RECT rcView;
460 SIZE dpi;
461 int nAvailWidth;
462 ME_Style *current_style;
463 HFONT orig_font;
465 /* those are valid inside ME_WrapTextParagraph and related */
466 ME_TextEditor *editor;
467 } ME_Context;
469 struct text_selection
471 ITextSelection ITextSelection_iface;
472 LONG ref;
474 struct text_services *services;
477 struct text_services
479 IUnknown IUnknown_inner;
480 ITextServices ITextServices_iface;
481 IRichEditOle IRichEditOle_iface;
482 ITextDocument2Old ITextDocument2Old_iface;
483 IUnknown *outer_unk;
484 LONG ref;
485 ME_TextEditor *editor;
486 struct text_selection *text_selection;
487 struct list rangelist;
488 struct list clientsites;
489 char spare[256]; /* for bug #12179 */
492 #endif