comctl32/tests: Make test_combo_WS_VSCROLL() static.
[wine.git] / dlls / riched20 / editstr.h
blob2bf680ed64a2b4fc411124a114d36e8223446d64
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 void (*free)(struct tagME_String *);
62 } ME_String;
64 typedef struct tagME_FontCacheItem
66 LOGFONTW lfSpecs;
67 HFONT hFont;
68 int nRefs;
69 int nAge;
70 } ME_FontCacheItem;
72 #define HFONT_CACHE_SIZE 10
74 typedef struct tagME_Style
76 CHARFORMAT2W fmt;
78 ME_FontCacheItem *font_cache; /* cached font for the style */
79 TEXTMETRICW tm; /* cached font metrics for the style */
80 int nRefs; /* reference count */
81 SCRIPT_CACHE script_cache;
82 struct list entry;
83 } ME_Style;
85 typedef enum {
86 diInvalid,
87 diTextStart, /* start of the text buffer */
88 diParagraph, /* paragraph start */
89 diCell, /* cell start */
90 diRun, /* run (sequence of chars with the same character format) */
91 diStartRow, /* start of the row (line of text on the screen) */
92 diTextEnd, /* end of the text buffer */
94 /********************* these below are meant for finding only *********************/
95 diStartRowOrParagraph, /* 7 */
96 diStartRowOrParagraphOrEnd,
97 diRunOrParagraph,
98 diRunOrStartRow,
99 diParagraphOrEnd,
100 diRunOrParagraphOrEnd, /* 12 */
101 } ME_DIType;
103 #define SELECTIONBAR_WIDTH 8
105 /******************************** run flags *************************/
106 #define MERF_STYLEFLAGS 0x0FFF
107 /* run contains non-text content, which has its own rules for wrapping, sizing etc */
108 #define MERF_GRAPHICS 0x001
109 /* run is a tab (or, in future, any kind of content whose size is dependent on run position) */
110 #define MERF_TAB 0x002
111 /* run is a cell boundary */
112 #define MERF_ENDCELL 0x004 /* v4.1 */
114 #define MERF_NONTEXT (MERF_GRAPHICS | MERF_TAB | MERF_ENDCELL)
116 /* run is splittable (contains white spaces in the middle or end) */
117 #define MERF_SPLITTABLE 0x001000
118 /* run starts with whitespaces */
119 #define MERF_STARTWHITE 0x002000
120 /* run ends with whitespaces */
121 #define MERF_ENDWHITE 0x004000
122 /* run is completely made of whitespaces */
123 #define MERF_WHITESPACE 0x008000
124 /* the "end of paragraph" run, contains 1 character */
125 #define MERF_ENDPARA 0x100000
126 /* forcing the "end of row" run, contains 1 character */
127 #define MERF_ENDROW 0x200000
128 /* run is hidden */
129 #define MERF_HIDDEN 0x400000
130 /* start of a table row has an empty paragraph that should be skipped over. */
131 #define MERF_TABLESTART 0x800000 /* v4.1 */
133 /* runs with any of these flags set cannot be joined */
134 #define MERF_NOJOIN (MERF_GRAPHICS|MERF_TAB|MERF_ENDPARA|MERF_ENDROW)
135 /* runs that don't contain real text */
136 #define MERF_NOTEXT (MERF_GRAPHICS|MERF_TAB|MERF_ENDPARA|MERF_ENDROW)
138 /* those flags are kept when the row is split */
139 #define MERF_SPLITMASK (~(0))
141 /******************************** para flags *************************/
143 /* this paragraph was already wrapped and hasn't changed, every change resets that flag */
144 #define MEPF_REWRAP 0x01
145 /* v4.1 */
146 #define MEPF_CELL 0x04 /* The paragraph is nested in a cell */
147 #define MEPF_ROWSTART 0x08 /* Hidden empty paragraph at the start of the row */
148 #define MEPF_ROWEND 0x10 /* Visible empty paragraph at the end of the row */
149 #define MEPF_COMPLEX 0x20 /* Use uniscribe */
151 /******************************** structures *************************/
153 struct tagME_DisplayItem;
155 typedef struct tagME_Run
157 ME_Style *style;
158 struct tagME_Paragraph *para; /* ptr to the run's paragraph */
159 int nCharOfs; /* relative to para's offset */
160 int len; /* length of run's text */
161 int nWidth; /* width of full run, width of leading&trailing ws */
162 int nFlags;
163 int nAscent, nDescent; /* pixels above/below baseline */
164 POINT pt; /* relative to para's position */
165 REOBJECT *ole_obj; /* FIXME: should be a union with strText (at least) */
167 SCRIPT_ANALYSIS script_analysis;
168 int num_glyphs, max_glyphs;
169 WORD *glyphs;
170 SCRIPT_VISATTR *vis_attrs;
171 int *advances;
172 GOFFSET *offsets;
173 int max_clusters;
174 WORD *clusters;
175 } ME_Run;
177 typedef struct tagME_Border
179 int width;
180 COLORREF colorRef;
181 } ME_Border;
183 typedef struct tagME_BorderRect
185 ME_Border top;
186 ME_Border left;
187 ME_Border bottom;
188 ME_Border right;
189 } ME_BorderRect;
191 struct para_num
193 ME_Style *style;
194 ME_String *text;
195 INT width;
196 POINT pt;
199 typedef struct tagME_Paragraph
201 PARAFORMAT2 fmt;
202 ME_String *text;
204 struct tagME_DisplayItem *pCell; /* v4.1 */
205 ME_BorderRect border;
207 int nCharOfs;
208 int nFlags;
209 POINT pt;
210 int nHeight, nWidth;
211 int nRows;
212 struct para_num para_num;
213 ME_Run *eop_run; /* ptr to the end-of-para run */
214 struct tagME_DisplayItem *prev_para, *next_para;
215 } ME_Paragraph;
217 typedef struct tagME_Cell /* v4.1 */
219 int nNestingLevel; /* 0 for normal cells, and greater for nested cells */
220 int nRightBoundary;
221 ME_BorderRect border;
222 POINT pt;
223 int nHeight, nWidth;
224 int yTextOffset; /* The text offset is caused by the largest top border. */
225 struct tagME_DisplayItem *prev_cell, *next_cell, *parent_cell;
226 } ME_Cell;
228 typedef struct tagME_Row
230 int nHeight;
231 int nBaseline;
232 int nWidth;
233 int nLMargin;
234 int nRMargin;
235 POINT pt;
236 } ME_Row;
238 /* the display item list layout is like this:
239 * - the document consists of paragraphs
240 * - each paragraph contains at least one run, the last run in the paragraph
241 * is an end-of-paragraph run
242 * - each formatted paragraph contains at least one row, which corresponds
243 * to a screen line (that's why there are no rows in an unformatted
244 * paragraph
245 * - the paragraphs contain "shortcut" pointers to the previous and the next
246 * paragraph, that makes iteration over paragraphs faster
247 * - the list starts with diTextStart and ends with diTextEnd
250 typedef struct tagME_DisplayItem
252 ME_DIType type;
253 struct tagME_DisplayItem *prev, *next;
254 union {
255 ME_Run run;
256 ME_Row row;
257 ME_Cell cell;
258 ME_Paragraph para;
259 } member;
260 } ME_DisplayItem;
262 typedef struct tagME_TextBuffer
264 ME_DisplayItem *pFirst, *pLast;
265 ME_Style *pCharStyle;
266 ME_Style *pDefaultStyle;
267 } ME_TextBuffer;
269 typedef struct tagME_Cursor
271 ME_DisplayItem *pPara;
272 ME_DisplayItem *pRun;
273 int nOffset;
274 } ME_Cursor;
276 typedef enum {
277 umAddToUndo,
278 umAddToRedo,
279 umIgnore,
280 umAddBackToUndo
281 } ME_UndoMode;
283 enum undo_type
285 undo_insert_run,
286 undo_delete_run,
287 undo_join_paras,
288 undo_split_para,
289 undo_set_para_fmt,
290 undo_set_char_fmt,
291 undo_end_transaction, /* marks the end of a group of changes for undo */
292 undo_potential_end_transaction /* allows grouping typed chars for undo */
295 struct insert_run_item
297 int pos, len;
298 WCHAR *str;
299 ME_Style *style;
300 DWORD flags;
303 struct delete_run_item
305 int pos, len;
308 struct join_paras_item
310 int pos;
313 struct split_para_item
315 int pos;
316 PARAFORMAT2 fmt;
317 ME_BorderRect border;
318 ME_String *eol_str;
319 DWORD flags;
320 ME_BorderRect cell_border;
321 int cell_right_boundary;
324 struct set_para_fmt_item
326 int pos;
327 PARAFORMAT2 fmt;
328 ME_BorderRect border;
331 struct set_char_fmt_item
333 int pos, len;
334 CHARFORMAT2W fmt;
337 struct undo_item
339 struct list entry;
340 enum undo_type type;
341 union
343 struct insert_run_item insert_run;
344 struct delete_run_item delete_run;
345 struct join_paras_item join_paras;
346 struct split_para_item split_para;
347 struct set_para_fmt_item set_para_fmt;
348 struct set_char_fmt_item set_char_fmt;
349 } u;
352 typedef enum {
353 stPosition = 0,
354 stWord,
355 stLine,
356 stParagraph,
357 stDocument
358 } ME_SelectionType;
360 typedef struct tagME_FontTableItem {
361 BYTE bCharSet;
362 WCHAR *szFaceName;
363 } ME_FontTableItem;
366 #define STREAMIN_BUFFER_SIZE 4096 /* M$ compatibility */
368 struct tagME_InStream {
369 EDITSTREAM *editstream;
370 DWORD dwSize;
371 DWORD dwUsed;
372 char buffer[STREAMIN_BUFFER_SIZE];
374 typedef struct tagME_InStream ME_InStream;
376 typedef struct tagME_TextEditor
378 HWND hWnd, hwndParent;
379 ITextHost *texthost;
380 IRichEditOle *reOle;
381 BOOL bEmulateVersion10;
382 ME_TextBuffer *pBuffer;
383 ME_Cursor *pCursors;
384 DWORD styleFlags;
385 DWORD exStyleFlags;
386 int nCursors;
387 SIZE sizeWindow;
388 int nTotalLength, nLastTotalLength;
389 int nTotalWidth, nLastTotalWidth;
390 int nAvailWidth; /* 0 = wrap to client area, else wrap width in twips */
391 int nUDArrowX;
392 COLORREF rgbBackColor;
393 HBRUSH hbrBackground;
394 BOOL bCaretAtEnd;
395 int nEventMask;
396 int nModifyStep;
397 struct list undo_stack;
398 struct list redo_stack;
399 int nUndoStackSize;
400 int nUndoLimit;
401 ME_UndoMode nUndoMode;
402 int nParagraphs;
403 int nLastSelStart, nLastSelEnd;
404 ME_DisplayItem *pLastSelStartPara, *pLastSelEndPara;
405 ME_FontCacheItem pFontCache[HFONT_CACHE_SIZE];
406 int nZoomNumerator, nZoomDenominator;
407 RECT prevClientRect;
408 RECT rcFormat;
409 BOOL bDefaultFormatRect;
410 BOOL bWordWrap;
411 int nTextLimit;
412 EDITWORDBREAKPROCW pfnWordBreak;
413 LPRICHEDITOLECALLBACK lpOleCallback;
414 /*TEXTMODE variable; contains only one of each of the following options:
415 *TM_RICHTEXT or TM_PLAINTEXT
416 *TM_SINGLELEVELUNDO or TM_MULTILEVELUNDO
417 *TM_SINGLECODEPAGE or TM_MULTICODEPAGE*/
418 int mode;
419 BOOL bHideSelection;
420 BOOL AutoURLDetect_bEnable;
421 WCHAR cPasswordMask;
422 BOOL bHaveFocus;
423 BOOL bDialogMode; /* Indicates that we are inside a dialog window */
424 /*for IME */
425 int imeStartIndex;
426 DWORD selofs; /* The size of the selection bar on the left side of control */
427 ME_SelectionType nSelectionType;
429 /* Track previous notified selection */
430 CHARRANGE notified_cr;
432 /* Cache previously set scrollbar info */
433 SCROLLINFO vert_si, horz_si;
435 BOOL bMouseCaptured;
436 int wheel_remain;
437 struct list style_list;
438 } ME_TextEditor;
440 typedef struct tagME_Context
442 HDC hDC;
443 POINT pt;
444 RECT rcView;
445 SIZE dpi;
446 int nAvailWidth;
448 /* those are valid inside ME_WrapTextParagraph and related */
449 ME_TextEditor *editor;
450 } ME_Context;
452 #endif