comparison win/dw.c @ 1550:78a2e6a51285

Added basic rich edit control support for MLEs on Windows. This is disabled by default, I tried switching to the richedit control to work around a problem with the edit control not being able to switch word wrap modes without recreating the control. However despite rich edit messages that look like they will do just that, the rich edit controls appear to have the same problem. Committing this code though in case we want to switch to rich edit in the future for other reasons.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Fri, 13 Jan 2012 22:01:15 +0000
parents edbc7405ed4d
children 4a9c574d5c17
comparison
equal deleted inserted replaced
1549:ca6be9c48fff 1550:78a2e6a51285
27 #include "XBrowseForFolder.h" 27 #include "XBrowseForFolder.h"
28 #endif 28 #endif
29 #ifdef AEROGLASS 29 #ifdef AEROGLASS
30 #include <uxtheme.h> 30 #include <uxtheme.h>
31 #endif 31 #endif
32 #include <richedit.h>
32 33
33 #ifdef GDIPLUS 34 #ifdef GDIPLUS
34 /* GDI+ Headers are not C compatible... so define what we need here instead */ 35 /* GDI+ Headers are not C compatible... so define what we need here instead */
35 struct GdiplusStartupInput 36 struct GdiplusStartupInput
36 { 37 {
115 HRESULT (WINAPI *_CloseThemeData)(HTHEME hTheme); 116 HRESULT (WINAPI *_CloseThemeData)(HTHEME hTheme);
116 BOOL _dw_composition = FALSE; 117 BOOL _dw_composition = FALSE;
117 COLORREF _dw_transparencykey = RGB(200,201,202); 118 COLORREF _dw_transparencykey = RGB(200,201,202);
118 HANDLE hdwm = 0, huxtheme = 0; 119 HANDLE hdwm = 0, huxtheme = 0;
119 #endif 120 #endif
121
122 /* Needed for Rich Edit controls */
123 HANDLE hrichedit = 0;
120 124
121 /* 125 /*
122 * MinGW Is missing a bunch of definitions 126 * MinGW Is missing a bunch of definitions
123 * so #define them here... 127 * so #define them here...
124 */ 128 */
3877 { 3881 {
3878 FreeLibrary(hdwm); 3882 FreeLibrary(hdwm);
3879 hdwm = 0; 3883 hdwm = 0;
3880 } 3884 }
3881 #endif 3885 #endif
3886 #ifdef RICHEDIT
3887 /* Attempt to load rich edit library */
3888 if(!(hrichedit = LoadLibrary("riched20")))
3889 hrichedit = LoadLibrary("riched32");
3890 #endif
3882 return 0; 3891 return 0;
3883 } 3892 }
3884 3893
3885 static int _dw_main_running = FALSE; 3894 static int _dw_main_running = FALSE;
3886 3895
4473 dw_font_text_extents_get(handle, NULL, testtext, NULL, &thisheight); 4482 dw_font_text_extents_get(handle, NULL, testtext, NULL, &thisheight);
4474 thiswidth = 50; 4483 thiswidth = 50;
4475 extraheight = 6; 4484 extraheight = 6;
4476 } 4485 }
4477 /* Entryfields and MLE */ 4486 /* Entryfields and MLE */
4478 else if(strnicmp(tmpbuf, EDITCLASSNAME, strlen(EDITCLASSNAME)+1) == 0) 4487 else if(strnicmp(tmpbuf, EDITCLASSNAME, strlen(EDITCLASSNAME)+1) == 0 ||
4488 strnicmp(tmpbuf, RICHEDIT_CLASS, strlen(RICHEDIT_CLASS)+1) == 0)
4479 { 4489 {
4480 LONG style = GetWindowLong(handle, GWL_STYLE); 4490 LONG style = GetWindowLong(handle, GWL_STYLE);
4481 if((style & ES_MULTILINE)) 4491 if((style & ES_MULTILINE))
4482 { 4492 {
4483 unsigned long bytes; 4493 unsigned long bytes;
5774 */ 5784 */
5775 HWND API dw_mle_new(ULONG id) 5785 HWND API dw_mle_new(ULONG id)
5776 { 5786 {
5777 5787
5778 HWND tmp = CreateWindowEx(WS_EX_CLIENTEDGE, 5788 HWND tmp = CreateWindowEx(WS_EX_CLIENTEDGE,
5779 EDITCLASSNAME, 5789 hrichedit ? RICHEDIT_CLASS : EDITCLASSNAME,
5780 "", 5790 "",
5781 WS_VISIBLE | WS_BORDER | 5791 WS_VISIBLE | WS_BORDER |
5782 WS_VSCROLL | ES_MULTILINE | 5792 WS_VSCROLL | ES_MULTILINE |
5783 ES_WANTRETURN | WS_CHILD | 5793 ES_WANTRETURN | WS_CHILD |
5784 WS_CLIPCHILDREN, 5794 WS_CLIPCHILDREN,
7902 */ 7912 */
7903 if(state) 7913 if(state)
7904 dw_window_set_style(handle, 0, ES_AUTOHSCROLL); 7914 dw_window_set_style(handle, 0, ES_AUTOHSCROLL);
7905 else 7915 else
7906 dw_window_set_style(handle, ES_AUTOHSCROLL, ES_AUTOHSCROLL); 7916 dw_window_set_style(handle, ES_AUTOHSCROLL, ES_AUTOHSCROLL);
7917 /* If it is a rich edit control use the rich edit message */
7918 if(hrichedit)
7919 {
7920 if(state)
7921 SendMessage(handle, EM_SETOPTIONS, (WPARAM)ECOOP_AND, (LPARAM)~ECO_AUTOHSCROLL);
7922 else
7923 SendMessage(handle, EM_SETOPTIONS, (WPARAM)ECOOP_OR, (LPARAM)ECO_AUTOHSCROLL);
7924 }
7907 } 7925 }
7908 7926
7909 /* 7927 /*
7910 * Sets the current cursor position of an MLE box. 7928 * Sets the current cursor position of an MLE box.
7911 * Parameters: 7929 * Parameters: