2 * RichEdit - functions dealing with editor object
4 * Copyright 2004 by Krzysztof Foltman
5 * Copyright 2005 by Cihan Altinay
6 * Copyright 2005 by Phil Krylov
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 API implementation status:
26 Messages (ANSI versions not done yet)
27 - EM_AUTOURLDETECT 2.0
38 + EM_FINDTEXT (only FR_DOWN flag implemented)
39 + EM_FINDTEXTEX (only FR_DOWN flag implemented)
43 - EM_GETAUTOURLDETECT 2.0
44 - EM_GETBIDIOPTIONS 3.0
45 - EM_GETCHARFORMAT (partly done)
48 + EM_GETFIRSTVISIBLELINE (can be optimized if needed)
49 - EM_GETIMECOLOR 1.0asian
50 - EM_GETIMECOMPMODE 2.0
51 - EM_GETIMEOPTIONS 1.0asian
53 - EM_GETLANGOPTIONS 2.0
56 + EM_GETLINECOUNT returns number of rows, not of paragraphs
61 - EM_GETPASSWORDCHAR 2.0
62 - EM_GETPUNCTUATION 1.0asian
66 + EM_GETSELTEXT (ANSI&Unicode)
70 + EM_GETTEXTLENGTHEX (GTL_PRECISE unimplemented)
72 ? + EM_GETTEXTRANGE (ANSI&Unicode)
73 - EM_GETTYPOGRAPHYOPTIONS 3.0
76 - EM_GETWORDBREAKPROCEX
77 - EM_GETWORDWRAPMODE 1.0asian
89 + EM_REPLACESEL (proper style?) ANSI&Unicode
93 - EM_SETBIDIOPTIONS 3.0
95 - EM_SETCHARFORMAT (partly done, no ANSI)
97 + EM_SETEVENTMASK (few notifications supported)
99 - EM_SETIMECOLOR 1.0asian
100 - EM_SETIMEOPTIONS 1.0asian
101 - EM_SETLANGOPTIONS 2.0
103 + EM_SETMODIFY (not sure if implementation is correct)
108 - EM_SETPASSWORDCHAR 2.0
109 - EM_SETPUNCTUATION 1.0asian
110 + EM_SETREADONLY no beep on modification attempt
112 + EM_SETRECTNP (EM_SETRECT without repainting)
114 - EM_SETSCROLLPOS 3.0
117 + EM_SETTEXTEX 3.0 (unicode only, no rich text insertion handling, proper style?)
119 - EM_SETTYPOGRAPHYOPTIONS 3.0
120 - EM_SETUNDOLIMIT 2.0
121 + EM_SETWORDBREAKPROC (used only for word movement at the moment)
122 - EM_SETWORDBREAKPROCEX
123 - EM_SETWORDWRAPMODE 1.0asian
125 - EM_SHOWSCROLLBAR 2.0
126 - EM_STOPGROUPTYPING 2.0
134 + WM_GETDLGCODE (the current implementation is incomplete)
135 + WM_GETTEXT (ANSI&Unicode)
136 + WM_GETTEXTLENGTH (ANSI version sucks)
139 + WM_SETTEXT (resets undo stack !) (proper style?) ANSI&Unicode
141 - WM_STYLECHANGED (things like read-only flag)
146 * EN_CHANGE (sent from the wrong place)
163 * EN_UPDATE (sent from the wrong place)
171 - ES_DISABLENOSCROLL (scrollbar is always visible)
172 - ES_EX_NOCALLOLEINIT
174 - ES_MULTILINE (currently single line controls aren't supported)
176 - ES_READONLY (I'm not sure if beeping is the proper behaviour)
182 - ES_WANTRETURN (don't know how to do WM_GETDLGCODE part)
189 * RICHED20 TODO (incomplete):
191 * - messages/styles/notifications listed above
193 * - add remaining CHARFORMAT/PARAFORMAT fields
194 * - right/center align should strip spaces from the beginning
195 * - pictures/OLE objects (not just smiling faces that lack API support ;-) )
196 * - COM interface (looks like a major pain in the TODO list)
197 * - calculate heights of pictures (half-done)
198 * - horizontal scrolling (not even started)
199 * - hysteresis during wrapping (related to scrollbars appearing/disappearing)
201 * - how to implement EM_FORMATRANGE and EM_DISPLAYBAND ? (Mission Impossible)
202 * - italic caret with italic fonts
204 * - most notifications aren't sent at all (the most important ones are)
205 * - when should EN_SELCHANGE be sent after text change ? (before/after EN_UPDATE?)
206 * - WM_SETTEXT may use wrong style (but I'm 80% sure it's OK)
207 * - EM_GETCHARFORMAT with SCF_SELECTION may not behave 100% like in original (but very close)
208 * - full justification
211 * - ListBox & ComboBox not implemented
213 * Bugs that are probably fixed, but not so easy to verify:
214 * - EN_UPDATE/EN_CHANGE are handled very incorrectly (should be OK now)
215 * - undo for ME_JoinParagraphs doesn't store paragraph format ? (it does)
216 * - check/fix artificial EOL logic (bCursorAtEnd, hardly logical)
217 * - caret shouldn't be displayed when selection isn't empty
218 * - check refcounting in style management functions (looks perfect now, but no bugs is suspicious)
219 * - undo for setting default format (done, might be buggy)
220 * - styles might be not released properly (looks like they work like charm, but who knows?
227 #define NO_SHLWAPI_STREAM
230 #include "textserv.h"
233 WINE_DEFAULT_DEBUG_CHANNEL(richedit
);
236 HANDLE me_heap
= NULL
;
238 static BOOL ME_ListBoxRegistered
= FALSE
;
239 static BOOL ME_ComboBoxRegistered
= FALSE
;
241 static ME_TextBuffer
*ME_MakeText(void) {
243 ME_TextBuffer
*buf
= ALLOC_OBJ(ME_TextBuffer
);
245 ME_DisplayItem
*p1
= ME_MakeDI(diTextStart
);
246 ME_DisplayItem
*p2
= ME_MakeDI(diTextEnd
);
252 p1
->member
.para
.next_para
= p2
;
253 p2
->member
.para
.prev_para
= p1
;
254 p2
->member
.para
.nCharOfs
= 0;
258 buf
->pCharStyle
= NULL
;
264 static LRESULT
ME_StreamInText(ME_TextEditor
*editor
, DWORD dwFormat
, ME_InStream
*stream
, ME_Style
*style
)
266 WCHAR wszText
[STREAMIN_BUFFER_SIZE
+1];
269 TRACE("%08lx %p\n", dwFormat
, stream
);
276 ME_StreamInFill(stream
);
277 if (stream
->editstream
->dwError
)
283 if (!(dwFormat
& SF_UNICODE
))
285 /* FIXME? this is doomed to fail on true MBCS like UTF-8, luckily they're unlikely to be used as CP_ACP */
286 nWideChars
= MultiByteToWideChar(CP_ACP
, 0, stream
->buffer
, stream
->dwSize
, wszText
, STREAMIN_BUFFER_SIZE
);
291 nWideChars
= stream
->dwSize
>> 1;
292 pText
= (WCHAR
*)stream
->buffer
;
295 ME_InsertTextFromCursor(editor
, 0, pText
, nWideChars
, style
);
296 if (stream
->dwSize
== 0)
300 ME_CommitUndo(editor
);
301 ME_UpdateRepaint(editor
);
305 static void ME_RTFCharAttrHook(RTF_Info
*info
)
308 fmt
.cbSize
= sizeof(fmt
);
311 switch(info
->rtfMinor
)
314 /* FIXME add more flags once they're implemented */
315 fmt
.dwMask
= CFM_BOLD
| CFM_ITALIC
| CFM_UNDERLINE
| CFM_STRIKEOUT
| CFM_COLOR
| CFM_BACKCOLOR
| CFM_SIZE
| CFM_WEIGHT
;
316 fmt
.dwEffects
= CFE_AUTOCOLOR
| CFE_AUTOBACKCOLOR
;
317 fmt
.yHeight
= 12*20; /* 12pt */
321 fmt
.dwMask
= CFM_BOLD
;
322 fmt
.dwEffects
= info
->rtfParam
? fmt
.dwMask
: 0;
325 fmt
.dwMask
= CFM_ITALIC
;
326 fmt
.dwEffects
= info
->rtfParam
? fmt
.dwMask
: 0;
329 fmt
.dwMask
= CFM_UNDERLINE
;
330 fmt
.dwEffects
= info
->rtfParam
? fmt
.dwMask
: 0;
331 fmt
.bUnderlineType
= CFU_CF1UNDERLINE
;
334 fmt
.dwMask
= CFM_UNDERLINE
;
338 fmt
.dwMask
= CFM_STRIKEOUT
;
339 fmt
.dwEffects
= info
->rtfParam
? fmt
.dwMask
: 0;
343 case rtfSubScrShrink
:
344 case rtfSuperScrShrink
:
346 fmt
.dwMask
= CFM_SUBSCRIPT
|CFM_SUPERSCRIPT
;
347 if (info
->rtfMinor
== rtfSubScrShrink
) fmt
.dwEffects
= CFE_SUBSCRIPT
;
348 if (info
->rtfMinor
== rtfSuperScrShrink
) fmt
.dwEffects
= CFE_SUPERSCRIPT
;
349 if (info
->rtfMinor
== rtfNoSuperSub
) fmt
.dwEffects
= 0;
352 fmt
.dwMask
= CFM_HIDDEN
;
353 fmt
.dwEffects
= info
->rtfParam
? fmt
.dwMask
: 0;
356 fmt
.dwMask
= CFM_BACKCOLOR
;
358 if (info
->rtfParam
== 0)
359 fmt
.dwEffects
= CFE_AUTOBACKCOLOR
;
360 else if (info
->rtfParam
!= rtfNoParam
)
362 RTFColor
*c
= RTFGetColor(info
, info
->rtfParam
);
363 fmt
.crTextColor
= (c
->rtfCBlue
<<16)|(c
->rtfCGreen
<<8)|(c
->rtfCRed
);
367 fmt
.dwMask
= CFM_COLOR
;
369 if (info
->rtfParam
== 0)
370 fmt
.dwEffects
= CFE_AUTOCOLOR
;
371 else if (info
->rtfParam
!= rtfNoParam
)
373 RTFColor
*c
= RTFGetColor(info
, info
->rtfParam
);
374 fmt
.crTextColor
= (c
->rtfCBlue
<<16)|(c
->rtfCGreen
<<8)|(c
->rtfCRed
);
378 if (info
->rtfParam
!= rtfNoParam
)
380 RTFFont
*f
= RTFGetFont(info
, info
->rtfParam
);
383 MultiByteToWideChar(CP_ACP
, 0, f
->rtfFName
, -1, fmt
.szFaceName
, sizeof(fmt
.szFaceName
)/sizeof(WCHAR
));
384 fmt
.szFaceName
[sizeof(fmt
.szFaceName
)/sizeof(WCHAR
)-1] = '\0';
385 fmt
.bCharSet
= f
->rtfFCharSet
;
386 fmt
.dwMask
= CFM_FACE
| CFM_CHARSET
;
391 fmt
.dwMask
= CFM_SIZE
;
392 if (info
->rtfParam
!= rtfNoParam
)
393 fmt
.yHeight
= info
->rtfParam
*10;
398 RTFFlushOutputBuffer(info
);
399 /* FIXME too slow ? how come ? */
400 style2
= ME_ApplyStyle(info
->style
, &fmt
);
401 ME_ReleaseStyle(info
->style
);
402 info
->style
= style2
;
403 info
->styleChanged
= TRUE
;
407 /* FIXME this function doesn't get any information about context of the RTF tag, which is very bad,
408 the same tags mean different things in different contexts */
409 static void ME_RTFParAttrHook(RTF_Info
*info
)
412 fmt
.cbSize
= sizeof(fmt
);
415 switch(info
->rtfMinor
)
417 case rtfParDef
: /* I'm not 100% sure what does it do, but I guess it restores default paragraph attributes */
418 fmt
.dwMask
= PFM_ALIGNMENT
| PFM_TABSTOPS
| PFM_OFFSET
| PFM_STARTINDENT
;
419 fmt
.wAlignment
= PFA_LEFT
;
421 fmt
.dxOffset
= fmt
.dxStartIndent
= 0;
424 ME_GetSelectionParaFormat(info
->editor
, &fmt
);
425 fmt
.dwMask
= PFM_STARTINDENT
| PFM_OFFSET
;
426 fmt
.dxStartIndent
+= info
->rtfParam
+ fmt
.dxOffset
;
427 fmt
.dxOffset
= -info
->rtfParam
;
430 ME_GetSelectionParaFormat(info
->editor
, &fmt
);
431 fmt
.dwMask
= PFM_STARTINDENT
;
432 fmt
.dxStartIndent
= -fmt
.dxOffset
+ info
->rtfParam
;
435 fmt
.dwMask
= PFM_RIGHTINDENT
;
436 fmt
.dxRightIndent
= info
->rtfParam
;
440 fmt
.dwMask
= PFM_ALIGNMENT
;
441 fmt
.wAlignment
= PFA_LEFT
;
444 fmt
.dwMask
= PFM_ALIGNMENT
;
445 fmt
.wAlignment
= PFA_RIGHT
;
448 fmt
.dwMask
= PFM_ALIGNMENT
;
449 fmt
.wAlignment
= PFA_CENTER
;
452 ME_GetSelectionParaFormat(info
->editor
, &fmt
);
453 if (!(fmt
.dwMask
& PFM_TABSTOPS
))
455 fmt
.dwMask
|= PFM_TABSTOPS
;
458 if (fmt
.cTabCount
< MAX_TAB_STOPS
)
459 fmt
.rgxTabs
[fmt
.cTabCount
++] = info
->rtfParam
;
463 RTFFlushOutputBuffer(info
);
464 /* FIXME too slow ? how come ?*/
465 ME_SetSelectionParaFormat(info
->editor
, &fmt
);
469 static void ME_RTFReadHook(RTF_Info
*info
) {
470 switch(info
->rtfClass
)
473 switch(info
->rtfMajor
)
476 if (info
->stackTop
< maxStack
) {
477 memcpy(&info
->stack
[info
->stackTop
].fmt
, &info
->style
->fmt
, sizeof(CHARFORMAT2W
));
478 info
->stack
[info
->stackTop
].codePage
= info
->codePage
;
479 info
->stack
[info
->stackTop
].unicodeLength
= info
->unicodeLength
;
482 info
->styleChanged
= FALSE
;
487 RTFFlushOutputBuffer(info
);
488 if (info
->stackTop
<=1) {
489 info
->rtfClass
= rtfEOF
;
493 assert(info
->stackTop
>= 0);
494 if (info
->styleChanged
)
496 /* FIXME too slow ? how come ? */
497 s
= ME_ApplyStyle(info
->style
, &info
->stack
[info
->stackTop
].fmt
);
498 ME_ReleaseStyle(info
->style
);
500 info
->codePage
= info
->stack
[info
->stackTop
].codePage
;
501 info
->unicodeLength
= info
->stack
[info
->stackTop
].unicodeLength
;
508 switch(info
->rtfMajor
)
511 ME_RTFCharAttrHook(info
);
514 ME_RTFParAttrHook(info
);
522 ME_StreamInFill(ME_InStream
*stream
)
524 stream
->editstream
->dwError
= stream
->editstream
->pfnCallback(stream
->editstream
->dwCookie
,
525 (BYTE
*)stream
->buffer
,
526 sizeof(stream
->buffer
),
527 (LONG
*)&stream
->dwSize
);
531 static LRESULT
ME_StreamIn(ME_TextEditor
*editor
, DWORD format
, EDITSTREAM
*stream
)
535 int from
, to
, to2
, nUndoMode
;
537 int nEventMask
= editor
->nEventMask
;
538 ME_InStream inStream
;
540 TRACE("stream==%p hWnd==%p format==0x%X\n", stream
, editor
->hWnd
, (UINT
)format
);
541 editor
->nEventMask
= 0;
543 ME_GetSelection(editor
, &from
, &to
);
544 if (format
& SFF_SELECTION
) {
545 style
= ME_GetSelectionInsertStyle(editor
);
547 ME_InternalDeleteText(editor
, from
, to
-from
);
550 style
= editor
->pBuffer
->pDefaultStyle
;
551 ME_AddRefStyle(style
);
552 SendMessageA(editor
->hWnd
, EM_SETSEL
, 0, 0);
553 ME_InternalDeleteText(editor
, 0, ME_GetTextLength(editor
));
555 ME_ClearTempStyle(editor
);
556 /* FIXME restore default paragraph formatting ! */
559 nUndoMode
= editor
->nUndoMode
;
560 editor
->nUndoMode
= umIgnore
;
562 inStream
.editstream
= stream
;
563 inStream
.editstream
->dwError
= 0;
569 /* Check if it's really RTF, and if it is not, use plain text */
570 ME_StreamInFill(&inStream
);
571 if (!inStream
.editstream
->dwError
)
573 if (strncmp(inStream
.buffer
, "{\\rtf1", 6) && strncmp(inStream
.buffer
, "{\\urtf", 6))
581 if (!inStream
.editstream
->dwError
)
583 if (format
& SF_RTF
) {
584 /* setup the RTF parser */
585 memset(&parser
, 0, sizeof parser
);
586 RTFSetEditStream(&parser
, &inStream
);
587 parser
.rtfFormat
= format
&(SF_TEXT
|SF_RTF
);
588 parser
.hwndEdit
= editor
->hWnd
;
589 parser
.editor
= editor
;
590 parser
.style
= style
;
593 RTFSetReadHook(&parser
, ME_RTFReadHook
);
598 RTFFlushOutputBuffer(&parser
);
601 style
= parser
.style
;
603 else if (format
& SF_TEXT
)
604 ME_StreamInText(editor
, format
, &inStream
, style
);
606 ERR("EM_STREAMIN without SF_TEXT or SF_RTF\n");
607 ME_GetSelection(editor
, &to
, &to2
);
608 /* put the cursor at the top */
609 if (!(format
& SFF_SELECTION
))
610 SendMessageA(editor
->hWnd
, EM_SETSEL
, 0, 0);
613 editor
->nUndoMode
= nUndoMode
;
614 pUI
= ME_AddUndoItem(editor
, diUndoDeleteRun
, NULL
);
615 TRACE("from %d to %d\n", from
, to
);
616 if (pUI
&& from
< to
)
621 ME_CommitUndo(editor
);
622 ME_ReleaseStyle(style
);
623 editor
->nEventMask
= nEventMask
;
626 ME_UpdateRepaint(editor
);
628 if (!(format
& SFF_SELECTION
)) {
629 ME_ClearTempStyle(editor
);
631 ME_MoveCaret(editor
);
632 ME_SendSelChange(editor
);
633 ME_SendRequestResize(editor
, FALSE
);
640 ME_FindItemAtOffset(ME_TextEditor
*editor
, ME_DIType nItemType
, int nOffset
, int *nItemOffset
)
642 ME_DisplayItem
*item
= ME_FindItemFwd(editor
->pBuffer
->pFirst
, diParagraph
);
644 while (item
&& item
->member
.para
.next_para
->member
.para
.nCharOfs
<= nOffset
)
645 item
= ME_FindItemFwd(item
, diParagraph
);
650 nOffset
-= item
->member
.para
.nCharOfs
;
651 if (nItemType
== diParagraph
) {
653 *nItemOffset
= nOffset
;
658 item
= ME_FindItemFwd(item
, diRun
);
659 } while (item
&& (item
->member
.run
.nCharOfs
+ ME_StrLen(item
->member
.run
.strText
) <= nOffset
));
661 nOffset
-= item
->member
.run
.nCharOfs
;
663 *nItemOffset
= nOffset
;
670 ME_FindText(ME_TextEditor
*editor
, DWORD flags
, CHARRANGE
*chrg
, WCHAR
*text
, CHARRANGE
*chrgText
)
673 int nLen
= lstrlenW(text
);
675 ME_DisplayItem
*item
;
676 ME_DisplayItem
*para
;
678 TRACE("flags==0x%08lx, chrg->cpMin==%ld, chrg->cpMax==%ld text==%s\n",
679 flags
, chrg
->cpMin
, chrg
->cpMax
, debugstr_w(text
));
681 if (!(flags
& FR_MATCHCASE
))
682 FIXME("Case-insensitive search not implemented\n");
683 if (flags
& ~(FR_DOWN
| FR_MATCHCASE
))
684 FIXME("Flags 0x%08lx not implemented\n", flags
& ~(FR_DOWN
| FR_MATCHCASE
));
686 if (chrg
->cpMax
== -1)
689 nMax
= ME_GetTextLength(editor
);
693 nMin
= min(chrg
->cpMin
, chrg
->cpMax
);
694 nMax
= max(chrg
->cpMin
, chrg
->cpMax
);
700 chrgText
->cpMin
= chrgText
->cpMax
= ((flags
& FR_DOWN
) ? nMin
: nMax
);
701 return chrgText
->cpMin
;
704 if (flags
& FR_DOWN
) /* Forward search */
707 item
= ME_FindItemAtOffset(editor
, diRun
, nStart
, &nStart
);
711 para
= ME_GetParagraph(item
);
713 && para
->member
.para
.nCharOfs
+ item
->member
.run
.nCharOfs
+ nStart
+ nLen
< nMax
)
715 ME_DisplayItem
*pCurItem
= item
;
716 int nCurStart
= nStart
;
719 while (pCurItem
&& pCurItem
->member
.run
.strText
->szData
[nCurStart
+ nMatched
] == text
[nMatched
])
722 if (nMatched
== nLen
)
724 nStart
+= para
->member
.para
.nCharOfs
+ item
->member
.run
.nCharOfs
;
727 chrgText
->cpMin
= nStart
;
728 chrgText
->cpMax
= nStart
+ nLen
;
730 TRACE("found at %d-%d\n", nStart
, nStart
+ nLen
);
733 if (nCurStart
+ nMatched
== ME_StrLen(pCurItem
->member
.run
.strText
))
735 pCurItem
= ME_FindItemFwd(pCurItem
, diRun
);
736 para
= ME_GetParagraph(pCurItem
);
737 nCurStart
= -nMatched
;
741 if (nStart
== ME_StrLen(item
->member
.run
.strText
))
743 item
= ME_FindItemFwd(item
, diRun
);
744 para
= ME_GetParagraph(item
);
749 else /* Backward search */
752 item
= ME_FindItemAtOffset(editor
, diRun
, nEnd
, &nEnd
);
756 para
= ME_GetParagraph(item
);
759 && para
->member
.para
.nCharOfs
+ item
->member
.run
.nCharOfs
+ nEnd
- nLen
>= nMin
)
761 ME_DisplayItem
*pCurItem
= item
;
765 while (pCurItem
&& pCurItem
->member
.run
.strText
->szData
[nCurEnd
- nMatched
- 1] == text
[nLen
- nMatched
- 1])
768 if (nMatched
== nLen
)
770 nStart
= para
->member
.para
.nCharOfs
+ item
->member
.run
.nCharOfs
+ nCurEnd
- nMatched
;
773 chrgText
->cpMin
= nStart
;
774 chrgText
->cpMax
= nStart
+ nLen
;
776 TRACE("found at %d-%d\n", nStart
, nStart
+ nLen
);
779 if (nCurEnd
- nMatched
== 0)
781 pCurItem
= ME_FindItemBack(pCurItem
, diRun
);
782 para
= ME_GetParagraph(pCurItem
);
783 nCurEnd
= ME_StrLen(pCurItem
->member
.run
.strText
) + nMatched
;
789 item
= ME_FindItemBack(item
, diRun
);
790 para
= ME_GetParagraph(item
);
791 nEnd
= ME_StrLen(item
->member
.run
.strText
);
795 TRACE("not found\n");
801 ME_KeyDown(ME_TextEditor
*editor
, WORD nKey
)
803 BOOL ctrl_is_down
= GetKeyState(VK_CONTROL
) & 0x8000;
804 BOOL shift_is_down
= GetKeyState(VK_SHIFT
) & 0x8000;
816 ME_ArrowKey(editor
, nKey
, shift_is_down
, ctrl_is_down
);
820 /* FIXME backspace and delete aren't the same, they act different wrt paragraph style of the merged paragraph */
821 if (GetWindowLongW(editor
->hWnd
, GWL_STYLE
) & ES_READONLY
)
823 if (ME_IsSelection(editor
))
824 ME_DeleteSelection(editor
);
825 else if (nKey
== VK_DELETE
|| ME_ArrowKey(editor
, VK_LEFT
, FALSE
, FALSE
))
826 ME_DeleteTextAtCursor(editor
, 1, 1);
829 ME_QueueInvalidateFromCursor(editor
, 1);
830 ME_UpdateRepaint(editor
);
831 ME_SendRequestResize(editor
, FALSE
);
842 ME_GetSelectionCharFormat(editor
, &chf
);
843 ME_DumpStyleToBuf(&chf
, buf
);
844 MessageBoxA(NULL
, buf
, "Style dump", MB_OK
);
848 ME_CheckCharOffsets(editor
);
855 static void ME_ShowContextMenu(ME_TextEditor
*editor
, int x
, int y
)
860 if(!editor
->lpOleCallback
)
862 ME_GetSelection(editor
, (int *)&selrange
.cpMin
, (int *)&selrange
.cpMax
);
863 if(selrange
.cpMin
== selrange
.cpMax
)
864 seltype
|= SEL_EMPTY
;
867 /* FIXME: Handle objects */
869 if(selrange
.cpMax
-selrange
.cpMin
> 1)
870 seltype
|= SEL_MULTICHAR
;
872 if(SUCCEEDED(IRichEditOleCallback_GetContextMenu(editor
->lpOleCallback
, seltype
, NULL
, &selrange
, &menu
)))
874 TrackPopupMenu(menu
, TPM_LEFTALIGN
| TPM_RIGHTBUTTON
, x
, y
, 0, GetParent(editor
->hWnd
), NULL
);
879 ME_TextEditor
*ME_MakeEditor(HWND hWnd
) {
880 ME_TextEditor
*ed
= ALLOC_OBJ(ME_TextEditor
);
884 ed
->bEmulateVersion10
= FALSE
;
885 ed
->pBuffer
= ME_MakeText();
887 ME_MakeFirstParagraph(hDC
, ed
->pBuffer
);
888 ReleaseDC(hWnd
, hDC
);
889 ed
->bCaretShown
= FALSE
;
891 ed
->pCursors
= ALLOC_N_OBJ(ME_Cursor
, ed
->nCursors
);
892 ed
->pCursors
[0].pRun
= ME_FindItemFwd(ed
->pBuffer
->pFirst
, diRun
);
893 ed
->pCursors
[0].nOffset
= 0;
894 ed
->pCursors
[1].pRun
= ME_FindItemFwd(ed
->pBuffer
->pFirst
, diRun
);
895 ed
->pCursors
[1].nOffset
= 0;
896 ed
->nLastTotalLength
= ed
->nTotalLength
= 0;
899 ed
->rgbBackColor
= -1;
900 ed
->hbrBackground
= GetSysColorBrush(COLOR_WINDOW
);
901 ed
->bCaretAtEnd
= FALSE
;
904 ed
->pUndoStack
= ed
->pRedoStack
= NULL
;
905 ed
->nUndoMode
= umAddToUndo
;
907 ed
->nLastSelStart
= ed
->nLastSelEnd
= 0;
909 ed
->nZoomNumerator
= ed
->nZoomDenominator
= 0;
911 ed
->nInvalidOfs
= -1;
912 ed
->pfnWordBreak
= NULL
;
913 ed
->lpOleCallback
= NULL
;
914 GetClientRect(hWnd
, &ed
->rcFormat
);
915 for (i
=0; i
<HFONT_CACHE_SIZE
; i
++)
917 ed
->pFontCache
[i
].nRefs
= 0;
918 ed
->pFontCache
[i
].nAge
= 0;
919 ed
->pFontCache
[i
].hFont
= NULL
;
921 ME_CheckCharOffsets(ed
);
925 typedef struct tagME_GlobalDestStruct
929 } ME_GlobalDestStruct
;
931 static DWORD CALLBACK
ME_AppendToHGLOBAL(DWORD_PTR dwCookie
, LPBYTE lpBuff
, LONG cb
, LONG
*pcb
)
933 ME_GlobalDestStruct
*pData
= (ME_GlobalDestStruct
*)dwCookie
;
937 nMaxSize
= GlobalSize(pData
->hData
);
938 if (pData
->nLength
+cb
+1 >= cb
)
940 /* round up to 2^17 */
941 int nNewSize
= (((nMaxSize
+cb
+1)|0x1FFFF)+1) & 0xFFFE0000;
942 pData
->hData
= GlobalReAlloc(pData
->hData
, nNewSize
, 0);
944 pDest
= (BYTE
*)GlobalLock(pData
->hData
);
945 memcpy(pDest
+ pData
->nLength
, lpBuff
, cb
);
946 pData
->nLength
+= cb
;
947 pDest
[pData
->nLength
] = '\0';
948 GlobalUnlock(pData
->hData
);
954 static DWORD CALLBACK
ME_ReadFromHGLOBALUnicode(DWORD_PTR dwCookie
, LPBYTE lpBuff
, LONG cb
, LONG
*pcb
)
956 ME_GlobalDestStruct
*pData
= (ME_GlobalDestStruct
*)dwCookie
;
961 pDest
= (WORD
*)lpBuff
;
962 pSrc
= (WORD
*)GlobalLock(pData
->hData
);
963 for (i
= 0; i
<cb
&& pSrc
[pData
->nLength
+i
]; i
++) {
964 pDest
[i
] = pSrc
[pData
->nLength
+i
];
968 GlobalUnlock(pData
->hData
);
972 static DWORD CALLBACK
ME_ReadFromHGLOBALRTF(DWORD_PTR dwCookie
, LPBYTE lpBuff
, LONG cb
, LONG
*pcb
)
974 ME_GlobalDestStruct
*pData
= (ME_GlobalDestStruct
*)dwCookie
;
979 pSrc
= (BYTE
*)GlobalLock(pData
->hData
);
980 for (i
= 0; i
<cb
&& pSrc
[pData
->nLength
+i
]; i
++) {
981 pDest
[i
] = pSrc
[pData
->nLength
+i
];
985 GlobalUnlock(pData
->hData
);
990 void ME_DestroyEditor(ME_TextEditor
*editor
)
992 ME_DisplayItem
*pFirst
= editor
->pBuffer
->pFirst
;
993 ME_DisplayItem
*p
= pFirst
, *pNext
= NULL
;
996 ME_ClearTempStyle(editor
);
997 ME_EmptyUndoStack(editor
);
1000 ME_DestroyDisplayItem(p
);
1003 ME_ReleaseStyle(editor
->pBuffer
->pDefaultStyle
);
1004 for (i
=0; i
<HFONT_CACHE_SIZE
; i
++)
1006 if (editor
->pFontCache
[i
].hFont
)
1007 DeleteObject(editor
->pFontCache
[i
].hFont
);
1009 DeleteObject(editor
->hbrBackground
);
1010 if(editor
->lpOleCallback
)
1011 IUnknown_Release(editor
->lpOleCallback
);
1016 static const WCHAR wszClassName
[] = {'R', 'i', 'c', 'h', 'E', 'd', 'i', 't', '2', '0', 'W', 0};
1017 static const WCHAR wszClassName50
[] = {'R', 'i', 'c', 'h', 'E', 'd', 'i', 't', '5', '0', 'W', 0};
1018 static const WCHAR wszClassNameListBox
[] = {'R','E','L','i','s','t','B','o','x','2','0','W', 0};
1019 static const WCHAR wszClassNameComboBox
[] = {'R','E','C','o','m','b','o','B','o','x','2','0','W', 0};
1021 BOOL WINAPI
DllMain(HINSTANCE hinstDLL
, DWORD fdwReason
, LPVOID lpvReserved
)
1026 case DLL_PROCESS_ATTACH
:
1027 DisableThreadLibraryCalls(hinstDLL
);
1028 me_heap
= HeapCreate (0, 0x10000, 0);
1029 ME_RegisterEditorClass(hinstDLL
);
1032 case DLL_PROCESS_DETACH
:
1033 UnregisterClassW(wszClassName
, 0);
1034 UnregisterClassW(wszClassName50
, 0);
1035 UnregisterClassA("RichEdit20A", 0);
1036 UnregisterClassA("RichEdit50A", 0);
1037 if (ME_ListBoxRegistered
)
1038 UnregisterClassW(wszClassNameListBox
, 0);
1039 if (ME_ComboBoxRegistered
)
1040 UnregisterClassW(wszClassNameComboBox
, 0);
1041 HeapDestroy (me_heap
);
1049 #define UNSUPPORTED_MSG(e) \
1051 FIXME(#e ": stub\n"); \
1052 return DefWindowProcW(hWnd, msg, wParam, lParam);
1054 static const char * const edit_messages
[] = {
1083 "EM_SETPASSWORDCHAR",
1084 "EM_EMPTYUNDOBUFFER",
1085 "EM_GETFIRSTVISIBLELINE",
1087 "EM_SETWORDBREAKPROC",
1088 "EM_GETWORDBREAKPROC",
1089 "EM_GETPASSWORDCHAR",
1097 static const char * const richedit_messages
[] = {
1102 "EM_EXLINEFROMCHAR",
1108 "EM_GETOLEINTERFACE",
1118 "EM_SETOLECALLBACK",
1120 "EM_SETTARGETDEVICE",
1128 "EM_GETWORDBREAKPROCEX",
1129 "EM_SETWORDBREAKPROCEX",
1131 "EM_UNKNOWN_USER_83",
1136 "EM_STOPGROUPTYPING",
1140 "EM_GETAUTOURLDETECT",
1143 "EM_GETTEXTLENGTHEX",
1146 "EM_UNKNOWN_USER_98",
1147 "EM_UNKNOWN_USER_99",
1148 "EM_SETPUNCTUATION",
1149 "EM_GETPUNCTUATION",
1150 "EM_SETWORDWRAPMODE",
1151 "EM_GETWORDWRAPMODE",
1157 "EM_UNKNOWN_USER_109",
1158 "EM_UNKNOWN_USER_110",
1159 "EM_UNKNOWN_USER_111",
1160 "EM_UNKNOWN_USER_112",
1161 "EM_UNKNOWN_USER_113",
1162 "EM_UNKNOWN_USER_114",
1163 "EM_UNKNOWN_USER_115",
1164 "EM_UNKNOWN_USER_116",
1165 "EM_UNKNOWN_USER_117",
1166 "EM_UNKNOWN_USER_118",
1167 "EM_UNKNOWN_USER_119",
1168 "EM_SETLANGOPTIONS",
1169 "EM_GETLANGOPTIONS",
1170 "EM_GETIMECOMPMODE",
1174 "EM_SETIMEMODEBIAS",
1179 get_msg_name(UINT msg
)
1181 if (msg
>= EM_GETSEL
&& msg
<= EM_SETLIMITTEXT
)
1182 return edit_messages
[msg
- EM_GETSEL
];
1183 if (msg
>= EM_CANPASTE
&& msg
<= EM_GETIMEMODEBIAS
)
1184 return richedit_messages
[msg
- EM_CANPASTE
];
1188 /******************************************************************
1189 * RichEditANSIWndProc (RICHED20.10)
1191 LRESULT WINAPI
RichEditANSIWndProc(HWND hWnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
) {
1193 ME_TextEditor
*editor
= (ME_TextEditor
*)GetWindowLongW(hWnd
, 0);
1195 TRACE("hWnd %p msg %04x (%s) %08x %08lx\n",
1196 hWnd
, msg
, get_msg_name(msg
), wParam
, lParam
);
1200 UNSUPPORTED_MSG(EM_AUTOURLDETECT
)
1201 UNSUPPORTED_MSG(EM_DISPLAYBAND
)
1202 UNSUPPORTED_MSG(EM_EXLIMITTEXT
)
1203 UNSUPPORTED_MSG(EM_FINDWORDBREAK
)
1204 UNSUPPORTED_MSG(EM_FMTLINES
)
1205 UNSUPPORTED_MSG(EM_FORMATRANGE
)
1206 UNSUPPORTED_MSG(EM_GETAUTOURLDETECT
)
1207 UNSUPPORTED_MSG(EM_GETBIDIOPTIONS
)
1208 UNSUPPORTED_MSG(EM_GETEDITSTYLE
)
1209 UNSUPPORTED_MSG(EM_GETIMECOMPMODE
)
1210 /* UNSUPPORTED_MSG(EM_GETIMESTATUS) missing in Wine headers */
1211 UNSUPPORTED_MSG(EM_GETLANGOPTIONS
)
1212 UNSUPPORTED_MSG(EM_GETLIMITTEXT
)
1213 UNSUPPORTED_MSG(EM_GETLINE
)
1214 /* UNSUPPORTED_MSG(EM_GETOLEINTERFACE) separate stub */
1215 UNSUPPORTED_MSG(EM_GETOPTIONS
)
1216 UNSUPPORTED_MSG(EM_GETPASSWORDCHAR
)
1217 UNSUPPORTED_MSG(EM_GETREDONAME
)
1218 UNSUPPORTED_MSG(EM_GETSCROLLPOS
)
1219 UNSUPPORTED_MSG(EM_GETTEXTMODE
)
1220 UNSUPPORTED_MSG(EM_GETTYPOGRAPHYOPTIONS
)
1221 UNSUPPORTED_MSG(EM_GETUNDONAME
)
1222 UNSUPPORTED_MSG(EM_GETWORDBREAKPROCEX
)
1223 UNSUPPORTED_MSG(EM_HIDESELECTION
)
1224 UNSUPPORTED_MSG(EM_LIMITTEXT
) /* also known as EM_SETLIMITTEXT */
1225 UNSUPPORTED_MSG(EM_PASTESPECIAL
)
1226 UNSUPPORTED_MSG(EM_SCROLL
)
1227 UNSUPPORTED_MSG(EM_SCROLLCARET
)
1228 UNSUPPORTED_MSG(EM_SELECTIONTYPE
)
1229 UNSUPPORTED_MSG(EM_SETBIDIOPTIONS
)
1230 UNSUPPORTED_MSG(EM_SETEDITSTYLE
)
1231 UNSUPPORTED_MSG(EM_SETFONTSIZE
)
1232 UNSUPPORTED_MSG(EM_SETLANGOPTIONS
)
1233 UNSUPPORTED_MSG(EM_SETOPTIONS
)
1234 UNSUPPORTED_MSG(EM_SETPALETTE
)
1235 UNSUPPORTED_MSG(EM_SETPASSWORDCHAR
)
1236 UNSUPPORTED_MSG(EM_SETSCROLLPOS
)
1237 UNSUPPORTED_MSG(EM_SETTABSTOPS
)
1238 UNSUPPORTED_MSG(EM_SETTARGETDEVICE
)
1239 UNSUPPORTED_MSG(EM_SETTEXTMODE
)
1240 UNSUPPORTED_MSG(EM_SETTYPOGRAPHYOPTIONS
)
1241 UNSUPPORTED_MSG(EM_SETUNDOLIMIT
)
1242 UNSUPPORTED_MSG(EM_SETWORDBREAKPROCEX
)
1243 UNSUPPORTED_MSG(EM_SHOWSCROLLBAR
)
1244 UNSUPPORTED_MSG(WM_SETFONT
)
1245 UNSUPPORTED_MSG(WM_STYLECHANGING
)
1246 UNSUPPORTED_MSG(WM_STYLECHANGED
)
1247 /* UNSUPPORTED_MSG(WM_UNICHAR) FIXME missing in Wine headers */
1249 /* Messages specific to Richedit controls */
1252 return ME_StreamIn(editor
, wParam
, (EDITSTREAM
*)lParam
);
1254 return ME_StreamOut(editor
, wParam
, (EDITSTREAM
*)lParam
);
1257 UINT code
= DLGC_WANTCHARS
|DLGC_WANTARROWS
;
1258 if (GetWindowLongW(hWnd
, GWL_STYLE
)&ES_WANTRETURN
)
1259 code
|= 0; /* FIXME what can we do here ? ask for messages and censor them ? */
1264 CREATESTRUCTW
*pcs
= (CREATESTRUCTW
*)lParam
;
1265 TRACE("WM_NCCREATE: style 0x%08lx\n", pcs
->style
);
1266 editor
= ME_MakeEditor(hWnd
);
1267 SetWindowLongW(hWnd
, 0, (long)editor
);
1268 pcs
= 0; /* ignore */
1271 case EM_EMPTYUNDOBUFFER
:
1272 ME_EmptyUndoStack(editor
);
1276 /* Note: wParam/lParam can be NULL */
1278 PUINT pfrom
= wParam
? (PUINT
)wParam
: &from
;
1279 PUINT pto
= lParam
? (PUINT
)lParam
: &to
;
1280 ME_GetSelection(editor
, (int *)pfrom
, (int *)pto
);
1281 if ((*pfrom
|*pto
) & 0xFFFF0000)
1283 return MAKELONG(*pfrom
,*pto
);
1287 CHARRANGE
*pRange
= (CHARRANGE
*)lParam
;
1288 ME_GetSelection(editor
, (int *)&pRange
->cpMin
, (int *)&pRange
->cpMax
);
1289 TRACE("EM_EXGETSEL = (%ld,%ld)\n", pRange
->cpMin
, pRange
->cpMax
);
1293 return editor
->pUndoStack
!= NULL
;
1295 return editor
->pRedoStack
!= NULL
;
1296 case WM_UNDO
: /* FIXME: actually not the same */
1305 ME_InvalidateSelection(editor
);
1306 ME_SetSelection(editor
, wParam
, lParam
);
1307 ME_InvalidateSelection(editor
);
1308 ME_SendSelChange(editor
);
1313 CHARRANGE
*pRange
= (CHARRANGE
*)lParam
;
1314 TRACE("EM_EXSETSEL (%ld,%ld)\n", pRange
->cpMin
, pRange
->cpMax
);
1315 ME_InvalidateSelection(editor
);
1316 ME_SetSelection(editor
, pRange
->cpMin
, pRange
->cpMax
);
1317 ME_InvalidateSelection(editor
);
1318 ME_SendSelChange(editor
);
1323 LPWSTR wszText
= (LPWSTR
)lParam
;
1324 SETTEXTEX
*pStruct
= (SETTEXTEX
*)wParam
;
1325 size_t len
= lstrlenW(wszText
);
1328 TRACE("EM_SETTEXEX - %s, flags %d, cp %d\n", debugstr_w(wszText
), (int)pStruct
->flags
, pStruct
->codepage
);
1329 if (pStruct
->codepage
!= 1200) {
1330 FIXME("EM_SETTEXTEX only supports unicode right now!\n");
1333 /* FIXME: this should support RTF strings too, according to MSDN */
1334 if (pStruct
->flags
& ST_SELECTION
) {
1335 ME_GetSelection(editor
, &from
, &to
);
1336 style
= ME_GetSelectionInsertStyle(editor
);
1337 ME_InternalDeleteText(editor
, from
, to
- from
);
1338 ME_InsertTextFromCursor(editor
, 0, wszText
, len
, style
);
1339 ME_ReleaseStyle(style
);
1342 ME_InternalDeleteText(editor
, 0, ME_GetTextLength(editor
));
1343 ME_InsertTextFromCursor(editor
, 0, wszText
, -1, editor
->pBuffer
->pDefaultStyle
);
1346 ME_CommitUndo(editor
);
1347 if (!(pStruct
->flags
& ST_KEEPUNDO
))
1348 ME_EmptyUndoStack(editor
);
1349 ME_UpdateRepaint(editor
);
1352 case EM_SETBKGNDCOLOR
:
1354 LRESULT lColor
= ME_GetBackColor(editor
);
1355 if (editor
->rgbBackColor
!= -1)
1356 DeleteObject(editor
->hbrBackground
);
1359 editor
->rgbBackColor
= -1;
1360 editor
->hbrBackground
= GetSysColorBrush(COLOR_WINDOW
);
1364 editor
->rgbBackColor
= lParam
;
1365 editor
->hbrBackground
= CreateSolidBrush(editor
->rgbBackColor
);
1367 if (editor
->bRedraw
)
1369 InvalidateRect(hWnd
, NULL
, TRUE
);
1375 return editor
->nModifyStep
== 0 ? 0 : 1;
1379 editor
->nModifyStep
= 0x80000000;
1381 editor
->nModifyStep
= 0;
1385 case EM_SETREADONLY
:
1387 long nStyle
= GetWindowLongW(hWnd
, GWL_STYLE
);
1389 nStyle
|= ES_READONLY
;
1391 nStyle
&= ~ES_READONLY
;
1392 SetWindowLongW(hWnd
, GWL_STYLE
, nStyle
);
1395 case EM_SETEVENTMASK
:
1397 DWORD nOldMask
= editor
->nEventMask
;
1399 editor
->nEventMask
= lParam
;
1402 case EM_GETEVENTMASK
:
1403 return editor
->nEventMask
;
1404 case EM_SETCHARFORMAT
:
1406 CHARFORMAT2W buf
, *p
;
1407 BOOL bRepaint
= TRUE
;
1408 p
= ME_ToCF2W(&buf
, (CHARFORMAT2W
*)lParam
);
1410 ME_SetDefaultCharFormat(editor
, p
);
1411 else if (wParam
== (SCF_WORD
| SCF_SELECTION
))
1412 FIXME("EM_SETCHARFORMAT: word selection not supported\n");
1413 else if (wParam
== SCF_ALL
)
1414 ME_SetCharFormat(editor
, 0, ME_GetTextLength(editor
), p
);
1417 ME_GetSelection(editor
, &from
, &to
);
1418 bRepaint
= (from
!= to
);
1419 ME_SetSelectionCharFormat(editor
, p
);
1421 ME_CommitUndo(editor
);
1423 ME_UpdateRepaint(editor
);
1426 case EM_GETCHARFORMAT
:
1428 CHARFORMAT2W tmp
, *dst
= (CHARFORMAT2W
*)lParam
;
1429 if (dst
->cbSize
!= sizeof(CHARFORMATA
) &&
1430 dst
->cbSize
!= sizeof(CHARFORMATW
) &&
1431 dst
->cbSize
!= sizeof(CHARFORMAT2A
) &&
1432 dst
->cbSize
!= sizeof(CHARFORMAT2W
))
1434 tmp
.cbSize
= sizeof(tmp
);
1436 ME_GetDefaultCharFormat(editor
, &tmp
);
1438 ME_GetSelectionCharFormat(editor
, &tmp
);
1439 ME_CopyToCFAny(dst
, &tmp
);
1442 case EM_SETPARAFORMAT
:
1443 ME_SetSelectionParaFormat(editor
, (PARAFORMAT2
*)lParam
);
1444 ME_UpdateRepaint(editor
);
1445 ME_CommitUndo(editor
);
1447 case EM_GETPARAFORMAT
:
1448 ME_GetSelectionParaFormat(editor
, (PARAFORMAT2
*)lParam
);
1450 case EM_GETFIRSTVISIBLELINE
:
1452 ME_DisplayItem
*p
= editor
->pBuffer
->pFirst
;
1453 int y
= editor
->nScrollPosY
;
1458 p
= ME_FindItemFwd(p
, diStartRowOrParagraphOrEnd
);
1459 if (p
->type
== diTextEnd
)
1461 if (p
->type
== diParagraph
) {
1462 ypara
= p
->member
.para
.nYPos
;
1465 ystart
= ypara
+ p
->member
.row
.nYPos
;
1466 yend
= ystart
+ p
->member
.row
.nHeight
;
1476 int nPos
= editor
->nScrollPosY
, nEnd
= editor
->nTotalLength
- editor
->sizeWindow
.cy
;
1477 nPos
+= 8 * lParam
; /* FIXME follow the original */
1482 if (nPos
!= editor
->nScrollPosY
) {
1483 int dy
= editor
->nScrollPosY
- nPos
;
1484 editor
->nScrollPosY
= nPos
;
1485 SetScrollPos(hWnd
, SB_VERT
, nPos
, TRUE
);
1486 if (editor
->bRedraw
)
1488 ScrollWindow(hWnd
, 0, dy
, NULL
, NULL
);
1492 return TRUE
; /* Should return false if a single line richedit control */
1497 ME_GetSelection(editor
, &from
, &to
);
1498 ME_InternalDeleteText(editor
, from
, to
-from
);
1499 ME_CommitUndo(editor
);
1500 ME_UpdateRepaint(editor
);
1507 LPWSTR wszText
= ME_ToUnicode(hWnd
, (void *)lParam
);
1508 size_t len
= lstrlenW(wszText
);
1509 TRACE("EM_REPLACESEL - %s\n", debugstr_w(wszText
));
1511 ME_GetSelection(editor
, &from
, &to
);
1512 style
= ME_GetSelectionInsertStyle(editor
);
1513 ME_InternalDeleteText(editor
, from
, to
-from
);
1514 ME_InsertTextFromCursor(editor
, 0, wszText
, len
, style
);
1515 ME_ReleaseStyle(style
);
1516 ME_EndToUnicode(hWnd
, wszText
);
1517 /* drop temporary style if line end */
1518 /* FIXME question: does abc\n mean: put abc, clear temp style, put \n? (would require a change) */
1519 if (len
>0 && wszText
[len
-1] == '\n')
1520 ME_ClearTempStyle(editor
);
1522 ME_CommitUndo(editor
);
1524 ME_EmptyUndoStack(editor
);
1525 ME_UpdateRepaint(editor
);
1530 ME_InternalDeleteText(editor
, 0, ME_GetTextLength(editor
));
1533 LPWSTR wszText
= ME_ToUnicode(hWnd
, (void *)lParam
);
1534 TRACE("WM_SETTEXT lParam==%lx\n",lParam
);
1535 TRACE("WM_SETTEXT - %s\n", debugstr_w(wszText
)); /* debugstr_w() */
1536 if (lstrlenW(wszText
) > 0)
1538 /* uses default style! */
1539 ME_InsertTextFromCursor(editor
, 0, wszText
, -1, editor
->pBuffer
->pDefaultStyle
);
1541 ME_EndToUnicode(hWnd
, wszText
);
1544 TRACE("WM_SETTEXT - NULL\n");
1545 ME_CommitUndo(editor
);
1546 ME_EmptyUndoStack(editor
);
1547 ME_SetSelection(editor
, 0, 0);
1548 ME_UpdateRepaint(editor
);
1553 UINT nRTFFormat
= RegisterClipboardFormatA("Rich Text Format");
1554 if (IsClipboardFormatAvailable(nRTFFormat
))
1556 if (IsClipboardFormatAvailable(CF_UNICODETEXT
))
1564 ME_GlobalDestStruct gds
;
1565 UINT nRTFFormat
= RegisterClipboardFormatA("Rich Text Format");
1568 if (IsClipboardFormatAvailable(nRTFFormat
))
1569 cf
= nRTFFormat
, dwFormat
= SF_RTF
;
1570 else if (IsClipboardFormatAvailable(CF_UNICODETEXT
))
1571 cf
= CF_UNICODETEXT
, dwFormat
= SF_TEXT
|SF_UNICODE
;
1575 if (!OpenClipboard(hWnd
))
1577 gds
.hData
= GetClipboardData(cf
);
1579 es
.dwCookie
= (DWORD
)&gds
;
1580 es
.pfnCallback
= dwFormat
== SF_RTF
? ME_ReadFromHGLOBALRTF
: ME_ReadFromHGLOBALUnicode
;
1581 SendMessageW(hWnd
, EM_STREAMIN
, dwFormat
|SFF_SELECTION
, (LPARAM
)&es
);
1593 ME_GlobalDestStruct gds
;
1595 if (!OpenClipboard(hWnd
))
1599 ME_GetSelection(editor
, &from
, &to
);
1600 pars
= ME_CountParagraphsBetween(editor
, from
, to
);
1601 hData
= GlobalAlloc(GMEM_MOVEABLE
, sizeof(WCHAR
)*(to
-from
+pars
+1));
1602 data
= (WCHAR
*)GlobalLock(hData
);
1603 ME_GetTextW(editor
, data
, from
, to
-from
, TRUE
);
1604 GlobalUnlock(hData
);
1606 gds
.hData
= GlobalAlloc(GMEM_MOVEABLE
, 0);
1608 es
.dwCookie
= (DWORD
)&gds
;
1609 es
.pfnCallback
= ME_AppendToHGLOBAL
;
1610 SendMessageW(hWnd
, EM_STREAMOUT
, SFF_SELECTION
|SF_RTF
, (LPARAM
)&es
);
1611 GlobalReAlloc(gds
.hData
, gds
.nLength
+1, 0);
1613 SetClipboardData(CF_UNICODETEXT
, hData
);
1614 SetClipboardData(RegisterClipboardFormatA("Rich Text Format"), gds
.hData
);
1619 ME_InternalDeleteText(editor
, from
, to
-from
);
1620 ME_CommitUndo(editor
);
1621 ME_UpdateRepaint(editor
);
1625 case WM_GETTEXTLENGTH
:
1626 return ME_GetTextLength(editor
);
1627 case EM_GETTEXTLENGTHEX
:
1628 return ME_GetTextLengthEx(editor
, (GETTEXTLENGTHEX
*)wParam
);
1631 TEXTRANGEW tr
; /* W and A differ only by rng->lpstrText */
1633 tr
.chrg
.cpMax
= wParam
-1;
1634 tr
.lpstrText
= (WCHAR
*)lParam
;
1635 return RichEditANSIWndProc(hWnd
, EM_GETTEXTRANGE
, 0, (LPARAM
)&tr
);
1639 GETTEXTEX
*ex
= (GETTEXTEX
*)wParam
;
1642 if (ex
->flags
& ~(GT_SELECTION
| GT_USECRLF
))
1643 FIXME("GETTEXTEX flags 0x%08lx not supported\n", ex
->flags
& ~(GT_SELECTION
| GT_USECRLF
));
1645 if (ex
->flags
& GT_SELECTION
)
1647 ME_GetSelection(editor
, &nStart
, &nCount
);
1649 nCount
= min(nCount
, ex
->cb
- 1);
1654 nCount
= ex
->cb
- 1;
1656 if (ex
->codepage
== 1200 || IsWindowUnicode(hWnd
))
1658 nCount
= min(nCount
, ex
->cb
/ sizeof(WCHAR
) - 1);
1659 return ME_GetTextW(editor
, (LPWSTR
)lParam
, nStart
, nCount
, ex
->flags
& GT_USECRLF
);
1663 /* potentially each char may be a CR, why calculate the exact value with O(N) when
1664 we can just take a bigger buffer? :) */
1665 int crlfmul
= (ex
->flags
& GT_USECRLF
) ? 2 : 1;
1666 LPWSTR buffer
= HeapAlloc(GetProcessHeap(), 0, (crlfmul
*nCount
+ 1) * sizeof(WCHAR
));
1667 DWORD buflen
= ex
->cb
;
1671 buflen
= ME_GetTextW(editor
, buffer
, nStart
, nCount
, ex
->flags
& GT_USECRLF
);
1672 rc
= WideCharToMultiByte(ex
->codepage
, flags
, buffer
, buflen
, (LPSTR
)lParam
, ex
->cb
, ex
->lpDefaultChar
, ex
->lpUsedDefaultChar
);
1674 HeapFree(GetProcessHeap(),0,buffer
);
1681 TEXTRANGEW tr
; /* W and A differ only by rng->lpstrText */
1682 ME_GetSelection(editor
, &from
, &to
);
1683 tr
.chrg
.cpMin
= from
;
1685 tr
.lpstrText
= (WCHAR
*)lParam
;
1686 return RichEditANSIWndProc(hWnd
, EM_GETTEXTRANGE
, 0, (LPARAM
)&tr
);
1688 case EM_GETTEXTRANGE
:
1690 TEXTRANGEW
*rng
= (TEXTRANGEW
*)lParam
;
1691 TRACE("EM_GETTEXTRANGE min=%ld max=%ld unicode=%d emul1.0=%d length=%d\n",
1692 rng
->chrg
.cpMin
, rng
->chrg
.cpMax
, IsWindowUnicode(hWnd
),
1693 editor
->bEmulateVersion10
, ME_GetTextLength(editor
));
1694 if (IsWindowUnicode(hWnd
))
1695 return ME_GetTextW(editor
, rng
->lpstrText
, rng
->chrg
.cpMin
, rng
->chrg
.cpMax
-rng
->chrg
.cpMin
, editor
->bEmulateVersion10
);
1698 int nLen
= rng
->chrg
.cpMax
-rng
->chrg
.cpMin
;
1699 WCHAR
*p
= ALLOC_N_OBJ(WCHAR
, nLen
+1);
1700 int nChars
= ME_GetTextW(editor
, p
, rng
->chrg
.cpMin
, nLen
, editor
->bEmulateVersion10
);
1701 /* FIXME this is a potential security hole (buffer overrun)
1702 if you know more about wchar->mbyte conversion please explain
1704 WideCharToMultiByte(CP_ACP
, 0, p
, nChars
+1, (char *)rng
->lpstrText
, nLen
+1, NULL
, NULL
);
1709 case EM_GETLINECOUNT
:
1711 ME_DisplayItem
*item
= editor
->pBuffer
->pFirst
->next
;
1714 while (item
!= editor
->pBuffer
->pLast
)
1716 assert(item
->type
== diParagraph
);
1717 nRows
+= item
->member
.para
.nRows
;
1718 item
= item
->member
.para
.next_para
;
1720 TRACE("EM_GETLINECOUNT: nRows==%d\n", nRows
);
1721 return max(1, nRows
);
1723 case EM_LINEFROMCHAR
:
1726 return ME_RowNumberFromCharOfs(editor
, ME_GetCursorOfs(editor
, 1));
1728 return ME_RowNumberFromCharOfs(editor
, wParam
);
1730 case EM_EXLINEFROMCHAR
:
1732 return ME_RowNumberFromCharOfs(editor
, lParam
);
1736 ME_DisplayItem
*item
, *para
;
1740 item
= ME_FindItemBack(editor
->pCursors
[0].pRun
, diStartRow
);
1742 item
= ME_FindRowWithNumber(editor
, wParam
);
1745 para
= ME_GetParagraph(item
);
1746 item
= ME_FindItemFwd(item
, diRun
);
1747 nCharOfs
= para
->member
.para
.nCharOfs
+ item
->member
.run
.nCharOfs
;
1748 TRACE("EM_LINEINDEX: nCharOfs==%d\n", nCharOfs
);
1753 ME_DisplayItem
*item
, *item_end
;
1754 int nChars
= 0, nThisLineOfs
= 0, nNextLineOfs
= 0;
1756 if (wParam
> ME_GetTextLength(editor
))
1760 FIXME("EM_LINELENGTH: returning number of unselected characters on lines with selection unsupported.\n");
1763 item
= ME_FindItemAtOffset(editor
, diRun
, wParam
, NULL
);
1764 item
= ME_RowStart(item
);
1765 nThisLineOfs
= ME_CharOfsFromRunOfs(editor
, ME_FindItemFwd(item
, diRun
), 0);
1766 item_end
= ME_FindItemFwd(item
, diStartRow
);
1768 nNextLineOfs
= ME_CharOfsFromRunOfs(editor
, ME_FindItemFwd(item_end
, diRun
), 0);
1770 nNextLineOfs
= ME_FindItemFwd(item
, diParagraphOrEnd
)->member
.para
.nCharOfs
1771 - (editor
->bEmulateVersion10
?2:1);
1772 nChars
= nNextLineOfs
- nThisLineOfs
;
1773 TRACE("EM_LINELENGTH(%d)==%d\n",wParam
, nChars
);
1778 FINDTEXTA
*ft
= (FINDTEXTA
*)lParam
;
1779 int nChars
= MultiByteToWideChar(CP_ACP
, 0, ft
->lpstrText
, -1, NULL
, 0);
1782 if ((tmp
= ALLOC_N_OBJ(WCHAR
, nChars
)) != NULL
)
1783 MultiByteToWideChar(CP_ACP
, 0, ft
->lpstrText
, -1, tmp
, nChars
);
1784 return ME_FindText(editor
, wParam
, &ft
->chrg
, tmp
, NULL
);
1788 FINDTEXTEXA
*ex
= (FINDTEXTEXA
*)lParam
;
1789 int nChars
= MultiByteToWideChar(CP_ACP
, 0, ex
->lpstrText
, -1, NULL
, 0);
1792 if ((tmp
= ALLOC_N_OBJ(WCHAR
, nChars
)) != NULL
)
1793 MultiByteToWideChar(CP_ACP
, 0, ex
->lpstrText
, -1, tmp
, nChars
);
1794 return ME_FindText(editor
, wParam
, &ex
->chrg
, tmp
, &ex
->chrgText
);
1798 FINDTEXTW
*ft
= (FINDTEXTW
*)lParam
;
1799 return ME_FindText(editor
, wParam
, &ft
->chrg
, ft
->lpstrText
, NULL
);
1801 case EM_FINDTEXTEXW
:
1803 FINDTEXTEXW
*ex
= (FINDTEXTEXW
*)lParam
;
1804 return ME_FindText(editor
, wParam
, &ex
->chrg
, ex
->lpstrText
, &ex
->chrgText
);
1807 if (!wParam
|| !lParam
)
1809 *(int *)wParam
= editor
->nZoomNumerator
;
1810 *(int *)lParam
= editor
->nZoomDenominator
;
1813 return ME_SetZoom(editor
, wParam
, lParam
);
1814 case EM_CHARFROMPOS
:
1815 return ME_CharFromPos(editor
, ((POINTL
*)lParam
)->x
, ((POINTL
*)lParam
)->y
);
1816 case EM_POSFROMCHAR
:
1818 ME_DisplayItem
*pRun
;
1819 int nCharOfs
, nOffset
, nLength
;
1823 /* detect which API version we're dealing with */
1824 if (wParam
>= 0x40000)
1826 nLength
= ME_GetTextLength(editor
);
1828 if (nCharOfs
< nLength
) {
1829 ME_RunOfsFromCharOfs(editor
, nCharOfs
, &pRun
, &nOffset
);
1830 assert(pRun
->type
== diRun
);
1831 pt
.y
= pRun
->member
.run
.pt
.y
;
1832 pt
.x
= pRun
->member
.run
.pt
.x
+ ME_PointFromChar(editor
, &pRun
->member
.run
, nOffset
);
1833 pt
.y
+= ME_GetParagraph(pRun
)->member
.para
.nYPos
;
1836 pt
.y
= editor
->pBuffer
->pLast
->member
.para
.nYPos
;
1838 if (wParam
>= 0x40000) {
1839 *(POINTL
*)wParam
= pt
;
1841 return MAKELONG( pt
.x
, pt
.y
);
1844 ME_CommitUndo(editor
);
1845 ME_WrapMarkedParagraphs(editor
);
1846 ME_MoveCaret(editor
);
1849 ME_DestroyEditor(editor
);
1850 SetWindowLongW(hWnd
, 0, 0);
1852 case WM_LBUTTONDOWN
:
1854 ME_LButtonDown(editor
, (short)LOWORD(lParam
), (short)HIWORD(lParam
));
1858 if (GetCapture() == hWnd
)
1859 ME_MouseMove(editor
, (short)LOWORD(lParam
), (short)HIWORD(lParam
));
1862 if (GetCapture() == hWnd
)
1865 case WM_LBUTTONDBLCLK
:
1866 ME_SelectWord(editor
);
1868 case WM_CONTEXTMENU
:
1869 ME_ShowContextMenu(editor
, (short)LOWORD(lParam
), (short)HIWORD(lParam
));
1872 if (editor
->bRedraw
)
1877 hDC
= BeginPaint(hWnd
, &ps
);
1878 ME_PaintContent(editor
, hDC
, FALSE
, &ps
.rcPaint
);
1879 EndPaint(hWnd
, &ps
);
1883 ME_ShowCaret(editor
);
1884 ME_SendOldNotify(editor
, EN_SETFOCUS
);
1887 ME_HideCaret(editor
);
1888 ME_SendOldNotify(editor
, EN_KILLFOCUS
);
1892 if (editor
->bRedraw
)
1894 HDC hDC
= (HDC
)wParam
;
1896 if (GetUpdateRect(hWnd
,&rc
,TRUE
))
1898 FillRect(hDC
, &rc
, editor
->hbrBackground
);
1904 TRACE("editor wnd command = %d\n", LOWORD(wParam
));
1907 if (ME_KeyDown(editor
, LOWORD(wParam
)))
1912 WCHAR wstr
= LOWORD(wParam
);
1916 case 3: /* Ctrl-C */
1917 SendMessageW(editor
->hWnd
, WM_COPY
, 0, 0);
1921 if (GetWindowLongW(editor
->hWnd
, GWL_STYLE
) & ES_READONLY
) {
1922 MessageBeep(MB_ICONERROR
);
1923 return 0; /* FIXME really 0 ? */
1928 case 1: /* Ctrl-A */
1929 ME_SetSelection(editor
, 0, -1);
1931 case 22: /* Ctrl-V */
1932 SendMessageW(editor
->hWnd
, WM_PASTE
, 0, 0);
1934 case 24: /* Ctrl-X */
1935 SendMessageW(editor
->hWnd
, WM_CUT
, 0, 0);
1937 case 25: /* Ctrl-Y */
1938 SendMessageW(editor
->hWnd
, EM_REDO
, 0, 0);
1940 case 26: /* Ctrl-Z */
1941 SendMessageW(editor
->hWnd
, EM_UNDO
, 0, 0);
1944 if (((unsigned)wstr
)>=' ' || wstr
=='\r' || wstr
=='\t') {
1945 /* FIXME maybe it would make sense to call EM_REPLACESEL instead ? */
1946 ME_Style
*style
= ME_GetInsertStyle(editor
, 0);
1947 ME_SaveTempStyle(editor
);
1948 ME_InsertTextFromCursor(editor
, 0, &wstr
, 1, style
);
1949 ME_ReleaseStyle(style
);
1950 ME_CommitUndo(editor
);
1951 ME_UpdateRepaint(editor
);
1957 int nPos
= editor
->nScrollPosY
;
1958 si
.cbSize
= sizeof(SCROLLINFO
);
1959 si
.fMask
= SIF_PAGE
|SIF_POS
|SIF_RANGE
|SIF_TRACKPOS
;
1960 GetScrollInfo(hWnd
, SB_VERT
, &si
);
1961 switch(LOWORD(wParam
)) {
1963 nPos
-= 24; /* FIXME follow the original */
1964 if (nPos
<0) nPos
= 0;
1968 int nEnd
= editor
->nTotalLength
- editor
->sizeWindow
.cy
;
1969 nPos
+= 24; /* FIXME follow the original */
1970 if (nPos
>=nEnd
) nPos
= nEnd
;
1974 nPos
-= editor
->sizeWindow
.cy
;
1975 if (nPos
<0) nPos
= 0;
1978 nPos
+= editor
->sizeWindow
.cy
;
1979 if (nPos
>=editor
->nTotalLength
) nPos
= editor
->nTotalLength
-1;
1982 case SB_THUMBPOSITION
:
1983 nPos
= si
.nTrackPos
;
1986 if (nPos
!= editor
->nScrollPosY
) {
1987 int dy
= editor
->nScrollPosY
- nPos
;
1988 editor
->nScrollPosY
= nPos
;
1989 SetScrollPos(hWnd
, SB_VERT
, nPos
, TRUE
);
1990 if (editor
->bRedraw
)
1992 ScrollWindow(hWnd
, 0, dy
, NULL
, NULL
);
2000 int gcWheelDelta
= 0, nPos
= editor
->nScrollPosY
, nEnd
= editor
->nTotalLength
- editor
->sizeWindow
.cy
;
2001 UINT pulScrollLines
;
2002 SystemParametersInfoW(SPI_GETWHEELSCROLLLINES
,0, &pulScrollLines
, 0);
2003 gcWheelDelta
-= GET_WHEEL_DELTA_WPARAM(wParam
);
2004 if (abs(gcWheelDelta
) >= WHEEL_DELTA
&& pulScrollLines
)
2005 nPos
+= pulScrollLines
* (gcWheelDelta
/ WHEEL_DELTA
) * 8; /* FIXME follow the original */
2010 if (nPos
!= editor
->nScrollPosY
) {
2011 int dy
= editor
->nScrollPosY
- nPos
;
2012 editor
->nScrollPosY
= nPos
;
2013 SetScrollPos(hWnd
, SB_VERT
, nPos
, TRUE
);
2014 if (editor
->bRedraw
)
2016 ScrollWindow(hWnd
, 0, dy
, NULL
, NULL
);
2024 *((RECT
*)lParam
) = editor
->rcFormat
;
2032 RECT
*rc
= (RECT
*)lParam
;
2036 editor
->rcFormat
.left
+= rc
->left
;
2037 editor
->rcFormat
.top
+= rc
->top
;
2038 editor
->rcFormat
.right
+= rc
->right
;
2039 editor
->rcFormat
.bottom
+= rc
->bottom
;
2043 editor
->rcFormat
= *rc
;
2048 GetClientRect(hWnd
, &editor
->rcFormat
);
2050 if (msg
!= EM_SETRECTNP
)
2051 ME_RewrapRepaint(editor
);
2054 case EM_REQUESTRESIZE
:
2055 ME_SendRequestResize(editor
, TRUE
);
2058 editor
->bRedraw
= wParam
;
2062 GetClientRect(hWnd
, &editor
->rcFormat
);
2063 ME_RewrapRepaint(editor
);
2064 return DefWindowProcW(hWnd
, msg
, wParam
, lParam
);
2066 case EM_GETOLEINTERFACE
:
2068 LPVOID
*ppvObj
= (LPVOID
*) lParam
;
2069 FIXME("EM_GETOLEINTERFACE %p: stub\n", ppvObj
);
2070 return CreateIRichEditOle(ppvObj
);
2072 case EM_SETOLECALLBACK
:
2073 if(editor
->lpOleCallback
)
2074 IUnknown_Release(editor
->lpOleCallback
);
2075 editor
->lpOleCallback
= (LPRICHEDITOLECALLBACK
)lParam
;
2076 if(editor
->lpOleCallback
)
2077 IUnknown_AddRef(editor
->lpOleCallback
);
2079 case EM_GETWORDBREAKPROC
:
2080 return (LRESULT
)editor
->pfnWordBreak
;
2081 case EM_SETWORDBREAKPROC
:
2083 EDITWORDBREAKPROCW pfnOld
= editor
->pfnWordBreak
;
2085 editor
->pfnWordBreak
= (EDITWORDBREAKPROCW
)lParam
;
2086 return (LRESULT
)pfnOld
;
2090 return DefWindowProcW(hWnd
, msg
, wParam
, lParam
);
2096 /******************************************************************
2097 * RichEdit10ANSIWndProc (RICHED20.9)
2099 LRESULT WINAPI
RichEdit10ANSIWndProc(HWND hWnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
2103 /* FIXME: this is NOT the same as 2.0 version */
2104 result
= RichEditANSIWndProc(hWnd
, msg
, wParam
, lParam
);
2105 if (msg
== WM_NCCREATE
)
2107 ME_TextEditor
*editor
= (ME_TextEditor
*)GetWindowLongW(hWnd
, 0);
2109 editor
->bEmulateVersion10
= TRUE
;
2110 editor
->pBuffer
->pLast
->member
.para
.nCharOfs
= 2;
2115 void ME_SendOldNotify(ME_TextEditor
*editor
, int nCode
)
2117 HWND hWnd
= editor
->hWnd
;
2118 SendMessageA(GetParent(hWnd
), WM_COMMAND
, (nCode
<<16)|GetWindowLongW(hWnd
, GWLP_ID
), (LPARAM
)hWnd
);
2121 int ME_CountParagraphsBetween(ME_TextEditor
*editor
, int from
, int to
)
2123 ME_DisplayItem
*item
= ME_FindItemFwd(editor
->pBuffer
->pFirst
, diParagraph
);
2126 while(item
&& item
->member
.para
.next_para
->member
.para
.nCharOfs
<= from
)
2127 item
= item
->member
.para
.next_para
;
2130 while(item
&& item
->member
.para
.next_para
->member
.para
.nCharOfs
<= to
) {
2131 item
= item
->member
.para
.next_para
;
2138 int ME_GetTextW(ME_TextEditor
*editor
, WCHAR
*buffer
, int nStart
, int nChars
, int bCRLF
)
2140 ME_DisplayItem
*item
= ME_FindItemAtOffset(editor
, diRun
, nStart
, &nStart
);
2142 WCHAR
*pStart
= buffer
;
2151 int nLen
= ME_StrLen(item
->member
.run
.strText
) - nStart
;
2154 CopyMemory(buffer
, item
->member
.run
.strText
->szData
+ nStart
, sizeof(WCHAR
)*nLen
);
2161 item
= ME_FindItemFwd(item
, diRun
);
2164 while(nChars
&& item
)
2166 int nLen
= ME_StrLen(item
->member
.run
.strText
);
2170 if (item
->member
.run
.nFlags
& MERF_ENDPARA
)
2179 /* our end paragraph consists of 2 characters now */
2180 if (editor
->bEmulateVersion10
)
2184 CopyMemory(buffer
, item
->member
.run
.strText
->szData
, sizeof(WCHAR
)*nLen
);
2191 TRACE("nWritten=%d, actual=%d\n", nWritten
, buffer
-pStart
);
2195 item
= ME_FindItemFwd(item
, diRun
);
2198 TRACE("nWritten=%d, actual=%d\n", nWritten
, buffer
-pStart
);
2202 void ME_RegisterEditorClass(HINSTANCE hInstance
)
2208 wcW
.style
= CS_DBLCLKS
| CS_HREDRAW
| CS_VREDRAW
| CS_GLOBALCLASS
;
2209 wcW
.lpfnWndProc
= RichEditANSIWndProc
;
2212 wcW
.hInstance
= NULL
; /* hInstance would register DLL-local class */
2214 wcW
.hCursor
= LoadCursorW(NULL
, MAKEINTRESOURCEW(IDC_IBEAM
));
2215 wcW
.hbrBackground
= (HBRUSH
)GetStockObject(NULL_BRUSH
);
2216 wcW
.lpszMenuName
= NULL
;
2217 wcW
.lpszClassName
= wszClassName
;
2218 bResult
= RegisterClassW(&wcW
);
2220 wcW
.lpszClassName
= wszClassName50
;
2221 bResult
= RegisterClassW(&wcW
);
2224 wcA
.style
= CS_DBLCLKS
| CS_HREDRAW
| CS_VREDRAW
| CS_GLOBALCLASS
;
2225 wcA
.lpfnWndProc
= RichEditANSIWndProc
;
2228 wcA
.hInstance
= NULL
; /* hInstance would register DLL-local class */
2230 wcA
.hCursor
= LoadCursorW(NULL
, MAKEINTRESOURCEW(IDC_IBEAM
));
2231 wcA
.hbrBackground
= (HBRUSH
)GetStockObject(NULL_BRUSH
);
2232 wcA
.lpszMenuName
= NULL
;
2233 wcA
.lpszClassName
= "RichEdit20A";
2234 bResult
= RegisterClassA(&wcA
);
2236 wcA
.lpszClassName
= "RichEdit50A";
2237 bResult
= RegisterClassA(&wcA
);
2241 LRESULT WINAPI
REComboWndProc(HWND hWnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
) {
2242 /* FIXME: Not implemented */
2243 TRACE("hWnd %p msg %04x (%s) %08x %08lx\n",
2244 hWnd
, msg
, get_msg_name(msg
), wParam
, lParam
);
2245 return DefWindowProcW(hWnd
, msg
, wParam
, lParam
);
2248 LRESULT WINAPI
REListWndProc(HWND hWnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
) {
2249 /* FIXME: Not implemented */
2250 TRACE("hWnd %p msg %04x (%s) %08x %08lx\n",
2251 hWnd
, msg
, get_msg_name(msg
), wParam
, lParam
);
2252 return DefWindowProcW(hWnd
, msg
, wParam
, lParam
);
2255 /******************************************************************
2256 * REExtendedRegisterClass (RICHED20.8)
2258 * FIXME undocumented
2259 * Need to check for errors and implement controls and callbacks
2261 LRESULT WINAPI
REExtendedRegisterClass(void)
2266 FIXME("semi stub\n");
2270 wcW
.hInstance
= NULL
;
2273 wcW
.hbrBackground
= (HBRUSH
)(COLOR_WINDOW
+1);
2274 wcW
.lpszMenuName
= NULL
;
2276 if (!ME_ListBoxRegistered
)
2278 wcW
.style
= CS_PARENTDC
| CS_DBLCLKS
| CS_GLOBALCLASS
;
2279 wcW
.lpfnWndProc
= REListWndProc
;
2280 wcW
.lpszClassName
= wszClassNameListBox
;
2281 if (RegisterClassW(&wcW
)) ME_ListBoxRegistered
= TRUE
;
2284 if (!ME_ComboBoxRegistered
)
2286 wcW
.style
= CS_PARENTDC
| CS_DBLCLKS
| CS_GLOBALCLASS
| CS_VREDRAW
| CS_HREDRAW
;
2287 wcW
.lpfnWndProc
= REComboWndProc
;
2288 wcW
.lpszClassName
= wszClassNameComboBox
;
2289 if (RegisterClassW(&wcW
)) ME_ComboBoxRegistered
= TRUE
;
2293 if (ME_ListBoxRegistered
)
2295 if (ME_ComboBoxRegistered
)