d3d9/tests: Test for Direct3DCreate9 failure.
[wine/wine64.git] / dlls / riched20 / editstr.h
blob1e2c770fbbe74b9d2e6d2aea5baac78a59af59e9
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>
33 #define COBJMACROS
34 #define NONAMELESSUNION
35 #define NONAMELESSSTRUCT
37 #include <windef.h>
38 #include <winbase.h>
39 #include <winnls.h>
40 #include <winnt.h>
41 #include <wingdi.h>
42 #include <winuser.h>
43 #include <richedit.h>
44 #include <commctrl.h>
45 #include <ole2.h>
46 #include <richole.h>
48 #include "wine/debug.h"
50 typedef struct tagME_String
52 WCHAR *szData;
53 int nLen, nBuffer;
54 } ME_String;
56 typedef struct tagME_Style
58 CHARFORMAT2W fmt;
60 HFONT hFont; /* cached font for the style */
61 TEXTMETRICW tm; /* cached font metrics for the style */
62 int nRefs; /* reference count */
63 int nSequence; /* incremented when cache needs to be rebuilt, ie. every screen redraw */
64 } ME_Style;
66 typedef enum {
67 diInvalid,
68 diTextStart, /* start of the text buffer */
69 diParagraph, /* paragraph start */
70 diRun, /* run (sequence of chars with the same character format) */
71 diStartRow, /* start of the row (line of text on the screen) */
72 diTextEnd, /* end of the text buffer */
74 /********************* these below are meant for finding only *********************/
75 diStartRowOrParagraph, /* 5 */
76 diStartRowOrParagraphOrEnd,
77 diRunOrParagraph,
78 diRunOrStartRow,
79 diParagraphOrEnd,
80 diRunOrParagraphOrEnd, /* 10 */
82 diUndoInsertRun, /* 11 */
83 diUndoDeleteRun, /* 12 */
84 diUndoJoinParagraphs, /* 13 */
85 diUndoSplitParagraph, /* 14 */
86 diUndoSetParagraphFormat, /* 15 */
87 diUndoSetCharFormat, /* 16 */
88 diUndoEndTransaction, /* 17 */
89 diUndoSetDefaultCharFormat, /* 18 */
90 } ME_DIType;
92 /******************************** run flags *************************/
93 #define MERF_STYLEFLAGS 0x0FFF
94 /* run contains non-text content, which has its own rules for wrapping, sizing etc */
95 #define MERF_GRAPHICS 0x001
96 /* run is a tab (or, in future, any kind of content whose size is dependent on run position) */
97 #define MERF_TAB 0x002
98 /* run is a cell boundary */
99 #define MERF_CELL 0x004
101 #define MERF_NONTEXT (MERF_GRAPHICS | MERF_TAB | MERF_CELL)
103 /* run is splittable (contains white spaces in the middle or end) */
104 #define MERF_SPLITTABLE 0x001000
105 /* run starts with whitespaces */
106 #define MERF_STARTWHITE 0x002000
107 /* run ends with whitespaces */
108 #define MERF_ENDWHITE 0x004000
109 /* run is completely made of whitespaces */
110 #define MERF_WHITESPACE 0x008000
111 /* run is a last (dummy) run in the paragraph */
112 #define MERF_SKIPPED 0x010000
113 /* flags that are calculated during text wrapping */
114 #define MERF_CALCBYWRAP 0x0F0000
115 /* the "end of paragraph" run, contains 1 character */
116 #define MERF_ENDPARA 0x100000
117 /* forcing the "end of row" run, contains 1 character */
118 #define MERF_ENDROW 0x200000
119 /* run is hidden */
120 #define MERF_HIDDEN 0x400000
122 /* runs with any of these flags set cannot be joined */
123 #define MERF_NOJOIN (MERF_GRAPHICS|MERF_TAB|MERF_ENDPARA|MERF_ENDROW)
124 /* runs that don't contain real text */
125 #define MERF_NOTEXT (MERF_GRAPHICS|MERF_TAB|MERF_ENDPARA|MERF_ENDROW)
127 /* those flags are kept when the row is split */
128 #define MERF_SPLITMASK (~(0))
130 /******************************** para flags *************************/
132 /* this paragraph was already wrapped and hasn't changed, every change resets that flag */
133 #define MEPF_REWRAP 1
134 #define MEPF_REPAINT 2
136 /******************************** structures *************************/
138 struct tagME_DisplayItem;
140 typedef struct tagME_Run
142 ME_String *strText;
143 ME_Style *style;
144 int nCharOfs; /* relative to para's offset */
145 int nWidth; /* width of full run, width of leading&trailing ws */
146 int nFlags;
147 int nAscent, nDescent; /* pixels above/below baseline */
148 POINT pt; /* relative to para's position */
149 struct tagME_TableCell *pCell; /* for MERF_CELL: points to respective cell in ME_Paragraph */
150 REOBJECT *ole_obj; /* FIXME: should be a union with strText (at least) */
151 int nCR; int nLF; /* for MERF_ENDPARA: number of \r and \n characters encoded by run */
152 } ME_Run;
154 typedef struct tagME_Document {
155 struct tagME_DisplayItem *def_char_style;
156 struct tagME_DisplayItem *def_para_style;
157 int last_wrapped_line;
158 } ME_Document;
160 typedef struct tagME_TableCell
162 int nRightBoundary;
163 struct tagME_TableCell *next;
164 } ME_TableCell;
166 typedef struct tagME_Paragraph
168 PARAFORMAT2 *pFmt;
170 BOOL bTable; /* this paragraph is a table row */
171 struct tagME_TableCell *pCells; /* list of cells and their properties */
172 struct tagME_TableCell *pLastCell; /* points to the last cell in the list */
174 int nCharOfs;
175 int nFlags;
176 int nYPos, nHeight;
177 int nLastPaintYPos, nLastPaintHeight;
178 int nRows;
179 struct tagME_DisplayItem *prev_para, *next_para, *document;
180 } ME_Paragraph;
182 typedef struct tagME_Row
184 int nHeight;
185 int nBaseline;
186 int nWidth;
187 int nLMargin;
188 int nRMargin;
189 int nYPos;
190 } ME_Row;
192 /* the display item list layout is like this:
193 * - the document consists of paragraphs
194 * - each paragraph contains at least one run, the last run in the paragraph
195 * is an end-of-paragraph run
196 * - each formatted paragraph contains at least one row, which corresponds
197 * to a screen line (that's why there are no rows in an unformatted
198 * paragraph
199 * - the paragraphs contain "shortcut" pointers to the previous and the next
200 * paragraph, that makes iteration over paragraphs faster
201 * - the list starts with diTextStart and ends with diTextEnd
204 typedef struct tagME_DisplayItem
206 ME_DIType type;
207 struct tagME_DisplayItem *prev, *next;
208 union {
209 ME_Run run;
210 ME_Row row;
211 ME_Paragraph para;
212 ME_Document doc; /* not used */
213 ME_Style *ustyle; /* used by diUndoSetCharFormat */
214 } member;
215 } ME_DisplayItem;
217 typedef struct tagME_UndoItem
219 ME_DisplayItem di;
220 int nStart, nLen;
221 int nCR, nLF; /* used by diUndoSplitParagraph */
222 } ME_UndoItem;
224 typedef struct tagME_TextBuffer
226 ME_DisplayItem *pFirst, *pLast;
227 ME_Style *pCharStyle;
228 ME_Style *pDefaultStyle;
229 } ME_TextBuffer;
231 typedef struct tagME_Cursor
233 ME_DisplayItem *pRun;
234 int nOffset;
235 } ME_Cursor;
237 typedef enum {
238 umAddToUndo,
239 umAddToRedo,
240 umIgnore,
241 umAddBackToUndo
242 } ME_UndoMode;
244 typedef struct tagME_FontTableItem {
245 BYTE bCharSet;
246 WCHAR *szFaceName;
247 } ME_FontTableItem;
250 #define STREAMIN_BUFFER_SIZE 4096 /* M$ compatibility */
252 struct tagME_InStream {
253 EDITSTREAM *editstream;
254 DWORD dwSize;
255 DWORD dwUsed;
256 char buffer[STREAMIN_BUFFER_SIZE];
258 typedef struct tagME_InStream ME_InStream;
261 #define STREAMOUT_BUFFER_SIZE 4096
262 #define STREAMOUT_FONTTBL_SIZE 8192
263 #define STREAMOUT_COLORTBL_SIZE 1024
265 typedef struct tagME_OutStream {
266 EDITSTREAM *stream;
267 char buffer[STREAMOUT_BUFFER_SIZE];
268 UINT pos, written;
269 UINT nCodePage;
270 UINT nFontTblLen;
271 ME_FontTableItem fonttbl[STREAMOUT_FONTTBL_SIZE];
272 UINT nColorTblLen;
273 COLORREF colortbl[STREAMOUT_COLORTBL_SIZE];
274 UINT nDefaultFont;
275 UINT nDefaultCodePage;
276 } ME_OutStream;
278 typedef struct tagME_FontCacheItem
280 LOGFONTW lfSpecs;
281 HFONT hFont;
282 int nRefs;
283 int nAge;
284 } ME_FontCacheItem;
286 #define HFONT_CACHE_SIZE 10
288 typedef struct tagME_TextEditor
290 HWND hWnd;
291 BOOL bEmulateVersion10;
292 BOOL bCaretShown;
293 ME_TextBuffer *pBuffer;
294 ME_Cursor *pCursors;
295 int nCursors;
296 SIZE sizeWindow;
297 int nTotalLength, nLastTotalLength;
298 int nHeight;
299 int nUDArrowX;
300 int nSequence;
301 COLORREF rgbBackColor;
302 HBRUSH hbrBackground;
303 BOOL bCaretAtEnd;
304 int nEventMask;
305 int nModifyStep;
306 ME_DisplayItem *pUndoStack, *pRedoStack, *pUndoStackBottom;
307 int nUndoStackSize;
308 int nUndoLimit;
309 ME_UndoMode nUndoMode;
310 int nParagraphs;
311 int nLastSelStart, nLastSelEnd;
312 ME_DisplayItem *pLastSelStartPara, *pLastSelEndPara;
313 ME_FontCacheItem pFontCache[HFONT_CACHE_SIZE];
314 int nZoomNumerator, nZoomDenominator;
315 RECT rcFormat;
316 BOOL bRedraw;
317 BOOL bWordWrap;
318 int nInvalidOfs;
319 int nTextLimit;
320 EDITWORDBREAKPROCW pfnWordBreak;
321 LPRICHEDITOLECALLBACK lpOleCallback;
322 /*TEXTMODE variable; contains only one of each of the following options:
323 *TM_RICHTEXT or TM_PLAINTEXT
324 *TM_SINGLELEVELUNDO or TM_MULTILEVELUNDO
325 *TM_SINGLECODEPAGE or TM_MULTICODEPAGE*/
326 int mode;
327 BOOL bHideSelection;
328 BOOL AutoURLDetect_bEnable;
329 WCHAR cPasswordMask;
330 BOOL bHaveFocus;
331 /*for IME */
332 int imeStartIndex;
333 DWORD selofs, linesel, sely;
335 /* Track previous notified selection */
336 CHARRANGE notified_cr;
337 } ME_TextEditor;
339 typedef struct tagME_Context
341 HDC hDC;
342 POINT pt;
343 POINT ptRowOffset;
344 RECT rcView;
345 HBRUSH hbrMargin;
346 SIZE dpi;
348 /* those are valid inside ME_WrapTextParagraph and related */
349 POINT ptFirstRun;
350 ME_TextEditor *editor;
351 int nSequence;
352 } ME_Context;
354 typedef struct tagME_WrapContext
356 ME_Style *style;
357 ME_Context *context;
358 int nLeftMargin, nRightMargin, nFirstMargin;
359 int nAvailWidth;
360 int nRow;
361 POINT pt;
362 BOOL bOverflown;
363 ME_DisplayItem *pRowStart;
365 ME_DisplayItem *pLastSplittableRun;
366 POINT ptLastSplittableRun;
367 } ME_WrapContext;
369 #endif