TESTING -- override pthreads to fix gstreamer v5
[wine/multimedia.git] / dlls / riched20 / editstr.h
blobbe925db9dc387962f25e8d61435eee6a5fa4e768
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 #ifndef _WIN32_IE
25 #define _WIN32_IE 0x0400
26 #endif
28 #include <assert.h>
29 #include <stdarg.h>
30 #include <stdio.h>
31 #include <stdlib.h>
32 #include <limits.h>
34 #define COBJMACROS
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"
50 #include "wine/debug.h"
51 #include "wine/list.h"
53 #ifdef __i386__
54 extern const struct ITextHostVtbl itextHostStdcallVtbl DECLSPEC_HIDDEN;
55 #endif /* __i386__ */
57 typedef struct tagME_String
59 WCHAR *szData;
60 int nLen, nBuffer;
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 typedef struct tagME_Run
156 ME_Style *style;
157 struct tagME_Paragraph *para; /* ptr to the run's paragraph */
158 int nCharOfs; /* relative to para's offset */
159 int len; /* length of run's text */
160 int nWidth; /* width of full run, width of leading&trailing ws */
161 int nFlags;
162 int nAscent, nDescent; /* pixels above/below baseline */
163 POINT pt; /* relative to para's position */
164 REOBJECT *ole_obj; /* FIXME: should be a union with strText (at least) */
166 SCRIPT_ANALYSIS script_analysis;
167 int num_glyphs, max_glyphs;
168 WORD *glyphs;
169 SCRIPT_VISATTR *vis_attrs;
170 int *advances;
171 GOFFSET *offsets;
172 int max_clusters;
173 WORD *clusters;
174 } ME_Run;
176 typedef struct tagME_Border
178 int width;
179 COLORREF colorRef;
180 } ME_Border;
182 typedef struct tagME_BorderRect
184 ME_Border top;
185 ME_Border left;
186 ME_Border bottom;
187 ME_Border right;
188 } ME_BorderRect;
190 typedef struct tagME_Paragraph
192 PARAFORMAT2 *pFmt;
193 ME_String *text;
195 struct tagME_DisplayItem *pCell; /* v4.1 */
196 ME_BorderRect border;
198 int nCharOfs;
199 int nFlags;
200 POINT pt;
201 int nHeight, nWidth;
202 int nRows;
203 struct tagME_DisplayItem *prev_para, *next_para;
204 } ME_Paragraph;
206 typedef struct tagME_Cell /* v4.1 */
208 int nNestingLevel; /* 0 for normal cells, and greater for nested cells */
209 int nRightBoundary;
210 ME_BorderRect border;
211 POINT pt;
212 int nHeight, nWidth;
213 int yTextOffset; /* The text offset is caused by the largest top border. */
214 struct tagME_DisplayItem *prev_cell, *next_cell, *parent_cell;
215 } ME_Cell;
217 typedef struct tagME_Row
219 int nHeight;
220 int nBaseline;
221 int nWidth;
222 int nLMargin;
223 int nRMargin;
224 POINT pt;
225 } ME_Row;
227 /* the display item list layout is like this:
228 * - the document consists of paragraphs
229 * - each paragraph contains at least one run, the last run in the paragraph
230 * is an end-of-paragraph run
231 * - each formatted paragraph contains at least one row, which corresponds
232 * to a screen line (that's why there are no rows in an unformatted
233 * paragraph
234 * - the paragraphs contain "shortcut" pointers to the previous and the next
235 * paragraph, that makes iteration over paragraphs faster
236 * - the list starts with diTextStart and ends with diTextEnd
239 typedef struct tagME_DisplayItem
241 ME_DIType type;
242 struct tagME_DisplayItem *prev, *next;
243 union {
244 ME_Run run;
245 ME_Row row;
246 ME_Cell cell;
247 ME_Paragraph para;
248 } member;
249 } ME_DisplayItem;
251 typedef struct tagME_TextBuffer
253 ME_DisplayItem *pFirst, *pLast;
254 ME_Style *pCharStyle;
255 ME_Style *pDefaultStyle;
256 } ME_TextBuffer;
258 typedef struct tagME_Cursor
260 ME_DisplayItem *pPara;
261 ME_DisplayItem *pRun;
262 int nOffset;
263 } ME_Cursor;
265 typedef enum {
266 umAddToUndo,
267 umAddToRedo,
268 umIgnore,
269 umAddBackToUndo
270 } ME_UndoMode;
272 enum undo_type
274 undo_insert_run,
275 undo_delete_run,
276 undo_join_paras,
277 undo_split_para,
278 undo_set_para_fmt,
279 undo_set_char_fmt,
280 undo_end_transaction, /* marks the end of a group of changes for undo */
281 undo_potential_end_transaction /* allows grouping typed chars for undo */
284 struct insert_run_item
286 int pos, len;
287 WCHAR *str;
288 ME_Style *style;
289 DWORD flags;
292 struct delete_run_item
294 int pos, len;
297 struct join_paras_item
299 int pos;
302 struct split_para_item
304 int pos;
305 PARAFORMAT2 fmt;
306 ME_BorderRect border;
307 ME_String *eol_str;
308 DWORD flags;
309 ME_BorderRect cell_border;
310 int cell_right_boundary;
313 struct set_para_fmt_item
315 int pos;
316 PARAFORMAT2 fmt;
317 ME_BorderRect border;
320 struct set_char_fmt_item
322 int pos, len;
323 CHARFORMAT2W fmt;
326 struct undo_item
328 struct list entry;
329 enum undo_type type;
330 union
332 struct insert_run_item insert_run;
333 struct delete_run_item delete_run;
334 struct join_paras_item join_paras;
335 struct split_para_item split_para;
336 struct set_para_fmt_item set_para_fmt;
337 struct set_char_fmt_item set_char_fmt;
338 } u;
341 typedef enum {
342 stPosition = 0,
343 stWord,
344 stLine,
345 stParagraph,
346 stDocument
347 } ME_SelectionType;
349 typedef struct tagME_FontTableItem {
350 BYTE bCharSet;
351 WCHAR *szFaceName;
352 } ME_FontTableItem;
355 #define STREAMIN_BUFFER_SIZE 4096 /* M$ compatibility */
357 struct tagME_InStream {
358 EDITSTREAM *editstream;
359 DWORD dwSize;
360 DWORD dwUsed;
361 char buffer[STREAMIN_BUFFER_SIZE];
363 typedef struct tagME_InStream ME_InStream;
366 #define STREAMOUT_BUFFER_SIZE 4096
367 #define STREAMOUT_FONTTBL_SIZE 8192
368 #define STREAMOUT_COLORTBL_SIZE 1024
370 typedef struct tagME_OutStream {
371 EDITSTREAM *stream;
372 char buffer[STREAMOUT_BUFFER_SIZE];
373 UINT pos, written;
374 UINT nCodePage;
375 UINT nFontTblLen;
376 ME_FontTableItem fonttbl[STREAMOUT_FONTTBL_SIZE];
377 UINT nColorTblLen;
378 COLORREF colortbl[STREAMOUT_COLORTBL_SIZE];
379 UINT nDefaultFont;
380 UINT nDefaultCodePage;
381 /* nNestingLevel = 0 means we aren't in a cell, 1 means we are in a cell,
382 * an greater numbers mean we are in a cell nested within a cell. */
383 UINT nNestingLevel;
384 } ME_OutStream;
386 typedef struct tagME_TextEditor
388 HWND hWnd, hwndParent;
389 ITextHost *texthost;
390 IRichEditOle *reOle;
391 BOOL bEmulateVersion10;
392 ME_TextBuffer *pBuffer;
393 ME_Cursor *pCursors;
394 DWORD styleFlags;
395 DWORD alignStyle;
396 DWORD exStyleFlags;
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 COLORREF rgbBackColor;
404 HBRUSH hbrBackground;
405 BOOL bCaretAtEnd;
406 int nEventMask;
407 int nModifyStep;
408 struct list undo_stack;
409 struct list redo_stack;
410 int nUndoStackSize;
411 int nUndoLimit;
412 ME_UndoMode nUndoMode;
413 int nParagraphs;
414 int nLastSelStart, nLastSelEnd;
415 ME_DisplayItem *pLastSelStartPara, *pLastSelEndPara;
416 ME_FontCacheItem pFontCache[HFONT_CACHE_SIZE];
417 int nZoomNumerator, nZoomDenominator;
418 RECT prevClientRect;
419 RECT rcFormat;
420 BOOL bDefaultFormatRect;
421 BOOL bWordWrap;
422 int nTextLimit;
423 EDITWORDBREAKPROCW pfnWordBreak;
424 LPRICHEDITOLECALLBACK lpOleCallback;
425 /*TEXTMODE variable; contains only one of each of the following options:
426 *TM_RICHTEXT or TM_PLAINTEXT
427 *TM_SINGLELEVELUNDO or TM_MULTILEVELUNDO
428 *TM_SINGLECODEPAGE or TM_MULTICODEPAGE*/
429 int mode;
430 BOOL bHideSelection;
431 BOOL AutoURLDetect_bEnable;
432 WCHAR cPasswordMask;
433 BOOL bHaveFocus;
434 BOOL bDialogMode; /* Indicates that we are inside a dialog window */
435 /*for IME */
436 int imeStartIndex;
437 DWORD selofs; /* The size of the selection bar on the left side of control */
438 ME_SelectionType nSelectionType;
440 /* Track previous notified selection */
441 CHARRANGE notified_cr;
443 /* Cache previously set scrollbar info */
444 SCROLLINFO vert_si, horz_si;
446 BOOL bMouseCaptured;
447 int wheel_remain;
448 struct list style_list;
449 } ME_TextEditor;
451 typedef struct tagME_Context
453 HDC hDC;
454 POINT pt;
455 RECT rcView;
456 SIZE dpi;
457 int nAvailWidth;
459 /* those are valid inside ME_WrapTextParagraph and related */
460 ME_TextEditor *editor;
461 } ME_Context;
463 typedef struct tagME_WrapContext
465 ME_Style *style;
466 ME_Context *context;
467 int nLeftMargin, nRightMargin, nFirstMargin;
468 int nAvailWidth;
469 int nRow;
470 POINT pt;
471 BOOL bOverflown, bWordWrap;
472 ME_DisplayItem *pPara;
473 ME_DisplayItem *pRowStart;
475 ME_DisplayItem *pLastSplittableRun;
476 } ME_WrapContext;
478 #endif