ReactOS 0.4.17-dev-1421-g4623072
edit.c
Go to the documentation of this file.
1/*
2 * Edit control
3 *
4 * Copyright David W. Metcalfe, 1994
5 * Copyright William Magro, 1995, 1996
6 * Copyright Frans van Dorsselaer, 1996, 1997
7 *
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
13 *
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 *
23 * TODO:
24 * - EN_ALIGN_LTR_EC
25 * - EN_ALIGN_RTL_EC
26 * - ES_OEMCONVERT
27 *
28 */
29
30#include <user32.h>
31#define WIN32_LEAN_AND_MEAN
32#include <usp10.h>
33
34#ifdef __REACTOS__
35#include <immdev.h>
36#define ImmGetCompositionStringW IMM_FN(ImmGetCompositionStringW)
37#define ImmGetCompositionWindow IMM_FN(ImmGetCompositionWindow)
38#define ImmGetContext IMM_FN(ImmGetContext)
39#define ImmIsIME IMM_FN(ImmIsIME)
40#define ImmLockIMC IMM_FN(ImmLockIMC)
41#define ImmNotifyIME IMM_FN(ImmNotifyIME)
42#define ImmReleaseContext IMM_FN(ImmReleaseContext)
43#define ImmSetCompositionFontW IMM_FN(ImmSetCompositionFontW)
44#define ImmSetCompositionWindow IMM_FN(ImmSetCompositionWindow)
45#define ImmUnlockIMC IMM_FN(ImmUnlockIMC)
46#endif
47
51
52#define BUFLIMIT_INITIAL 30000 /* initial buffer size */
53#define GROWLENGTH 32 /* buffers granularity in bytes: must be power of 2 */
54#define ROUND_TO_GROW(size) (((size) + (GROWLENGTH - 1)) & ~(GROWLENGTH - 1))
55#define HSCROLL_FRACTION 3 /* scroll window by 1/3 width */
56
57/*
58 * extra flags for EDITSTATE.flags field
59 */
60#define EF_MODIFIED 0x0001 /* text has been modified */
61#define EF_FOCUSED 0x0002 /* we have input focus */
62#define EF_UPDATE 0x0004 /* notify parent of changed state */
63#define EF_VSCROLL_TRACK 0x0008 /* don't SetScrollPos() since we are tracking the thumb */
64#define EF_HSCROLL_TRACK 0x0010 /* don't SetScrollPos() since we are tracking the thumb */
65#define EF_AFTER_WRAP 0x0080 /* the caret is displayed after the last character of a
66 wrapped line, instead of in front of the next character */
67#define EF_USE_SOFTBRK 0x0100 /* Enable soft breaks in text. */
68#define EF_DIALOGMODE 0x0200 /* Indicates that we are inside a dialog window */
70typedef enum
72 END_0 = 0, /* line ends with terminating '\0' character */
73 END_WRAP, /* line is wrapped */
74 END_HARD, /* line ends with a hard return '\r\n' */
75 END_SOFT, /* line ends with a soft return '\r\r\n' */
76 END_RICH /* line ends with a single '\n' */
77} LINE_END;
78
79typedef struct tagLINEDEF {
80 INT length; /* bruto length of a line in bytes */
81 INT net_length; /* netto length of a line in visible characters */
83 INT width; /* width of the line in pixels */
84 INT index; /* line index into the buffer */
85 SCRIPT_STRING_ANALYSIS ssa; /* Uniscribe Data */
87} LINEDEF;
88
89typedef struct
91 BOOL is_unicode; /* how the control was created */
92 LPWSTR text; /* the actual contents of the control */
93 UINT text_length; /* cached length of text buffer (in WCHARs) - use get_text_length() to retrieve */
94 UINT buffer_size; /* the size of the buffer in characters */
95 UINT buffer_limit; /* the maximum size to which the buffer may grow in characters */
96 HFONT font; /* NULL means standard system font */
97 INT x_offset; /* scroll offset for multi lines this is in pixels
98 for single lines it's in characters */
99#ifdef __REACTOS__
100 DWORD dwCaretWidth;
101#endif
102 INT line_height; /* height of a screen line in pixels */
103 INT char_width; /* average character width in pixels */
104 DWORD style; /* sane version of wnd->dwStyle */
105 WORD flags; /* flags that are not in es->style or wnd->flags (EF_XXX) */
106 INT undo_insert_count; /* number of characters inserted in sequence */
107 UINT undo_position; /* character index of the insertion and deletion */
108 LPWSTR undo_text; /* deleted text */
109 UINT undo_buffer_size; /* size of the deleted text buffer */
110 INT selection_start; /* == selection_end if no selection */
111 INT selection_end; /* == current caret position */
112 WCHAR password_char; /* == 0 if no password char, and for multi line controls */
113 INT left_margin; /* in pixels */
114 INT right_margin; /* in pixels */
115 RECT format_rect;
116 INT text_width; /* width of the widest line in pixels for multi line controls
117 and just line width for single line controls */
118 void *word_break_proc; /* 32-bit word break proc: ANSI or Unicode */
119 INT line_count; /* number of lines */
120 INT y_offset; /* scroll offset in number of lines */
121 BOOL bCaptureState; /* flag indicating whether mouse was captured */
122 BOOL bEnableState; /* flag keeping the enable state */
123 HWND hwndSelf; /* the our window handle */
124 HWND hwndParent; /* Handle of parent for sending EN_* messages.
125 Even if parent will change, EN_* messages
126 should be sent to the first parent. */
127 HWND hwndListBox; /* handle of ComboBox's listbox or NULL */
128 INT wheelDeltaRemainder; /* scroll wheel delta left over after scrolling whole lines */
129 BYTE lead_byte; /* DBCS lead byte store for WM_CHAR */
130 /*
131 * only for multi line controls
132 */
133 INT lock_count; /* amount of re-entries in the EditWndProc */
134 INT tabs_count;
135 LPINT tabs;
136 LINEDEF *first_line_def; /* linked list of (soft) linebreaks */
137 HLOCAL hloc32W; /* our unicode local memory block */
138 HLOCAL hloc32A; /* alias for ANSI control receiving EM_GETHANDLE
139 or EM_SETHANDLE */
140 HLOCAL hlocapp; /* The text buffer handle belongs to the app */
141 /*
142 * IME Data
143 */
144 UINT ime_status; /* IME status flag */
145
146 /*
147 * Uniscribe Data
148 */
149 SCRIPT_LOGATTR *logAttr;
150 SCRIPT_STRING_ANALYSIS ssa; /* Uniscribe Data for single line controls */
151} EDITSTATE;
152
154#define SWAP_UINT32(x,y) do { UINT temp = (UINT)(x); (x) = (UINT)(y); (y) = temp; } while(0)
155#define ORDER_UINT(x,y) do { if ((UINT)(y) < (UINT)(x)) SWAP_UINT32((x),(y)); } while(0)
157static inline BOOL notify_parent(const EDITSTATE *es, INT code)
158{
159 HWND hwnd = es->hwndSelf;
160 TRACE("notification %d sent to %p.\n", code, es->hwndParent);
161 SendMessageW(es->hwndParent, WM_COMMAND, MAKEWPARAM(GetWindowLongPtrW(es->hwndSelf, GWLP_ID), code), (LPARAM)es->hwndSelf);
162 return IsWindow(hwnd);
163}
166{
167 return (EDITSTATE *)NtUserGetPrivateData( hwnd, 0, sizeof(EDITSTATE *) );
168}
171{
172 return (EDITSTATE *)NtUserSetPrivateData( hwnd, 0, sizeof(EDITSTATE *), (LONG_PTR)state );
173}
174
175static LRESULT EDIT_EM_PosFromChar(EDITSTATE *es, INT index, BOOL after_wrap);
176
177/*********************************************************************
178 *
179 * EM_CANUNDO
180 *
181 */
182static inline BOOL EDIT_EM_CanUndo(const EDITSTATE *es)
183{
184 return (es->undo_insert_count || lstrlenW(es->undo_text));
185}
186
187
188/*********************************************************************
189 *
190 * EM_EMPTYUNDOBUFFER
191 *
192 */
193static inline void EDIT_EM_EmptyUndoBuffer(EDITSTATE *es)
194{
195 es->undo_insert_count = 0;
196 *es->undo_text = '\0';
197}
198
199
200/**********************************************************************
201 * get_app_version
202 *
203 * Returns the window version in case Wine emulates a later version
204 * of windows than the application expects.
205 *
206 * In a number of cases when windows runs an application that was
207 * designed for an earlier windows version, windows reverts
208 * to "old" behaviour of that earlier version.
209 *
210 * An example is a disabled edit control that needs to be painted.
211 * Old style behaviour is to send a WM_CTLCOLOREDIT message. This was
212 * changed in Win95, NT4.0 by a WM_CTLCOLORSTATIC message _only_ for
213 * applications with an expected version 0f 4.0 or higher.
214 *
215 */
217{
218 static DWORD version;
219 if (!version)
220 {
221 DWORD dwEmulatedVersion;
223 DWORD dwProcVersion = GetProcessVersion(0);
224
225 info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW);
227 dwEmulatedVersion = MAKELONG( info.dwMinorVersion, info.dwMajorVersion );
228 /* FIXME: this may not be 100% correct; see discussion on the
229 * wine developer list in Nov 1999 */
230 version = dwProcVersion < dwEmulatedVersion ? dwProcVersion : dwEmulatedVersion;
231 }
232 return version;
233}
235static HBRUSH EDIT_NotifyCtlColor(EDITSTATE *es, HDC hdc)
236{
237 HBRUSH hbrush;
238 UINT msg;
239
240 if ( get_app_version() >= 0x40000 && (!es->bEnableState || (es->style & ES_READONLY)))
242 else
244
245 /* why do we notify to es->hwndParent, and we send this one to GetParent()? */
246#ifdef __REACTOS__
247 /* ReactOS r54259 */
248 hbrush = GetControlBrush(es->hwndSelf, hdc, msg);
249#else
250 hbrush = (HBRUSH)SendMessageW(GetParent(es->hwndSelf), msg, (WPARAM)hdc, (LPARAM)es->hwndSelf);
251 if (!hbrush)
252 hbrush = (HBRUSH)DefWindowProcW(GetParent(es->hwndSelf), msg, (WPARAM)hdc, (LPARAM)es->hwndSelf);
253#endif
254 return hbrush;
255}
256
258static inline UINT get_text_length(EDITSTATE *es)
259{
260 if(es->text_length == (UINT)-1)
261 es->text_length = lstrlenW(es->text);
262 return es->text_length;
263}
264
265
266/*********************************************************************
267 *
268 * EDIT_WordBreakProc
269 *
270 * Find the beginning of words.
271 * Note: unlike the specs for a WordBreakProc, this function can
272 * only be called without linebreaks between s[0] up to
273 * s[count - 1]. Remember it is only called
274 * internally, so we can decide this for ourselves.
275 * Additionally we will always be breaking the full string.
276 *
277 */
279{
280 INT ret = 0;
281
282 TRACE("s=%p, index=%d, count=%d, action=%d\n", s, index, count, action);
283
284 if(!s) return 0;
285
286 if (!es->logAttr)
287 {
288 SCRIPT_ANALYSIS psa;
289
290 memset(&psa,0,sizeof(SCRIPT_ANALYSIS));
292
293 es->logAttr = HeapAlloc(GetProcessHeap(), 0, sizeof(SCRIPT_LOGATTR) * get_text_length(es));
294 ScriptBreak(es->text, get_text_length(es), &psa, es->logAttr);
295 }
296
297 switch (action) {
298 case WB_LEFT:
299 if (index)
300 index--;
301 while (index && !es->logAttr[index].fSoftBreak)
302 index--;
303 ret = index;
304 break;
305 case WB_RIGHT:
306 if (!count)
307 break;
308 while (index < count && s[index] && !es->logAttr[index].fSoftBreak)
309 index++;
310 ret = index;
311 break;
312 case WB_ISDELIMITER:
313 ret = es->logAttr[index].fWhiteSpace;
314 break;
315 default:
316 ERR("unknown action code, please report !\n");
317 break;
318 }
319 return ret;
320}
321
322
323/*********************************************************************
324 *
325 * EDIT_CallWordBreakProc
326 *
327 * Call appropriate WordBreakProc (internal or external).
328 *
329 * Note: The "start" argument should always be an index referring
330 * to es->text. The actual wordbreak proc might be
331 * 16 bit, so we can't always pass any 32 bit LPSTR.
332 * Hence we assume that es->text is the buffer that holds
333 * the string under examination (we can decide this for ourselves).
334 *
335 */
337{
338 INT ret;
339
340 if (es->word_break_proc)
341 {
342 if(es->is_unicode)
343 {
344 EDITWORDBREAKPROCW wbpW = (EDITWORDBREAKPROCW)es->word_break_proc;
345
346 TRACE_(relay)("\1Call wordbreakW %p (str=%s,idx=%d,cnt=%d,act=%d)\n",
347 es->word_break_proc, debugstr_wn(es->text + start, count), index, count, action);
348 ret = wbpW(es->text + start, index, count, action);
349 TRACE_(relay)("\1Ret wordbreakW %p retval=%d\n", es->word_break_proc, ret );
350 }
351 else
352 {
353 EDITWORDBREAKPROCA wbpA = (EDITWORDBREAKPROCA)es->word_break_proc;
354 INT countA;
355 CHAR *textA;
356
357 countA = WideCharToMultiByte(CP_ACP, 0, es->text + start, count, NULL, 0, NULL, NULL);
358 textA = HeapAlloc(GetProcessHeap(), 0, countA);
359#ifdef __REACTOS__
360 /* ReactOS r33503 */
361 if (textA == NULL) return 0;
362#endif
363 WideCharToMultiByte(CP_ACP, 0, es->text + start, count, textA, countA, NULL, NULL);
364 TRACE_(relay)("\1Call wordbreakA %p(str=%s,idx=%d,cnt=%d,act=%d)\n",
365 es->word_break_proc, debugstr_an(textA, countA), index, countA, action);
366 ret = wbpA(textA, index, countA, action);
368 TRACE_(relay)("\1Ret wordbreakA %p retval=%d\n", es->word_break_proc, ret );
369 }
370 }
371 else
373
374 return ret;
375}
377static inline void EDIT_InvalidateUniscribeData_linedef(LINEDEF *line_def)
378{
379 if (line_def->ssa)
380 {
381 ScriptStringFree(&line_def->ssa);
382 line_def->ssa = NULL;
383 }
384}
386static inline void EDIT_InvalidateUniscribeData(EDITSTATE *es)
387{
388 LINEDEF *line_def = es->first_line_def;
389 while (line_def)
390 {
392 line_def = line_def->next;
393 }
394 if (es->ssa)
395 {
396 ScriptStringFree(&es->ssa);
397 es->ssa = NULL;
398 }
399}
402{
403 if (!line_def)
404 return NULL;
405
406 if (line_def->net_length && !line_def->ssa)
407 {
408 int index = line_def->index;
409 HFONT old_font = NULL;
410 HDC udc = dc;
411 SCRIPT_TABDEF tabdef;
412 HRESULT hr;
413
414 if (!udc)
415 udc = NtUserGetDC(es->hwndSelf);
416 if (es->font)
417 old_font = SelectObject(udc, es->font);
418
419 tabdef.cTabStops = es->tabs_count;
420 tabdef.iScale = GdiGetCharDimensions(udc, NULL, NULL);
421 tabdef.pTabStops = es->tabs;
422 tabdef.iTabOrigin = 0;
423
424 if (es->style & ES_PASSWORD)
425 hr = ScriptStringAnalyse(udc, &es->password_char, line_def->net_length,
426#ifdef __REACTOS__
427 /* ReactOS r57679 */
428 (3*line_def->net_length/2+16), -1,
429#else
430 (1.5*line_def->net_length+16), -1,
431#endif
433 NULL, NULL, NULL, &tabdef, NULL, &line_def->ssa);
434 else
435 hr = ScriptStringAnalyse(udc, &es->text[index], line_def->net_length,
436#ifdef __REACTOS__
437 /* ReactOS r57679 */
438 (3*line_def->net_length/2+16), -1,
439#else
440 (1.5*line_def->net_length+16), -1,
441#endif
443 NULL, NULL, NULL, &tabdef, NULL, &line_def->ssa);
444
445 if (FAILED(hr))
446 {
447 WARN("ScriptStringAnalyse failed (%lx)\n",hr);
448 line_def->ssa = NULL;
449 }
450
451 if (es->font)
452 SelectObject(udc, old_font);
453 if (udc != dc)
454 NtUserReleaseDC( es->hwndSelf, udc );
455 }
456
457 return line_def->ssa;
458}
461{
462 LINEDEF *line_def;
463
464 if (!(es->style & ES_MULTILINE))
465 {
466 if (!es->ssa)
467 {
469 HFONT old_font = NULL;
470 HDC udc = dc;
471
472 if (!udc)
473 udc = NtUserGetDC(es->hwndSelf);
474 if (es->font)
475 old_font = SelectObject(udc, es->font);
476
477 if (es->style & ES_PASSWORD)
478#ifdef __REACTOS__
479 /* ReactOS r57677 */
480 ScriptStringAnalyse(udc, &es->password_char, length, (3*length/2+16), -1, SSA_LINK|SSA_FALLBACK|SSA_GLYPHS|SSA_PASSWORD, -1, NULL, NULL, NULL, NULL, NULL, &es->ssa);
481#else
482 ScriptStringAnalyse(udc, &es->password_char, length, (1.5*length+16), -1, SSA_LINK|SSA_FALLBACK|SSA_GLYPHS|SSA_PASSWORD, -1, NULL, NULL, NULL, NULL, NULL, &es->ssa);
483#endif
484 else
485#ifdef __REACTOS__
486 /* ReactOS r57677 */
487 ScriptStringAnalyse(udc, es->text, length, (3*length/2+16), -1, SSA_LINK|SSA_FALLBACK|SSA_GLYPHS, -1, NULL, NULL, NULL, NULL, NULL, &es->ssa);
488#else
489 ScriptStringAnalyse(udc, es->text, length, (1.5*length+16), -1, SSA_LINK|SSA_FALLBACK|SSA_GLYPHS, -1, NULL, NULL, NULL, NULL, NULL, &es->ssa);
490#endif
491
492 if (es->font)
493 SelectObject(udc, old_font);
494 if (udc != dc)
495 NtUserReleaseDC( es->hwndSelf, udc );
496 }
497 return es->ssa;
498 }
499 else
500 {
501 line_def = es->first_line_def;
502 while (line_def && line)
503 {
504 line_def = line_def->next;
505 line--;
506 }
507
508 return EDIT_UpdateUniscribeData_linedef(es,dc,line_def);
509 }
510}
513{
514 INT vlc = es->line_height ? (es->format_rect.bottom - es->format_rect.top) / es->line_height : 0;
515 return max(1,vlc);
516}
517
518/*********************************************************************
519 *
520 * EDIT_BuildLineDefs_ML
521 *
522 * Build linked list of text lines.
523 * Lines can end with '\0' (last line), a character (if it is wrapped),
524 * a soft return '\r\r\n' or a hard return '\r\n'
525 *
526 */
527static void EDIT_BuildLineDefs_ML(EDITSTATE *es, INT istart, INT iend, INT delta, HRGN hrgn)
528{
529 LPWSTR current_position, cp;
530 INT fw;
531 LINEDEF *current_line;
532 LINEDEF *previous_line;
533 LINEDEF *start_line;
534 INT line_index = 0, nstart_line, nstart_index;
535 INT line_count = es->line_count;
536 INT orig_net_length;
537 RECT rc;
538 INT vlc;
539
540 if (istart == iend && delta == 0)
541 return;
542
543 previous_line = NULL;
544 current_line = es->first_line_def;
545
546 /* Find starting line. istart must lie inside an existing line or
547 * at the end of buffer */
548 do {
549 if (istart < current_line->index + current_line->length ||
550 current_line->ending == END_0)
551 break;
552
553 previous_line = current_line;
554 current_line = current_line->next;
555 line_index++;
556 } while (current_line);
557
558 if (!current_line) /* Error occurred start is not inside previous buffer */
559 {
560 FIXME(" modification occurred outside buffer\n");
561 return;
562 }
563
564 /* Remember start of modifications in order to calculate update region */
565 nstart_line = line_index;
566 nstart_index = current_line->index;
567
568 /* We must start to reformat from the previous line since the modifications
569 * may have caused the line to wrap upwards. */
570 if (!(es->style & ES_AUTOHSCROLL) && line_index > 0)
571 {
572 line_index--;
573 current_line = previous_line;
574 }
575 start_line = current_line;
576
577 fw = es->format_rect.right - es->format_rect.left;
578 current_position = es->text + current_line->index;
580 do {
581 if (current_line != start_line)
582 {
583 if (!current_line || current_line->index + delta > current_position - es->text)
584 {
585 /* The buffer has been expanded, create a new line and
586 insert it into the link list */
588#ifdef __REACTOS__
589 /* ReactOS r33503 */
590 if (new_line == NULL)
591 break;
592#endif
593 new_line->next = previous_line->next;
594 previous_line->next = new_line;
595 current_line = new_line;
596 es->line_count++;
597 }
598 else if (current_line->index + delta < current_position - es->text)
599 {
600 /* The previous line merged with this line so we delete this extra entry */
601 previous_line->next = current_line->next;
602 HeapFree(GetProcessHeap(), 0, current_line);
603 current_line = previous_line->next;
604 es->line_count--;
605 continue;
606 }
607 else /* current_line->index + delta == current_position */
608 {
609 if (current_position - es->text > iend)
610 break; /* We reached end of line modifications */
611 /* else recalculate this line */
612 }
613 }
614
615 current_line->index = current_position - es->text;
616 orig_net_length = current_line->net_length;
617
618 /* Find end of line */
619 cp = current_position;
620 while (*cp) {
621 if (*cp == '\n') break;
622 if ((*cp == '\r') && (*(cp + 1) == '\n'))
623 break;
624 cp++;
625 }
626
627 /* Mark type of line termination */
628 if (!(*cp)) {
629 current_line->ending = END_0;
630 current_line->net_length = lstrlenW(current_position);
631 } else if ((cp > current_position) && (*(cp - 1) == '\r')) {
632 current_line->ending = END_SOFT;
633 current_line->net_length = cp - current_position - 1;
634 } else if (*cp == '\n') {
635 current_line->ending = END_RICH;
636 current_line->net_length = cp - current_position;
637 } else {
638 current_line->ending = END_HARD;
639 current_line->net_length = cp - current_position;
640 }
641
642 if (current_line->net_length)
643 {
644 const SIZE *sz;
647 if (current_line->ssa)
648 {
649 sz = ScriptString_pSize(current_line->ssa);
650 /* Calculate line width */
651 current_line->width = sz->cx;
652 }
653 else current_line->width = es->char_width * current_line->net_length;
654 }
655 else current_line->width = 0;
656
657 /* FIXME: check here for lines that are too wide even in AUTOHSCROLL (> 32767 ???) */
658
659/* Line breaks just look back from the end and find the next break and try that. */
660
661 if (!(es->style & ES_AUTOHSCROLL)) {
662 if (current_line->width > fw && fw > es->char_width) {
663
664 INT prev, next;
665 int w;
666 const SIZE *sz;
667 float d;
668
669 prev = current_line->net_length - 1;
670 w = current_line->net_length;
671 d = (float)current_line->width/(float)fw;
672 if (d > 1.2f) d -= 0.2f;
673 next = prev/d;
674 if (next >= prev) next = prev-1;
675 do {
676 prev = EDIT_CallWordBreakProc(es, current_position - es->text,
677 next, current_line->net_length, WB_LEFT);
678 current_line->net_length = prev;
681 if (current_line->ssa)
682 sz = ScriptString_pSize(current_line->ssa);
683 else sz = 0;
684 if (sz)
685 current_line->width = sz->cx;
686 else
687 prev = 0;
688 next = prev - 1;
689 } while (prev && current_line->width > fw);
690 current_line->net_length = w;
691
692 if (prev == 0) { /* Didn't find a line break so force a break */
693 INT *piDx;
694 const INT *count;
695
698
699 if (current_line->ssa)
700 {
701 count = ScriptString_pcOutChars(current_line->ssa);
702 piDx = HeapAlloc(GetProcessHeap(),0,sizeof(INT) * (*count));
703 ScriptStringGetLogicalWidths(current_line->ssa,piDx);
704
705 prev = current_line->net_length-1;
706 do {
707 current_line->width -= piDx[prev];
708 prev--;
709 } while ( prev > 0 && current_line->width > fw);
710 if (prev<=0)
711 prev = 1;
712 HeapFree(GetProcessHeap(),0,piDx);
713 }
714 else
715 prev = (fw / es->char_width);
716 }
717
718 /* If the first line we are calculating, wrapped before istart, we must
719 * adjust istart in order for this to be reflected in the update region. */
720 if (current_line->index == nstart_index && istart > current_line->index + prev)
721 istart = current_line->index + prev;
722 /* else if we are updating the previous line before the first line we
723 * are re-calculating and it expanded */
724 else if (current_line == start_line &&
725 current_line->index != nstart_index && orig_net_length < prev)
726 {
727 /* Line expanded due to an upwards line wrap so we must partially include
728 * previous line in update region */
729 nstart_line = line_index;
730 nstart_index = current_line->index;
731 istart = current_line->index + orig_net_length;
732 }
733
734 current_line->net_length = prev;
735 current_line->ending = END_WRAP;
736
737 if (current_line->net_length > 0)
738 {
740 if (current_line->ssa)
741 {
742 sz = ScriptString_pSize(current_line->ssa);
743 current_line->width = sz->cx;
744 }
745 else
746 current_line->width = 0;
747 }
748 else current_line->width = 0;
749 }
750 else if (current_line == start_line &&
751 current_line->index != nstart_index &&
752 orig_net_length < current_line->net_length) {
753 /* The previous line expanded but it's still not as wide as the client rect */
754 /* The expansion is due to an upwards line wrap so we must partially include
755 it in the update region */
756 nstart_line = line_index;
757 nstart_index = current_line->index;
758 istart = current_line->index + orig_net_length;
759 }
760 }
761
762
763 /* Adjust length to include line termination */
764 switch (current_line->ending) {
765 case END_SOFT:
766 current_line->length = current_line->net_length + 3;
767 break;
768 case END_RICH:
769 current_line->length = current_line->net_length + 1;
770 break;
771 case END_HARD:
772 current_line->length = current_line->net_length + 2;
773 break;
774 case END_WRAP:
775 case END_0:
776 current_line->length = current_line->net_length;
777 break;
778 }
779 es->text_width = max(es->text_width, current_line->width);
780 current_position += current_line->length;
781 previous_line = current_line;
782
783 /* Discard data for non-visible lines. It will be calculated as needed */
784 if ((line_index < es->y_offset) || (line_index > es->y_offset + vlc))
786
787 current_line = current_line->next;
788 line_index++;
789 } while (previous_line->ending != END_0);
790
791 /* Finish adjusting line indexes by delta or remove hanging lines */
792 if (previous_line->ending == END_0)
793 {
794 LINEDEF *pnext = NULL;
795
796 previous_line->next = NULL;
797 while (current_line)
798 {
799 pnext = current_line->next;
801 HeapFree(GetProcessHeap(), 0, current_line);
802 current_line = pnext;
803 es->line_count--;
804 }
805 }
806 else if (delta != 0)
807 {
808 while (current_line)
809 {
810 current_line->index += delta;
811 current_line = current_line->next;
812 }
813 }
814
815 /* Calculate rest of modification rectangle */
816 if (hrgn)
817 {
818 HRGN tmphrgn;
819 /*
820 * We calculate two rectangles. One for the first line which may have
821 * an indent with respect to the format rect. The other is a format-width
822 * rectangle that spans the rest of the lines that changed or moved.
823 */
824 rc.top = es->format_rect.top + nstart_line * es->line_height -
825 (es->y_offset * es->line_height); /* Adjust for vertical scrollbar */
826 rc.bottom = rc.top + es->line_height;
827 if ((es->style & ES_CENTER) || (es->style & ES_RIGHT))
828 rc.left = es->format_rect.left;
829 else
830#ifdef __REACTOS__ /* CORE-11475 */
831 rc.left = (short)LOWORD(EDIT_EM_PosFromChar(es, nstart_index, FALSE));
832#else
833 rc.left = LOWORD(EDIT_EM_PosFromChar(es, nstart_index, FALSE));
834#endif
835 rc.right = es->format_rect.right;
836 SetRectRgn(hrgn, rc.left, rc.top, rc.right, rc.bottom);
837
838 rc.top = rc.bottom;
839 rc.left = es->format_rect.left;
840 rc.right = es->format_rect.right;
841 /*
842 * If lines were added or removed we must re-paint the remainder of the
843 * lines since the remaining lines were either shifted up or down.
844 */
845 if (line_count < es->line_count) /* We added lines */
846 rc.bottom = es->line_count * es->line_height;
847 else if (line_count > es->line_count) /* We removed lines */
848 rc.bottom = line_count * es->line_height;
849 else
850 rc.bottom = line_index * es->line_height;
851 rc.bottom += es->format_rect.top;
852 rc.bottom -= (es->y_offset * es->line_height); /* Adjust for vertical scrollbar */
853 tmphrgn = CreateRectRgn(rc.left, rc.top, rc.right, rc.bottom);
854 CombineRgn(hrgn, hrgn, tmphrgn, RGN_OR);
855 DeleteObject(tmphrgn);
856 }
857}
858
859/*********************************************************************
860 *
861 * EDIT_CalcLineWidth_SL
862 *
863 */
865{
867 if (es->ssa)
868 {
869 const SIZE *size;
870 size = ScriptString_pSize(es->ssa);
871 es->text_width = size->cx;
872 }
873 else
874 es->text_width = 0;
875}
876
877/*********************************************************************
878 *
879 * EDIT_CharFromPos
880 *
881 * Beware: This is not the function called on EM_CHARFROMPOS
882 * The position _can_ be outside the formatting / client
883 * rectangle
884 * The return value is only the character index
885 *
886 */
887static INT EDIT_CharFromPos(EDITSTATE *es, INT x, INT y, LPBOOL after_wrap)
888{
889 INT index;
890
891 if (es->style & ES_MULTILINE) {
892 int trailing;
893 INT line = (y - es->format_rect.top) / es->line_height + es->y_offset;
894 INT line_index = 0;
895 LINEDEF *line_def = es->first_line_def;
897 while ((line > 0) && line_def->next) {
898 line_index += line_def->length;
899 line_def = line_def->next;
900 line--;
901 }
902
903 x += es->x_offset - es->format_rect.left;
904 if (es->style & ES_RIGHT)
905 x -= (es->format_rect.right - es->format_rect.left) - line_def->width;
906 else if (es->style & ES_CENTER)
907 x -= ((es->format_rect.right - es->format_rect.left) - line_def->width) / 2;
908 if (x >= line_def->width) {
909 if (after_wrap)
910 *after_wrap = (line_def->ending == END_WRAP);
911 return line_index + line_def->net_length;
912 }
913 if (x <= 0 || !line_def->ssa) {
914 if (after_wrap)
915 *after_wrap = FALSE;
916 return line_index;
917 }
918
919 ScriptStringXtoCP(line_def->ssa, x , &index, &trailing);
920 if (trailing) index++;
921 index += line_index;
922 if (after_wrap)
923 *after_wrap = ((index == line_index + line_def->net_length) &&
924 (line_def->ending == END_WRAP));
925 } else {
926 INT xoff = 0;
928 if (after_wrap)
929 *after_wrap = FALSE;
930 x -= es->format_rect.left;
931 if (!x)
932 return es->x_offset;
933
934 if (!es->x_offset)
935 {
936 INT indent = (es->format_rect.right - es->format_rect.left) - es->text_width;
937 if (es->style & ES_RIGHT)
938 x -= indent;
939 else if (es->style & ES_CENTER)
940 x -= indent / 2;
941 }
942
944 if (es->x_offset)
945 {
946 if (es->ssa)
947 {
948 if (es->x_offset>= get_text_length(es))
949 {
950 const SIZE *size;
951 size = ScriptString_pSize(es->ssa);
952 xoff = size->cx;
953 }
954 ScriptStringCPtoX(es->ssa, es->x_offset, FALSE, &xoff);
955 }
956 else
957 xoff = 0;
958 }
959 if (x < 0)
960 {
961 if (x + xoff > 0 || !es->ssa)
962 {
963 ScriptStringXtoCP(es->ssa, x+xoff, &index, &trailing);
964 if (trailing) index++;
965 }
966 else
967 index = 0;
968 }
969 else
970 {
971 if (x)
972 {
973 const SIZE *size = NULL;
974 if (es->ssa)
975 size = ScriptString_pSize(es->ssa);
976 if (!size)
977 index = 0;
978 else if (x > size->cx)
980 else if (es->ssa)
981 {
982 ScriptStringXtoCP(es->ssa, x+xoff, &index, &trailing);
983 if (trailing) index++;
984 }
985 else
986 index = 0;
987 }
988 else
989 index = es->x_offset;
990 }
991 }
992 return index;
993}
994
995
996/*********************************************************************
997 *
998 * EDIT_ConfinePoint
999 *
1000 * adjusts the point to be within the formatting rectangle
1001 * (so CharFromPos returns the nearest _visible_ character)
1002 *
1004static void EDIT_ConfinePoint(const EDITSTATE *es, LPINT x, LPINT y)
1005{
1006 *x = min(max(*x, es->format_rect.left), es->format_rect.right - 1);
1007 *y = min(max(*y, es->format_rect.top), es->format_rect.bottom - 1);
1008}
1009
1010
1011/*********************************************************************
1012 *
1013 * EM_LINEFROMCHAR
1014 *
1017{
1018 INT line;
1019 LINEDEF *line_def;
1020
1021 if (!(es->style & ES_MULTILINE))
1022 return 0;
1023 if (index > (INT)get_text_length(es))
1024 return es->line_count - 1;
1025 if (index == -1)
1026 index = min(es->selection_start, es->selection_end);
1027
1028 line = 0;
1029 line_def = es->first_line_def;
1030 index -= line_def->length;
1031 while ((index >= 0) && line_def->next) {
1032 line++;
1033 line_def = line_def->next;
1034 index -= line_def->length;
1035 }
1036 return line;
1037}
1038
1039
1040/*********************************************************************
1041 *
1042 * EM_LINEINDEX
1043 *
1045static INT EDIT_EM_LineIndex(const EDITSTATE *es, INT line)
1046{
1047 INT line_index;
1048 const LINEDEF *line_def;
1049
1050 if (!(es->style & ES_MULTILINE))
1051 return 0;
1052 if (line >= es->line_count)
1053 return -1;
1054
1055 line_index = 0;
1056 line_def = es->first_line_def;
1057 if (line == -1) {
1058 INT index = es->selection_end - line_def->length;
1059 while ((index >= 0) && line_def->next) {
1060 line_index += line_def->length;
1061 line_def = line_def->next;
1062 index -= line_def->length;
1063 }
1064 } else {
1065 while (line > 0) {
1066 line_index += line_def->length;
1067 line_def = line_def->next;
1068 line--;
1069 }
1070 }
1071 return line_index;
1072}
1073
1074
1075/*********************************************************************
1076 *
1077 * EM_LINELENGTH
1078 *
1081{
1082 LINEDEF *line_def;
1083
1084 if (!(es->style & ES_MULTILINE))
1085 return get_text_length(es);
1086
1087 if (index == -1) {
1088 /* get the number of remaining non-selected chars of selected lines */
1089 INT32 l; /* line number */
1090 INT32 li; /* index of first char in line */
1091 INT32 count;
1092 l = EDIT_EM_LineFromChar(es, es->selection_start);
1093 /* # chars before start of selection area */
1094 count = es->selection_start - EDIT_EM_LineIndex(es, l);
1095 l = EDIT_EM_LineFromChar(es, es->selection_end);
1096 /* # chars after end of selection */
1098 count += li + EDIT_EM_LineLength(es, li) - es->selection_end;
1099 return count;
1100 }
1101 line_def = es->first_line_def;
1102 index -= line_def->length;
1103 while ((index >= 0) && line_def->next) {
1104 line_def = line_def->next;
1105 index -= line_def->length;
1106 }
1107 return line_def->net_length;
1108}
1109
1110
1111/*********************************************************************
1112 *
1113 * EM_POSFROMCHAR
1114 *
1116static LRESULT EDIT_EM_PosFromChar(EDITSTATE *es, INT index, BOOL after_wrap)
1117{
1119 INT l;
1120 INT li;
1121 INT x = 0;
1122 INT y = 0;
1123 INT w;
1124 INT lw;
1125 LINEDEF *line_def;
1126
1127 index = min(index, len);
1128 if (es->style & ES_MULTILINE) {
1131
1132 y = (l - es->y_offset) * es->line_height;
1134 if (after_wrap && (li == index) && l) {
1135 INT l2 = l - 1;
1136 line_def = es->first_line_def;
1137 while (l2) {
1138 line_def = line_def->next;
1139 l2--;
1140 }
1141 if (line_def->ending == END_WRAP) {
1142 l--;
1143 y -= es->line_height;
1145 }
1146 }
1147
1148 line_def = es->first_line_def;
1149 while (line_def->index != li)
1150 line_def = line_def->next;
1151
1152 lw = line_def->width;
1153 w = es->format_rect.right - es->format_rect.left;
1154 if (line_def->ssa)
1155 ScriptStringCPtoX(line_def->ssa, (index - 1) - li, TRUE, &x);
1156 x -= es->x_offset;
1157
1158 if (es->style & ES_RIGHT)
1159 x = w - (lw - x);
1160 else if (es->style & ES_CENTER)
1161 x += (w - lw) / 2;
1162 } else {
1163 INT xoff = 0;
1164 INT xi = 0;
1166 if (es->x_offset)
1167 {
1168 if (es->ssa)
1169 {
1170 if (es->x_offset >= get_text_length(es))
1171 {
1172 int leftover = es->x_offset - get_text_length(es);
1173 if (es->ssa)
1174 {
1175 const SIZE *size;
1176 size = ScriptString_pSize(es->ssa);
1177 xoff = size->cx;
1178 }
1179 else
1180 xoff = 0;
1181 xoff += es->char_width * leftover;
1182 }
1183 else
1184 ScriptStringCPtoX(es->ssa, es->x_offset, FALSE, &xoff);
1185 }
1186 else
1187 xoff = 0;
1188 }
1189 if (index)
1190 {
1191 if (index >= get_text_length(es))
1192 {
1193 if (es->ssa)
1194 {
1195 const SIZE *size;
1196 size = ScriptString_pSize(es->ssa);
1197 xi = size->cx;
1198 }
1199 else
1200 xi = 0;
1201 }
1202 else if (es->ssa)
1203 ScriptStringCPtoX(es->ssa, index, FALSE, &xi);
1204 else
1205 xi = 0;
1206 }
1207 x = xi - xoff;
1208
1209 if (index >= es->x_offset) {
1210 if (!es->x_offset && (es->style & (ES_RIGHT | ES_CENTER)))
1211 {
1212 w = es->format_rect.right - es->format_rect.left;
1213 if (w > es->text_width)
1214 {
1215 if (es->style & ES_RIGHT)
1216 x += w - es->text_width;
1217 else if (es->style & ES_CENTER)
1218 x += (w - es->text_width) / 2;
1219 }
1220 }
1221 }
1222 y = 0;
1223 }
1224 x += es->format_rect.left;
1225 y += es->format_rect.top;
1226 return MAKELONG((INT16)x, (INT16)y);
1227}
1228
1229
1230/*********************************************************************
1231 *
1232 * EDIT_GetLineRect
1233 *
1234 * Calculates the bounding rectangle for a line from a starting
1235 * column to an ending column.
1236 *
1238static void EDIT_GetLineRect(EDITSTATE *es, INT line, INT scol, INT ecol, LPRECT rc)
1239{
1241 INT line_index = 0;
1242 INT pt1, pt2, pt3;
1243
1244 if (es->style & ES_MULTILINE)
1245 {
1246 const LINEDEF *line_def = NULL;
1247 rc->top = es->format_rect.top + (line - es->y_offset) * es->line_height;
1248 if (line >= es->line_count)
1249 return;
1250
1251 line_def = es->first_line_def;
1252 if (line == -1) {
1253 INT index = es->selection_end - line_def->length;
1254 while ((index >= 0) && line_def->next) {
1255 line_index += line_def->length;
1256 line_def = line_def->next;
1257 index -= line_def->length;
1258 }
1259 } else {
1260 while (line > 0) {
1261 line_index += line_def->length;
1262 line_def = line_def->next;
1263 line--;
1264 }
1265 }
1266 ssa = line_def->ssa;
1267 }
1268 else
1269 {
1270 line_index = 0;
1271 rc->top = es->format_rect.top;
1272 ssa = es->ssa;
1273 }
1274
1275 rc->bottom = rc->top + es->line_height;
1276 pt1 = (scol == 0) ? es->format_rect.left : (short)LOWORD(EDIT_EM_PosFromChar(es, line_index + scol, TRUE));
1277 pt2 = (ecol == -1) ? es->format_rect.right : (short)LOWORD(EDIT_EM_PosFromChar(es, line_index + ecol, TRUE));
1278 if (ssa)
1279 {
1280 ScriptStringCPtoX(ssa, scol, FALSE, &pt3);
1281 pt3+=es->format_rect.left;
1282 }
1283 else pt3 = pt1;
1284 rc->right = max(max(pt1 , pt2),pt3);
1285 rc->left = min(min(pt1, pt2),pt3);
1286}
1287
1289static inline void text_buffer_changed(EDITSTATE *es)
1290{
1291 es->text_length = (UINT)-1;
1292
1293 HeapFree( GetProcessHeap(), 0, es->logAttr );
1294 es->logAttr = NULL;
1296}
1297
1298/*********************************************************************
1299 * EDIT_LockBuffer
1300 *
1302static void EDIT_LockBuffer(EDITSTATE *es)
1303{
1304 if (!es->text) {
1305
1306#ifdef __REACTOS__
1307/* FIXME: What is this ? */
1308 CHAR *textA = NULL; // ReactOS Hacked! r45670
1309 //UINT countA = 0;
1310
1311 if(es->hloc32W)
1312 {
1313 if(es->hloc32A)
1314 {
1315 TRACE("Synchronizing with 32-bit ANSI buffer\n");
1316 textA = LocalLock(es->hloc32A);
1317 //countA = strlen(textA) + 1;
1318 }
1319 }
1320 else {
1321 ERR("no buffer ... please report\n");
1322 return;
1323 }
1324
1325 if (textA)
1326 {
1327#else
1328 if(!es->hloc32W) return;
1329
1330 if(es->hloc32A)
1331 {
1332 CHAR *textA = LocalLock(es->hloc32A);
1333#endif
1334 HLOCAL hloc32W_new;
1335 UINT countW_new = MultiByteToWideChar(CP_ACP, 0, textA, -1, NULL, 0);
1336 if(countW_new > es->buffer_size + 1)
1337 {
1338 UINT alloc_size = ROUND_TO_GROW(countW_new * sizeof(WCHAR));
1339 TRACE("Resizing 32-bit UNICODE buffer from %d+1 to %d WCHARs\n", es->buffer_size, countW_new);
1340 hloc32W_new = LocalReAlloc(es->hloc32W, alloc_size, LMEM_MOVEABLE | LMEM_ZEROINIT);
1341 if(hloc32W_new)
1342 {
1343 es->hloc32W = hloc32W_new;
1344 es->buffer_size = LocalSize(hloc32W_new)/sizeof(WCHAR) - 1;
1345 TRACE("Real new size %d+1 WCHARs\n", es->buffer_size);
1346 }
1347 else
1348 WARN("FAILED! Will synchronize partially\n");
1349 }
1350 es->text = LocalLock(es->hloc32W);
1351 MultiByteToWideChar(CP_ACP, 0, textA, -1, es->text, es->buffer_size + 1);
1352 LocalUnlock(es->hloc32A);
1353 }
1354 else es->text = LocalLock(es->hloc32W);
1355 }
1356 es->lock_count++;
1357}
1358
1359
1360/*********************************************************************
1361 *
1362 * EDIT_UnlockBuffer
1363 *
1366{
1367 /* Edit window might be already destroyed */
1368 if(!IsWindow(es->hwndSelf))
1369 {
1370 WARN("edit hwnd %p already destroyed\n", es->hwndSelf);
1371 return;
1372 }
1373
1374 if (!es->lock_count) {
1375 ERR("lock_count == 0 ... please report\n");
1376 return;
1377 }
1378 if (!es->text) {
1379 ERR("es->text == 0 ... please report\n");
1380 return;
1381 }
1382 if (force || (es->lock_count == 1)) {
1383 if (es->hloc32W) {
1384 UINT countA = 0;
1385 UINT countW = get_text_length(es) + 1;
1386
1387 if(es->hloc32A)
1388 {
1389 UINT countA_new = WideCharToMultiByte(CP_ACP, 0, es->text, countW, NULL, 0, NULL, NULL);
1390 TRACE("Synchronizing with 32-bit ANSI buffer\n");
1391 TRACE("%d WCHARs translated to %d bytes\n", countW, countA_new);
1392 countA = LocalSize(es->hloc32A);
1393 if(countA_new > countA)
1394 {
1395 HLOCAL hloc32A_new;
1396 UINT alloc_size = ROUND_TO_GROW(countA_new);
1397 TRACE("Resizing 32-bit ANSI buffer from %d to %d bytes\n", countA, alloc_size);
1398 hloc32A_new = LocalReAlloc(es->hloc32A, alloc_size, LMEM_MOVEABLE | LMEM_ZEROINIT);
1399 if(hloc32A_new)
1400 {
1401 es->hloc32A = hloc32A_new;
1402 countA = LocalSize(hloc32A_new);
1403 TRACE("Real new size %d bytes\n", countA);
1404 }
1405 else
1406 WARN("FAILED! Will synchronize partially\n");
1407 }
1408 WideCharToMultiByte(CP_ACP, 0, es->text, countW,
1409 LocalLock(es->hloc32A), countA, NULL, NULL);
1410 LocalUnlock(es->hloc32A);
1411 }
1412
1413 LocalUnlock(es->hloc32W);
1414 es->text = NULL;
1415 }
1416 else {
1417 ERR("no buffer ... please report\n");
1418 return;
1419 }
1420 }
1421 es->lock_count--;
1422}
1423
1424
1425/*********************************************************************
1426 *
1427 * EDIT_MakeFit
1428 *
1429 * Try to fit size + 1 characters in the buffer.
1432{
1433 HLOCAL hNew32W;
1434
1435 if (size <= es->buffer_size)
1436 return TRUE;
1437
1438 TRACE("trying to ReAlloc to %d+1 characters\n", size);
1439
1440 /* Force edit to unlock its buffer. es->text now NULL */
1442
1443 if (es->hloc32W) {
1444 UINT alloc_size = ROUND_TO_GROW((size + 1) * sizeof(WCHAR));
1445 if ((hNew32W = LocalReAlloc(es->hloc32W, alloc_size, LMEM_MOVEABLE | LMEM_ZEROINIT))) {
1446 TRACE("Old 32 bit handle %p, new handle %p\n", es->hloc32W, hNew32W);
1447 es->hloc32W = hNew32W;
1448 es->buffer_size = LocalSize(hNew32W)/sizeof(WCHAR) - 1;
1449 }
1450 }
1451
1453
1454 if (es->buffer_size < size) {
1455 WARN("FAILED ! We now have %d+1\n", es->buffer_size);
1457 return FALSE;
1458 } else {
1459 TRACE("We now have %d+1\n", es->buffer_size);
1460 return TRUE;
1461 }
1462}
1463
1464
1465/*********************************************************************
1466 *
1467 * EDIT_MakeUndoFit
1468 *
1469 * Try to fit size + 1 bytes in the undo buffer.
1470 *
1473{
1474 UINT alloc_size;
1475
1476 if (size <= es->undo_buffer_size)
1477 return TRUE;
1478
1479 TRACE("trying to ReAlloc to %d+1\n", size);
1480
1481 alloc_size = ROUND_TO_GROW((size + 1) * sizeof(WCHAR));
1482 if ((es->undo_text = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, es->undo_text, alloc_size))) {
1483 es->undo_buffer_size = alloc_size/sizeof(WCHAR) - 1;
1484 return TRUE;
1485 }
1486 else
1487 {
1488 WARN("FAILED ! We now have %d+1\n", es->undo_buffer_size);
1489 return FALSE;
1490 }
1491}
1492
1493
1494/*********************************************************************
1495 *
1496 * EDIT_UpdateTextRegion
1497 *
1499static void EDIT_UpdateTextRegion(EDITSTATE *es, HRGN hrgn, BOOL bErase)
1500{
1501 if (es->flags & EF_UPDATE) {
1502 es->flags &= ~EF_UPDATE;
1503 if (!notify_parent(es, EN_UPDATE)) return;
1504 }
1505 NtUserInvalidateRgn(es->hwndSelf, hrgn, bErase);
1506}
1507
1508
1509/*********************************************************************
1510 *
1511 * EDIT_UpdateText
1512 *
1514static void EDIT_UpdateText(EDITSTATE *es, const RECT *rc, BOOL bErase)
1515{
1516 if (es->flags & EF_UPDATE) {
1517 es->flags &= ~EF_UPDATE;
1518 if (!notify_parent(es, EN_UPDATE)) return;
1519 }
1520 NtUserInvalidateRect(es->hwndSelf, rc, bErase);
1521}
1522
1523/*********************************************************************
1524 *
1525 * EDIT_SL_InvalidateText
1526 *
1527 * Called from EDIT_InvalidateText().
1528 * Does the job for single-line controls only.
1529 *
1532{
1533 RECT line_rect;
1534 RECT rc;
1535
1536 EDIT_GetLineRect(es, 0, start, end, &line_rect);
1537 if (IntersectRect(&rc, &line_rect, &es->format_rect))
1538 EDIT_UpdateText(es, &rc, TRUE);
1539}
1540
1541/*********************************************************************
1542 *
1543 * EDIT_ML_InvalidateText
1544 *
1545 * Called from EDIT_InvalidateText().
1546 * Does the job for multi-line controls only.
1547 *
1550{
1554 INT sc;
1555 INT ec;
1556 RECT rc1;
1557 RECT rcWnd;
1558 RECT rcLine;
1559 RECT rcUpdate;
1560 INT l;
1561
1562 if ((el < es->y_offset) || (sl > es->y_offset + vlc))
1563 return;
1564
1565 sc = start - EDIT_EM_LineIndex(es, sl);
1566 ec = end - EDIT_EM_LineIndex(es, el);
1567 if (sl < es->y_offset) {
1568 sl = es->y_offset;
1569 sc = 0;
1570 }
1571 if (el > es->y_offset + vlc) {
1572 el = es->y_offset + vlc;
1574 }
1575 GetClientRect(es->hwndSelf, &rc1);
1576 IntersectRect(&rcWnd, &rc1, &es->format_rect);
1577 if (sl == el) {
1578 EDIT_GetLineRect(es, sl, sc, ec, &rcLine);
1579 if (IntersectRect(&rcUpdate, &rcWnd, &rcLine))
1580 EDIT_UpdateText(es, &rcUpdate, TRUE);
1581 } else {
1582 EDIT_GetLineRect(es, sl, sc,
1584 EDIT_EM_LineIndex(es, sl)),
1585 &rcLine);
1586 if (IntersectRect(&rcUpdate, &rcWnd, &rcLine))
1587 EDIT_UpdateText(es, &rcUpdate, TRUE);
1588 for (l = sl + 1 ; l < el ; l++) {
1589 EDIT_GetLineRect(es, l, 0,
1592 &rcLine);
1593 if (IntersectRect(&rcUpdate, &rcWnd, &rcLine))
1594 EDIT_UpdateText(es, &rcUpdate, TRUE);
1595 }
1596 EDIT_GetLineRect(es, el, 0, ec, &rcLine);
1597 if (IntersectRect(&rcUpdate, &rcWnd, &rcLine))
1598 EDIT_UpdateText(es, &rcUpdate, TRUE);
1599 }
1600}
1601
1602
1603/*********************************************************************
1604 *
1605 * EDIT_InvalidateText
1606 *
1607 * Invalidate the text from offset start up to, but not including,
1608 * offset end. Useful for (re)painting the selection.
1609 * Regions outside the linewidth are not invalidated.
1610 * end == -1 means end == TextLength.
1611 * start and end need not be ordered.
1612 *
1615{
1616 if (end == start)
1617 return;
1618
1619 if (end == -1)
1621
1622 if (end < start) {
1623 INT tmp = start;
1624 start = end;
1625 end = tmp;
1626 }
1627
1628 if (es->style & ES_MULTILINE)
1630 else
1632}
1633
1634
1635/*********************************************************************
1636 *
1637 * EDIT_EM_SetSel
1638 *
1639 * note: unlike the specs say: the order of start and end
1640 * _is_ preserved in Windows. (i.e. start can be > end)
1641 * In other words: this handler is OK
1642 *
1644static void EDIT_EM_SetSel(EDITSTATE *es, UINT start, UINT end, BOOL after_wrap)
1645{
1646 UINT old_start = es->selection_start;
1647 UINT old_end = es->selection_end;
1649
1650 if (start == (UINT)-1) {
1651 start = es->selection_end;
1652 end = es->selection_end;
1653 } else {
1654 start = min(start, len);
1655 end = min(end, len);
1656 }
1657 es->selection_start = start;
1658 es->selection_end = end;
1659 if (after_wrap)
1660 es->flags |= EF_AFTER_WRAP;
1661 else
1662 es->flags &= ~EF_AFTER_WRAP;
1663 /* Compute the necessary invalidation region. */
1664 /* Note that we don't need to invalidate regions which have
1665 * "never" been selected, or those which are "still" selected.
1666 * In fact, every time we hit a selection boundary, we can
1667 * *toggle* whether we need to invalidate. Thus we can optimize by
1668 * *sorting* the interval endpoints. Let's assume that we sort them
1669 * in this order:
1670 * start <= end <= old_start <= old_end
1671 * Knuth 5.3.1 (p 183) assures us that this can be done optimally
1672 * in 5 comparisons; i.e. it is impossible to do better than the
1673 * following: */
1674 ORDER_UINT(end, old_end);
1675 ORDER_UINT(start, old_start);
1676 ORDER_UINT(old_start, old_end);
1678 /* Note that at this point 'end' and 'old_start' are not in order, but
1679 * start is definitely the min. and old_end is definitely the max. */
1680 if (end != old_start)
1681 {
1682/*
1683 * One can also do
1684 * ORDER_UINT32(end, old_start);
1685 * EDIT_InvalidateText(es, start, end);
1686 * EDIT_InvalidateText(es, old_start, old_end);
1687 * in place of the following if statement.
1688 * (That would complete the optimal five-comparison four-element sort.)
1689 */
1690 if (old_start > end )
1691 {
1693 EDIT_InvalidateText(es, old_start, old_end);
1694 }
1695 else
1696 {
1697 EDIT_InvalidateText(es, start, old_start);
1698 EDIT_InvalidateText(es, end, old_end);
1699 }
1700 }
1701 else EDIT_InvalidateText(es, start, old_end);
1702}
1703
1704
1705/*********************************************************************
1706 *
1707 * EDIT_UpdateScrollInfo
1708 *
1711{
1712 if ((es->style & WS_VSCROLL) && !(es->flags & EF_VSCROLL_TRACK))
1713 {
1714 SCROLLINFO si;
1715 si.cbSize = sizeof(SCROLLINFO);
1717 si.nMin = 0;
1718 si.nMax = es->line_count - 1;
1719 si.nPage = es->line_height ? (es->format_rect.bottom - es->format_rect.top) / es->line_height : 0;
1720 si.nPos = es->y_offset;
1721 TRACE("SB_VERT, nMin=%d, nMax=%d, nPage=%d, nPos=%d\n",
1722 si.nMin, si.nMax, si.nPage, si.nPos);
1723#ifdef __REACTOS__
1724 /* Unlike WINE, SetScrollInfo is more than just a NtUserSetScrollInfo wrapper on ReactOS. */
1725 SetScrollInfo(es->hwndSelf, SB_VERT, &si, TRUE);
1726#else
1727 NtUserSetScrollInfo(es->hwndSelf, SB_VERT, &si, TRUE);
1728#endif
1729 }
1730
1731 if ((es->style & WS_HSCROLL) && !(es->flags & EF_HSCROLL_TRACK))
1732 {
1733 SCROLLINFO si;
1734 si.cbSize = sizeof(SCROLLINFO);
1736 si.nMin = 0;
1737 si.nMax = es->text_width - 1;
1738 si.nPage = es->format_rect.right - es->format_rect.left;
1739 si.nPos = es->x_offset;
1740 TRACE("SB_HORZ, nMin=%d, nMax=%d, nPage=%d, nPos=%d\n",
1741 si.nMin, si.nMax, si.nPage, si.nPos);
1742#ifdef __REACTOS__
1743 SetScrollInfo(es->hwndSelf, SB_HORZ, &si, TRUE);
1744#else
1745 NtUserSetScrollInfo(es->hwndSelf, SB_HORZ, &si, TRUE);
1746#endif
1747 }
1748}
1749
1750
1751/*********************************************************************
1752 *
1753 * EDIT_EM_LineScroll_internal
1754 *
1755 * Version of EDIT_EM_LineScroll for internal use.
1756 * It doesn't refuse if ES_MULTILINE is set and assumes that
1757 * dx is in pixels, dy - in lines.
1758 *
1761{
1762 INT nyoff;
1763 INT x_offset_in_pixels;
1764 INT lines_per_page;
1765
1766 if (!es->line_height || !es->char_width)
1767 return TRUE;
1768
1769 lines_per_page = (es->format_rect.bottom - es->format_rect.top) / es->line_height;
1770
1771 if (es->style & ES_MULTILINE)
1772 {
1773 x_offset_in_pixels = es->x_offset;
1774 }
1775 else
1776 {
1777 dy = 0;
1778 x_offset_in_pixels = (short)LOWORD(EDIT_EM_PosFromChar(es, es->x_offset, FALSE));
1779 }
1780
1781 if (-dx > x_offset_in_pixels)
1782 dx = -x_offset_in_pixels;
1783 if (dx > es->text_width - x_offset_in_pixels)
1784 dx = es->text_width - x_offset_in_pixels;
1785 nyoff = max(0, es->y_offset + dy);
1786 if (nyoff >= es->line_count - lines_per_page)
1787 nyoff = max(0, es->line_count - lines_per_page);
1788 dy = (es->y_offset - nyoff) * es->line_height;
1789 if (dx || dy) {
1790 RECT rc1;
1791 RECT rc;
1792
1793 es->y_offset = nyoff;
1794 if(es->style & ES_MULTILINE)
1795 es->x_offset += dx;
1796 else
1797 es->x_offset += dx / es->char_width;
1798
1799 GetClientRect(es->hwndSelf, &rc1);
1800 IntersectRect(&rc, &rc1, &es->format_rect);
1801 NtUserScrollWindowEx(es->hwndSelf, -dx, dy,
1802 NULL, &rc, NULL, NULL, SW_INVALIDATE);
1803 /* force scroll info update */
1805 }
1806 if (dx && !(es->flags & EF_HSCROLL_TRACK))
1808 if (dy && !(es->flags & EF_VSCROLL_TRACK))
1810 return TRUE;
1811}
1812
1813/*********************************************************************
1814 *
1815 * EM_LINESCROLL
1816 *
1817 * NOTE: dx is in average character widths, dy - in lines;
1818 *
1821{
1822 if (!(es->style & ES_MULTILINE))
1823 return FALSE;
1824
1825 dx *= es->char_width;
1827}
1828
1829
1830/*********************************************************************
1831 *
1832 * EM_SCROLL
1833 *
1836{
1837 INT dy;
1838
1839 if (!(es->style & ES_MULTILINE))
1840 return (LRESULT)FALSE;
1841
1842 dy = 0;
1843
1844 switch (action) {
1845 case SB_LINEUP:
1846 if (es->y_offset)
1847 dy = -1;
1848 break;
1849 case SB_LINEDOWN:
1850 if (es->y_offset < es->line_count - 1)
1851 dy = 1;
1852 break;
1853 case SB_PAGEUP:
1854 if (es->y_offset)
1855 dy = -(es->format_rect.bottom - es->format_rect.top) / es->line_height;
1856 break;
1857 case SB_PAGEDOWN:
1858 if (es->y_offset < es->line_count - 1)
1859 dy = (es->format_rect.bottom - es->format_rect.top) / es->line_height;
1860 break;
1861 default:
1863 }
1864 if (dy) {
1866 /* check if we are going to move too far */
1867 if(es->y_offset + dy > es->line_count - vlc)
1868 dy = max(es->line_count - vlc, 0) - es->y_offset;
1869
1870 /* Notification is done in EDIT_EM_LineScroll */
1871 if(dy) {
1873 return MAKELONG(dy, TRUE);
1874 }
1875
1876 }
1877 return (LRESULT)FALSE;
1878}
1879
1880#ifdef __REACTOS__
1881static void EDIT_ImmSetCompositionWindow(EDITSTATE *es, POINT pt)
1882{
1883 COMPOSITIONFORM CompForm;
1884 HIMC hIMC = ImmGetContext(es->hwndSelf);
1885 if (!hIMC)
1886 {
1887 ERR("!hIMC\n");
1888 return;
1889 }
1890
1891 CompForm.ptCurrentPos = pt;
1892 if (es->style & ES_MULTILINE)
1893 {
1894 CompForm.dwStyle = CFS_RECT;
1895 CompForm.rcArea = es->format_rect;
1896 }
1897 else
1898 {
1899 CompForm.dwStyle = CFS_POINT;
1900 SetRectEmpty(&CompForm.rcArea);
1901 }
1902
1903 ImmSetCompositionWindow(hIMC, &CompForm);
1904 ImmReleaseContext(es->hwndSelf, hIMC);
1905}
1906#else
1908{
1910 {
1911 .dwStyle = CFS_RECT,
1912 .ptCurrentPos = {.x = x, .y = y},
1913 .rcArea = es->format_rect,
1914 };
1915 HIMC himc = ImmGetContext(es->hwndSelf);
1917 ImmReleaseContext(es->hwndSelf, himc);
1918}
1919#endif
1920
1921/*********************************************************************
1922 *
1923 * EDIT_SetCaretPos
1924 *
1926static void EDIT_SetCaretPos(EDITSTATE *es, INT pos,
1927 BOOL after_wrap)
1928{
1929 LRESULT res;
1930
1931 if (es->flags & EF_FOCUSED)
1932 {
1933 res = EDIT_EM_PosFromChar(es, pos, after_wrap);
1934#ifdef __REACTOS__
1935 HKL hKL = GetKeyboardLayout(0);
1936 POINT pt = { (short)LOWORD(res), (short)HIWORD(res) };
1937
1938 /* Don't set caret if not focused */
1939 if ((es->flags & EF_FOCUSED) == 0)
1940 return;
1941
1942 SetCaretPos(pt.x, pt.y);
1943
1944 if (ImmIsIME(hKL))
1945 EDIT_ImmSetCompositionWindow(es, pt);
1946#else
1947 TRACE("%d - %dx%d\n", pos, (short)LOWORD(res), (short)HIWORD(res));
1948 NtUserSetCaretPos((short)LOWORD(res), (short)HIWORD(res));
1950#endif
1951 }
1952}
1953
1954
1955/*********************************************************************
1956 *
1957 * EM_SCROLLCARET
1958 *
1960static void EDIT_EM_ScrollCaret(EDITSTATE *es)
1961{
1962 if (es->style & ES_MULTILINE) {
1963 INT l;
1964 INT vlc;
1965 INT ww;
1966 INT cw = es->char_width;
1967 INT x;
1968 INT dy = 0;
1969 INT dx = 0;
1970
1971 l = EDIT_EM_LineFromChar(es, es->selection_end);
1972 x = (short)LOWORD(EDIT_EM_PosFromChar(es, es->selection_end, es->flags & EF_AFTER_WRAP));
1974 if (l >= es->y_offset + vlc)
1975 dy = l - vlc + 1 - es->y_offset;
1976 if (l < es->y_offset)
1977 dy = l - es->y_offset;
1978 ww = es->format_rect.right - es->format_rect.left;
1979 if (x < es->format_rect.left)
1980 dx = x - es->format_rect.left - ww / HSCROLL_FRACTION / cw * cw;
1981 if (x > es->format_rect.right)
1982 dx = x - es->format_rect.left - (HSCROLL_FRACTION - 1) * ww / HSCROLL_FRACTION / cw * cw;
1983 if (dy || dx || (es->y_offset && (es->line_count - es->y_offset < vlc)))
1984 {
1985 /* check if we are going to move too far */
1986 if(es->x_offset + dx + ww > es->text_width)
1987 dx = es->text_width - ww - es->x_offset;
1988 if(dx || dy || (es->y_offset && (es->line_count - es->y_offset < vlc)))
1990 }
1991 } else {
1992 INT x;
1993 INT goal;
1994 INT format_width;
1995
1996 x = (short)LOWORD(EDIT_EM_PosFromChar(es, es->selection_end, FALSE));
1997 format_width = es->format_rect.right - es->format_rect.left;
1998 if (x < es->format_rect.left) {
1999 goal = es->format_rect.left + format_width / HSCROLL_FRACTION;
2000 do {
2001 es->x_offset--;
2002 x = (short)LOWORD(EDIT_EM_PosFromChar(es, es->selection_end, FALSE));
2003 } while ((x < goal) && es->x_offset);
2004 /* FIXME: use ScrollWindow() somehow to improve performance */
2006 } else if (x > es->format_rect.right) {
2007 INT x_last;
2009 goal = es->format_rect.right - format_width / HSCROLL_FRACTION;
2010 do {
2011 es->x_offset++;
2012 x = (short)LOWORD(EDIT_EM_PosFromChar(es, es->selection_end, FALSE));
2014 } while ((x > goal) && (x_last > es->format_rect.right));
2015 /* FIXME: use ScrollWindow() somehow to improve performance */
2017 }
2018 }
2019
2020 EDIT_SetCaretPos(es, es->selection_end, es->flags & EF_AFTER_WRAP);
2021}
2022
2023
2024/*********************************************************************
2025 *
2026 * EDIT_MoveBackward
2027 *
2029static void EDIT_MoveBackward(EDITSTATE *es, BOOL extend)
2030{
2031 INT e = es->selection_end;
2032
2033 if (e) {
2034 e--;
2035 if ((es->style & ES_MULTILINE) && e &&
2036 (es->text[e - 1] == '\r') && (es->text[e] == '\n')) {
2037 e--;
2038 if (e && (es->text[e - 1] == '\r'))
2039 e--;
2040 }
2041 }
2042 EDIT_EM_SetSel(es, extend ? es->selection_start : e, e, FALSE);
2044}
2045
2046
2047/*********************************************************************
2048 *
2049 * EDIT_MoveDown_ML
2050 *
2051 * Only for multi line controls
2052 * Move the caret one line down, on a column with the nearest
2053 * x coordinate on the screen (might be a different column).
2054 *
2056static void EDIT_MoveDown_ML(EDITSTATE *es, BOOL extend)
2057{
2058 INT s = es->selection_start;
2059 INT e = es->selection_end;
2060 BOOL after_wrap = (es->flags & EF_AFTER_WRAP);
2061 LRESULT pos = EDIT_EM_PosFromChar(es, e, after_wrap);
2062 INT x = (short)LOWORD(pos);
2063 INT y = (short)HIWORD(pos);
2064
2065 e = EDIT_CharFromPos(es, x, y + es->line_height, &after_wrap);
2066 if (!extend)
2067 s = e;
2068 EDIT_EM_SetSel(es, s, e, after_wrap);
2070}
2071
2072
2073/*********************************************************************
2074 *
2075 * EDIT_MoveEnd
2076 *
2078static void EDIT_MoveEnd(EDITSTATE *es, BOOL extend, BOOL ctrl)
2079{
2080 BOOL after_wrap = FALSE;
2081 INT e;
2082
2083 /* Pass a high value in x to make sure of receiving the end of the line */
2084 if (!ctrl && (es->style & ES_MULTILINE))
2085 e = EDIT_CharFromPos(es, 0x3fffffff,
2086 HIWORD(EDIT_EM_PosFromChar(es, es->selection_end, es->flags & EF_AFTER_WRAP)), &after_wrap);
2087 else
2088 e = get_text_length(es);
2089 EDIT_EM_SetSel(es, extend ? es->selection_start : e, e, after_wrap);
2091}
2092
2093
2094/*********************************************************************
2095 *
2096 * EDIT_MoveForward
2097 *
2099static void EDIT_MoveForward(EDITSTATE *es, BOOL extend)
2100{
2101 INT e = es->selection_end;
2102
2103 if (es->text[e]) {
2104 e++;
2105 if ((es->style & ES_MULTILINE) && (es->text[e - 1] == '\r')) {
2106 if (es->text[e] == '\n')
2107 e++;
2108 else if ((es->text[e] == '\r') && (es->text[e + 1] == '\n'))
2109 e += 2;
2110 }
2111 }
2112 EDIT_EM_SetSel(es, extend ? es->selection_start : e, e, FALSE);
2114}
2115
2116
2117/*********************************************************************
2118 *
2119 * EDIT_MoveHome
2120 *
2121 * Home key: move to beginning of line.
2122 *
2124static void EDIT_MoveHome(EDITSTATE *es, BOOL extend, BOOL ctrl)
2125{
2126 INT e;
2127
2128 /* Pass the x_offset in x to make sure of receiving the first position of the line */
2129 if (!ctrl && (es->style & ES_MULTILINE))
2130 e = EDIT_CharFromPos(es, -es->x_offset,
2131 HIWORD(EDIT_EM_PosFromChar(es, es->selection_end, es->flags & EF_AFTER_WRAP)), NULL);
2132 else
2133 e = 0;
2134 EDIT_EM_SetSel(es, extend ? es->selection_start : e, e, FALSE);
2136}
2137
2138
2139/*********************************************************************
2140 *
2141 * EDIT_MovePageDown_ML
2142 *
2143 * Only for multi line controls
2144 * Move the caret one page down, on a column with the nearest
2145 * x coordinate on the screen (might be a different column).
2146 *
2148static void EDIT_MovePageDown_ML(EDITSTATE *es, BOOL extend)
2149{
2150 INT s = es->selection_start;
2151 INT e = es->selection_end;
2152 BOOL after_wrap = (es->flags & EF_AFTER_WRAP);
2153 LRESULT pos = EDIT_EM_PosFromChar(es, e, after_wrap);
2154 INT x = (short)LOWORD(pos);
2155 INT y = (short)HIWORD(pos);
2156
2158 y + (es->format_rect.bottom - es->format_rect.top),
2159 &after_wrap);
2160 if (!extend)
2161 s = e;
2162 EDIT_EM_SetSel(es, s, e, after_wrap);
2164}
2165
2166
2167/*********************************************************************
2168 *
2169 * EDIT_MovePageUp_ML
2170 *
2171 * Only for multi line controls
2172 * Move the caret one page up, on a column with the nearest
2173 * x coordinate on the screen (might be a different column).
2174 *
2176static void EDIT_MovePageUp_ML(EDITSTATE *es, BOOL extend)
2177{
2178 INT s = es->selection_start;
2179 INT e = es->selection_end;
2180 BOOL after_wrap = (es->flags & EF_AFTER_WRAP);
2181 LRESULT pos = EDIT_EM_PosFromChar(es, e, after_wrap);
2182 INT x = (short)LOWORD(pos);
2183 INT y = (short)HIWORD(pos);
2184
2186 y - (es->format_rect.bottom - es->format_rect.top),
2187 &after_wrap);
2188 if (!extend)
2189 s = e;
2190 EDIT_EM_SetSel(es, s, e, after_wrap);
2192}
2193
2194
2195/*********************************************************************
2196 *
2197 * EDIT_MoveUp_ML
2198 *
2199 * Only for multi line controls
2200 * Move the caret one line up, on a column with the nearest
2201 * x coordinate on the screen (might be a different column).
2202 *
2204static void EDIT_MoveUp_ML(EDITSTATE *es, BOOL extend)
2205{
2206 INT s = es->selection_start;
2207 INT e = es->selection_end;
2208 BOOL after_wrap = (es->flags & EF_AFTER_WRAP);
2209 LRESULT pos = EDIT_EM_PosFromChar(es, e, after_wrap);
2210 INT x = (short)LOWORD(pos);
2211 INT y = (short)HIWORD(pos);
2212
2213 e = EDIT_CharFromPos(es, x, y - es->line_height, &after_wrap);
2214 if (!extend)
2215 s = e;
2216 EDIT_EM_SetSel(es, s, e, after_wrap);
2218}
2219
2220
2221/*********************************************************************
2222 *
2223 * EDIT_MoveWordBackward
2224 *
2226static void EDIT_MoveWordBackward(EDITSTATE *es, BOOL extend)
2227{
2228 INT s = es->selection_start;
2229 INT e = es->selection_end;
2230 INT l;
2231 INT ll;
2232 INT li;
2233
2237 if (e - li == 0) {
2238 if (l) {
2239 li = EDIT_EM_LineIndex(es, l - 1);
2240 e = li + EDIT_EM_LineLength(es, li);
2241 }
2242 } else {
2244 }
2245 if (!extend)
2246 s = e;
2249}
2250
2251
2252/*********************************************************************
2253 *
2254 * EDIT_MoveWordForward
2255 *
2257static void EDIT_MoveWordForward(EDITSTATE *es, BOOL extend)
2258{
2259 INT s = es->selection_start;
2260 INT e = es->selection_end;
2261 INT l;
2262 INT ll;
2263 INT li;
2264
2268 if (e - li == ll) {
2269 if ((es->style & ES_MULTILINE) && (l != es->line_count - 1))
2270 e = EDIT_EM_LineIndex(es, l + 1);
2271 } else {
2273 li, e - li + 1, ll, WB_RIGHT);
2274 }
2275 if (!extend)
2276 s = e;
2279}
2280
2281
2282/*********************************************************************
2283 *
2284 * EDIT_PaintText
2285 *
2288{
2289 COLORREF BkColor;
2290 COLORREF TextColor;
2291 INT ret;
2292 INT li;
2293 INT BkMode;
2294 SIZE size;
2295
2296 if (!count)
2297 return 0;
2298 BkMode = GetBkMode(dc);
2299 BkColor = GetBkColor(dc);
2300 TextColor = GetTextColor(dc);
2301 if (rev) {
2305 }
2307 if (es->style & ES_MULTILINE) {
2308 ret = (INT)LOWORD(TabbedTextOutW(dc, x, y, es->text + li + col, count,
2309 es->tabs_count, es->tabs, es->format_rect.left - es->x_offset));
2310 } else {
2311 TextOutW(dc, x, y, es->text + li + col, count);
2312 GetTextExtentPoint32W(dc, es->text + li + col, count, &size);
2313 ret = size.cx;
2314 }
2315 if (rev) {
2316 SetBkColor(dc, BkColor);
2317 SetTextColor(dc, TextColor);
2318 SetBkMode(dc, BkMode);
2319 }
2320 return ret;
2321}
2322
2323
2324/*********************************************************************
2325 *
2326 * EDIT_PaintLine
2327 *
2329static void EDIT_PaintLine(EDITSTATE *es, HDC dc, INT line, BOOL rev)
2330{
2331 INT s = 0;
2332 INT e = 0;
2333 INT li = 0;
2334 INT ll = 0;
2335 INT x;
2336 INT y;
2337 LRESULT pos;
2339
2340 if (es->style & ES_MULTILINE) {
2342
2343 if ((line < es->y_offset) || (line > es->y_offset + vlc) || (line >= es->line_count))
2344 return;
2345 } else if (line)
2346 return;
2347
2348 TRACE("line=%d\n", line);
2349
2352 x = (short)LOWORD(pos);
2353 y = (short)HIWORD(pos);
2354
2355 if (es->style & ES_MULTILINE)
2356 {
2357 int line_idx = line;
2358 x = -es->x_offset;
2359 if (es->style & ES_RIGHT || es->style & ES_CENTER)
2360 {
2361 LINEDEF *line_def = es->first_line_def;
2362 int w, lw;
2363
2364 while (line_def && line_idx)
2365 {
2366 line_def = line_def->next;
2367 line_idx--;
2368 }
2369 w = es->format_rect.right - es->format_rect.left;
2370 lw = line_def->width;
2371
2372 if (es->style & ES_RIGHT)
2373 x = w - (lw - x);
2374 else if (es->style & ES_CENTER)
2375 x += (w - lw) / 2;
2376 }
2377 x += es->format_rect.left;
2378 }
2379
2380 if (rev)
2381 {
2384 s = min(es->selection_start, es->selection_end);
2385 e = max(es->selection_start, es->selection_end);
2386 s = min(li + ll, max(li, s));
2387 e = min(li + ll, max(li, e));
2388 }
2389
2390 if (ssa)
2391 ScriptStringOut(ssa, x, y, 0, &es->format_rect, s - li, e - li, FALSE);
2392 else if (rev && (s != e) &&
2393 ((es->flags & EF_FOCUSED) || (es->style & ES_NOHIDESEL))) {
2394 x += EDIT_PaintText(es, dc, x, y, line, 0, s - li, FALSE);
2395 x += EDIT_PaintText(es, dc, x, y, line, s - li, e - s, TRUE);
2396 x += EDIT_PaintText(es, dc, x, y, line, e - li, li + ll - e, FALSE);
2397 } else
2398 x += EDIT_PaintText(es, dc, x, y, line, 0, ll, FALSE);
2399}
2400
2401
2402/*********************************************************************
2403 *
2404 * EDIT_AdjustFormatRect
2405 *
2406 * Adjusts the format rectangle for the current font and the
2407 * current client rectangle.
2408 *
2411{
2412 RECT ClientRect;
2413
2414 es->format_rect.right = max(es->format_rect.right, es->format_rect.left + es->char_width);
2415 if (es->style & ES_MULTILINE)
2416 {
2417 INT fw, vlc, max_x_offset, max_y_offset;
2418
2420 es->format_rect.bottom = es->format_rect.top + vlc * es->line_height;
2421
2422 /* correct es->x_offset */
2423 fw = es->format_rect.right - es->format_rect.left;
2424 max_x_offset = es->text_width - fw;
2425 if(max_x_offset < 0) max_x_offset = 0;
2426 if(es->x_offset > max_x_offset)
2427 es->x_offset = max_x_offset;
2428
2429 /* correct es->y_offset */
2430 max_y_offset = es->line_count - vlc;
2431 if(max_y_offset < 0) max_y_offset = 0;
2432 if(es->y_offset > max_y_offset)
2433 es->y_offset = max_y_offset;
2434
2435 /* force scroll info update */
2437 }
2438 else
2439 {
2440 /* Windows doesn't care to fix text placement for SL controls */
2441 es->format_rect.bottom = es->format_rect.top + es->line_height;
2442
2443 /* Always stay within the client area */
2444 GetClientRect(es->hwndSelf, &ClientRect);
2445 es->format_rect.bottom = min(es->format_rect.bottom, ClientRect.bottom);
2446 }
2447
2448 if ((es->style & ES_MULTILINE) && !(es->style & ES_AUTOHSCROLL))
2450
2451 EDIT_SetCaretPos(es, es->selection_end, es->flags & EF_AFTER_WRAP);
2452}
2454static int EDIT_is_valid_format_rect(const EDITSTATE *es, const RECT *rc)
2455{
2456 if (IsRectEmpty(rc))
2457 return 0;
2458 if (es->text_width > (rc->right - rc->left) || (es->line_height * es->line_count) > (rc->bottom - rc->top))
2459 return 0;
2460 return 1;
2461}
2462
2463/*********************************************************************
2464 *
2465 * EDIT_SetRectNP
2466 *
2467 * note: this is not (exactly) the handler called on EM_SETRECTNP
2468 * it is also used to set the rect of a single line control
2469 *
2471static void EDIT_SetRectNP(EDITSTATE *es, const RECT *rc)
2472{
2474 INT bw, bh;
2475 BOOL too_large = FALSE;
2476 RECT edit_rect;
2477
2479
2481 {
2482 CopyRect(&es->format_rect, rc);
2483 GetClientRect(es->hwndSelf, &edit_rect);
2484 too_large = (rc->bottom - rc->top) > (edit_rect.bottom - edit_rect.top);
2485 }
2486 else
2487 {
2488 GetClientRect(es->hwndSelf, &es->format_rect);
2489 }
2490
2491 if (ExStyle & WS_EX_CLIENTEDGE && !too_large) {
2492 es->format_rect.left++;
2493 es->format_rect.right--;
2494
2495 if (es->format_rect.bottom - es->format_rect.top
2496 >= es->line_height + 2)
2497 {
2498 es->format_rect.top++;
2499 es->format_rect.bottom--;
2500 }
2501 }
2502 else if (es->style & WS_BORDER) {
2504 bh = GetSystemMetrics(SM_CYBORDER) + 1;
2505 es->format_rect.left += bw;
2506 es->format_rect.right -= bw;
2507 if (es->format_rect.bottom - es->format_rect.top
2508 >= es->line_height + 2 * bh)
2509 {
2510 es->format_rect.top += bh;
2511 es->format_rect.bottom -= bh;
2512 }
2513 }
2514
2515 es->format_rect.left += es->left_margin;
2516 es->format_rect.right -= es->right_margin;
2518}
2519
2520
2521/*********************************************************************
2522 *
2523 * EM_CHARFROMPOS
2524 *
2525 * returns line number (not index) in high-order word of result.
2526 * NB : Q137805 is unclear about this. POINT * pointer in lParam apply
2527 * to Richedit, not to the edit control. Original documentation is valid.
2528 * FIXME: do the specs mean to return -1 if outside client area or
2529 * if outside formatting rectangle ???
2530 *
2533{
2534 POINT pt;
2535 RECT rc;
2536 INT index;
2537
2538 pt.x = x;
2539 pt.y = y;
2540 GetClientRect(es->hwndSelf, &rc);
2541 if (!PtInRect(&rc, pt))
2542 return -1;
2543
2546}
2547
2548
2549/*********************************************************************
2550 *
2551 * EM_FMTLINES
2552 *
2553 * Enable or disable soft breaks.
2554 *
2555 * This means: insert or remove the soft linebreak character (\r\r\n).
2556 * Take care to check if the text still fits the buffer after insertion.
2557 * If not, notify with EN_ERRSPACE.
2558 *
2560static BOOL EDIT_EM_FmtLines(EDITSTATE *es, BOOL add_eol)
2561{
2562 es->flags &= ~EF_USE_SOFTBRK;
2563 if (add_eol) {
2564 es->flags |= EF_USE_SOFTBRK;
2565 FIXME("soft break enabled, not implemented\n");
2566 }
2567 return add_eol;
2568}
2569
2570
2571/*********************************************************************
2572 *
2573 * EM_GETHANDLE
2574 *
2575 * Hopefully this won't fire back at us.
2576 * We always start with a fixed buffer in the local heap.
2577 * Despite of the documentation says that the local heap is used
2578 * only if DS_LOCALEDIT flag is set, NT and 2000 always allocate
2579 * buffer on the local heap.
2580 *
2583{
2584 HLOCAL hLocal;
2585
2586 if (!(es->style & ES_MULTILINE))
2587 return 0;
2588
2589 if(es->is_unicode)
2590 hLocal = es->hloc32W;
2591 else
2592 {
2593 if(!es->hloc32A)
2594 {
2595 CHAR *textA;
2596 UINT countA, alloc_size;
2597 TRACE("Allocating 32-bit ANSI alias buffer\n");
2598 countA = WideCharToMultiByte(CP_ACP, 0, es->text, -1, NULL, 0, NULL, NULL);
2599 alloc_size = ROUND_TO_GROW(countA);
2600 if(!(es->hloc32A = LocalAlloc(LMEM_MOVEABLE | LMEM_ZEROINIT, alloc_size)))
2601 {
2602 ERR("Could not allocate %d bytes for 32-bit ANSI alias buffer\n", alloc_size);
2603 return 0;
2604 }
2605 textA = LocalLock(es->hloc32A);
2606 WideCharToMultiByte(CP_ACP, 0, es->text, -1, textA, countA, NULL, NULL);
2607 LocalUnlock(es->hloc32A);
2608 }
2609 hLocal = es->hloc32A;
2610 }
2611
2613
2614 /* The text buffer handle belongs to the app */
2615 es->hlocapp = hLocal;
2616
2617 TRACE("Returning %p, LocalSize() = %Id\n", hLocal, LocalSize(hLocal));
2618 return hLocal;
2619}
2620
2621
2622/*********************************************************************
2623 *
2624 * EM_GETLINE
2625 *
2627static INT EDIT_EM_GetLine(EDITSTATE *es, INT line, LPWSTR dst, BOOL unicode)
2628{
2629 LPWSTR src;
2630 INT line_len, dst_len;
2631 INT i;
2632
2633 if (es->style & ES_MULTILINE) {
2634 if (line >= es->line_count)
2635 return 0;
2636 } else
2637 line = 0;
2639 src = es->text + i;
2640 line_len = EDIT_EM_LineLength(es, i);
2641 dst_len = *(WORD *)dst;
2642 if(unicode)
2643 {
2644 if(dst_len <= line_len)
2645 {
2646 memcpy(dst, src, dst_len * sizeof(WCHAR));
2647 return dst_len;
2648 }
2649 else /* Append 0 if enough space */
2650 {
2651 memcpy(dst, src, line_len * sizeof(WCHAR));
2652 dst[line_len] = 0;
2653 return line_len;
2654 }
2655 }
2656 else
2657 {
2658 INT ret = WideCharToMultiByte(CP_ACP, 0, src, line_len, (LPSTR)dst, dst_len, NULL, NULL);
2659 if(!ret && line_len) /* Insufficient buffer size */
2660 return dst_len;
2661 if(ret < dst_len) /* Append 0 if enough space */
2662 ((LPSTR)dst)[ret] = 0;
2663 return ret;
2664 }
2665}
2666
2667
2668/*********************************************************************
2669 *
2670 * EM_GETSEL
2671 *
2674{
2675 UINT s = es->selection_start;
2676 UINT e = es->selection_end;
2677
2678 ORDER_UINT(s, e);
2679 if (start)
2680 *start = s;
2681 if (end)
2682 *end = e;
2683 return MAKELONG(s, e);
2684}
2685
2686
2687/*********************************************************************
2688 *
2689 * EM_REPLACESEL
2690 *
2691 * FIXME: handle ES_NUMBER and ES_OEMCONVERT here
2692 *
2694static void EDIT_EM_ReplaceSel(EDITSTATE *es, BOOL can_undo, const WCHAR *lpsz_replace, UINT strl,
2695 BOOL send_update, BOOL honor_limit)
2696{
2697 UINT tl = get_text_length(es);
2698 UINT utl;
2699 UINT s;
2700 UINT e;
2701 UINT i;
2702 UINT size;
2703 LPWSTR p;
2704 HRGN hrgn = 0;
2705 LPWSTR buf = NULL;
2706 UINT bufl;
2707
2708 TRACE("%s, can_undo %d, send_update %d\n",
2709 debugstr_wn(lpsz_replace, strl), can_undo, send_update);
2710
2711 s = es->selection_start;
2712 e = es->selection_end;
2713
2715 if ((s == e) && !strl)
2716 return;
2717
2718 ORDER_UINT(s, e);
2719
2720 size = tl - (e - s) + strl;
2721 if (!size)
2722 es->text_width = 0;
2723
2724 /* Issue the EN_MAXTEXT notification and continue with replacing text
2725 * so that buffer limit is honored. */
2726 if ((honor_limit) && (size > es->buffer_limit))
2727 {
2728 if (!notify_parent(es, EN_MAXTEXT)) return;
2729 /* Buffer limit can be smaller than the actual length of text in combobox */
2730 if (es->buffer_limit < (tl - (e-s)))
2731 strl = 0;
2732 else
2733 strl = min(strl, es->buffer_limit - (tl - (e-s)));
2734 }
2735
2736 if (!EDIT_MakeFit(es, tl - (e - s) + strl))
2737 return;
2738
2739 if (e != s) {
2740 /* there is something to be deleted */
2741 TRACE("deleting stuff.\n");
2742 bufl = e - s;
2743 buf = HeapAlloc(GetProcessHeap(), 0, (bufl + 1) * sizeof(WCHAR));
2744 if (!buf) return;
2745 memcpy(buf, es->text + s, bufl * sizeof(WCHAR));
2746 buf[bufl] = 0; /* ensure 0 termination */
2747 /* now delete */
2748 lstrcpyW(es->text + s, es->text + e);
2750 }
2751 if (strl) {
2752 /* there is an insertion */
2753 tl = get_text_length(es);
2754 TRACE("inserting stuff (tl %d, strl %d, selstart %d (%s), text %s)\n", tl, strl, s, debugstr_w(es->text + s), debugstr_w(es->text));
2755 for (p = es->text + tl ; p >= es->text + s ; p--)
2756 p[strl] = p[0];
2757 for (i = 0 , p = es->text + s ; i < strl ; i++)
2758 p[i] = lpsz_replace[i];
2759 if(es->style & ES_UPPERCASE)
2760 CharUpperBuffW(p, strl);
2761 else if(es->style & ES_LOWERCASE)
2762 CharLowerBuffW(p, strl);
2764 }
2765 if (es->style & ES_MULTILINE)
2766 {
2767 INT st = min(es->selection_start, es->selection_end);
2769
2770 hrgn = CreateRectRgn(0, 0, 0, 0);
2771 EDIT_BuildLineDefs_ML(es, st, st + strl,
2772 strl - abs(es->selection_end - es->selection_start), hrgn);
2773 /* if text is too long undo all changes */
2774 if (honor_limit && !(es->style & ES_AUTOVSCROLL) && (es->line_count > vlc)) {
2775 if (strl)
2776 lstrcpyW(es->text + e, es->text + e + strl);
2777 if (e != s)
2778 for (i = 0 , p = es->text ; i < e - s ; i++)
2779 p[i + s] = buf[i];
2782 abs(es->selection_end - es->selection_start) - strl, hrgn);
2783 strl = 0;
2784 e = s;
2785 SetRectRgn(hrgn, 0, 0, 0, 0);
2786 if (!notify_parent(es, EN_MAXTEXT)) return;
2787 }
2788 }
2789 else {
2790 INT fw = es->format_rect.right - es->format_rect.left;
2793 /* remove chars that don't fit */
2794 if (honor_limit && !(es->style & ES_AUTOHSCROLL) && (es->text_width > fw)) {
2795 while ((es->text_width > fw) && s + strl >= s) {
2796 lstrcpyW(es->text + s + strl - 1, es->text + s + strl);
2797 strl--;
2798 es->text_length = -1;
2801 }
2803 if (!notify_parent(es, EN_MAXTEXT)) return;
2804 }
2805 }
2806
2807 if (e != s) {
2808 if (can_undo) {
2809 utl = lstrlenW(es->undo_text);
2810 if (!es->undo_insert_count && (*es->undo_text && (s == es->undo_position))) {
2811 /* undo-buffer is extended to the right */
2812 EDIT_MakeUndoFit(es, utl + e - s);
2813 memcpy(es->undo_text + utl, buf, (e - s)*sizeof(WCHAR));
2814 (es->undo_text + utl)[e - s] = 0; /* ensure 0 termination */
2815 } else if (!es->undo_insert_count && (*es->undo_text && (e == es->undo_position))) {
2816 /* undo-buffer is extended to the left */
2817 EDIT_MakeUndoFit(es, utl + e - s);
2818 for (p = es->undo_text + utl ; p >= es->undo_text ; p--)
2819 p[e - s] = p[0];
2820 for (i = 0 , p = es->undo_text ; i < e - s ; i++)
2821 p[i] = buf[i];
2822 es->undo_position = s;
2823 } else {
2824 /* new undo-buffer */
2825 EDIT_MakeUndoFit(es, e - s);
2826 memcpy(es->undo_text, buf, (e - s)*sizeof(WCHAR));
2827 es->undo_text[e - s] = 0; /* ensure 0 termination */
2828 es->undo_position = s;
2829 }
2830 /* any deletion makes the old insertion-undo invalid */
2831 es->undo_insert_count = 0;
2832 } else
2834 }
2835 if (strl) {
2836 if (can_undo) {
2837 if ((s == es->undo_position) ||
2838 ((es->undo_insert_count) &&
2839 (s == es->undo_position + es->undo_insert_count)))
2840 /*
2841 * insertion is new and at delete position or
2842 * an extension to either left or right
2843 */
2844 es->undo_insert_count += strl;
2845 else {
2846 /* new insertion undo */
2847 es->undo_position = s;
2848 es->undo_insert_count = strl;
2849 /* new insertion makes old delete-buffer invalid */
2850 *es->undo_text = '\0';
2851 }
2852 } else
2854 }
2855
2857
2858 s += strl;
2859
2860 /* If text has been deleted and we're right or center aligned then scroll rightward */
2861 if (es->style & (ES_RIGHT | ES_CENTER))
2862 {
2863 INT delta = strl - abs(es->selection_end - es->selection_start);
2864
2865 if (delta < 0 && es->x_offset)
2866 {
2867 if (abs(delta) > es->x_offset)
2868 es->x_offset = 0;
2869 else
2870 es->x_offset += delta;
2871 }
2872 }
2873
2875 es->flags |= EF_MODIFIED;
2876 if (send_update) es->flags |= EF_UPDATE;
2877 if (hrgn)
2878 {
2881 }
2882 else
2884
2886
2887 /* force scroll info update */
2889
2890
2891 if(send_update || (es->flags & EF_UPDATE))
2892 {
2893 es->flags &= ~EF_UPDATE;
2894 if (!notify_parent(es, EN_CHANGE)) return;
2895 }
2897}
2898
2899
2900/*********************************************************************
2901 *
2902 * EM_SETHANDLE
2903 *
2904 * FIXME: ES_LOWERCASE, ES_UPPERCASE, ES_OEMCONVERT, ES_NUMBER ???
2905 *
2907static void EDIT_EM_SetHandle(EDITSTATE *es, HLOCAL hloc)
2908{
2909 if (!(es->style & ES_MULTILINE))
2910 return;
2911
2912 if (!hloc) {
2913 WARN("called with NULL handle\n");
2914 return;
2915 }
2916
2917#ifdef __REACTOS__
2918 if (es->text)
2919#endif
2921
2922 if(es->is_unicode)
2923 {
2924 if(es->hloc32A)
2925 {
2926 LocalFree(es->hloc32A);
2927 es->hloc32A = NULL;
2928 }
2929 es->hloc32W = hloc;
2930 }
2931 else
2932 {
2933 INT countW, countA;
2934 HLOCAL hloc32W_new;
2935 WCHAR *textW;
2936 CHAR *textA;
2937
2938 countA = LocalSize(hloc);
2939 textA = LocalLock(hloc);
2940 countW = MultiByteToWideChar(CP_ACP, 0, textA, countA, NULL, 0);
2941 if(!(hloc32W_new = LocalAlloc(LMEM_MOVEABLE | LMEM_ZEROINIT, countW * sizeof(WCHAR))))
2942 {
2943 ERR("Could not allocate new unicode buffer\n");
2944 return;
2945 }
2946 textW = LocalLock(hloc32W_new);
2947 MultiByteToWideChar(CP_ACP, 0, textA, countA, textW, countW);
2948 LocalUnlock(hloc32W_new);
2949 LocalUnlock(hloc);
2950
2951 if(es->hloc32W)
2952 LocalFree(es->hloc32W);
2953
2954 es->hloc32W = hloc32W_new;
2955 es->hloc32A = hloc;
2956 }
2957
2958 es->buffer_size = LocalSize(es->hloc32W)/sizeof(WCHAR) - 1;
2959
2960 /* The text buffer handle belongs to the control */
2961 es->hlocapp = NULL;
2962
2965
2966 es->x_offset = es->y_offset = 0;
2967 es->selection_start = es->selection_end = 0;
2969 es->flags &= ~EF_MODIFIED;
2970 es->flags &= ~EF_UPDATE;
2974 /* force scroll info update */
2976}
2977
2978
2979/*********************************************************************
2980 *
2981 * EM_SETLIMITTEXT
2982 *
2983 * NOTE: this version currently implements WinNT limits
2984 *
2987{
2988 if (!limit) limit = ~0u;
2989 if (!(es->style & ES_MULTILINE)) limit = min(limit, 0x7ffffffe);
2990 es->buffer_limit = limit;
2991}
2993static BOOL is_cjk_charset(HDC dc)
2994{
2995 switch (GdiGetCodePage(dc)) {
2996 case 932: case 936: case 949: case 950: case 1361:
2997 return TRUE;
2998 default:
2999 return FALSE;
3000 }
3001}
3003static BOOL is_cjk_font(HDC dc)
3004{
3007 return (GetTextCharsetInfo(dc, &fs, 0) != DEFAULT_CHARSET &&
3008 (fs.fsCsb[0] & FS_DBCS_MASK));
3009}
3011static int get_cjk_fontinfo_margin(int width, int side_bearing)
3012{
3013 int margin;
3014 if (side_bearing < 0)
3015 margin = min(-side_bearing, width/2);
3016 else
3017 margin = 0;
3018 return margin;
3019}
3020
3021struct char_width_info {
3023};
3024
3025/* Undocumented gdi32 export */
3027
3028/*********************************************************************
3029 *
3030 * EM_SETMARGINS
3031 *
3032 * EC_USEFONTINFO is used as a left or right value i.e. lParam and not as an
3033 * action wParam despite what the docs say. EC_USEFONTINFO calculates the
3034 * margin according to the textmetrics of the current font.
3035 *
3036 * When EC_USEFONTINFO is used, the margins only change if the edit control is
3037 * equal to or larger than a certain size. The empty client rect is treated as
3038 * 80 pixels width.
3041 WORD left, WORD right, BOOL repaint)
3042{
3044 INT default_left_margin = 0; /* in pixels */
3045 INT default_right_margin = 0; /* in pixels */
3046
3047 /* Set the default margins depending on the font */
3048 if (es->font && (left == EC_USEFONTINFO || right == EC_USEFONTINFO)) {
3049 HDC dc = NtUserGetDC(es->hwndSelf);
3050 HFONT old_font = SelectObject(dc, es->font);
3051 LONG width = GdiGetCharDimensions(dc, &tm, NULL), rc_width;
3052 RECT rc;
3053
3054 /* The default margins are only non zero for TrueType or Vector fonts */
3055 if (tm.tmPitchAndFamily & ( TMPF_VECTOR | TMPF_TRUETYPE )) {
3056 struct char_width_info width_info;
3057
3058 if ((is_cjk_charset(dc) || is_cjk_font(dc)) &&
3059 GetCharWidthInfo(dc, &width_info))
3060 {
3061 default_left_margin = get_cjk_fontinfo_margin(width, width_info.min_lsb);
3062 default_right_margin = get_cjk_fontinfo_margin(width, width_info.min_rsb);
3063 }
3064 else
3065 {
3066 default_left_margin = width / 2;
3067 default_right_margin = width / 2;
3068 }
3069
3070 GetClientRect(es->hwndSelf, &rc);
3071 rc_width = !IsRectEmpty(&rc) ? rc.right - rc.left : 80;
3072 if (rc_width < default_left_margin + default_right_margin + width * 2) {
3073 default_left_margin = es->left_margin;
3074 default_right_margin = es->right_margin;
3075 }
3076 }
3077 SelectObject(dc, old_font);
3078 NtUserReleaseDC( es->hwndSelf, dc );
3079 }
3080
3081 if (action & EC_LEFTMARGIN) {
3082 es->format_rect.left -= es->left_margin;
3083 if (left != EC_USEFONTINFO)
3084 es->left_margin = left;
3085 else
3086 es->left_margin = default_left_margin;
3087 es->format_rect.left += es->left_margin;
3088 }
3089
3090 if (action & EC_RIGHTMARGIN) {
3091 es->format_rect.right += es->right_margin;
3092 if (right != EC_USEFONTINFO)
3093 es->right_margin = right;
3094 else
3095 es->right_margin = default_right_margin;
3096 es->format_rect.right -= es->right_margin;
3097 }
3098
3101 if (repaint) EDIT_UpdateText(es, NULL, TRUE);
3102 }
3103
3104 TRACE("left=%d, right=%d\n", es->left_margin, es->right_margin);
3105}
3106
3107
3108/*********************************************************************
3109 *
3110 * EM_SETPASSWORDCHAR
3111 *
3114{
3115 LONG style;
3116
3117 if (es->password_char == c)
3118 return TRUE;
3119
3120 style = GetWindowLongW( es->hwndSelf, GWL_STYLE );
3121 es->password_char = c;
3122 if (c) {
3123 SetWindowLongW( es->hwndSelf, GWL_STYLE, style | ES_PASSWORD );
3124 es->style |= ES_PASSWORD;
3125 } else {
3126 SetWindowLongW( es->hwndSelf, GWL_STYLE, style & ~ES_PASSWORD );
3127 es->style &= ~ES_PASSWORD;
3128 }
3131 return TRUE;
3132}
3133
3134
3135/*********************************************************************
3136 *
3137 * EM_SETTABSTOPS
3138 *
3140static BOOL EDIT_EM_SetTabStops(EDITSTATE *es, INT count, const INT *tabs)
3141{
3142 if (!(es->style & ES_MULTILINE))
3143 return FALSE;
3144 HeapFree(GetProcessHeap(), 0, es->tabs);
3145 es->tabs_count = count;
3146 if (!count)
3147 es->tabs = NULL;
3148 else {
3149 es->tabs = HeapAlloc(GetProcessHeap(), 0, count * sizeof(INT));
3150#ifdef __REACTOS__
3151 /* ReactOS r33503 */
3152 if (es->tabs == NULL)
3153 {
3154 es->tabs_count = 0;
3155 return FALSE;
3156 }
3157#endif
3158 memcpy(es->tabs, tabs, count * sizeof(INT));
3159 }
3161 return TRUE;
3162}
3163
3164
3165/*********************************************************************
3166 *
3167 * EM_SETWORDBREAKPROC
3168 *
3170static void EDIT_EM_SetWordBreakProc(EDITSTATE *es, void *wbp)
3171{
3172 if (es->word_break_proc == wbp)
3173 return;
3174
3175 es->word_break_proc = wbp;
3176
3177 if ((es->style & ES_MULTILINE) && !(es->style & ES_AUTOHSCROLL)) {
3180 }
3181}
3182
3183
3184/*********************************************************************
3185 *
3186 * EM_UNDO / WM_UNDO
3187 *
3190{
3191 INT ulength;
3192 LPWSTR utext;
3193
3194 /* As per MSDN spec, for a single-line edit control,
3195 the return value is always TRUE */
3196 if( es->style & ES_READONLY )
3197 return !(es->style & ES_MULTILINE);
3198
3199 ulength = lstrlenW(es->undo_text);
3200
3201 utext = HeapAlloc(GetProcessHeap(), 0, (ulength + 1) * sizeof(WCHAR));
3202#ifdef __REACTOS__
3203 /* ReactOS r33503 */
3204 if (utext == NULL)
3205 return FALSE;
3206#endif
3207
3208 lstrcpyW(utext, es->undo_text);
3209
3210 TRACE("before UNDO:insertion length = %d, deletion buffer = %s\n",
3211 es->undo_insert_count, debugstr_w(utext));
3212
3213 EDIT_EM_SetSel(es, es->undo_position, es->undo_position + es->undo_insert_count, FALSE);
3215 EDIT_EM_ReplaceSel(es, TRUE, utext, ulength, TRUE, TRUE);
3216 EDIT_EM_SetSel(es, es->undo_position, es->undo_position + es->undo_insert_count, FALSE);
3217 /* send the notification after the selection start and end are set */
3218 if (!notify_parent(es, EN_CHANGE)) return TRUE;
3220 HeapFree(GetProcessHeap(), 0, utext);
3221
3222 TRACE("after UNDO:insertion length = %d, deletion buffer = %s\n",
3223 es->undo_insert_count, debugstr_w(es->undo_text));
3224 return TRUE;
3225}
3226
3227
3228/* Helper function for WM_CHAR
3229 *
3230 * According to an MSDN blog article titled "Just because you're a control
3231 * doesn't mean that you're necessarily inside a dialog box," multiline edit
3232 * controls without ES_WANTRETURN would attempt to detect whether it is inside
3233 * a dialog box or not.
3235static inline BOOL EDIT_IsInsideDialog(EDITSTATE *es)
3236{
3237 return (es->flags & EF_DIALOGMODE);
3238}
3239
3240
3241/*********************************************************************
3242 *
3243 * WM_PASTE
3244 *
3246static void EDIT_WM_Paste(EDITSTATE *es)
3247{
3248 HGLOBAL hsrc;
3249 LPWSTR src, ptr;
3250 int len;
3251
3252 /* Protect read-only edit control from modification */
3253 if(es->style & ES_READONLY)
3254 return;
3255
3256 OpenClipboard(es->hwndSelf);
3257 if ((hsrc = GetClipboardData(CF_UNICODETEXT))) {
3258 src = GlobalLock(hsrc);
3259 len = lstrlenW(src);
3260 /* Protect single-line edit against pasting new line character */
3261 if (!(es->style & ES_MULTILINE) && ((ptr = wcschr(src, '\n')))) {
3262 len = ptr - src;
3263 if (len && src[len - 1] == '\r')
3264 --len;
3265 }
3267 GlobalUnlock(hsrc);
3268 }
3269 else if (es->style & ES_PASSWORD) {
3270 /* clear selected text in password edit box even with empty clipboard */
3272 }
3274}
3275
3276
3277/*********************************************************************
3278 *
3279 * WM_COPY
3280 *
3282static void EDIT_WM_Copy(EDITSTATE *es)
3283{
3284 INT s = min(es->selection_start, es->selection_end);
3285 INT e = max(es->selection_start, es->selection_end);
3286 HGLOBAL hdst;
3287 LPWSTR dst;
3288 DWORD len;
3289
3290 if (e == s) return;
3291
3292 len = e - s;
3293 hdst = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, (len + 1) * sizeof(WCHAR));
3294 dst = GlobalLock(hdst);
3295 memcpy(dst, es->text + s, len * sizeof(WCHAR));
3296 dst[len] = 0; /* ensure 0 termination */
3297 TRACE("%s\n", debugstr_w(dst));
3298 GlobalUnlock(hdst);
3299 OpenClipboard(es->hwndSelf);
3303}
3304
3305
3306/*********************************************************************
3307 *
3308 * WM_CLEAR
3309 *
3311static inline void EDIT_WM_Clear(EDITSTATE *es)
3312{
3313 /* Protect read-only edit control from modification */
3314 if(es->style & ES_READONLY)
3315 return;
3316
3318}
3319
3320
3321/*********************************************************************
3322 *
3323 * WM_CUT
3324 *
3326static inline void EDIT_WM_Cut(EDITSTATE *es)
3327{
3330}
3331
3332
3333/*********************************************************************
3334 *
3335 * WM_CHAR
3336 *
3339{
3340 BOOL control;
3341
3342
3343 if (es->bCaptureState)
3344 return 1;
3345
3347
3348 switch (c) {
3349 case '\r':
3350 /* If it's not a multiline edit box, it would be ignored below.
3351 * For multiline edit without ES_WANTRETURN, we have to make a
3352 * special case.
3353 */
3354 if ((es->style & ES_MULTILINE) && !(es->style & ES_WANTRETURN))
3356 break;
3357 case '\n':
3358 if (es->style & ES_MULTILINE) {
3359 if (es->style & ES_READONLY) {
3362 } else {
3363 EDIT_EM_ReplaceSel(es, TRUE, L"\r\n", 2, TRUE, TRUE);
3364 }
3365 }
3366 break;
3367 case '\t':
3368 if ((es->style & ES_MULTILINE) && !(es->style & ES_READONLY))
3369 {
3371 break;
3372 EDIT_EM_ReplaceSel(es, TRUE, L"\t", 1, TRUE, TRUE);
3373 }
3374 break;
3375 case VK_BACK:
3376 if (!(es->style & ES_READONLY) && !control) {
3377 if (es->selection_start != es->selection_end)
3379 else {
3380 /* delete character left of caret */
3381 EDIT_EM_SetSel(es, (UINT)-1, 0, FALSE);
3384 }
3385 }
3386 break;
3387 case 0x03: /* ^C */
3388 if (!(es->style & ES_PASSWORD))
3389 SendMessageW(es->hwndSelf, WM_COPY, 0, 0);
3390 break;
3391 case 0x16: /* ^V */
3392 if (!(es->style & ES_READONLY))
3393 SendMessageW(es->hwndSelf, WM_PASTE, 0, 0);
3394 break;
3395 case 0x18: /* ^X */
3396 if (!((es->style & ES_READONLY) || (es->style & ES_PASSWORD)))
3397 SendMessageW(es->hwndSelf, WM_CUT, 0, 0);
3398 break;
3399 case 0x1A: /* ^Z */
3400 if (!(es->style & ES_READONLY))
3401 SendMessageW(es->hwndSelf, WM_UNDO, 0, 0);
3402 break;
3403
3404 default:
3405 /*If Edit control style is ES_NUMBER allow users to key in only numeric values*/
3406 if( (es->style & ES_NUMBER) && !( c >= '0' && c <= '9') )
3407 break;
3408
3409 if (!(es->style & ES_READONLY) && (c >= ' ') && (c != 127))
3411 break;
3412 }
3413 return 1;
3414}
3415
3416
3417/*********************************************************************
3418 *
3419 * EDIT_ContextMenuCommand
3420 *
3422static void EDIT_ContextMenuCommand(EDITSTATE *es, UINT id)
3423{
3424 switch (id) {
3425 case EM_UNDO:
3426 SendMessageW(es->hwndSelf, WM_UNDO, 0, 0);
3427 break;
3428 case WM_CUT:
3429 SendMessageW(es->hwndSelf, WM_CUT, 0, 0);
3430 break;
3431 case WM_COPY:
3432 SendMessageW(es->hwndSelf, WM_COPY, 0, 0);
3433 break;
3434 case WM_PASTE:
3435 SendMessageW(es->hwndSelf, WM_PASTE, 0, 0);
3436 break;
3437 case WM_CLEAR:
3438 SendMessageW(es->hwndSelf, WM_CLEAR, 0, 0);
3439 break;
3440 case EM_SETSEL:
3441 SendMessageW(es->hwndSelf, EM_SETSEL, 0, -1);
3442 break;
3443 default:
3444 ERR("unknown menu item, please report\n");
3445 break;
3446 }
3447}
3448
3449
3450/*********************************************************************
3451 *
3452 * WM_CONTEXTMENU
3453 *
3454 * Note: the resource files resource/sysres_??.rc cannot define a
3455 * single popup menu. Hence we use a (dummy) menubar
3456 * containing the single popup menu as its first item.
3457 *
3458 * FIXME: the message identifiers have been chosen arbitrarily,
3459 * hence we use MF_BYPOSITION.
3460 * We might as well use the "real" values (anybody knows ?)
3461 * The menu definition is in resources/sysres_??.rc.
3462 * Once these are OK, we better use MF_BYCOMMAND here
3463 * (as we do in EDIT_WM_Command()).
3464 *
3466static void EDIT_WM_ContextMenu(EDITSTATE *es, INT x, INT y)
3467{
3468 HMENU menu = LoadMenuA(user32_module, "EDITMENU");
3469 HMENU popup = GetSubMenu(menu, 0);
3470 UINT start = es->selection_start;
3471 UINT end = es->selection_end;
3472 BOOL enabled;
3473 UINT cmd;
3474
3476
3477 /* undo */
3478 enabled = EDIT_EM_CanUndo(es) && !(es->style & ES_READONLY);
3480 /* cut */
3481 enabled = (end - start) && !(es->style & ES_PASSWORD) && !(es->style & ES_READONLY);
3483 /* copy */
3484 enabled = (end - start) && !(es->style & ES_PASSWORD);
3486 /* paste */
3489 /* delete */
3490 enabled = (end - start) && !(es->style & ES_READONLY);
3492 /* select all */
3495
3496 if (x == -1 && y == -1) /* passed via VK_APPS press/release */
3497 {
3498#ifdef __REACTOS__ /* Should be dropped */
3499 RECT rc;
3500
3501 /* ReactOS r29811 */
3502 GetClientRect(es->hwndSelf, &rc);
3503 MapWindowPoints(es->hwndSelf, 0, (POINT *)&rc, 2);
3504 x = rc.left + (rc.right - rc.left) / 2;
3505 y = rc.top + (rc.bottom - rc.top) / 2;
3506#else
3507 POINT pt;
3508 RECT rc;
3509
3510 /* Windows places the menu at the edit's center in this case */
3511 GetClientRect( es->hwndSelf, &rc );
3512 pt.x = rc.right / 2;
3513 pt.y = rc.bottom / 2;
3514 ClientToScreen( es->hwndSelf, &pt );
3515 x = pt.x;
3516 y = pt.y;
3517#endif
3518 }
3519
3520 if (!(es->flags & EF_FOCUSED))
3521 NtUserSetFocus(es->hwndSelf);
3522
3524 x, y, 0, es->hwndSelf, NULL);
3525
3526 if (cmd)
3528
3530}
3531
3532
3533/*********************************************************************
3534 *
3535 * WM_GETTEXT
3536 *
3538static INT EDIT_WM_GetText(const EDITSTATE *es, INT count, LPWSTR dst, BOOL unicode)
3539{
3540 if(!count) return 0;
3541
3542 if(unicode)
3543 {
3544 lstrcpynW(dst, es->text, count);
3545 return lstrlenW(dst);
3546 }
3547 else
3548 {
3549 LPSTR textA = (LPSTR)dst;
3550 if (!WideCharToMultiByte(CP_ACP, 0, es->text, -1, textA, count, NULL, NULL))
3551 textA[count - 1] = 0; /* ensure 0 termination */
3552 return strlen(textA);
3553 }
3554}
3555
3556/*********************************************************************
3557 *
3558 * EDIT_CheckCombo
3559 *
3562{
3563 HWND hLBox = es->hwndListBox;
3564 HWND hCombo;
3565 BOOL bDropped;
3566 int nEUI;
3567
3568 if (!hLBox)
3569 return FALSE;
3570
3571 hCombo = GetParent(es->hwndSelf);
3572 bDropped = TRUE;
3573 nEUI = 0;
3574
3575 TRACE_(combo)("[%p]: handling msg %x (%x)\n", es->hwndSelf, msg, key);
3576
3577 if (key == VK_UP || key == VK_DOWN)
3578 {
3579 if (SendMessageW(hCombo, CB_GETEXTENDEDUI, 0, 0))
3580 nEUI = 1;
3581
3582 if (msg == WM_KEYDOWN || nEUI)
3583 bDropped = (BOOL)SendMessageW(hCombo, CB_GETDROPPEDSTATE, 0, 0);
3584 }
3585
3586 switch (msg)
3587 {
3588 case WM_KEYDOWN:
3589 if (!bDropped && nEUI && (key == VK_UP || key == VK_DOWN))
3590 {
3591 /* make sure ComboLBox pops up */
3592 SendMessageW(hCombo, CB_SETEXTENDEDUI, FALSE, 0);
3593 key = VK_F4;
3594 nEUI = 2;
3595 }
3596
3597 SendMessageW(hLBox, WM_KEYDOWN, key, 0);
3598 break;
3599
3600 case WM_SYSKEYDOWN: /* Handle Alt+up/down arrows */
3601 if (nEUI)
3602 SendMessageW(hCombo, CB_SHOWDROPDOWN, !bDropped, 0);
3603 else
3604 SendMessageW(hLBox, WM_KEYDOWN, VK_F4, 0);
3605 break;
3606 }
3607
3608 if(nEUI == 2)
3609 SendMessageW(hCombo, CB_SETEXTENDEDUI, TRUE, 0);
3610
3611 return TRUE;
3612}
3613
3614
3615/*********************************************************************
3616 *
3617 * WM_KEYDOWN
3618 *
3619 * Handling of special keys that don't produce a WM_CHAR
3620 * (i.e. non-printable keys) & Backspace & Delete
3621 *
3624{
3625 BOOL shift;
3626 BOOL control;
3627
3628 if (es->bCaptureState)
3629 return 1;
3630
3631 if (NtUserGetKeyState(VK_MENU) & 0x8000)
3632 return 0;
3633
3634 shift = NtUserGetKeyState(VK_SHIFT) & 0x8000;
3636
3637 switch (key) {
3638 case VK_F4:
3639 case VK_UP:
3641 break;
3642
3643 /* fall through */
3644 case VK_LEFT:
3645 if ((es->style & ES_MULTILINE) && (key == VK_UP))
3647 else
3648 if (control)
3650 else
3652 break;
3653 case VK_DOWN:
3655 break;
3656 /* fall through */
3657 case VK_RIGHT:
3658 if ((es->style & ES_MULTILINE) && (key == VK_DOWN))
3660 else if (control)
3662 else
3664 break;
3665 case VK_HOME:
3667 break;
3668 case VK_END:
3670 break;
3671 case VK_PRIOR:
3672 if (es->style & ES_MULTILINE)
3674 else
3676 break;
3677 case VK_NEXT:
3678 if (es->style & ES_MULTILINE)
3680 else
3682 break;
3683 case VK_DELETE:
3684 if (!(es->style & ES_READONLY) && !(shift && control)) {
3685 if (es->selection_start != es->selection_end) {
3686 if (shift)
3687 EDIT_WM_Cut(es);
3688 else
3690 } else {
3691 EDIT_EM_SetSel(es, ~0u, 0, FALSE);
3692 if (shift)
3693 /* delete character left of caret */
3695 else if (control)
3696 /* delete to end of line */
3698 else
3699 /* delete character right of caret */
3702 }
3703 }
3704 break;
3705 case VK_INSERT:
3706 if (shift) {
3707 if (!(es->style & ES_READONLY))
3709 } else if (control)
3711 break;
3712 case VK_RETURN:
3713 /* If the edit doesn't want the return send a message to the default object */
3714 if(!(es->style & ES_MULTILINE) || !(es->style & ES_WANTRETURN))
3715 {
3716 DWORD dw;
3717
3718 if (!EDIT_IsInsideDialog(es)) break;
3719 if (control) break;
3720 dw = SendMessageW(es->hwndParent, DM_GETDEFID, 0, 0);
3721 if (HIWORD(dw) == DC_HASDEFID)
3722 {
3723 HWND hwDefCtrl = GetDlgItem(es->hwndParent, LOWORD(dw));
3724 if (hwDefCtrl)
3725 {
3726 SendMessageW(es->hwndParent, WM_NEXTDLGCTL, (WPARAM)hwDefCtrl, TRUE);
3727 PostMessageW(hwDefCtrl, WM_KEYDOWN, VK_RETURN, 0);
3728 }
3729 }
3730 }
3731 break;
3732 case VK_ESCAPE:
3733 if ((es->style & ES_MULTILINE) && EDIT_IsInsideDialog(es))
3734 PostMessageW(es->hwndParent, WM_CLOSE, 0, 0);
3735 break;
3736 case VK_TAB:
3737 if ((es->style & ES_MULTILINE) && EDIT_IsInsideDialog(es))
3738 SendMessageW(es->hwndParent, WM_NEXTDLGCTL, shift, 0);
3739 break;
3740#ifdef __REACTOS__
3741 /* ReactOS CORE-1419 */
3742 case VK_BACK:
3743 if (control)
3744 {
3745 FIXME("Ctrl+Backspace\n");
3746 }
3747 break;
3748#endif
3749 }
3750 return TRUE;
3751}
3752
3753
3754/*********************************************************************
3755 *
3756 * WM_KILLFOCUS
3757 *
3760{
3761#ifdef __REACTOS__
3762 HWND hCombo;
3763 LONG lStyles;
3764
3765 es->flags &= ~EF_FOCUSED;
3766 DestroyCaret();
3767 if(!(es->style & ES_NOHIDESEL))
3768 EDIT_InvalidateText(es, es->selection_start, es->selection_end);
3769
3770 /* throw away left over scroll when we lose focus */
3771 es->wheelDeltaRemainder = 0;
3772
3773 if (es->hwndListBox == NULL) {
3774 if (!notify_parent(es, EN_KILLFOCUS)) return 0;
3775 } else
3776 { /* send the undocumented WM_CBLOSTTEXTFOCUS message to combobox */
3777 hCombo = GetParent(es->hwndSelf);
3778 lStyles = GetWindowLong(hCombo, GWL_STYLE);
3779 if ((lStyles & CBS_DROPDOWN) || (lStyles & CBS_SIMPLE))
3780 SendMessage(hCombo, WM_CBLOSTTEXTFOCUS, 0, 0);
3781 }
3782#else
3783 es->flags &= ~EF_FOCUSED;
3784 NtUserDestroyCaret();
3785 if(!(es->style & ES_NOHIDESEL))
3786 EDIT_InvalidateText(es, es->selection_start, es->selection_end);
3787 if (!notify_parent(es, EN_KILLFOCUS)) return 0;
3788 /* throw away left over scroll when we lose focus */
3789 es->wheelDeltaRemainder = 0;
3790#endif
3791 return 0;
3792}
3793
3794
3795/*********************************************************************
3796 *
3797 * WM_LBUTTONDBLCLK
3798 *
3799 * The caret position has been set on the WM_LBUTTONDOWN message
3800 *
3803{
3804 INT s;
3805 INT e = es->selection_end;
3806 INT l;
3807 INT li;
3808 INT ll;
3809
3810 es->bCaptureState = TRUE;
3811 NtUserSetCapture(es->hwndSelf);
3812
3820 return 0;
3821}
3822
3823
3824/*********************************************************************
3825 *
3826 * WM_LBUTTONDOWN
3827 *
3830{
3831 INT e;
3832 BOOL after_wrap;
3833
3834 es->bCaptureState = TRUE;
3835 NtUserSetCapture(es->hwndSelf);
3836 EDIT_ConfinePoint(es, &x, &y);
3837 e = EDIT_CharFromPos(es, x, y, &after_wrap);
3838 EDIT_EM_SetSel(es, (keys & MK_SHIFT) ? es->selection_start : e, e, after_wrap);
3840 if (!(es->flags & EF_FOCUSED))
3841 NtUserSetFocus(es->hwndSelf);
3842
3843 return 0;
3844}
3845
3846
3847/*********************************************************************
3848 *
3849 * WM_LBUTTONUP
3850 *
3853{
3854 if (es->bCaptureState) {
3855 if (GetCapture() == es->hwndSelf) NtUserReleaseCapture();
3856 }
3857 es->bCaptureState = FALSE;
3858 return 0;
3859}
3860
3861
3862/*********************************************************************
3863 *
3864 * WM_MBUTTONDOWN
3865 *
3868{
3869 SendMessageW(es->hwndSelf, WM_PASTE, 0, 0);
3870 return 0;
3871}
3872
3873
3874/*********************************************************************
3875 *
3876 * WM_MOUSEMOVE
3877 *
3880{
3881 INT e;
3882 BOOL after_wrap;
3883
3884 /* If the mouse has been captured by process other than the edit control itself,
3885 * the windows edit controls will not select the strings with mouse move.
3886 */
3887 if (!es->bCaptureState || GetCapture() != es->hwndSelf)
3888 return 0;
3889
3890 e = EDIT_CharFromPos(es, x, y, &after_wrap);
3891 EDIT_EM_SetSel(es, es->selection_start, e, after_wrap);
3892 EDIT_SetCaretPos(es,es->selection_end,es->flags & EF_AFTER_WRAP);
3894 return 0;
3895}
3896
3897
3898/*********************************************************************
3899 *
3900 * WM_PAINT
3901 *
3903static void EDIT_WM_Paint(EDITSTATE *es, HDC hdc)
3904{
3905 PAINTSTRUCT ps;
3906 INT i;
3907 HDC dc;
3908 HFONT old_font = 0;
3909 RECT rc;
3910 RECT rcClient;
3911 RECT rcLine;
3912 RECT rcRgn;
3913 HBRUSH brush;
3914 HBRUSH old_brush;
3915 INT bw, bh;
3916 BOOL rev = es->bEnableState &&
3917 ((es->flags & EF_FOCUSED) ||
3918 (es->style & ES_NOHIDESEL));
3919 dc = hdc ? hdc : NtUserBeginPaint( es->hwndSelf, &ps );
3920
3921 /* The dc we use for calculating may not be the one we paint into.
3922 This is the safest action. */
3924 GetClientRect(es->hwndSelf, &rcClient);
3925
3926 /* get the background brush */
3927 brush = EDIT_NotifyCtlColor(es, dc);
3928
3929 /* paint the border and the background */
3930 IntersectClipRect(dc, rcClient.left, rcClient.top, rcClient.right, rcClient.bottom);
3931
3932 if(es->style & WS_BORDER) {
3935 rc = rcClient;
3936 if(es->style & ES_MULTILINE) {
3937 if(es->style & WS_HSCROLL) rc.bottom+=bh;
3938 if(es->style & WS_VSCROLL) rc.right+=bw;
3939 }
3940
3941 /* Draw the frame. Same code as in nonclient.c */
3943 PatBlt(dc, rc.left, rc.top, rc.right - rc.left, bh, PATCOPY);
3944 PatBlt(dc, rc.left, rc.top, bw, rc.bottom - rc.top, PATCOPY);
3945 PatBlt(dc, rc.left, rc.bottom - 1, rc.right - rc.left, -bw, PATCOPY);
3946 PatBlt(dc, rc.right - 1, rc.top, -bw, rc.bottom - rc.top, PATCOPY);
3947 SelectObject(dc, old_brush);
3948
3949 /* Keep the border clean */
3950 IntersectClipRect(dc, rc.left+bw, rc.top+bh,
3951 max(rc.right-bw, rc.left+bw), max(rc.bottom-bh, rc.top+bh));
3952 }
3953
3954 GetClipBox(dc, &rc);
3955 FillRect(dc, &rc, brush);
3956
3957 IntersectClipRect(dc, es->format_rect.left,
3958 es->format_rect.top,
3959 es->format_rect.right,
3960 es->format_rect.bottom);
3961 if (es->style & ES_MULTILINE) {
3962 rc = rcClient;
3963 IntersectClipRect(dc, rc.left, rc.top, rc.right, rc.bottom);
3964 }
3965 if (es->font)
3966 old_font = SelectObject(dc, es->font);
3967
3968 if (!es->bEnableState)
3970 GetClipBox(dc, &rcRgn);
3971 if (es->style & ES_MULTILINE) {
3973 for (i = es->y_offset ; i <= min(es->y_offset + vlc, es->y_offset + es->line_count - 1) ; i++) {
3975 EDIT_GetLineRect(es, i, 0, -1, &rcLine);
3976 if (IntersectRect(&rc, &rcRgn, &rcLine))
3977 EDIT_PaintLine(es, dc, i, rev);
3978 }
3979 } else {
3981 EDIT_GetLineRect(es, 0, 0, -1, &rcLine);
3982 if (IntersectRect(&rc, &rcRgn, &rcLine))
3983 EDIT_PaintLine(es, dc, 0, rev);
3984 }
3985 if (es->font)
3986 SelectObject(dc, old_font);
3987
3988 if (!hdc)
3989 NtUserEndPaint( es->hwndSelf, &ps );
3990}
3991
3992
3993/*********************************************************************
3994 *
3995 * WM_SETFOCUS
3996 *
3998static void EDIT_WM_SetFocus(EDITSTATE *es)
3999{
4000 es->flags |= EF_FOCUSED;
4001
4002 if (!(es->style & ES_NOHIDESEL))
4003 EDIT_InvalidateText(es, es->selection_start, es->selection_end);
4004
4005 /* single line edit updates itself */
4006 if (IsWindowVisible(es->hwndSelf) && !(es->style & ES_MULTILINE))
4007 {
4008 HDC hdc = NtUserGetDC(es->hwndSelf);
4010 NtUserReleaseDC( es->hwndSelf, hdc );
4011 }
4012
4013#ifdef __REACTOS__
4014 SystemParametersInfo(SPI_GETCARETWIDTH, 0, &es->dwCaretWidth, 0);
4015 CreateCaret(es->hwndSelf, NULL, es->dwCaretWidth, es->line_height);
4016#else
4017 NtUserCreateCaret( es->hwndSelf, 0, 1, es->line_height );
4018#endif
4019 EDIT_SetCaretPos(es, es->selection_end,
4020 es->flags & EF_AFTER_WRAP);
4021 NtUserShowCaret( es->hwndSelf );
4023}
4025static DWORD get_font_margins(HDC hdc, const TEXTMETRICW *tm, BOOL unicode)
4026{
4027 ABC abc[256];
4028 SHORT left, right;
4029 UINT i;
4030
4031 if (!(tm->tmPitchAndFamily & (TMPF_VECTOR | TMPF_TRUETYPE)))
4033
4034 if (unicode) {
4035 if (!is_cjk_charset(hdc) && !is_cjk_font(hdc))
4037 if (!GetCharABCWidthsW(hdc, 0, 255, abc))
4038 return 0;
4039 }
4040 else if (is_cjk_charset(hdc)) {
4041 if (!GetCharABCWidthsA(hdc, 0, 255, abc))
4042 return 0;
4043 }
4044 else
4046
4047 left = right = 0;
4048 for (i = 0; i < ARRAY_SIZE(abc); i++) {
4049 if (-abc[i].abcA > right) right = -abc[i].abcA;
4050 if (-abc[i].abcC > left ) left = -abc[i].abcC;
4051 }
4052 return MAKELONG(left, right);
4053}
4054
4055#ifndef __REACTOS__
4057{
4058 LOGFONTW composition_font;
4059 HIMC himc = ImmGetContext(es->hwndSelf);
4060 GetObjectW(es->font, sizeof(LOGFONTW), &composition_font);
4061 ImmSetCompositionFontW(himc, &composition_font);
4062 ImmReleaseContext(es->hwndSelf, himc);
4063}
4064#endif
4065
4066/*********************************************************************
4067 *
4068 * WM_SETFONT
4069 *
4070 * With Win95 look the margins are set to default font value unless
4071 * the system font (font == 0) is being set, in which case they are left
4072 * unchanged.
4073 *
4075static void EDIT_WM_SetFont(EDITSTATE *es, HFONT font, BOOL redraw)
4076{
4078 HDC dc;
4079 HFONT old_font = 0;
4080 RECT clientRect;
4081 DWORD margins;
4082
4083 es->font = font;
4085 dc = NtUserGetDC(es->hwndSelf);
4086 if (font)
4087 old_font = SelectObject(dc, font);
4089 es->line_height = tm.tmHeight;
4090 es->char_width = tm.tmAveCharWidth;
4091 margins = get_font_margins(dc, &tm, es->is_unicode);
4092 if (font)
4093 SelectObject(dc, old_font);
4094 NtUserReleaseDC( es->hwndSelf, dc );
4095
4096 /* Reset the format rect and the margins */
4097 GetClientRect(es->hwndSelf, &clientRect);
4098 EDIT_SetRectNP(es, &clientRect);
4099 if (margins)
4102
4103 if (es->style & ES_MULTILINE)
4105 else
4107
4108 if (redraw)
4110 if (es->flags & EF_FOCUSED) {
4111 DestroyCaret();
4112#ifdef __REACTOS__
4113 CreateCaret(es->hwndSelf, NULL, es->dwCaretWidth, es->line_height);
4114#else
4115 NtUserCreateCaret( es->hwndSelf, 0, 1, es->line_height );
4116#endif
4117 EDIT_SetCaretPos(es, es->selection_end,
4118 es->flags & EF_AFTER_WRAP);
4119 NtUserShowCaret( es->hwndSelf );
4120 }
4121
4122#ifdef __REACTOS__
4124 {
4125 LOGFONTW lf;
4126 HIMC hIMC = ImmGetContext(es->hwndSelf);
4127 if (font == NULL)
4129 GetObjectW(font, sizeof(lf), &lf);
4130 ImmSetCompositionFontW(hIMC, &lf);
4131 ImmReleaseContext(es->hwndSelf, hIMC);
4132 }
4133#else
4135#endif
4136}
4137
4138
4139/*********************************************************************
4140 *
4141 * WM_SETTEXT
4142 *
4143 * NOTES
4144 * For multiline controls (ES_MULTILINE), reception of WM_SETTEXT triggers:
4145 * The modified flag is reset. No notifications are sent.
4146 *
4147 * For single-line controls, reception of WM_SETTEXT triggers:
4148 * The modified flag is reset. EN_UPDATE and EN_CHANGE notifications are sent.
4149 *
4151static void EDIT_WM_SetText(EDITSTATE *es, LPCWSTR text, BOOL unicode)
4152{
4153 LPWSTR textW = NULL;
4154 if (!unicode && text)
4155 {
4157 INT countW = MultiByteToWideChar(CP_ACP, 0, textA, -1, NULL, 0);
4158 textW = HeapAlloc(GetProcessHeap(), 0, countW * sizeof(WCHAR));
4159 if (textW)
4160 MultiByteToWideChar(CP_ACP, 0, textA, -1, textW, countW);
4161 text = textW;
4162 }
4163
4164 if (es->flags & EF_UPDATE)
4165 /* fixed this bug once; complain if we see it about to happen again. */
4166 ERR("SetSel may generate UPDATE message whose handler may reset "
4167 "selection.\n");
4168
4169 EDIT_EM_SetSel(es, 0, (UINT)-1, FALSE);
4170 if (text)
4171 {
4172 TRACE("%s\n", debugstr_w(text));
4174 if(!unicode)
4176 }
4177 else
4178 {
4179 TRACE("<NULL>\n");
4181 }
4182 es->x_offset = 0;
4183 es->flags &= ~EF_MODIFIED;
4184 EDIT_EM_SetSel(es, 0, 0, FALSE);
4185
4186 /* Send the notification after the selection start and end have been set
4187 * edit control doesn't send notification on WM_SETTEXT
4188 * if it is multiline, or it is part of combobox
4189 */
4190 if( !((es->style & ES_MULTILINE) || es->hwndListBox))
4191 {
4192 if (!notify_parent(es, EN_UPDATE)) return;
4193 if (!notify_parent(es, EN_CHANGE)) return;
4194 }
4198}
4199
4200
4201/*********************************************************************
4202 *
4203 * WM_SIZE
4204 *
4206static void EDIT_WM_Size(EDITSTATE *es, UINT action)
4207{
4208 if ((action == SIZE_MAXIMIZED) || (action == SIZE_RESTORED)) {
4209 RECT rc;
4210 GetClientRect(es->hwndSelf, &rc);
4211 EDIT_SetRectNP(es, &rc);
4213 }
4214}
4215
4216
4217/*********************************************************************
4218 *
4219 * WM_STYLECHANGED
4220 *
4221 * This message is sent by SetWindowLong on having changed either the Style
4222 * or the extended style.
4223 *
4224 * We ensure that the window's version of the styles and the EDITSTATE's agree.
4225 *
4226 * See also EDIT_WM_NCCreate
4227 *
4228 * It appears that the Windows version of the edit control allows the style
4229 * (as retrieved by GetWindowLong) to be any value and maintains an internal
4230 * style variable which will generally be different. In this function we
4231 * update the internal style based on what changed in the externally visible
4232 * style.
4233 *
4234 * Much of this content as based upon the MSDN, especially:
4235 * Platform SDK Documentation -> User Interface Services ->
4236 * Windows User Interface -> Edit Controls -> Edit Control Reference ->
4237 * Edit Control Styles
4240{
4241 if (GWL_STYLE == which) {
4242 DWORD style_change_mask;
4243 DWORD new_style;
4244 /* Only a subset of changes can be applied after the control
4245 * has been created.
4246 */
4247#ifdef __REACTOS__
4248 style_change_mask = ES_UPPERCASE | ES_LOWERCASE |
4250#else
4251 style_change_mask = ES_UPPERCASE | ES_LOWERCASE |
4252 ES_NUMBER;
4253#endif
4254 if (es->style & ES_MULTILINE)
4255 style_change_mask |= ES_WANTRETURN;
4256
4257 new_style = style->styleNew & style_change_mask;
4258
4259 /* Number overrides lowercase overrides uppercase (at least it
4260 * does in Win95). However I'll bet that ES_NUMBER would be
4261 * invalid under Win 3.1.
4262 */
4263 if (new_style & ES_NUMBER) {
4264 ; /* do not override the ES_NUMBER */
4265 } else if (new_style & ES_LOWERCASE) {
4266 new_style &= ~ES_UPPERCASE;
4267 }
4268
4269 es->style = (es->style & ~style_change_mask) | new_style;
4270 } else if (GWL_EXSTYLE == which) {
4271 ; /* FIXME - what is needed here */
4272 } else {
4273 WARN ("Invalid style change %Id\n",which);
4274 }
4275
4276 return 0;
4277}
4278
4279/*********************************************************************
4280 *
4281 * WM_SYSKEYDOWN
4282 *
4285{
4286 if ((key == VK_BACK) && (key_data & 0x2000)) {
4287 if (EDIT_EM_CanUndo(es))
4289 return 0;
4290 } else if (key == VK_UP || key == VK_DOWN) {
4292 return 0;
4293 }
4294 return DefWindowProcW(es->hwndSelf, WM_SYSKEYDOWN, key, key_data);
4295}
4296
4297/*********************************************************************
4298 *
4299 * WM_HSCROLL
4300 *
4303{
4304 INT dx;
4305 INT fw;
4306
4307 if (!(es->style & ES_MULTILINE))
4308 return 0;
4309
4310 if (!(es->style & ES_AUTOHSCROLL))
4311 return 0;
4312
4313 dx = 0;
4314 fw = es->format_rect.right - es->format_rect.left;
4315 switch (action) {
4316 case SB_LINELEFT:
4317 TRACE("SB_LINELEFT\n");
4318 if (es->x_offset)
4319 dx = -es->char_width;
4320 break;
4321 case SB_LINERIGHT:
4322 TRACE("SB_LINERIGHT\n");
4323 if (es->x_offset < es->text_width)
4324 dx = es->char_width;
4325 break;
4326 case SB_PAGELEFT:
4327 TRACE("SB_PAGELEFT\n");
4328 if (es->x_offset)
4329 dx = -fw / HSCROLL_FRACTION / es->char_width * es->char_width;
4330 break;
4331 case SB_PAGERIGHT:
4332 TRACE("SB_PAGERIGHT\n");
4333 if (es->x_offset < es->text_width)
4334 dx = fw / HSCROLL_FRACTION / es->char_width * es->char_width;
4335 break;
4336 case SB_LEFT:
4337 TRACE("SB_LEFT\n");
4338 if (es->x_offset)
4339 dx = -es->x_offset;
4340 break;
4341 case SB_RIGHT:
4342 TRACE("SB_RIGHT\n");
4343 if (es->x_offset < es->text_width)
4344 dx = es->text_width - es->x_offset;
4345 break;
4346 case SB_THUMBTRACK:
4347 TRACE("SB_THUMBTRACK %d\n", pos);
4348 es->flags |= EF_HSCROLL_TRACK;
4349 if(es->style & WS_HSCROLL)
4350 dx = pos - es->x_offset;
4351 else
4352 {
4353 INT fw, new_x;
4354 /* Sanity check */
4355 if(pos < 0 || pos > 100) return 0;
4356 /* Assume default scroll range 0-100 */
4357 fw = es->format_rect.right - es->format_rect.left;
4358 new_x = pos * (es->text_width - fw) / 100;
4359 dx = es->text_width ? (new_x - es->x_offset) : 0;
4360 }
4361 break;
4362 case SB_THUMBPOSITION:
4363 TRACE("SB_THUMBPOSITION %d\n", pos);
4364 es->flags &= ~EF_HSCROLL_TRACK;
4365 if(GetWindowLongW( es->hwndSelf, GWL_STYLE ) & WS_HSCROLL)
4366 dx = pos - es->x_offset;
4367 else
4368 {
4369 INT fw, new_x;
4370 /* Sanity check */
4371 if(pos < 0 || pos > 100) return 0;
4372 /* Assume default scroll range 0-100 */
4373 fw = es->format_rect.right - es->format_rect.left;
4374 new_x = pos * (es->text_width - fw) / 100;
4375 dx = es->text_width ? (new_x - es->x_offset) : 0;
4376 }
4377 if (!dx) {
4378 /* force scroll info update */
4381 }
4382 break;
4383 case SB_ENDSCROLL:
4384 TRACE("SB_ENDSCROLL\n");
4385 break;
4386 /*
4387 * FIXME : the next two are undocumented !
4388 * Are we doing the right thing ?
4389 * At least Win 3.1 Notepad makes use of EM_GETTHUMB this way,
4390 * although it's also a regular control message.
4391 */
4392 case EM_GETTHUMB: /* this one is used by NT notepad */
4393 {
4394 LRESULT ret;
4395 if(GetWindowLongW( es->hwndSelf, GWL_STYLE ) & WS_HSCROLL)
4396 ret = GetScrollPos(es->hwndSelf, SB_HORZ);
4397 else
4398 {
4399 /* Assume default scroll range 0-100 */
4400 INT fw = es->format_rect.right - es->format_rect.left;
4401 ret = es->text_width ? es->x_offset * 100 / (es->text_width - fw) : 0;
4402 }
4403 TRACE("EM_GETTHUMB: returning %Id\n", ret);
4404 return ret;
4405 }
4406 case EM_LINESCROLL:
4407 TRACE("EM_LINESCROLL16\n");
4408 dx = pos;
4409 break;
4410
4411 default:
4412 ERR("undocumented WM_HSCROLL action %d (0x%04x), please report\n",
4413 action, action);
4414 return 0;
4415 }
4416 if (dx)
4417 {
4418 INT fw = es->format_rect.right - es->format_rect.left;
4419 /* check if we are going to move too far */
4420 if(es->x_offset + dx + fw > es->text_width)
4421 dx = es->text_width - fw - es->x_offset;
4422 if(dx)
4424 }
4425 return 0;
4426}
4427
4428
4429/*********************************************************************
4430 *
4431 * WM_VSCROLL
4432 *
4435{
4436 INT dy;
4437
4438 if (!(es->style & ES_MULTILINE))
4439 return 0;
4440
4441 if (!(es->style & ES_AUTOVSCROLL))
4442 return 0;
4443
4444 dy = 0;
4445 switch (action) {
4446 case SB_LINEUP:
4447 case SB_LINEDOWN:
4448 case SB_PAGEUP:
4449 case SB_PAGEDOWN:
4450 TRACE("action %d (%s)\n", action, (action == SB_LINEUP ? "SB_LINEUP" :
4451 (action == SB_LINEDOWN ? "SB_LINEDOWN" :
4452 (action == SB_PAGEUP ? "SB_PAGEUP" :
4453 "SB_PAGEDOWN"))));
4455 return 0;
4456 case SB_TOP:
4457 TRACE("SB_TOP\n");
4458 dy = -es->y_offset;
4459 break;
4460 case SB_BOTTOM:
4461 TRACE("SB_BOTTOM\n");
4462 dy = es->line_count - 1 - es->y_offset;
4463 break;
4464 case SB_THUMBTRACK:
4465 TRACE("SB_THUMBTRACK %d\n", pos);
4466 es->flags |= EF_VSCROLL_TRACK;
4467 if(es->style & WS_VSCROLL)
4468 dy = pos - es->y_offset;
4469 else
4470 {
4471 /* Assume default scroll range 0-100 */
4472 INT vlc, new_y;
4473 /* Sanity check */
4474 if(pos < 0 || pos > 100) return 0;
4476 new_y = pos * (es->line_count - vlc) / 100;
4477 dy = es->line_count ? (new_y - es->y_offset) : 0;
4478 TRACE("line_count=%d, y_offset=%d, pos=%d, dy = %d\n",
4479 es->line_count, es->y_offset, pos, dy);
4480 }
4481 break;
4482 case SB_THUMBPOSITION:
4483 TRACE("SB_THUMBPOSITION %d\n", pos);
4484 es->flags &= ~EF_VSCROLL_TRACK;
4485 if(es->style & WS_VSCROLL)
4486 dy = pos - es->y_offset;
4487 else
4488 {
4489 /* Assume default scroll range 0-100 */
4490 INT vlc, new_y;
4491 /* Sanity check */
4492 if(pos < 0 || pos > 100) return 0;
4494 new_y = pos * (es->line_count - vlc) / 100;
4495 dy = es->line_count ? (new_y - es->y_offset) : 0;
4496 TRACE("line_count=%d, y_offset=%d, pos=%d, dy = %d\n",
4497 es->line_count, es->y_offset, pos, dy);
4498 }
4499 if (!dy)
4500 {
4501 /* force scroll info update */
4504 }
4505 break;
4506 case SB_ENDSCROLL:
4507 TRACE("SB_ENDSCROLL\n");
4508 break;
4509 /*
4510 * FIXME : the next two are undocumented !
4511 * Are we doing the right thing ?
4512 * At least Win 3.1 Notepad makes use of EM_GETTHUMB this way,
4513 * although it's also a regular control message.
4514 */
4515 case EM_GETTHUMB: /* this one is used by NT notepad */
4516 {
4517 LRESULT ret;
4518 if(GetWindowLongW( es->hwndSelf, GWL_STYLE ) & WS_VSCROLL)
4519 ret = GetScrollPos(es->hwndSelf, SB_VERT);
4520 else
4521 {
4522 /* Assume default scroll range 0-100 */
4524 ret = es->line_count ? es->y_offset * 100 / (es->line_count - vlc) : 0;
4525 }
4526 TRACE("EM_GETTHUMB: returning %Id\n", ret);
4527 return ret;
4528 }
4529 case EM_LINESCROLL:
4530 TRACE("EM_LINESCROLL %d\n", pos);
4531 dy = pos;
4532 break;
4533
4534 default:
4535 ERR("undocumented WM_VSCROLL action %d (0x%04x), please report\n",
4536 action, action);
4537 return 0;
4538 }
4539 if (dy)
4541 return 0;
4542}
4543
4544/*********************************************************************
4545 *
4546 * EM_GETTHUMB
4547 *
4548 * FIXME: is this right ? (or should it be only VSCROLL)
4549 * (and maybe only for edit controls that really have their
4550 * own scrollbars) (and maybe only for multiline controls ?)
4551 * All in all: very poorly documented
4552 *
4555{
4558}
4559
4560
4561/********************************************************************
4562 *
4563 * The Following code is to handle inline editing from IMEs
4564 */
4566static void EDIT_GetResultStr(HIMC hIMC, EDITSTATE *es)
4567{
4568 LONG buflen;
4569 LPWSTR lpResultStr;
4570
4571 buflen = ImmGetCompositionStringW(hIMC, GCS_RESULTSTR, NULL, 0);
4572 if (buflen <= 0)
4573 {
4574 return;
4575 }
4576
4577 lpResultStr = HeapAlloc(GetProcessHeap(),0, buflen);
4578 if (!lpResultStr)
4579 {
4580 ERR("Unable to alloc buffer for IME string\n");
4581 return;
4582 }
4583
4584 ImmGetCompositionStringW(hIMC, GCS_RESULTSTR, lpResultStr, buflen);
4585 EDIT_EM_ReplaceSel(es, TRUE, lpResultStr, buflen / sizeof(WCHAR), TRUE, TRUE);
4586 HeapFree(GetProcessHeap(),0,lpResultStr);
4587}
4589static void EDIT_ImeComposition(HWND hwnd, LPARAM CompFlag, EDITSTATE *es)
4590{
4591 HIMC hIMC;
4592
4593 hIMC = ImmGetContext(hwnd);
4594 if (!hIMC)
4595 return;
4596
4597 if (CompFlag & GCS_RESULTSTR)
4598 EDIT_GetResultStr(hIMC, es);
4599 ImmReleaseContext(hwnd, hIMC);
4600}
4601
4602
4603/*********************************************************************
4604 *
4605 * WM_NCCREATE
4606 *
4607 * See also EDIT_WM_StyleChanged
4610{
4611 EDITSTATE *es;
4612 UINT alloc_size;
4613
4614 TRACE("Creating %s edit control, style = %08lx\n",
4615 unicode ? "Unicode" : "ANSI", lpcs->style);
4616
4617 if (!(es = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*es))))
4618 return FALSE;
4620
4621 /*
4622 * Note: since the EDITSTATE has not been fully initialized yet,
4623 * we can't use any API calls that may send
4624 * WM_XXX messages before WM_NCCREATE is completed.
4625 */
4626
4627 es->is_unicode = unicode;
4628 es->style = lpcs->style;
4629
4630 es->bEnableState = !(es->style & WS_DISABLED);
4631
4632 es->hwndSelf = hwnd;
4633 /* Save parent, which will be notified by EN_* messages */
4634 es->hwndParent = lpcs->hwndParent;
4635
4636 if (es->style & ES_COMBO)
4637 es->hwndListBox = GetDlgItem(es->hwndParent, ID_CB_LISTBOX);
4638
4639 /* FIXME: should we handle changes to WS_EX_RIGHT style after creation? */
4640 if (lpcs->dwExStyle & WS_EX_RIGHT) es->style |= ES_RIGHT;
4641
4642 /* Number overrides lowercase overrides uppercase (at least it
4643 * does in Win95). However I'll bet that ES_NUMBER would be
4644 * invalid under Win 3.1.
4645 */
4646 if (es->style & ES_NUMBER) {
4647 ; /* do not override the ES_NUMBER */
4648 } else if (es->style & ES_LOWERCASE) {
4649 es->style &= ~ES_UPPERCASE;
4650 }
4651 if (es->style & ES_MULTILINE) {
4652 es->buffer_limit = BUFLIMIT_INITIAL;
4653 if (es->style & WS_VSCROLL)
4654 es->style |= ES_AUTOVSCROLL;
4655 if (es->style & WS_HSCROLL)
4656 es->style |= ES_AUTOHSCROLL;
4657 es->style &= ~ES_PASSWORD;
4658 if ((es->style & ES_CENTER) || (es->style & ES_RIGHT)) {
4659 /* Confirmed - RIGHT overrides CENTER */
4660 if (es->style & ES_RIGHT)
4661 es->style &= ~ES_CENTER;
4662 es->style &= ~WS_HSCROLL;
4663 es->style &= ~ES_AUTOHSCROLL;
4664 }
4665 } else {
4666 es->buffer_limit = BUFLIMIT_INITIAL;
4667 if ((es->style & ES_RIGHT) && (es->style & ES_CENTER))
4668 es->style &= ~ES_CENTER;
4669 es->style &= ~WS_HSCROLL;
4670 es->style &= ~WS_VSCROLL;
4671 if (es->style & ES_PASSWORD)
4672 es->password_char = '*';
4673 }
4674
4675 alloc_size = ROUND_TO_GROW((es->buffer_size + 1) * sizeof(WCHAR));
4676 if(!(es->hloc32W = LocalAlloc(LMEM_MOVEABLE | LMEM_ZEROINIT, alloc_size)))
4677 goto cleanup;
4678 es->buffer_size = LocalSize(es->hloc32W)/sizeof(WCHAR) - 1;
4679
4680 if (!(es->undo_text = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (es->buffer_size + 1) * sizeof(WCHAR))))
4681 goto cleanup;
4682 es->undo_buffer_size = es->buffer_size;
4683
4684 if (es->style & ES_MULTILINE)
4685 if (!(es->first_line_def = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(LINEDEF))))
4686 goto cleanup;
4687 es->line_count = 1;
4688
4689 /*
4690 * In Win95 look and feel, the WS_BORDER style is replaced by the
4691 * WS_EX_CLIENTEDGE style for the edit control. This gives the edit
4692 * control a nonclient area so we don't need to draw the border.
4693 * If WS_BORDER without WS_EX_CLIENTEDGE is specified we shouldn't have
4694 * a nonclient area and we should handle painting the border ourselves.
4695 *
4696 * When making modifications please ensure that the code still works
4697 * for edit controls created directly with style 0x50800000, exStyle 0
4698 * (which should have a single pixel border)
4699 */
4700 if (lpcs->dwExStyle & WS_EX_CLIENTEDGE)
4701 es->style &= ~WS_BORDER;
4702 else if (es->style & WS_BORDER)
4704
4705 return TRUE;
4706
4707cleanup:
4708 set_control_state( es->hwndSelf, NULL );
4710 HeapFree(GetProcessHeap(), 0, es->first_line_def);
4711 HeapFree(GetProcessHeap(), 0, es->undo_text);
4712 if (es->hloc32W) LocalFree(es->hloc32W);
4713 HeapFree(GetProcessHeap(), 0, es->logAttr);
4714 HeapFree(GetProcessHeap(), 0, es);
4715 return FALSE;
4716}
4717
4718
4719/*********************************************************************
4720 *
4721 * WM_CREATE
4722 *
4725{
4726 RECT clientRect;
4727
4728 TRACE("%s\n", debugstr_w(name));
4729 /*
4730 * To initialize some final structure members, we call some helper
4731 * functions. However, since the EDITSTATE is not consistent (i.e.
4732 * not fully initialized), we should be very careful which
4733 * functions can be called, and in what order.
4734 */
4737
4738 /* We need to calculate the format rect
4739 (applications may send EM_SETMARGINS before the control gets visible) */
4740 GetClientRect(es->hwndSelf, &clientRect);
4741 EDIT_SetRectNP(es, &clientRect);
4742
4743 if (name && *name) {
4745 /* if we insert text to the editline, the text scrolls out
4746 * of the window, as the caret is placed after the insert
4747 * pos normally; thus we reset es->selection... to 0 and
4748 * update caret
4749 */
4750 es->selection_start = es->selection_end = 0;
4751 /* Adobe Photoshop does NOT like this. and MSDN says that EN_CHANGE
4752 * Messages are only to be sent when the USER does something to
4753 * change the contents. So I am removing this EN_CHANGE
4754 *
4755 * EDIT_NOTIFY_PARENT(es, EN_CHANGE);
4756 */
4758 }
4759 /* force scroll info update */
4761 /* The rule seems to return 1 here for success */
4762 /* Power Builder masked edit controls will crash */
4763 /* if not. */
4764 /* FIXME: is that in all cases so ? */
4765 return 1;
4766}
4767
4768
4769/*********************************************************************
4770 *
4771 * WM_NCDESTROY
4772 *
4775{
4776 LINEDEF *pc, *pp;
4777
4778 /* The app can own the text buffer handle */
4779 if (es->hloc32W && (es->hloc32W != es->hlocapp)) {
4780 LocalFree(es->hloc32W);
4781 }
4782 if (es->hloc32A && (es->hloc32A != es->hlocapp)) {
4783 LocalFree(es->hloc32A);
4784 }
4786 pc = es->first_line_def;
4787 while (pc)
4788 {
4789 pp = pc->next;
4790 HeapFree(GetProcessHeap(), 0, pc);
4791 pc = pp;
4792 }
4793
4794 set_control_state( es->hwndSelf, NULL );
4795 HeapFree(GetProcessHeap(), 0, es->undo_text);
4796 HeapFree(GetProcessHeap(), 0, es);
4797
4798 return 0;
4799}
4800
4803{
4804 if(unicode)
4805 return DefWindowProcW(hwnd, msg, wParam, lParam);
4806 else
4807 return DefWindowProcA(hwnd, msg, wParam, lParam);
4808}
4809
4810/*********************************************************************
4811 *
4812 * EditWndProc_common
4813 *
4814 * The messages are in the order of the actual integer values
4815 * (which can be found in include/windows.h)
4818{
4820 LRESULT result = 0;
4821#ifndef __REACTOS__ /* WM_IME_SETCONTEXT */
4822 POINT pt;
4823#endif
4824
4825 TRACE("hwnd=%p msg=%x (%s) wparam=%Ix lparam=%Ix\n", hwnd, msg, SPY_GetMsgName(msg, hwnd), wParam, lParam);
4826
4828
4829 if (!es && msg != WM_NCCREATE)
4830 return DefWindowProcT(hwnd, msg, wParam, lParam, unicode);
4831
4832 if (es && (msg != WM_NCDESTROY)) EDIT_LockBuffer(es);
4833
4834 switch (msg) {
4835 case EM_GETSEL:
4837 break;
4838
4839 case EM_SETSEL:
4842 result = 1;
4843 break;
4844
4845 case EM_GETRECT:
4846 if (lParam)
4847 CopyRect((LPRECT)lParam, &es->format_rect);
4848 break;
4849
4850 case EM_SETRECT:
4851 if ((es->style & ES_MULTILINE) && lParam) {
4854 }
4855 break;
4856
4857 case EM_SETRECTNP:
4858 if ((es->style & ES_MULTILINE) && lParam)
4860 break;
4861
4862 case EM_SCROLL:
4864 break;
4865
4866 case EM_LINESCROLL:
4868 break;
4869
4870 case EM_SCROLLCARET:
4872 result = 1;
4873 break;
4874
4875 case EM_GETMODIFY:
4876 result = ((es->flags & EF_MODIFIED) != 0);
4877 break;
4878
4879 case EM_SETMODIFY:
4880 if (wParam)
4881 es->flags |= EF_MODIFIED;
4882 else
4883 es->flags &= ~(EF_MODIFIED | EF_UPDATE); /* reset pending updates */
4884 break;
4885
4886 case EM_GETLINECOUNT:
4887 result = (es->style & ES_MULTILINE) ? es->line_count : 1;
4888 break;
4889
4890 case EM_LINEINDEX:
4892 break;
4893
4894 case EM_SETHANDLE:
4896 break;
4897
4898 case EM_GETHANDLE:
4900 break;
4901
4902 case EM_GETTHUMB:
4904 break;
4905
4906 /* these messages missing from specs */
4907 case 0x00bf:
4908 case 0x00c0:
4909 case 0x00c3:
4910 case 0x00ca:
4911 FIXME("undocumented message 0x%x, please report\n", msg);
4913 break;
4914
4915 case EM_LINELENGTH:
4917 break;
4918
4919 case EM_REPLACESEL:
4920 {
4921 LPWSTR textW;
4922
4923 if(unicode)
4924 textW = (LPWSTR)lParam;
4925 else
4926 {
4928 INT countW = MultiByteToWideChar(CP_ACP, 0, textA, -1, NULL, 0);
4929 if (!(textW = HeapAlloc(GetProcessHeap(), 0, countW * sizeof(WCHAR)))) break;
4930 MultiByteToWideChar(CP_ACP, 0, textA, -1, textW, countW);
4931 }
4932
4934 result = 1;
4935
4936 if(!unicode)
4938 break;
4939 }
4940
4941 case EM_GETLINE:
4943 break;
4944
4945 case EM_SETLIMITTEXT:
4947 break;
4948
4949 case EM_CANUNDO:
4951 break;
4952
4953 case EM_UNDO:
4954 case WM_UNDO:
4956 break;
4957
4958 case EM_FMTLINES:
4960 break;
4961
4962 case EM_LINEFROMCHAR:
4964 break;
4965
4966 case EM_SETTABSTOPS:
4968 break;
4969
4970 case EM_SETPASSWORDCHAR:
4971 {
4972 WCHAR charW = 0;
4973
4974 if(unicode)
4975 charW = (WCHAR)wParam;
4976 else
4977 {
4978 CHAR charA = wParam;
4979 MultiByteToWideChar(CP_ACP, 0, &charA, 1, &charW, 1);
4980 }
4981
4983 break;
4984 }
4985
4986 case EM_EMPTYUNDOBUFFER:
4988 break;
4989
4991 result = (es->style & ES_MULTILINE) ? es->y_offset : es->x_offset;
4992 break;
4993
4994 case EM_SETREADONLY:
4995 {
4996 DWORD old_style = es->style;
4997
4998 if (wParam) {
5001 es->style |= ES_READONLY;
5002 } else {
5005 es->style &= ~ES_READONLY;
5006 }
5007
5008 if (old_style ^ es->style)
5009 NtUserInvalidateRect(es->hwndSelf, NULL, TRUE);
5010
5011 result = 1;
5012 break;
5013 }
5014
5017 result = 1;
5018 break;
5019
5021 result = (LRESULT)es->word_break_proc;
5022 break;
5023
5024 case EM_GETPASSWORDCHAR:
5025 {
5026 if(unicode)
5027 result = es->password_char;
5028 else
5029 {
5030 WCHAR charW = es->password_char;
5031 CHAR charA = 0;
5032 WideCharToMultiByte(CP_ACP, 0, &charW, 1, &charA, 1, NULL, NULL);
5033 result = charA;
5034 }
5035 break;
5036 }
5037
5038 case EM_SETMARGINS:
5040 break;
5041
5042 case EM_GETMARGINS:
5043 result = MAKELONG(es->left_margin, es->right_margin);
5044 break;
5045
5046 case EM_GETLIMITTEXT:
5047 result = es->buffer_limit;
5048 break;
5049
5050 case EM_POSFROMCHAR:
5051 if ((INT)wParam >= get_text_length(es)) result = -1;
5053 break;
5054
5055 case EM_CHARFROMPOS:
5056 result = EDIT_EM_CharFromPos(es, (short)LOWORD(lParam), (short)HIWORD(lParam));
5057 break;
5058
5059 case EM_SETIMESTATUS:
5060 if (wParam == EMSIS_COMPOSITIONSTRING)
5061 es->ime_status = lParam & 0xFFFF;
5062
5063 result = 1;
5064 break;
5065
5066 case EM_GETIMESTATUS:
5067 result = wParam == EMSIS_COMPOSITIONSTRING ? es->ime_status : 1;
5068 break;
5069
5070 /* End of the EM_ messages which were in numerical order; what order
5071 * are these in? vaguely alphabetical?
5072 */
5073
5074 case WM_NCCREATE:
5076 break;
5077
5078 case WM_NCDESTROY:
5080#ifdef __REACTOS__
5082#endif
5083 es = NULL;
5084 break;
5085
5086 case WM_GETDLGCODE:
5088
5089 if (es->style & ES_MULTILINE)
5091
5092 if (lParam)
5093 {
5094 es->flags|=EF_DIALOGMODE;
5095
5096 if (((LPMSG)lParam)->message == WM_KEYDOWN)
5097 {
5098 int vk = (int)((LPMSG)lParam)->wParam;
5099
5100 if (es->hwndListBox)
5101 {
5102 if (vk == VK_RETURN || vk == VK_ESCAPE)
5105 }
5106 }
5107 }
5108 break;
5109
5110 case WM_CHAR:
5111 {
5112 WCHAR charW;
5113
5114 if(unicode)
5115 charW = wParam;
5116 else
5117 {
5118 BYTE low = wParam;
5120 if (es->lead_byte)
5121 {
5122 char ch[2];
5123 ch[0] = es->lead_byte;
5124 ch[1] = low;
5125 MultiByteToWideChar(cp, 0, ch, 2, &charW, 1);
5126 }
5127 else if (IsDBCSLeadByteEx(cp, low))
5128 {
5129 es->lead_byte = low;
5130 result = 1;
5131 break;
5132 }
5133 else
5134 MultiByteToWideChar(cp, 0, (char *)&low, 1, &charW, 1);
5135 es->lead_byte = 0;
5136 }
5137
5138 if (es->hwndListBox)
5139 {
5140 if (charW == VK_RETURN || charW == VK_ESCAPE)
5141 {
5144 break;
5145 }
5146 }
5147 result = EDIT_WM_Char(es, charW);
5148 break;
5149 }
5150
5151 case WM_UNICHAR:
5152 if (unicode)
5153 {
5154 if (wParam == UNICODE_NOCHAR) return TRUE;
5155 if (wParam <= 0x000fffff)
5156 {
5157 if(wParam > 0xffff) /* convert to surrogates */
5158 {
5159 wParam -= 0x10000;
5160 EDIT_WM_Char(es, (wParam >> 10) + 0xd800);
5161 EDIT_WM_Char(es, (wParam & 0x03ff) + 0xdc00);
5162 }
5163 else EDIT_WM_Char(es, wParam);
5164 }
5165 return 0;
5166 }
5167 break;
5168
5169 case WM_CLEAR:
5171 break;
5172
5173 case WM_CONTEXTMENU:
5174 EDIT_WM_ContextMenu(es, (short)LOWORD(lParam), (short)HIWORD(lParam));
5175 break;
5176
5177 case WM_COPY:
5179 break;
5180
5181 case WM_CREATE:
5182 if(unicode)
5184 else
5185 {
5186 LPCSTR nameA = ((LPCREATESTRUCTA)lParam)->lpszName;
5187 LPWSTR nameW = NULL;
5188 if(nameA)
5189 {
5190 INT countW = MultiByteToWideChar(CP_ACP, 0, nameA, -1, NULL, 0);
5191 if((nameW = HeapAlloc(GetProcessHeap(), 0, countW * sizeof(WCHAR))))
5192 MultiByteToWideChar(CP_ACP, 0, nameA, -1, nameW, countW);
5193 }
5196 }
5197 break;
5198
5199 case WM_CUT:
5200 EDIT_WM_Cut(es);
5201 break;
5202
5203 case WM_ENABLE:
5204 es->bEnableState = (BOOL) wParam;
5206 break;
5207
5208 case WM_ERASEBKGND:
5209 /* we do the proper erase in EDIT_WM_Paint */
5210 result = 1;
5211 break;
5212
5213 case WM_GETFONT:
5214 result = (LRESULT)es->font;
5215 break;
5216
5217 case WM_GETTEXT:
5219 break;
5220
5221 case WM_GETTEXTLENGTH:
5222 if (unicode) result = get_text_length(es);
5224 NULL, 0, NULL, NULL );
5225 break;
5226
5227 case WM_HSCROLL:
5229 break;
5230
5231 case WM_KEYDOWN:
5233 break;
5234
5235 case WM_KILLFOCUS:
5237 break;
5238
5239 case WM_LBUTTONDBLCLK:
5241 break;
5242
5243 case WM_LBUTTONDOWN:
5245 break;
5246
5247 case WM_LBUTTONUP:
5249 break;
5250
5251 case WM_MBUTTONDOWN:
5253 break;
5254
5255 case WM_MOUSEMOVE:
5256 result = EDIT_WM_MouseMove(es, (short)LOWORD(lParam), (short)HIWORD(lParam));
5257 break;
5258
5259 case WM_PRINTCLIENT:
5260 case WM_PAINT:
5262 break;
5263
5264 case WM_PASTE:
5266 break;
5267
5268 case WM_SETFOCUS:
5270 break;
5271
5272 case WM_SETFONT:
5273 EDIT_WM_SetFont(es, (HFONT)wParam, LOWORD(lParam) != 0);
5274 break;
5275
5276 case WM_SETREDRAW:
5277 /* FIXME: actually set an internal flag and behave accordingly */
5278 break;
5279
5280 case WM_SETTEXT:
5281 EDIT_WM_SetText(es, (LPCWSTR)lParam, unicode);
5282 result = TRUE;
5283 break;
5284
5285 case WM_SIZE:
5287 break;
5288
5289 case WM_STYLECHANGED:
5291 break;
5292
5293 case WM_STYLECHANGING:
5294 result = 0; /* See EDIT_WM_StyleChanged */
5295 break;
5296
5297 case WM_SYSKEYDOWN:
5299 break;
5300
5301 case WM_VSCROLL:
5302#ifdef __REACTOS__
5303 {
5304 SCROLLINFO si;
5305
5306 si.cbSize = sizeof(si);
5307 si.fMask = SIF_TRACKPOS;
5308 if (!GetScrollInfo(hwnd, SB_VERT, &si))
5309 {
5310 result = 1;
5311 break;
5312 }
5313 result = EDIT_WM_VScroll(es, LOWORD(wParam), si.nTrackPos);
5314 }
5315#else
5317 break;
5318#endif
5319
5320 case WM_CAPTURECHANGED:
5321 es->bCaptureState = FALSE;
5322 break;
5323
5324 case WM_MOUSEWHEEL:
5325 {
5326 int wheelDelta;
5327 INT pulScrollLines = 3;
5328 SystemParametersInfoW(SPI_GETWHEELSCROLLLINES,0, &pulScrollLines, 0);
5329
5330 if (wParam & (MK_SHIFT | MK_CONTROL)) {
5332 break;
5333 }
5334 wheelDelta = GET_WHEEL_DELTA_WPARAM(wParam);
5335 /* if scrolling changes direction, ignore left overs */
5336 if ((wheelDelta < 0 && es->wheelDeltaRemainder < 0) ||
5337 (wheelDelta > 0 && es->wheelDeltaRemainder > 0))
5338 es->wheelDeltaRemainder += wheelDelta;
5339 else
5340 es->wheelDeltaRemainder = wheelDelta;
5341 if (es->wheelDeltaRemainder && pulScrollLines)
5342 {
5343 int cLineScroll;
5344 pulScrollLines = min(es->line_count, pulScrollLines);
5345 cLineScroll = pulScrollLines * es->wheelDeltaRemainder / WHEEL_DELTA;
5346 es->wheelDeltaRemainder -= WHEEL_DELTA * cLineScroll / pulScrollLines;
5347 result = EDIT_EM_LineScroll(es, 0, -cLineScroll);
5348 }
5349 }
5350 break;
5351
5352
5353 /* IME messages to make the edit control IME aware */
5354 case WM_IME_SETCONTEXT:
5355#ifdef __REACTOS__
5356 {
5357 HKL hKL = GetKeyboardLayout(0);
5358
5359 /* Korean doesn't want composition window */
5360 if (PRIMARYLANGID(LOWORD(hKL)) == LANG_KOREAN)
5361 lParam &= ~ISC_SHOWUICOMPOSITIONWINDOW;
5362
5363 if (wParam)
5364 {
5365 HIMC hIMC = ImmGetContext(hwnd);
5367 if (pIC)
5368 {
5369 pIC->dwUIFlags &= ~0x40000;
5370 ImmUnlockIMC(hIMC);
5371 }
5372 if (GetWin32ClientInfo()->CI_flags & CI_WOW)
5374 ImmReleaseContext(hwnd, hIMC);
5375 }
5376
5378 }
5379#else
5383#endif
5384 break;
5385
5386#ifdef __REACTOS__
5387 case WM_IME_STARTCOMPOSITION:
5388 {
5389 HKL hKL = GetKeyboardLayout(0);
5390
5391 /* Korean doesn't want composition window */
5392 if (PRIMARYLANGID(LOWORD(hKL)) == LANG_KOREAN)
5393 return TRUE;
5394
5395 result = DefWindowProcT(hwnd, msg, wParam, lParam, unicode);
5396 }
5397 break;
5398#endif
5399
5400 case WM_IME_COMPOSITION:
5402 if ((lParam & GCS_RESULTSTR) && (es->ime_status & EIMES_GETCOMPSTRATONCE))
5404 return DefWindowProcW(hwnd, msg, wParam, lParam);
5405
5406 case WM_IME_SELECT:
5407#ifdef __REACTOS__
5408 result = DefWindowProcT(hwnd, msg, wParam, lParam, unicode);
5409#endif
5410 break;
5411
5412 case WM_IME_CONTROL:
5413#ifdef __REACTOS__
5414 result = DefWindowProcT(hwnd, msg, wParam, lParam, unicode);
5415#endif
5416 break;
5417
5418 case WM_IME_REQUEST:
5419 switch (wParam)
5420 {
5421 case IMR_QUERYCHARPOSITION:
5422 {
5423 LRESULT pos;
5424 IMECHARPOSITION *chpos = (IMECHARPOSITION *)lParam;
5425
5426 pos = EDIT_EM_PosFromChar(es, es->selection_start + chpos->dwCharPos, FALSE);
5427 chpos->pt.x = LOWORD(pos);
5428 chpos->pt.y = HIWORD(pos);
5429 chpos->cLineHeight = es->line_height;
5430 chpos->rcDocument = es->format_rect;
5431 MapWindowPoints(hwnd, 0, &chpos->pt, 1);
5432 MapWindowPoints(hwnd, 0, (POINT*)&chpos->rcDocument, 2);
5433 result = 1;
5434 break;
5435 }
5436 }
5437 break;
5438
5439 default:
5440 result = DefWindowProcT(hwnd, msg, wParam, lParam, unicode);
5441 break;
5442 }
5443
5444#ifdef __REACTOS__
5445 /* ReactOS: check GetWindowLong in case es has been destroyed during processing */
5446 if (IsWindow(hwnd) && es && msg != EM_GETHANDLE && GetWindowLongPtrW(hwnd, 0))
5447#else
5448 if (IsWindow(hwnd) && es && msg != EM_GETHANDLE)
5449#endif
5451
5452 TRACE("hwnd=%p msg=%x (%s) -- 0x%08Ix\n", hwnd, msg, SPY_GetMsgName(msg, hwnd), result);
5453
5454 return result;
5455}
5456
5457#ifdef __REACTOS__
5458
5459/*********************************************************************
5460 *
5461 * EditWndProc (USER32.@)
5462 */
5464{
5465 return EditWndProc_common(hWnd, uMsg, wParam, lParam, FALSE);
5466}
5467
5468/*********************************************************************
5469 *
5470 * EditWndProcW (USER32.@)
5471 */
5473{
5474 return EditWndProc_common(hWnd, uMsg, wParam, lParam, TRUE);
5475}
5476
5477/*********************************************************************
5478 * edit class descriptor
5479 */
5480static const WCHAR editW[] = {'E','d','i','t',0};
5482{
5483 editW, /* name */
5484 CS_DBLCLKS | CS_PARENTDC, /* style */
5485 &pfnClientA.pfnEditWndProc, /* procA */
5486 &pfnClientW.pfnEditWndProc, /* procW */
5487#ifndef _WIN64
5488 sizeof(EDITSTATE *) + sizeof(WORD), /* extra */
5489#else
5490 sizeof(EDITSTATE *), /* extra */
5491#endif
5492 IDC_IBEAM, /* cursor */
5493 0 /* brush */
5494};
5495#endif
static HRGN hrgn
static HBRUSH hbrush
short INT16
Definition: actypes.h:130
static int bw
Definition: maze.c:120
static int state
Definition: maze.c:121
const DWORD ExStyle
Definition: appswitch.c:73
#define msg(x)
Definition: auth_time.c:54
HWND hWnd
Definition: settings.c:17
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
int rev
Definition: sort.c:17
static const WCHAR nameW[]
Definition: main.c:49
#define CF_UNICODETEXT
Definition: constants.h:408
#define index(s, c)
Definition: various.h:29
#define ARRAY_SIZE(A)
Definition: main.h:20
static RECT margins
Definition: print.c:55
#define FIXME(fmt,...)
Definition: precomp.h:53
#define WARN(fmt,...)
Definition: precomp.h:61
#define ERR(fmt,...)
Definition: precomp.h:57
w ll
Definition: byte_order.h:167
r l[0]
Definition: byte_order.h:168
return
Definition: dirsup.c:529
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
LRESULT WINAPI EditWndProcW(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
LRESULT WINAPI EditWndProcA(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
static HWND hwndParent
Definition: cryptui.c:299
HDC dc
Definition: cylfrac.c:34
static float(WINAPI *pD2D1Tan)(float angle)
HRESULT hr
Definition: delayimp.cpp:582
DWORD HIMC
Definition: dimm.idl:75
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static void EDIT_WM_Paint(EDITSTATE *es, HDC hdc)
Definition: edit.c:3628
static void EDIT_MoveEnd(EDITSTATE *es, BOOL extend, BOOL ctrl)
Definition: edit.c:1896
static void EDIT_PaintLine(EDITSTATE *es, HDC dc, INT line, BOOL rev)
Definition: edit.c:2179
static void EDIT_GetResultStr(HIMC hIMC, EDITSTATE *es)
Definition: edit.c:4451
static BOOL EDIT_IsInsideDialog(EDITSTATE *es)
Definition: edit.c:2982
#define EF_MODIFIED
Definition: edit.c:65
static INT get_vertical_line_count(EDITSTATE *es)
Definition: edit.c:414
static INT EDIT_WordBreakProc(EDITSTATE *es, LPWSTR s, INT index, INT count, INT action)
Definition: edit.c:236
static LRESULT EDIT_WM_LButtonDblClk(EDITSTATE *es)
Definition: edit.c:3513
static void EDIT_MoveBackward(EDITSTATE *es, BOOL extend)
Definition: edit.c:1847
static LRESULT EDIT_WM_Char(EDITSTATE *es, WCHAR c)
Definition: edit.c:3085
BOOL WINAPI GetCharWidthInfo(HDC, struct char_width_info *)
static void EDIT_WM_SetFont(EDITSTATE *es, HFONT font, BOOL redraw)
Definition: edit.c:3837
static SCRIPT_STRING_ANALYSIS EDIT_UpdateUniscribeData(EDITSTATE *es, HDC dc, INT line)
Definition: edit.c:372
static void EDIT_EM_ReplaceSel(EDITSTATE *es, BOOL can_undo, const WCHAR *lpsz_replace, UINT strl, BOOL send_update, BOOL honor_limit)
Definition: edit.c:2490
#define EF_AFTER_WRAP
Definition: edit.c:70
static void EDIT_CalcLineWidth_SL(EDITSTATE *es)
Definition: edit.c:761
static LRESULT EDIT_WM_MButtonDown(EDITSTATE *es)
Definition: edit.c:3584
static void EDIT_EM_ScrollCaret(EDITSTATE *es)
Definition: edit.c:1778
#define ID_CB_LISTBOX
Definition: edit.c:74
static void EDIT_InvalidateUniscribeData_linedef(LINEDEF *line_def)
Definition: edit.c:306
#define ROUND_TO_GROW(size)
Definition: edit.c:59
static BOOL EDIT_CheckCombo(EDITSTATE *es, UINT msg, INT key)
Definition: edit.c:3286
static void EDIT_SetRectNP(EDITSTATE *es, const RECT *rc)
Definition: edit.c:2317
static BOOL EDIT_EM_FmtLines(EDITSTATE *es, BOOL add_eol)
Definition: edit.c:2389
static void EDIT_WM_Copy(EDITSTATE *es)
Definition: edit.c:3029
static void EDIT_ML_InvalidateText(EDITSTATE *es, INT start, INT end)
Definition: edit.c:1394
static void EDIT_GetLineRect(EDITSTATE *es, INT line, INT scol, INT ecol, LPRECT rc)
Definition: edit.c:1147
static BOOL EDIT_EM_LineScroll_internal(EDITSTATE *es, INT dx, INT dy)
Definition: edit.c:1601
static void EDIT_SetCaretPos(EDITSTATE *es, INT pos, BOOL after_wrap)
Definition: edit.c:1750
static void EDIT_BuildLineDefs_ML(EDITSTATE *es, INT istart, INT iend, INT delta, HRGN hrgn)
Definition: edit.c:429
static void EDIT_MoveUp_ML(EDITSTATE *es, BOOL extend)
Definition: edit.c:2022
static INT EDIT_PaintText(EDITSTATE *es, HDC dc, INT x, INT y, INT line, INT col, INT count, BOOL rev)
Definition: edit.c:2105
static LRESULT EDIT_EM_CharFromPos(EDITSTATE *es, INT x, INT y)
Definition: edit.c:2361
static void EDIT_MoveHome(EDITSTATE *es, BOOL extend, BOOL ctrl)
Definition: edit.c:1942
static LRESULT EDIT_WM_HScroll(EDITSTATE *es, INT action, INT pos)
Definition: edit.c:4067
static void EDIT_WM_Cut(EDITSTATE *es)
Definition: edit.c:3073
static void EDIT_EM_SetPasswordChar(EDITSTATE *es, WCHAR c)
Definition: edit.c:2871
static SCRIPT_STRING_ANALYSIS EDIT_UpdateUniscribeData_linedef(EDITSTATE *es, HDC dc, LINEDEF *line_def)
Definition: edit.c:330
#define EF_FOCUSED
Definition: edit.c:66
struct tagLINEDEF LINEDEF
static void EDIT_AdjustFormatRect(EDITSTATE *es)
Definition: edit.c:2266
static INT EDIT_WM_GetText(const EDITSTATE *es, INT count, LPWSTR dst)
Definition: edit.c:3272
static void EDIT_WM_ContextMenu(EDITSTATE *es, INT x, INT y)
Definition: edit.c:3216
static LRESULT EDIT_WM_MouseMove(EDITSTATE *es, INT x, INT y)
Definition: edit.c:3596
static void EDIT_MovePageUp_ML(EDITSTATE *es, BOOL extend)
Definition: edit.c:1994
static void EDIT_LockBuffer(EDITSTATE *es)
Definition: edit.c:1211
static void EDIT_UnlockBuffer(EDITSTATE *es, BOOL force)
Definition: edit.c:1230
static LRESULT EDIT_WM_NCDestroy(EDITSTATE *es)
Definition: edit.c:4700
static LRESULT EDIT_WM_LButtonDown(EDITSTATE *es, DWORD keys, INT x, INT y)
Definition: edit.c:3542
static BOOL notify_parent(const EDITSTATE *es, INT code)
Definition: edit.c:166
static INT EDIT_EM_LineIndex(const EDITSTATE *es, INT line)
Definition: edit.c:942
static void EDIT_ConfinePoint(const EDITSTATE *es, LPINT x, LPINT y)
Definition: edit.c:901
static HLOCAL EDIT_EM_GetHandle(EDITSTATE *es)
Definition: edit.c:2411
static INT EDIT_EM_GetLine(EDITSTATE *es, INT line, LPWSTR dst)
Definition: edit.c:2431
#define EF_UPDATE
Definition: edit.c:67
static BOOL EDIT_EM_Undo(EDITSTATE *es)
Definition: edit.c:2941
static UINT get_text_length(EDITSTATE *es)
Definition: edit.c:216
static void EDIT_InvalidateUniscribeData(EDITSTATE *es)
Definition: edit.c:315
static void EDIT_WM_Paste(EDITSTATE *es)
Definition: edit.c:2993
#define EF_HSCROLL_TRACK
Definition: edit.c:69
static void EDIT_UpdateScrollInfo(EDITSTATE *es)
Definition: edit.c:1560
static void EDIT_MovePageDown_ML(EDITSTATE *es, BOOL extend)
Definition: edit.c:1966
static LRESULT EDIT_WM_KillFocus(HTHEME theme, EDITSTATE *es)
Definition: edit.c:3485
static void EDIT_MoveWordForward(EDITSTATE *es, BOOL extend)
Definition: edit.c:2075
static int get_cjk_fontinfo_margin(int width, int side_bearing)
Definition: edit.c:2770
static LRESULT EDIT_WM_SysKeyDown(EDITSTATE *es, INT key, DWORD key_data)
Definition: edit.c:4030
static LRESULT EDIT_EM_GetThumb(EDITSTATE *es)
Definition: edit.c:4319
static LRESULT EDIT_WM_NCCreate(HWND hwnd, LPCREATESTRUCTW lpcs)
Definition: edit.c:4532
static LRESULT EDIT_WM_LButtonUp(EDITSTATE *es)
Definition: edit.c:3568
static void EDIT_WM_Clear(EDITSTATE *es)
Definition: edit.c:3058
static BOOL EDIT_EM_CanUndo(const EDITSTATE *es)
Definition: edit.c:181
static void EDIT_EM_EmptyUndoBuffer(EDITSTATE *es)
Definition: edit.c:192
static INT EDIT_CharFromPos(EDITSTATE *es, INT x, INT y, LPBOOL after_wrap)
Definition: edit.c:784
static void EDIT_EM_SetMargins(EDITSTATE *es, INT action, WORD left, WORD right, BOOL repaint)
Definition: edit.c:2799
static void EDIT_MoveWordBackward(EDITSTATE *es, BOOL extend)
Definition: edit.c:2044
static void text_buffer_changed(EDITSTATE *es)
Definition: edit.c:1198
#define EF_USE_SOFTBRK
Definition: edit.c:71
static HBRUSH EDIT_NotifyCtlColor(EDITSTATE *es, HDC hdc)
Definition: edit.c:198
static void EDIT_WM_SetFocus(HTHEME theme, EDITSTATE *es)
Definition: edit.c:3779
#define HSCROLL_FRACTION
Definition: edit.c:60
static void EDIT_EM_SetHandle(EDITSTATE *es, HLOCAL hloc)
Definition: edit.c:2707
static LRESULT EDIT_WM_Create(EDITSTATE *es, const WCHAR *name)
Definition: edit.c:4645
static void EDIT_InvalidateText(EDITSTATE *es, INT start, INT end)
Definition: edit.c:1459
static LRESULT EDIT_WM_KeyDown(EDITSTATE *es, INT key)
Definition: edit.c:3348
static void EDIT_EM_SetLimitText(EDITSTATE *es, UINT limit)
Definition: edit.c:2749
static LRESULT EDIT_EM_PosFromChar(EDITSTATE *es, INT index, BOOL after_wrap)
Definition: edit.c:1013
#define BUFLIMIT_INITIAL
Definition: edit.c:57
static void EDIT_MoveForward(EDITSTATE *es, BOOL extend)
Definition: edit.c:1917
#define EF_DIALOGMODE
Definition: edit.c:72
static LRESULT EDIT_EM_Scroll(EDITSTATE *es, INT action)
Definition: edit.c:1672
static LRESULT EDIT_EM_GetSel(const EDITSTATE *es, PUINT start, PUINT end)
Definition: edit.c:2469
static void EDIT_EM_SetWordBreakProc(EDITSTATE *es, EDITWORDBREAKPROCW wbp)
Definition: edit.c:2922
static void EDIT_SL_InvalidateText(EDITSTATE *es, INT start, INT end)
Definition: edit.c:1376
LINE_END
Definition: edit.c:77
@ END_SOFT
Definition: edit.c:81
@ END_RICH
Definition: edit.c:82
@ END_HARD
Definition: edit.c:80
@ END_0
Definition: edit.c:78
@ END_WRAP
Definition: edit.c:79
static void EDIT_MoveDown_ML(EDITSTATE *es, BOOL extend)
Definition: edit.c:1874
#define EF_VSCROLL_TRACK
Definition: edit.c:68
static LRESULT EDIT_WM_StyleChanged(EDITSTATE *es, WPARAM which, const STYLESTRUCT *style)
Definition: edit.c:3985
static INT EDIT_CallWordBreakProc(EDITSTATE *es, INT start, INT index, INT count, INT action)
Definition: edit.c:294
static INT EDIT_EM_LineFromChar(EDITSTATE *es, INT index)
Definition: edit.c:913
static void EDIT_ContextMenuCommand(EDITSTATE *es, UINT id)
Definition: edit.c:3172
#define ORDER_UINT(x, y)
Definition: edit.c:164
static LRESULT EDIT_WM_VScroll(EDITSTATE *es, INT action, INT pos)
Definition: edit.c:4199
static BOOL EDIT_MakeFit(EDITSTATE *es, UINT size)
Definition: edit.c:1276
static void EDIT_WM_SetText(EDITSTATE *es, LPCWSTR text)
Definition: edit.c:3910
static BOOL EDIT_MakeUndoFit(EDITSTATE *es, UINT size)
Definition: edit.c:1317
static void EDIT_UpdateTextRegion(EDITSTATE *es, HRGN hrgn, BOOL bErase)
Definition: edit.c:1344
static void EDIT_UpdateText(EDITSTATE *es, const RECT *rc, BOOL bErase)
Definition: edit.c:1359
static BOOL EDIT_EM_SetTabStops(EDITSTATE *es, INT count, const INT *tabs)
Definition: edit.c:2900
static DWORD get_font_margins(HDC hdc, const TEXTMETRICW *tm)
Definition: edit.c:3805
static BOOL EDIT_EM_SetSel(EDITSTATE *es, UINT start, UINT end, BOOL after_wrap)
Definition: edit.c:1489
static void EDIT_ImeComposition(HWND hwnd, LPARAM CompFlag, EDITSTATE *es)
Definition: edit.c:4486
static BOOL EDIT_EM_LineScroll(EDITSTATE *es, INT dx, INT dy)
Definition: edit.c:1657
static void EDIT_WM_Size(EDITSTATE *es, UINT action)
Definition: edit.c:3952
static INT EDIT_EM_LineLength(EDITSTATE *es, INT index)
Definition: edit.c:977
static const WCHAR indent[]
Definition: object.c:1231
#define wcschr
Definition: compat.h:17
#define GetProcessHeap()
Definition: compat.h:736
#define CP_ACP
Definition: compat.h:109
#define TRACE_(x)
Definition: compat.h:76
#define HeapAlloc
Definition: compat.h:733
#define HeapReAlloc
Definition: compat.h:734
static __inline const char * debugstr_an(const char *s, int n)
Definition: compat.h:55
#define HeapFree(x, y, z)
Definition: compat.h:735
#define WINE_DECLARE_DEBUG_CHANNEL(x)
Definition: compat.h:45
#define lstrcpyW
Definition: compat.h:749
#define WideCharToMultiByte
Definition: compat.h:111
#define MultiByteToWideChar
Definition: compat.h:110
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
#define lstrcpynW
Definition: compat.h:738
#define lstrlenW
Definition: compat.h:750
static const WCHAR version[]
Definition: asmname.c:66
static void cleanup(void)
Definition: main.c:1335
DWORD WINAPI GetProcessVersion(IN DWORD ProcessId)
Definition: proc.c:1661
BOOL WINAPI GetVersionExW(IN LPOSVERSIONINFOW lpVersionInformation)
Definition: version.c:37
BOOL WINAPI IsDBCSLeadByteEx(UINT codepage, BYTE testchar)
Definition: locale.c:2106
const UINT * keys
Definition: locale.c:418
DWORD WINAPI CharLowerBuffW(WCHAR *str, DWORD len)
Definition: string.c:1130
DWORD WINAPI CharUpperBuffW(WCHAR *str, DWORD len)
Definition: string.c:1243
BOOL force
Definition: metahost.c:100
const WCHAR * text
Definition: package.c:1826
unsigned char ch[4][2]
Definition: console.c:118
unsigned short vk
Definition: console.c:118
_ACRTIMP size_t __cdecl strlen(const char *)
Definition: string.c:1597
HRESULT WINAPI ScriptStringFree(SCRIPT_STRING_ANALYSIS *pssa)
Definition: usp10.c:2561
HRESULT WINAPI ScriptStringGetLogicalWidths(SCRIPT_STRING_ANALYSIS ssa, int *piDx)
Definition: usp10.c:3815
HRESULT WINAPI ScriptStringAnalyse(HDC hdc, const void *pString, int cString, int cGlyphs, int iCharset, DWORD dwFlags, int iReqWidth, SCRIPT_CONTROL *psControl, SCRIPT_STATE *psState, const int *piDx, SCRIPT_TABDEF *pTabdef, const BYTE *pbInClass, SCRIPT_STRING_ANALYSIS *pssa)
Definition: usp10.c:1953
HRESULT WINAPI ScriptStringOut(SCRIPT_STRING_ANALYSIS ssa, int iX, int iY, UINT uOptions, const RECT *prc, int iMinSel, int iMaxSel, BOOL fDisabled)
Definition: usp10.c:2371
const SIZE *WINAPI ScriptString_pSize(SCRIPT_STRING_ANALYSIS ssa)
Definition: usp10.c:3887
const int *WINAPI ScriptString_pcOutChars(SCRIPT_STRING_ANALYSIS ssa)
Definition: usp10.c:3949
HRESULT WINAPI ScriptStringXtoCP(SCRIPT_STRING_ANALYSIS ssa, int iX, int *piCh, int *piTrailing)
Definition: usp10.c:2479
HRESULT WINAPI ScriptStringCPtoX(SCRIPT_STRING_ANALYSIS ssa, int icp, BOOL fTrailing, int *pX)
Definition: usp10.c:2416
HRESULT WINAPI ScriptBreak(const WCHAR *chars, int count, const SCRIPT_ANALYSIS *sa, SCRIPT_LOGATTR *la)
Definition: usp10.c:3051
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:94
#define pt(x, y)
Definition: drawing.c:79
return ret
Definition: mutex.c:147
action
Definition: namespace.c:714
#define L(x)
Definition: resources.c:13
struct FONTSIGNATURE FONTSIGNATURE
Definition: dwrite_3.idl:31
#define abs(i)
Definition: fconv.c:206
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
int form
Definition: main.c:89
pKey DeleteObject()
LARGE_INTEGER li
Definition: fxtimerapi.cpp:235
GLuint start
Definition: gl.h:1545
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLdouble s
Definition: gl.h:2039
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLuint GLuint end
Definition: gl.h:1545
GLint GLint GLsizei width
Definition: gl.h:1546
GLenum GLenum GLsizei const GLuint GLboolean enabled
Definition: glext.h:7750
GLuint res
Definition: glext.h:9613
GLenum src
Definition: glext.h:6340
GLsizeiptr size
Definition: glext.h:5919
const GLubyte * c
Definition: glext.h:8905
GLuint index
Definition: glext.h:6031
GLbitfield flags
Definition: glext.h:7161
GLdouble GLdouble right
Definition: glext.h:10859
GLint limit
Definition: glext.h:10326
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLint left
Definition: glext.h:7726
GLenum GLenum dst
Definition: glext.h:6340
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
GLuint64EXT * result
Definition: glext.h:11304
GLfloat GLfloat p
Definition: glext.h:8902
GLenum GLsizei len
Definition: glext.h:6722
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
unsigned int UINT
Definition: sysinfo.c:13
HLOCAL NTAPI LocalReAlloc(HLOCAL hMem, SIZE_T dwBytes, UINT uFlags)
Definition: heapmem.c:1625
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1390
LPVOID NTAPI LocalLock(HLOCAL hMem)
Definition: heapmem.c:1616
BOOL NTAPI LocalUnlock(HLOCAL hMem)
Definition: heapmem.c:1805
SIZE_T NTAPI LocalSize(HLOCAL hMem)
Definition: heapmem.c:1794
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
#define fs
Definition: i386-dis.c:444
#define es
Definition: i386-dis.c:440
BOOL WINAPI ImmSetCompositionFontW(_In_ HIMC hIMC, _In_ LPLOGFONTW lplf)
Definition: ime.c:1323
struct INPUTCONTEXTDX * LPINPUTCONTEXTDX
#define CFS_RECT
Definition: imm.h:324
#define CPS_CANCEL
Definition: imm.h:181
BOOL WINAPI ImmSetCompositionWindow(_In_ HIMC hIMC, _In_ LPCOMPOSITIONFORM lpCompForm)
Definition: ime.c:1150
#define GCS_RESULTSTR
Definition: imm.h:234
HIMC WINAPI ImmGetContext(_In_ HWND hWnd)
Definition: imm.c:1066
#define CFS_POINT
Definition: imm.h:325
BOOL WINAPI ImmReleaseContext(_In_ HWND hWnd, _In_ HIMC hIMC)
Definition: imm.c:1110
LONG WINAPI ImmGetCompositionStringW(_In_ HIMC hIMC, _In_ DWORD dwIndex, _Out_writes_bytes_opt_(dwBufLen) LPVOID lpBuf, _In_ DWORD dwBufLen)
Definition: compstr.c:949
BOOL WINAPI ImmIsIME(_In_ HKL hKL)
Definition: ime.c:430
BOOL WINAPI ImmNotifyIME(_In_ HIMC hIMC, _In_ DWORD dwAction, _In_ DWORD dwIndex, _In_ DWORD_PTR dwValue)
Definition: ime.c:459
LPINPUTCONTEXT WINAPI ImmLockIMC(_In_ HIMC hIMC)
Definition: imm.c:1080
#define NI_COMPOSITIONSTR
Definition: immdev.h:363
BOOL WINAPI ImmUnlockIMC(_In_ HIMC hIMC)
Definition: imm.c:1090
DWORD NTAPI NtUserScrollWindowEx(HWND hWnd, INT dx, INT dy, const RECT *rect, const RECT *clipRect, HRGN hrgnUpdate, LPRECT rcUpdate, UINT flags)
Definition: scrollex.c:571
#define FNID_DESTROY
Definition: ntuser.h:929
BOOL NTAPI NtUserShowCaret(HWND hWnd)
Definition: caret.c:422
HWND NTAPI NtUserSetFocus(HWND hWnd)
Definition: focus.c:1717
DWORD NTAPI NtUserSetScrollInfo(HWND hwnd, int fnBar, LPCSCROLLINFO lpsi, BOOL bRedraw)
Definition: scrollbar.c:1344
BOOL NTAPI NtUserInvalidateRect(HWND hWnd, CONST RECT *lpRect, BOOL bErase)
Definition: painting.c:2541
BOOL NTAPI NtUserGetCaretPos(LPPOINT lpPoint)
Definition: caret.c:394
BOOL NTAPI NtUserCloseClipboard(VOID)
Definition: clipboard.c:589
BOOL NTAPI NtUserInvalidateRgn(HWND hWnd, HRGN hRgn, BOOL bErase)
Definition: painting.c:2557
BOOL NTAPI NtUserCreateCaret(HWND hWnd, HBITMAP hBitmap, int nWidth, int nHeight)
Definition: caret.c:307
BOOL NTAPI NtUserEmptyClipboard(VOID)
Definition: clipboard.c:722
UINT NTAPI NtUserEnableMenuItem(HMENU hMenu, UINT uIDEnableItem, UINT uEnable)
Definition: menu.c:5872
BOOL NTAPI NtUserEndPaint(HWND hWnd, CONST PAINTSTRUCT *lPs)
Definition: painting.c:1660
HDC NTAPI NtUserBeginPaint(HWND hWnd, PAINTSTRUCT *lPs)
Definition: painting.c:1614
HWND NTAPI NtUserSetCapture(HWND Wnd)
Definition: focus.c:1699
BOOL NTAPI NtUserDestroyMenu(HMENU hMenu)
Definition: menu.c:5842
SHORT NTAPI NtUserGetKeyState(INT VirtKey)
Definition: msgqueue.c:2573
#define GetWin32ClientInfo()
Definition: ntuser.h:380
#define CI_WOW
Definition: ntuser.h:330
BOOL NTAPI NtUserIsClipboardFormatAvailable(UINT format)
Definition: clipboard.c:872
BOOL NTAPI NtUserSetWindowFNID(HWND hWnd, WORD fnID)
Definition: window.c:4335
HDC NTAPI NtUserGetDC(HWND hWnd)
Definition: windc.c:1014
REFIID LPVOID DWORD_PTR dw
Definition: atlbase.h:40
#define FAILED(hr)
Definition: intsafe.h:51
static ERESOURCE GlobalLock
Definition: sys_arch.c:8
#define d
Definition: ke_i.h:81
#define e
Definition: ke_i.h:82
#define c
Definition: ke_i.h:80
#define debugstr_wn
Definition: kernel32.h:33
#define debugstr_w
Definition: kernel32.h:32
GLint dy
Definition: linetemp.h:97
if(dx< 0)
Definition: linetemp.h:194
GLint dx
Definition: linetemp.h:97
POINT cp
Definition: magnifier.c:59
#define LMEM_MOVEABLE
Definition: minwinbase.h:82
#define LMEM_ZEROINIT
Definition: minwinbase.h:85
LONG_PTR LPARAM
Definition: minwindef.h:175
BOOL * LPBOOL
Definition: minwindef.h:138
LONG_PTR LRESULT
Definition: minwindef.h:176
UINT_PTR WPARAM
Definition: minwindef.h:174
int * LPINT
Definition: minwindef.h:151
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static PVOID ptr
Definition: dispmode.c:27
HDC hdc
Definition: main.c:9
static const char textA[]
Definition: registrar.c:40
#define ES_COMBO
Definition: edit.c:29
static HDC
Definition: imagelist.c:88
static const WCHAR textW[]
Definition: itemdlg.c:1621
static SYSTEM_INFO si
Definition: virtual.c:39
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
static BOOL is_cjk_charset(HDC dc)
Definition: edit.c:1498
static BOOL is_cjk_font(HDC dc)
Definition: edit.c:1612
#define menu
Definition: input.c:3282
#define shift
Definition: input.c:3280
#define ctrl
Definition: input.c:3281
static DWORD get_input_codepage(void)
Definition: msg.c:16553
#define min(a, b)
Definition: monoChain.cc:55
UINT_PTR HKL
Definition: msctf.idl:125
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
Definition: mk_font.cpp:20
unsigned int * PUINT
Definition: ndis.h:50
#define BOOL
Definition: nt_native.h:43
#define LRESULT
Definition: ole.h:14
#define LOWORD(l)
Definition: pedump.c:82
#define ES_PASSWORD
Definition: pedump.c:670
#define ES_READONLY
Definition: pedump.c:675
#define ES_LOWERCASE
Definition: pedump.c:669
#define ES_AUTOVSCROLL
Definition: pedump.c:671
#define ES_WANTRETURN
Definition: pedump.c:676
#define ES_UPPERCASE
Definition: pedump.c:668
short WCHAR
Definition: pedump.c:58
#define WS_BORDER
Definition: pedump.c:625
#define ES_NOHIDESEL
Definition: pedump.c:673
#define WS_VSCROLL
Definition: pedump.c:627
#define ES_AUTOHSCROLL
Definition: pedump.c:672
short SHORT
Definition: pedump.c:59
long LONG
Definition: pedump.c:60
#define WS_DISABLED
Definition: pedump.c:621
#define ES_LEFT
Definition: pedump.c:664
#define WS_HSCROLL
Definition: pedump.c:628
#define ES_CENTER
Definition: pedump.c:665
#define ES_RIGHT
Definition: pedump.c:666
char CHAR
Definition: pedump.c:57
#define ES_MULTILINE
Definition: pedump.c:667
#define INT
Definition: polytest.cpp:20
#define WM_PAINT
Definition: winuser.h:1648
#define EM_SETREADONLY
Definition: winuser.h:2044
#define WM_ERASEBKGND
Definition: winuser.h:1653
DWORD WINAPI GetSysColor(_In_ int)
#define MAKEWPARAM(l, h)
Definition: winuser.h:4117
BOOL WINAPI CopyRect(_Out_ LPRECT, _In_ LPCRECT)
BOOL WINAPI IsWindow(_In_opt_ HWND)
#define EM_GETIMESTATUS
Definition: winuser.h:2016
#define WM_CTLCOLORSTATIC
Definition: winuser.h:1800
#define MK_SHIFT
Definition: winuser.h:2405
#define WM_GETTEXTLENGTH
Definition: winuser.h:1647
#define EM_GETRECT
Definition: winuser.h:2025
HKL WINAPI GetKeyboardLayout(_In_ DWORD)
#define WM_IME_REQUEST
Definition: winuser.h:1864
#define WM_CLOSE
Definition: winuser.h:1649
#define SB_THUMBTRACK
Definition: winuser.h:573
#define GetWindowLongPtrW
Definition: winuser.h:4983
#define EM_LINEFROMCHAR
Definition: winuser.h:2030
#define VK_TAB
Definition: winuser.h:2235
#define WM_ENABLE
Definition: winuser.h:1643
#define SB_LINEUP
Definition: winuser.h:564
#define WM_HSCROLL
Definition: winuser.h:1771
#define WM_PASTE
Definition: winuser.h:1891
#define EN_KILLFOCUS
Definition: winuser.h:2054
#define COLOR_GRAYTEXT
Definition: winuser.h:943
#define EM_GETWORDBREAKPROC
Definition: winuser.h:2028
#define EM_FMTLINES
Definition: winuser.h:2015
#define EM_GETPASSWORDCHAR
Definition: winuser.h:2024
#define COLOR_WINDOWFRAME
Definition: winuser.h:930
int(CALLBACK * EDITWORDBREAKPROCA)(LPSTR, int, int, int)
Definition: winuser.h:3012
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define EC_RIGHTMARGIN
Definition: winuser.h:2643
LRESULT WINAPI DefWindowProcA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_CAPTURECHANGED
Definition: winuser.h:1836
struct tagSCROLLINFO SCROLLINFO
#define WM_VSCROLL
Definition: winuser.h:1772
#define TPM_RIGHTBUTTON
Definition: winuser.h:2416
#define SIF_RANGE
Definition: winuser.h:1246
#define WM_CREATE
Definition: winuser.h:1636
#define DLGC_WANTCHARS
Definition: winuser.h:2660
#define CB_SHOWDROPDOWN
Definition: winuser.h:1999
#define EM_SETIMESTATUS
Definition: winuser.h:2039
#define EM_GETSEL
Definition: winuser.h:2026
#define EN_SETFOCUS
Definition: winuser.h:2056
#define EM_SETPASSWORDCHAR
Definition: winuser.h:2043
#define EN_UPDATE
Definition: winuser.h:2057
#define EM_GETMODIFY
Definition: winuser.h:2023
#define SB_PAGERIGHT
Definition: winuser.h:571
#define WB_ISDELIMITER
Definition: winuser.h:549
#define WM_SIZE
Definition: winuser.h:1639
#define COLOR_HIGHLIGHT
Definition: winuser.h:937
HBRUSH WINAPI GetSysColorBrush(_In_ int)
HANDLE WINAPI SetClipboardData(_In_ UINT, _In_opt_ HANDLE)
#define SB_VERT
Definition: winuser.h:553
#define EM_EMPTYUNDOBUFFER
Definition: winuser.h:2014
#define SB_LEFT
Definition: winuser.h:575
LONG WINAPI SetWindowLongW(_In_ HWND, _In_ int, _In_ LONG)
LONG WINAPI GetWindowLongW(_In_ HWND, _In_ int)
#define SB_BOTTOM
Definition: winuser.h:577
#define DLGC_WANTALLKEYS
Definition: winuser.h:2654
#define WM_LBUTTONDBLCLK
Definition: winuser.h:1806
#define WM_COMMAND
Definition: winuser.h:1768
#define SW_INVALIDATE
Definition: winuser.h:2615
#define EM_REPLACESEL
Definition: winuser.h:2035
struct tagCREATESTRUCTA * LPCREATESTRUCTA
#define EC_USEFONTINFO
Definition: winuser.h:2644
#define VK_CONTROL
Definition: winuser.h:2239
#define EM_SETRECT
Definition: winuser.h:2045
#define DC_HASDEFID
Definition: winuser.h:2651
#define VK_UP
Definition: winuser.h:2261
BOOL WINAPI IsRectEmpty(_In_ LPCRECT)
#define WM_SETFOCUS
Definition: winuser.h:1641
#define SIF_PAGE
Definition: winuser.h:1244
#define WM_MOUSEMOVE
Definition: winuser.h:1803
#define WM_GETTEXT
Definition: winuser.h:1646
HWND WINAPI GetCapture(void)
Definition: message.c:2881
#define TPM_NONOTIFY
Definition: winuser.h:2422
BOOL WINAPI OpenClipboard(_In_opt_ HWND)
#define WM_CUT
Definition: winuser.h:1889
#define SB_LINERIGHT
Definition: winuser.h:567
#define CS_DBLCLKS
Definition: winuser.h:659
#define EN_MAXTEXT
Definition: winuser.h:2055
#define WM_LBUTTONDOWN
Definition: winuser.h:1804
#define EM_LINEINDEX
Definition: winuser.h:2031
#define EN_HSCROLL
Definition: winuser.h:2053
HANDLE WINAPI GetClipboardData(_In_ UINT)
#define SIF_TRACKPOS
Definition: winuser.h:1248
int WINAPI MapWindowPoints(_In_opt_ HWND hWndFrom, _In_opt_ HWND hWndTo, _Inout_updates_(cPoints) LPPOINT lpPoints, _In_ UINT cPoints)
#define WM_GETFONT
Definition: winuser.h:1679
#define EM_LINESCROLL
Definition: winuser.h:2033
#define EM_GETFIRSTVISIBLELINE
Definition: winuser.h:2017
#define EM_GETHANDLE
Definition: winuser.h:2018
BOOL WINAPI ClientToScreen(_In_ HWND, _Inout_ LPPOINT)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define WM_NEXTDLGCTL
Definition: winuser.h:1671
#define WM_UNDO
Definition: winuser.h:1893
#define VK_NEXT
Definition: winuser.h:2257
#define WM_NCCREATE
Definition: winuser.h:1711
#define WM_IME_SETCONTEXT
Definition: winuser.h:1857
BOOL WINAPI PtInRect(_In_ LPCRECT, _In_ POINT)
#define WM_SETTEXT
Definition: winuser.h:1645
#define EM_CANUNDO
Definition: winuser.h:2012
#define EM_LINELENGTH
Definition: winuser.h:2032
#define CBS_SIMPLE
Definition: winuser.h:291
#define SM_CYBORDER
Definition: winuser.h:976
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define EM_SETHANDLE
Definition: winuser.h:2038
#define VK_RETURN
Definition: winuser.h:2237
#define EM_GETLINE
Definition: winuser.h:2020
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
#define EM_SETRECTNP
Definition: winuser.h:2046
#define SB_LINELEFT
Definition: winuser.h:566
#define SIZE_MAXIMIZED
Definition: winuser.h:2543
#define MF_ENABLED
Definition: winuser.h:128
#define MK_CONTROL
Definition: winuser.h:2406
#define EM_SETLIMITTEXT
Definition: winuser.h:2040
#define WB_LEFT
Definition: winuser.h:550
#define WM_SETFONT
Definition: winuser.h:1678
#define VK_END
Definition: winuser.h:2258
#define TPM_LEFTALIGN
Definition: winuser.h:2413
#define VK_HOME
Definition: winuser.h:2259
#define MF_BYPOSITION
Definition: winuser.h:203
#define EM_UNDO
Definition: winuser.h:2050
#define SM_CXBORDER
Definition: winuser.h:975
#define DLGC_WANTARROWS
Definition: winuser.h:2652
#define SIF_DISABLENOSCROLL
Definition: winuser.h:1247
#define EM_SCROLL
Definition: winuser.h:2036
BOOL WINAPI IntersectRect(_Out_ LPRECT, _In_ LPCRECT, _In_ LPCRECT)
#define SB_PAGEDOWN
Definition: winuser.h:569
#define EM_SETWORDBREAKPROC
Definition: winuser.h:2049
#define SendMessage
Definition: winuser.h:6009
#define IDC_IBEAM
Definition: winuser.h:696
#define VK_BACK
Definition: winuser.h:2234
#define COLOR_HIGHLIGHTTEXT
Definition: winuser.h:938
#define SB_LINEDOWN
Definition: winuser.h:565
#define EM_SETSEL
Definition: winuser.h:2047
#define CBS_DROPDOWN
Definition: winuser.h:283
#define GetWindowLong
Definition: winuser.h:5962
#define VK_F4
Definition: winuser.h:2294
int(CALLBACK * EDITWORDBREAKPROCW)(LPWSTR, int, int, int)
Definition: winuser.h:3013
#define CB_GETDROPPEDSTATE
Definition: winuser.h:1974
#define ES_NUMBER
Definition: winuser.h:301
#define WM_LBUTTONUP
Definition: winuser.h:1805
#define WB_RIGHT
Definition: winuser.h:551
BOOL WINAPI SystemParametersInfoW(_In_ UINT uiAction, _In_ UINT uiParam, _Inout_opt_ PVOID pvParam, _In_ UINT fWinIni)
#define WM_CHAR
Definition: winuser.h:1745
BOOL WINAPI SetRectEmpty(_Out_ LPRECT)
HWND WINAPI GetParent(_In_ HWND)
#define VK_LEFT
Definition: winuser.h:2260
#define WM_NCDESTROY
Definition: winuser.h:1712
#define VK_RIGHT
Definition: winuser.h:2262
#define SIZE_RESTORED
Definition: winuser.h:2541
#define SB_TOP
Definition: winuser.h:578
#define EN_VSCROLL
Definition: winuser.h:2058
#define CB_GETEXTENDEDUI
Definition: winuser.h:1977
#define SIF_POS
Definition: winuser.h:1245
#define VK_DOWN
Definition: winuser.h:2263
#define GWLP_ID
Definition: winuser.h:871
#define WM_COPY
Definition: winuser.h:1890
#define EM_GETTHUMB
Definition: winuser.h:2027
#define SB_ENDSCROLL
Definition: winuser.h:574
#define EM_GETMARGINS
Definition: winuser.h:2022
#define WM_IME_CONTROL
Definition: winuser.h:1859
#define VK_SHIFT
Definition: winuser.h:2238
#define EM_SETTABSTOPS
Definition: winuser.h:2048
#define DLGC_WANTMESSAGE
Definition: winuser.h:2655
BOOL WINAPI TrackPopupMenu(_In_ HMENU, _In_ UINT, _In_ int, _In_ int, _Reserved_ int, _In_ HWND, _Reserved_ LPCRECT)
#define VK_PRIOR
Definition: winuser.h:2256
int WINAPI SetScrollInfo(_In_ HWND, _In_ int, _In_ LPCSCROLLINFO, _In_ BOOL)
#define VK_DELETE
Definition: winuser.h:2269
#define WM_IME_SELECT
Definition: winuser.h:1861
#define WS_EX_CLIENTEDGE
Definition: winuser.h:384
#define WM_CLEAR
Definition: winuser.h:1892
#define WM_KEYDOWN
Definition: winuser.h:1743
#define CB_SETEXTENDEDUI
Definition: winuser.h:1993
#define EM_GETLINECOUNT
Definition: winuser.h:2021
#define SB_RIGHT
Definition: winuser.h:576
BOOL WINAPI SetCaretPos(_In_ int, _In_ int)
int WINAPI GetScrollPos(_In_ HWND, _In_ int)
BOOL WINAPI CreateCaret(_In_ HWND, _In_opt_ HBITMAP, _In_ int, _In_ int)
BOOL WINAPI DestroyCaret(void)
Definition: caret.c:35
#define EC_LEFTMARGIN
Definition: winuser.h:2642
#define DM_GETDEFID
Definition: winuser.h:2134
#define TPM_RETURNCMD
Definition: winuser.h:2423
#define SystemParametersInfo
Definition: winuser.h:6024
#define EN_ERRSPACE
Definition: winuser.h:2052
#define GWL_STYLE
Definition: winuser.h:863
BOOL WINAPI GetScrollInfo(_In_ HWND, _In_ int, _Inout_ LPSCROLLINFO)
#define CS_PARENTDC
Definition: winuser.h:664
#define EM_SETMARGINS
Definition: winuser.h:2041
#define WM_CTLCOLOREDIT
Definition: winuser.h:1795
#define VK_ESCAPE
Definition: winuser.h:2250
#define DLGC_HASSETSEL
Definition: winuser.h:2656
BOOL WINAPI IsWindowVisible(_In_ HWND)
#define WM_KILLFOCUS
Definition: winuser.h:1642
int WINAPI GetSystemMetrics(_In_ int)
#define SB_PAGEUP
Definition: winuser.h:568
#define WM_SYSKEYDOWN
Definition: winuser.h:1747
#define VK_INSERT
Definition: winuser.h:2268
#define WM_GETDLGCODE
Definition: winuser.h:1717
#define WM_MBUTTONDOWN
Definition: winuser.h:1810
#define EM_SETMODIFY
Definition: winuser.h:2042
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define SB_HORZ
Definition: winuser.h:552
#define VK_MENU
Definition: winuser.h:2240
#define WS_EX_RIGHT
Definition: winuser.h:400
#define SB_PAGELEFT
Definition: winuser.h:570
#define GWL_EXSTYLE
Definition: winuser.h:862
#define MF_GRAYED
Definition: winuser.h:129
#define EN_CHANGE
Definition: winuser.h:2051
#define WM_SETREDRAW
Definition: winuser.h:1644
#define SB_THUMBPOSITION
Definition: winuser.h:572
LONG WINAPI TabbedTextOutW(_In_ HDC hdc, _In_ int x, _In_ int y, _In_reads_(chCount) LPCWSTR lpString, _In_ int chCount, _In_ int nTabPositions, _In_reads_opt_(nTabPositions) CONST INT *lpnTabStopPositions, _In_ int nTabOrigin)
HMENU WINAPI LoadMenuA(_In_opt_ HINSTANCE, _In_ LPCSTR)
void redraw(int x, int y, int cx, int cy)
Definition: qtewin.cpp:1248
PFNCLIENT pfnClientA
Definition: regcontrol.c:15
PFNCLIENT pfnClientW
Definition: regcontrol.c:16
const struct builtin_class_descr EDIT_builtin_class
#define EM_SCROLLCARET
Definition: richedit.h:81
#define WM_UNICHAR
Definition: richedit.h:67
#define EM_POSFROMCHAR
Definition: richedit.h:77
#define WM_CONTEXTMENU
Definition: richedit.h:64
#define EM_CHARFROMPOS
Definition: richedit.h:78
#define WM_PRINTCLIENT
Definition: richedit.h:70
#define EM_GETLIMITTEXT
Definition: richedit.h:74
#define PRIMARYLANGID(l)
Definition: nls.h:16
#define LANG_KOREAN
Definition: nls.h:84
#define memset(x, y, z)
Definition: compat.h:39
#define UINT
Definition: utils.c:29
#define TRACE(s)
Definition: solgame.cpp:4
wchar_t const *const size_t const buffer_size
Definition: stat.cpp:95
RECT rcArea
Definition: dimm.idl:88
DWORD dwStyle
Definition: dimm.idl:86
POINT ptCurrentPos
Definition: dimm.idl:87
Definition: edit.c:96
Definition: dcommon.idl:28
long bottom
Definition: dcommon.idl:29
long right
Definition: dcommon.idl:29
long left
Definition: dcommon.idl:29
long top
Definition: dcommon.idl:29
Definition: wingdi.h:1856
int abcA
Definition: wingdi.h:1857
int abcC
Definition: wingdi.h:1859
WNDPROC pfnEditWndProc
Definition: ntuser.h:835
LONG cx
Definition: kdterminal.h:27
Definition: ftp_var.h:139
Definition: inflate.c:139
Definition: dialog.c:52
Definition: ffs.h:70
Definition: copy.c:22
Definition: parser.c:49
Definition: tftpd.h:60
Definition: name.c:39
Definition: style.c:91
INT width
Definition: edit.c:89
struct tagLINEDEF * next
Definition: edit.c:92
INT length
Definition: edit.c:86
SCRIPT_STRING_ANALYSIS ssa
Definition: edit.c:91
INT index
Definition: edit.c:90
INT net_length
Definition: edit.c:87
LINE_END ending
Definition: edit.c:88
LONG right
Definition: windef.h:108
LONG bottom
Definition: windef.h:109
LONG top
Definition: windef.h:107
LONG left
Definition: windef.h:106
int * pTabStops
Definition: usp10.h:173
#define max(a, b)
Definition: svc.c:63
PSYMCRYPT_PARALLEL_HASH_OPERATION next
#define WHEEL_DELTA
Definition: treelist.c:99
#define WM_MOUSEWHEEL
Definition: treelist.c:96
else
Definition: tritemp.h:161
const char * LPCSTR
Definition: typedefs.h:52
int32_t INT32
Definition: typedefs.h:58
const uint16_t * LPCWSTR
Definition: typedefs.h:57
uint16_t * LPWSTR
Definition: typedefs.h:56
char * LPSTR
Definition: typedefs.h:51
int32_t INT
Definition: typedefs.h:58
#define MAKELONG(a, b)
Definition: typedefs.h:249
#define HIWORD(l)
Definition: typedefs.h:247
#define WM_CBLOSTTEXTFOCUS
Definition: undocuser.h:52
#define user32_module
Definition: user32p.h:40
const char * SPY_GetMsgName(UINT msg, HWND hWnd)
Definition: spy.c:2232
#define NtUserSetPrivateData(HWND, OFFSET, SIZE, VALUE)
Definition: user_x.h:132
#define NtUserReleaseDC(HWND, HDC)
Definition: user_x.h:120
#define NTUSER_WNDPROC_EDIT
Definition: user_x.h:140
#define MAKE_FNID(index)
Definition: user_x.h:143
#define NtUserGetPrivateData(HWND, OFFSET, SIZE)
Definition: user_x.h:131
#define NtUserReleaseCapture()
Definition: user_x.h:121
#define SSA_TAB
Definition: usp10.h:34
#define SSA_FALLBACK
Definition: usp10.h:38
#define SSA_LINK
Definition: usp10.h:45
#define SSA_PASSWORD
Definition: usp10.h:33
#define SSA_GLYPHS
Definition: usp10.h:40
#define SCRIPT_UNDEFINED
Definition: usp10.h:69
static GLenum which
Definition: wgl_font.c:159
HBRUSH FASTCALL GetControlBrush(PWND pwnd, HDC hdc, UINT ctlType)
Definition: misc.c:179
static void EDIT_UpdateImmCompositionWindow(EDITSTATE *es, UINT x, UINT y)
Definition: edit.c:1906
static EDITSTATE * get_control_state(HWND hwnd)
Definition: edit.c:164
LRESULT WINAPI EditWndProc_common(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, BOOL unicode)
Definition: edit.c:4816
static LRESULT DefWindowProcT(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, BOOL unicode)
Definition: edit.c:4801
static int EDIT_is_valid_format_rect(const EDITSTATE *es, const RECT *rc)
Definition: edit.c:2453
DWORD get_app_version(void)
Definition: edit.c:215
static void EDIT_UpdateImmCompositionFont(EDITSTATE *es)
Definition: edit.c:4055
static EDITSTATE * set_control_state(HWND hwnd, EDITSTATE *state)
Definition: edit.c:169
#define GMEM_MOVEABLE
Definition: winbase.h:318
#define GMEM_DDESHARE
Definition: winbase.h:322
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
DWORD COLORREF
Definition: windef.h:100
#define WINAPI
Definition: msvc.h:6
int WINAPI GetBkMode(_In_ HDC)
BOOL WINAPI GetTextMetricsW(_In_ HDC, _Out_ LPTEXTMETRICW)
Definition: text.c:221
HGDIOBJ WINAPI GetStockObject(_In_ int)
int WINAPI GetObjectW(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
#define FS_JOHAB
Definition: wingdi.h:574
BOOL WINAPI GetCharABCWidthsA(_In_ HDC hdc, _In_ UINT wFirst, _In_ UINT wLast, _Out_writes_(wLast - wFirst+1) LPABC lpABC)
int WINAPI GetTextCharsetInfo(_In_ HDC, _Out_opt_ LPFONTSIGNATURE, _In_ DWORD)
int WINAPI GetClipBox(_In_ HDC, _Out_ LPRECT)
#define FS_WANSUNG
Definition: wingdi.h:572
COLORREF WINAPI SetBkColor(_In_ HDC, _In_ COLORREF)
Definition: dc.c:999
HRGN WINAPI CreateRectRgn(_In_ int, _In_ int, _In_ int, _In_ int)
LONG WINAPI GdiGetCharDimensions(HDC, LPTEXTMETRICW, LONG *)
Definition: font.c:2341
COLORREF WINAPI GetTextColor(_In_ HDC)
Definition: text.c:860
int WINAPI IntersectClipRect(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
#define DEFAULT_GUI_FONT
Definition: wingdi.h:909
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1546
#define DEFAULT_CHARSET
Definition: wingdi.h:384
int WINAPI CombineRgn(_In_opt_ HRGN hrgnDest, _In_opt_ HRGN hrgnSrc1, _In_opt_ HRGN hrgnSrc2, _In_ int fnCombineMode)
#define TMPF_TRUETYPE
Definition: wingdi.h:1313
COLORREF WINAPI GetBkColor(_In_ HDC)
Definition: dc.c:978
#define PATCOPY
Definition: wingdi.h:335
#define TMPF_VECTOR
Definition: wingdi.h:1312
#define OPAQUE
Definition: wingdi.h:949
#define RGN_OR
Definition: wingdi.h:359
#define FS_JISJAPAN
Definition: wingdi.h:570
#define FS_CHINESETRAD
Definition: wingdi.h:573
#define FS_CHINESESIMP
Definition: wingdi.h:571
BOOL WINAPI PatBlt(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD)
DWORD WINAPI GdiGetCodePage(HDC)
BOOL WINAPI TextOutW(_In_ HDC hdc, _In_ int x, _In_ int y, _In_reads_(c) LPCWSTR lpString, _In_ int c)
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
int WINAPI SetBkMode(_In_ HDC, _In_ int)
Definition: dc.c:1056
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:917
BOOL WINAPI SetRectRgn(_In_ HRGN, _In_ int, _In_ int, _In_ int, _In_ int)
BOOL WINAPI GetTextExtentPoint32W(_In_ HDC hdc, _In_reads_(c) LPCWSTR lpString, _In_ int c, _Out_ LPSIZE psizl)
BOOL WINAPI GetCharABCWidthsW(_In_ HDC hdc, _In_ UINT wFirst, _In_ UINT wLast, _Out_writes_(wLast - wFirst+1) LPABC lpABC)
struct _OSVERSIONINFOW OSVERSIONINFOW
unsigned char BYTE
Definition: xxhash.c:193