source: trunk/src/riched32/richedit.c

Last change on this file was 22060, checked in by dmik, 13 years ago

riched32: Return TRUE from EM_SETBKGNDCOLOR and EM_SETCHARFORMAT.

This in particular fixes debug assertions in Java.

File size: 23.4 KB
RevLine 
[3515]1/*
2 * RichEdit32 functions
3 *
[9407]4 * This module is a simple wrapper for the edit controls.
5 * At the point, it is good only for application who use the RICHEDIT
6 * control to display RTF text.
[3515]7 *
8 * Copyright 2000 by Jean-Claude Batista
[3922]9 *
[9407]10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
14 *
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
[3515]23 */
[3922]24
[9407]25#include <string.h>
26#include "windef.h"
[3515]27#include "winbase.h"
[9407]28#include "wingdi.h"
29#include "winreg.h"
[3515]30#include "winerror.h"
31#include "riched32.h"
32#include "richedit.h"
33#include "charlist.h"
[9407]34#define NO_SHLWAPI_STREAM
35#include "shlwapi.h"
[3515]36
37#include "rtf.h"
38#include "rtf2text.h"
[9407]39#include "wine/debug.h"
[3515]40
41#define ID_EDIT 1
42
[9407]43WINE_DEFAULT_DEBUG_CHANNEL(richedit);
[3515]44
[21308]45#ifdef __WIN32OS2__
46/** custom build hack. */
47BOOL (* WINAPI pfnCustomRichedHack_EM_STREAMIN)(HWND, LPSTR) = NULL;
48#endif
49
[3515]50HANDLE RICHED32_hHeap = (HANDLE)NULL;
51/* LPSTR RICHED32_aSubclass = (LPSTR)NULL; */
52
[9407]53#define DPRINTF_EDIT_MSG32(str) \
54 TRACE(\
55 "32 bit : " str ": hwnd=%p, wParam=%08x, lParam=%08x\n"\
56 , \
57 hwnd, (UINT)wParam, (UINT)lParam)
58
[9859]59
60static INT CALLBACK EDIT_WordBreakProc(LPWSTR s, INT index, INT count, INT action);
61
[9857]62#ifdef __WIN32OS2__
[9859]63#include <dbglog.h>
64
[9857]65#define RICHEDIT_WND_PROP "RICHEDIT_PROP"
[9407]66
[9859]67FARPROC pfnEditProcA = (FARPROC)DefWindowProcA;
68FARPROC pfnEditProcW = (FARPROC)DefWindowProcW;
69
70typedef struct {
71 CHARFORMAT2A cf;
72 HBRUSH hbrBackground;
73} RICHEDIT_INFO;
[9857]74#endif
75
[9407]76/***********************************************************************
77 * DllMain [Internal] Initializes the internal 'RICHED32.DLL'.
[3515]78 *
79 * PARAMS
[9407]80 * hinstDLL [I] handle to the DLL's instance
[3515]81 * fdwReason [I]
[9407]82 * lpvReserved [I] reserved, must be NULL
[3515]83 *
84 * RETURNS
85 * Success: TRUE
86 * Failure: FALSE
87 */
88
[9407]89#ifdef __WIN32OS2__
90BOOL WINAPI RICHED32_LibMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
91#else
92BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
93#endif
[3515]94{
[9407]95 TRACE("\n");
96 switch (fdwReason)
97 {
98 case DLL_PROCESS_ATTACH:
99 /* create private heap */
100 RICHED32_hHeap = HeapCreate (0, 0x10000, 0);
101 /* register the Rich Edit class */
102 RICHED32_Register ();
103 break;
[3922]104
[9407]105 case DLL_PROCESS_DETACH:
106 /* unregister all common control classes */
107 RICHED32_Unregister ();
108 HeapDestroy (RICHED32_hHeap);
109 RICHED32_hHeap = (HANDLE)NULL;
110 break;
[3515]111 }
112 return TRUE;
113}
114
[9407]115/* Support routines for window procedure */
116 INT RICHEDIT_GetTextRange(HWND hwnd,TEXTRANGEA *tr);
117 INT RICHEDIT_GetSelText(HWND hwnd,LPSTR lpstrBuffer);
118
119
[3515]120/*
121 *
122 * DESCRIPTION:
123 * Window procedure of the RichEdit control.
124 *
125 */
126static LRESULT WINAPI RICHED32_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam,
127 LPARAM lParam)
128{
129 int RTFToBuffer(char* pBuffer, int nBufferSize);
130 LONG newstyle = 0;
[3922]131 LONG style = 0;
[3515]132
[9859]133 HWND hwndParent = GetParent(hwnd);
[9857]134 char* rtfBuffer;
135 HANDLE hProp = 0;
136 int rtfBufferSize;
137
138 CHARRANGE *cr;
[9859]139 FARPROC pfnEditProc;
[3922]140
[9859]141 TRACE("uMsg: 0x%x hwnd: %p",uMsg,hwnd);
[9407]142
[9859]143 if(IsWindowUnicode(hwnd)) {
144 pfnEditProc = pfnEditProcW;
[22060]145 }
[9859]146 else pfnEditProc = pfnEditProcA;
147
[3515]148 switch (uMsg)
149 {
[3922]150
151 case WM_CREATE :
[9859]152 {
153 RICHEDIT_INFO *prinfo;
154 LRESULT ret;
[3922]155
[9859]156 DPRINTF_EDIT_MSG32("WM_CREATE");
[9407]157
[9859]158 ret = pfnEditProc(hwnd, WM_CREATE, wParam, lParam);
159 if(ret) return ret; /* window creation cancelled */
[3787]160
[9859]161 hProp = GlobalAlloc(GMEM_MOVEABLE|GMEM_ZEROINIT, sizeof(RICHEDIT_INFO));
[22060]162 SetPropA(hwnd, RICHEDIT_WND_PROP, hProp);
[9859]163 return 0 ;
164 }
[3922]165
[9859]166 case WM_DESTROY:
167 {
168 RICHEDIT_INFO *prinfo;
[9857]169
[9859]170 hProp = GetPropA(hwnd, RICHEDIT_WND_PROP);
171 prinfo = (RICHEDIT_INFO *)GlobalLock(hProp);
172 if(prinfo) {
173 //Destroy old brush if present
174 if(prinfo->hbrBackground) DeleteObject(prinfo->hbrBackground);
175 GlobalUnlock(hProp);
176 }
[3922]177
[9859]178 if(hProp) GlobalFree(hProp);
179 RemovePropA(hwnd, RICHEDIT_WND_PROP);
[3922]180
[9859]181 return pfnEditProc(hwnd, uMsg, wParam, lParam);
182 }
[3922]183
[9859]184 /* Messages specific to Richedit controls */
[3515]185
[3922]186 case EM_STREAMIN:
[9859]187 {
[9407]188 DPRINTF_EDIT_MSG32("EM_STREAMIN");
[3922]189
[3515]190 /* setup the RTF parser */
191 RTFSetEditStream(( EDITSTREAM*)lParam);
[9407]192 rtfFormat = wParam&(SF_TEXT|SF_RTF);
[3515]193 WriterInit();
194 RTFInit ();
[3922]195 BeginFile();
[3515]196
197 /* do the parsing */
198 RTFRead ();
[3922]199
[3515]200 rtfBufferSize = RTFToBuffer(NULL, 0);
201 rtfBuffer = HeapAlloc(RICHED32_hHeap, 0,rtfBufferSize*sizeof(char));
202 if(rtfBuffer)
203 {
204 RTFToBuffer(rtfBuffer, rtfBufferSize);
[21308]205#ifdef __WIN32OS2__
206 /* This is a very very ugly hack to work around some major parsing errors. */
207 if (pfnCustomRichedHack_EM_STREAMIN)
208 pfnCustomRichedHack_EM_STREAMIN(hwnd, rtfBuffer);
209 else
210#endif
[9859]211 SetWindowTextA(hwnd,rtfBuffer);
[3515]212 HeapFree(RICHED32_hHeap, 0,rtfBuffer);
213 }
214 else
215 WARN("Not enough memory for a allocating rtfBuffer\n");
[3922]216
217 return 0;
[9859]218 }
[22060]219
[9407]220 case EM_AUTOURLDETECT:
221 DPRINTF_EDIT_MSG32("EM_AUTOURLDETECT Ignored");
222 return 0;
223
224 case EM_CANPASTE:
225 DPRINTF_EDIT_MSG32("EM_CANPASTE Ignored");
226 return 0;
227
228 case EM_CANREDO:
229 DPRINTF_EDIT_MSG32("EM_CANREDO Ignored");
230 return 0;
231
232 case EM_DISPLAYBAND:
233 DPRINTF_EDIT_MSG32("EM_DISPLAYBAND Ignored");
234 return 0;
235
236 case EM_EXGETSEL:
237 DPRINTF_EDIT_MSG32("EM_EXGETSEL -> EM_GETSEL");
238 cr = (VOID *) lParam;
[9859]239 pfnEditProc( hwnd, EM_GETSEL, (INT)&cr->cpMin, (INT)&cr->cpMax);
[9407]240 TRACE("cpMin: 0x%x cpMax: 0x%x\n",(INT)cr->cpMin,(INT)cr->cpMax);
241 return 0;
242
243 case EM_EXLIMITTEXT:
244 {
245 DWORD limit = lParam;
246 DPRINTF_EDIT_MSG32("EM_EXLIMITTEXT");
247 if (limit > 65534)
248 {
249 limit = 0xFFFFFFFF;
250 }
[9859]251 return pfnEditProc(hwnd,EM_SETLIMITTEXT,limit,0);
[9407]252 }
253
254 case EM_EXLINEFROMCHAR:
255 DPRINTF_EDIT_MSG32("EM_EXLINEFROMCHAR -> LINEFROMCHAR");
[9859]256 return pfnEditProc( hwnd, EM_LINEFROMCHAR, lParam, wParam);
[9407]257
258 case EM_EXSETSEL:
259 DPRINTF_EDIT_MSG32("EM_EXSETSEL -> EM_SETSEL");
260 cr = (VOID *) lParam;
[9859]261 pfnEditProc( hwnd, EM_SETSEL, cr->cpMin, cr->cpMax);
[9407]262 return 0;
263
264 case EM_FINDTEXT:
265 DPRINTF_EDIT_MSG32("EM_FINDTEXT Ignored");
266 return 0;
267
268 case EM_FINDTEXTEX:
269 DPRINTF_EDIT_MSG32("EM_FINDTEXTEX Ignored");
270 return 0;
271
272 case EM_FINDTEXTEXW:
273 DPRINTF_EDIT_MSG32("EM_FINDTEXTEXW Ignored");
274 return 0;
275
276 case EM_FINDTEXTW:
277 DPRINTF_EDIT_MSG32("EM_FINDTEXTW Ignored");
278 return 0;
279
280 case EM_FINDWORDBREAK:
[9859]281 {
282 DWORD ret = 0;
283 DWORD len = GetWindowTextLengthA(hwnd);
284 LPWSTR lpszText = (LPWSTR)HeapAlloc(RICHED32_hHeap, 0, (len+1)*sizeof(WCHAR));
[9407]285
[9859]286 if(lpszText == NULL) {
287 DebugInt3();
288 return 0;
289 }
290 lpszText[0] = 0;
291 GetWindowTextW(hwnd, lpszText, len);
292
293 DPRINTF_EDIT_MSG32("EM_FINDWORDBREAK: partly implemented");
294 switch(wParam) {
295 case WB_ISDELIMITER:
296 case WB_LEFT:
297 case WB_RIGHT:
298 ret = EDIT_WordBreakProc(lpszText, lParam, len, wParam);
299 break;
300 }
301 HeapFree(RICHED32_hHeap, 0, lpszText);
302 return ret;
303 }
304
[9407]305 case EM_FORMATRANGE:
306 DPRINTF_EDIT_MSG32("EM_FORMATRANGE Ignored");
307 return 0;
308
309 case EM_GETAUTOURLDETECT:
310 DPRINTF_EDIT_MSG32("EM_GETAUTOURLDETECT Ignored");
311 return 0;
312
313 case EM_GETBIDIOPTIONS:
314 DPRINTF_EDIT_MSG32("EM_GETBIDIOPTIONS Ignored");
315 return 0;
316
317 case EM_GETCHARFORMAT:
318 DPRINTF_EDIT_MSG32("EM_GETCHARFORMAT Ignored");
319 return 0;
320
321 case EM_GETEDITSTYLE:
322 DPRINTF_EDIT_MSG32("EM_GETEDITSTYLE Ignored");
323 return 0;
324
325 case EM_GETEVENTMASK:
326 DPRINTF_EDIT_MSG32("EM_GETEVENTMASK Ignored");
327 return 0;
328
329 case EM_GETIMECOLOR:
330 DPRINTF_EDIT_MSG32("EM_GETIMECOLOR Ignored");
331 return 0;
332
333 case EM_GETIMECOMPMODE:
334 DPRINTF_EDIT_MSG32("EM_GETIMECOMPMODE Ignored");
335 return 0;
336
337 case EM_GETIMEOPTIONS:
338 DPRINTF_EDIT_MSG32("EM_GETIMEOPTIONS Ignored");
339 return 0;
340
341 case EM_GETLANGOPTIONS:
342 DPRINTF_EDIT_MSG32("STUB: EM_GETLANGOPTIONS");
343 return 0;
344
345 case EM_GETOLEINTERFACE:
346 DPRINTF_EDIT_MSG32("EM_GETOLEINTERFACE Ignored");
347 return 0;
348
349 case EM_GETOPTIONS:
350 DPRINTF_EDIT_MSG32("EM_GETOPTIONS Ignored");
351 return 0;
352
353 case EM_GETPARAFORMAT:
354 DPRINTF_EDIT_MSG32("EM_GETPARAFORMAT Ignored");
355 return 0;
356
357 case EM_GETPUNCTUATION:
358 DPRINTF_EDIT_MSG32("EM_GETPUNCTUATION Ignored");
359 return 0;
360
361 case EM_GETREDONAME:
362 DPRINTF_EDIT_MSG32("EM_GETREDONAME Ignored");
363 return 0;
364
365 case EM_GETSCROLLPOS:
366 DPRINTF_EDIT_MSG32("EM_GETSCROLLPOS Ignored");
367 return 0;
368
369 case EM_GETSELTEXT:
370 DPRINTF_EDIT_MSG32("EM_GETSELTEXT");
[9859]371 return RICHEDIT_GetSelText(hwnd,(void *)lParam);
[9407]372
373 case EM_GETTEXTEX:
374 DPRINTF_EDIT_MSG32("EM_GETTEXTEX Ignored");
375 return 0;
376
377 case EM_GETTEXTLENGTHEX:
378 DPRINTF_EDIT_MSG32("EM_GETTEXTLENGTHEX Ignored");
379 return 0;
380
381 case EM_GETTEXTMODE:
382 DPRINTF_EDIT_MSG32("EM_GETTEXTMODE Ignored");
383 return 0;
384
385 case EM_GETTEXTRANGE:
386 DPRINTF_EDIT_MSG32("EM_GETTEXTRANGE");
[9859]387 return RICHEDIT_GetTextRange(hwnd,(TEXTRANGEA *)lParam);
[9407]388
389 case EM_GETTYPOGRAPHYOPTIONS:
390 DPRINTF_EDIT_MSG32("EM_GETTYPOGRAPHYOPTIONS Ignored");
391 return 0;
392
393 case EM_GETUNDONAME:
394 DPRINTF_EDIT_MSG32("EM_GETUNDONAME Ignored");
395 return 0;
396
397 case EM_GETWORDBREAKPROCEX:
398 DPRINTF_EDIT_MSG32("EM_GETWORDBREAKPROCEX Ignored");
399 return 0;
400
401 case EM_GETWORDWRAPMODE:
402 DPRINTF_EDIT_MSG32("EM_GETWORDWRAPMODE Ignored");
403 return 0;
404
405 case EM_GETZOOM:
406 DPRINTF_EDIT_MSG32("EM_GETZOOM Ignored");
407 return 0;
408
409 case EM_HIDESELECTION:
410 DPRINTF_EDIT_MSG32("EM_HIDESELECTION Ignored");
411 return 0;
412
413 case EM_PASTESPECIAL:
414 DPRINTF_EDIT_MSG32("EM_PASTESPECIAL Ignored");
415 return 0;
416
417 case EM_RECONVERSION:
418 DPRINTF_EDIT_MSG32("EM_RECONVERSION Ignored");
419 return 0;
420
421 case EM_REDO:
422 DPRINTF_EDIT_MSG32("EM_REDO Ignored");
423 return 0;
424
425 case EM_REQUESTRESIZE:
426 DPRINTF_EDIT_MSG32("EM_REQUESTRESIZE Ignored");
427 return 0;
428
429 case EM_SELECTIONTYPE:
430 DPRINTF_EDIT_MSG32("EM_SELECTIONTYPE Ignored");
431 return 0;
432
433 case EM_SETBIDIOPTIONS:
434 DPRINTF_EDIT_MSG32("EM_SETBIDIOPTIONS Ignored");
435 return 0;
436
437 case EM_SETBKGNDCOLOR:
[9859]438 {
439 RICHEDIT_INFO *prinfo;
[9857]440
[9859]441 DPRINTF_EDIT_MSG32("EM_SETBKGNDCOLOR");
442
[9857]443 hProp = GetPropA(hwnd, RICHEDIT_WND_PROP);
[9859]444 prinfo = (RICHEDIT_INFO *)GlobalLock(hProp);
[22060]445 if(prinfo)
[9857]446 {
[9859]447 prinfo->cf.dwMask |= CFM_BACKCOLOR;
448 prinfo->cf.crBackColor = (wParam) ? GetSysColor(COLOR_BACKGROUND) : (COLORREF)lParam;
[9857]449
450 //Destroy old brush if present
[9859]451 if(prinfo->hbrBackground) DeleteObject(prinfo->hbrBackground);
[9857]452
453 //Create a brush that we return in WM_CTLCOLORSTATIC
[9859]454 prinfo->hbrBackground = (DWORD)CreateSolidBrush(prinfo->cf.crBackColor);
[22060]455
[9859]456 dprintf(("Set background color to %x brush %x", prinfo->cf.crBackColor, prinfo->hbrBackground));
[9857]457
458 GlobalUnlock(hProp);
459 }
[22060]460 return 1;
[9859]461 }
[9407]462
463 case EM_SETCHARFORMAT:
[9857]464 {
465 CHARFORMAT2A *pnewcf = (CHARFORMAT2A *)lParam;
[9859]466 RICHEDIT_INFO *prinfo;
[9857]467
[9859]468 DPRINTF_EDIT_MSG32("EM_SETCHARFORMAT: not completely implemented!!");
469
[9857]470 hProp = GetPropA(hwnd, RICHEDIT_WND_PROP);
[9859]471 prinfo = (RICHEDIT_INFO *)GlobalLock(hProp);
[22060]472 if(prinfo && pnewcf && pnewcf->cbSize >= sizeof(CHARFORMATA))
[9857]473 {
474 if((pnewcf->dwMask & CFM_COLOR) && !(pnewcf->dwEffects & CFE_AUTOCOLOR)) {
[9859]475 prinfo->cf.dwMask |= CFM_COLOR;
476 prinfo->cf.crTextColor = pnewcf->crTextColor;
477 dprintf(("Set text color to %x", prinfo->cf.crTextColor));
[9857]478 }
[22060]479 if(pnewcf->cbSize == sizeof(CHARFORMAT2A))
[9857]480 {
[22060]481 if((pnewcf->dwMask & CFM_BACKCOLOR) && !(pnewcf->dwEffects & CFE_AUTOBACKCOLOR))
[9857]482 {
[9859]483 prinfo->cf.dwMask |= CFM_BACKCOLOR;
484 prinfo->cf.crBackColor = pnewcf->crBackColor;
[22060]485
[9857]486 //Destroy old brush if present
[9859]487 if(prinfo->hbrBackground) DeleteObject(prinfo->hbrBackground);
[9857]488
489 //Create a brush that we return in WM_CTLCOLORSTATIC
[9859]490 prinfo->hbrBackground = (DWORD)CreateSolidBrush(prinfo->cf.crBackColor);
[22060]491
[9859]492 dprintf(("Set background color to %x brush %x", prinfo->cf.crBackColor, prinfo->hbrBackground));
[9857]493 }
494 }
495 }
496
[9859]497 if(prinfo) GlobalUnlock(hProp);
[22060]498 return 1;
[9857]499 }
[9407]500
501 case EM_SETEDITSTYLE:
502 DPRINTF_EDIT_MSG32("EM_SETEDITSTYLE Ignored");
503 return 0;
504
505 case EM_SETEVENTMASK:
506 DPRINTF_EDIT_MSG32("EM_SETEVENTMASK Ignored");
507 return 0;
508
509 case EM_SETFONTSIZE:
510 DPRINTF_EDIT_MSG32("EM_SETFONTSIZE Ignored");
511 return 0;
512
513 case EM_SETIMECOLOR:
514 DPRINTF_EDIT_MSG32("EM_SETIMECOLO Ignored");
515 return 0;
516
517 case EM_SETIMEOPTIONS:
518 DPRINTF_EDIT_MSG32("EM_SETIMEOPTIONS Ignored");
519 return 0;
520
521 case EM_SETLANGOPTIONS:
522 DPRINTF_EDIT_MSG32("EM_SETLANGOPTIONS Ignored");
523 return 0;
524
525 case EM_SETOLECALLBACK:
526 DPRINTF_EDIT_MSG32("EM_SETOLECALLBACK Ignored");
527 return 0;
528
529 case EM_SETOPTIONS:
530 DPRINTF_EDIT_MSG32("EM_SETOPTIONS Ignored");
531 return 0;
532
533 case EM_SETPALETTE:
534 DPRINTF_EDIT_MSG32("EM_SETPALETTE Ignored");
535 return 0;
536
537 case EM_SETPARAFORMAT:
538 DPRINTF_EDIT_MSG32("EM_SETPARAFORMAT Ignored");
539 return 0;
540
541 case EM_SETPUNCTUATION:
542 DPRINTF_EDIT_MSG32("EM_SETPUNCTUATION Ignored");
543 return 0;
544
545 case EM_SETSCROLLPOS:
546 DPRINTF_EDIT_MSG32("EM_SETSCROLLPOS Ignored");
547 return 0;
548
549 case EM_SETTARGETDEVICE:
550 DPRINTF_EDIT_MSG32("EM_SETTARGETDEVICE Ignored");
551 return 0;
552
553 case EM_SETTEXTEX:
554 DPRINTF_EDIT_MSG32("EM_SETTEXTEX Ignored");
555 return 0;
556
557 case EM_SETTEXTMODE:
558 DPRINTF_EDIT_MSG32("EM_SETTEXTMODE Ignored");
559 return 0;
560
561 case EM_SETTYPOGRAPHYOPTIONS:
562 DPRINTF_EDIT_MSG32("EM_SETTYPOGRAPHYOPTIONS Ignored");
563 return 0;
564
565 case EM_SETUNDOLIMIT:
566 DPRINTF_EDIT_MSG32("EM_SETUNDOLIMIT Ignored");
567 return 0;
568
569 case EM_SETWORDBREAKPROCEX:
570 DPRINTF_EDIT_MSG32("EM_SETWORDBREAKPROCEX Ignored");
571 return 0;
572
573 case EM_SETWORDWRAPMODE:
574 DPRINTF_EDIT_MSG32("EM_SETWORDWRAPMODE Ignored");
575 return 0;
576
577 case EM_SETZOOM:
578 DPRINTF_EDIT_MSG32("EM_SETZOOM Ignored");
579 return 0;
580
581 case EM_SHOWSCROLLBAR:
582 DPRINTF_EDIT_MSG32("EM_SHOWSCROLLBAR Ignored");
583 return 0;
584
585 case EM_STOPGROUPTYPING:
586 DPRINTF_EDIT_MSG32("EM_STOPGROUPTYPING Ignored");
587 return 0;
588
589 case EM_STREAMOUT:
590 DPRINTF_EDIT_MSG32("EM_STREAMOUT Ignored");
591 return 0;
592
[9859]593#if 0
[9407]594 case WM_CTLCOLORSTATIC:
[9857]595#ifdef __WIN32OS2__
596 case WM_CTLCOLOREDIT:
[9859]597 {
598 RICHEDIT_INFO *prinfo;
[9857]599 HBRUSH hBrush = 0;
600 HDC hdc = (HDC)wParam;
601
602 hProp = GetPropA(hwnd, RICHEDIT_WND_PROP);
[9859]603 prinfo = (RICHEDIT_INFO *)GlobalLock(hProp);
604 if(prinfo)
[9857]605 {
[9859]606 if(prinfo->cf.dwMask & CFM_BACKCOLOR) {
607 SetBkColor(hdc, prinfo->cf.crBackColor);
608 hBrush = prinfo->hbrBackground;
[9857]609 }
[9859]610 if(prinfo->cf.dwMask & CFM_COLOR) {
611 SetTextColor(hdc, prinfo->cf.crTextColor);
[9857]612 }
613 }
[9859]614 if(prinfo) GlobalUnlock(hProp);
[9857]615
[22060]616 if(hBrush) return hBrush;
[9859]617 }
[9857]618#endif
[9407]619 DPRINTF_EDIT_MSG32("WM_CTLCOLORSTATIC Passed to default");
620 return DefWindowProcA( hwnd,uMsg,wParam,lParam);
[9859]621#endif
622
623 /* Edit control messages that are different for RichEdit controls */
624 case EM_CHARFROMPOS:
625 {
626 POINTL *lpPoint = (POINTL *)lParam;
627 DWORD curpos;
628
629 curpos = pfnEditProc(hwnd, EM_CHARFROMPOS, wParam, MAKELPARAM(lpPoint->x, lpPoint->y));
630 TRACE("curpos: 0x%x richedit pos: 0x%x\n", curpos, LOWORD(curpos));
631 return LOWORD(curpos);
632 }
633
[9407]634 /*
635 * used by IE in the EULA box
636 */
637 case WM_ALTTABACTIVE:
638 DPRINTF_EDIT_MSG32("WM_ALTTABACTIVE");
639 return DefWindowProcA( hwnd,uMsg,wParam,lParam);
[3515]640 }
[9407]641
[9859]642 /* pass the rest to the edit window procedure */
643 TRACE("Message 0x%x Passed to pfnEditProc hwnd=%p, wParam=%08x, lParam=%08x\n",
[9407]644 uMsg, hwnd, (UINT)wParam, (UINT)lParam);
645
[9859]646 return pfnEditProc(hwnd,uMsg,wParam,lParam);
[3515]647}
648
[9407]649/***********************************************************************
650 * DllGetVersion [RICHED32.2]
[3515]651 *
[9407]652 * Retrieves version information of the 'RICHED32.DLL'
[3515]653 *
654 * PARAMS
655 * pdvi [O] pointer to version information structure.
656 *
657 * RETURNS
658 * Success: S_OK
659 * Failure: E_INVALIDARG
660 *
661 * NOTES
662 * Returns version of a comctl32.dll from IE4.01 SP1.
663 */
664
665HRESULT WINAPI
666RICHED32_DllGetVersion (DLLVERSIONINFO *pdvi)
667{
[9407]668 TRACE("\n");
669
[3515]670 if (pdvi->cbSize != sizeof(DLLVERSIONINFO)) {
[3922]671
[3515]672 return E_INVALIDARG;
673 }
674
675 pdvi->dwMajorVersion = 4;
676 pdvi->dwMinorVersion = 0;
677 pdvi->dwBuildNumber = 0;
678 pdvi->dwPlatformID = 0;
679
680 return S_OK;
681}
682
683/***
684 * DESCRIPTION:
685 * Registers the window class.
[3922]686 *
[3515]687 * PARAMETER(S):
688 * None
689 *
690 * RETURN:
691 * None
692 */
693VOID RICHED32_Register(void)
694{
[3922]695 WNDCLASSA wndClass;
[3515]696
[9859]697#ifdef __WIN32OS2__
698 WNDCLASSA classinfoA;
699 WNDCLASSW classinfoW;
700
[22060]701 if(GetClassInfoA(NULL, "EDIT", &classinfoA))
[9859]702 {
703 pfnEditProcA = classinfoA.lpfnWndProc;
704 }
705 else DebugInt3();
[22060]706 if(GetClassInfoW(NULL, L"EDIT", &classinfoW))
[9859]707 {
708 pfnEditProcW = classinfoW.lpfnWndProc;
709 }
710 else DebugInt3();
711
712 ZeroMemory(&wndClass, sizeof(WNDCLASSA));
713 wndClass.style = classinfoA.style;
714 wndClass.lpfnWndProc = (WNDPROC)RICHED32_WindowProc;
715 wndClass.cbClsExtra = classinfoA.cbClsExtra;
716 wndClass.cbWndExtra = classinfoA.cbWndExtra;
717 wndClass.hCursor = classinfoA.hCursor;
718 wndClass.hbrBackground = classinfoA.hbrBackground;
719 wndClass.lpszClassName = RICHEDIT_CLASS10A; /* WC_RICHED32A; */
720#else
[9407]721 TRACE("\n");
722
[3515]723 ZeroMemory(&wndClass, sizeof(WNDCLASSA));
724 wndClass.style = CS_HREDRAW | CS_VREDRAW | CS_GLOBALCLASS;
725 wndClass.lpfnWndProc = (WNDPROC)RICHED32_WindowProc;
726 wndClass.cbClsExtra = 0;
727 wndClass.cbWndExtra = 0; /*(sizeof(RICHED32_INFO *);*/
728 wndClass.hCursor = LoadCursorA(0, IDC_ARROWA);
729 wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
[9407]730 wndClass.lpszClassName = RICHEDIT_CLASS10A; /* WC_RICHED32A; */
[9859]731#endif
[3515]732
733 RegisterClassA (&wndClass);
734}
735
736/***
737 * DESCRIPTION:
738 * Unregisters the window class.
[3922]739 *
[3515]740 * PARAMETER(S):
741 * None
742 *
743 * RETURN:
744 * None
745 */
746VOID RICHED32_Unregister(void)
747{
[9407]748 TRACE("\n");
749
[3515]750 UnregisterClassA(RICHEDIT_CLASS10A, (HINSTANCE)NULL);
[9859]751
752#ifdef __WIN32OS2__
753 pfnEditProcA = (FARPROC)DefWindowProcA;
754 pfnEditProcW = (FARPROC)DefWindowProcW;
755#endif
[3515]756}
[9407]757
758INT RICHEDIT_GetTextRange(HWND hwnd,TEXTRANGEA *tr)
759{
760 UINT alloc_size, text_size, range_size;
761 char *text;
762
763 TRACE("start: 0x%x stop: 0x%x\n",(INT)tr->chrg.cpMin,(INT)tr->chrg.cpMax);
764
765 if (!(alloc_size = SendMessageA(hwnd,WM_GETTEXTLENGTH,0,0))) return FALSE;
766 if (!(text = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (alloc_size+1))))
767 return FALSE;
768 text_size = SendMessageA(hwnd,WM_GETTEXT,alloc_size,(INT)text);
769
770 if (text_size > tr->chrg.cpMin)
771 {
772 range_size = (text_size> tr->chrg.cpMax) ? (tr->chrg.cpMax - tr->chrg.cpMin) : (text_size - tr->chrg.cpMin);
773 TRACE("EditText: %.30s ...\n",text+tr->chrg.cpMin);
774 memcpy(tr->lpstrText,text+tr->chrg.cpMin,range_size);
775 }
776 else range_size = 0;
777 HeapFree(GetProcessHeap(), 0, text);
778
779 return range_size;
780}
781
782INT RICHEDIT_GetSelText(HWND hwnd,LPSTR lpstrBuffer)
783{
784 TEXTRANGEA textrange;
785
786 textrange.lpstrText = lpstrBuffer;
787 SendMessageA(hwnd,EM_GETSEL,(INT)&textrange.chrg.cpMin,(INT)&textrange.chrg.cpMax);
788 return RICHEDIT_GetTextRange(hwnd,&textrange);
789}
[9859]790
791/*********************************************************************
792 *
793 * EDIT_WordBreakProc
794 *
795 * Find the beginning of words.
796 * Note: unlike the specs for a WordBreakProc, this function only
797 * allows to be called without linebreaks between s[0] upto
798 * s[count - 1]. Remember it is only called
799 * internally, so we can decide this for ourselves.
800 *
801 */
802static INT CALLBACK EDIT_WordBreakProc(LPWSTR s, INT index, INT count, INT action)
803{
804 INT ret = 0;
805
806 TRACE("s=%p, index=%d, count=%d, action=%d\n", s, index, count, action);
807
808 if(!s) return 0;
809
810 switch (action) {
811 case WB_LEFT:
812 if (!count)
813 break;
814 if (index)
815 index--;
816 if (s[index] == ' ') {
817 while (index && (s[index] == ' '))
818 index--;
819 if (index) {
820 while (index && (s[index] != ' '))
821 index--;
822 if (s[index] == ' ')
823 index++;
824 }
825 } else {
826 while (index && (s[index] != ' '))
827 index--;
828 if (s[index] == ' ')
829 index++;
830 }
831 ret = index;
832 break;
833 case WB_RIGHT:
834 if (!count)
835 break;
836 if (index)
837 index--;
838 if (s[index] == ' ')
839 while ((index < count) && (s[index] == ' ')) index++;
840 else {
841 while (s[index] && (s[index] != ' ') && (index < count))
842 index++;
843 while ((s[index] == ' ') && (index < count)) index++;
844 }
845 ret = index;
846 break;
847 case WB_ISDELIMITER:
848 ret = (s[index] == ' ');
849 break;
850 default:
851 ERR("unknown action code, please report !\n");
852 break;
853 }
854 return ret;
855}
[21308]856
857
858#ifdef __WIN32OS2__
859/** Enables a callback replacement for the SetWindowTextA call finalizing
860 * the handling of an EM_STREAMIN message.
861 * @remark don't use this hack.
862 */
863BOOL WINAPI ODIN_RichedHack_EM_STREAMIN(BOOL (* WINAPI pfn)(HWND, LPSTR))
864{
865 pfnCustomRichedHack_EM_STREAMIN = pfn;
866 return TRUE;
867}
868#endif
869
Note: See TracBrowser for help on using the repository browser.