riched20:EM_SETOPTIONS/EM_GETOPTIONS base implementation
Brian Chang
brianch at seas.ucla.edu
Tue Feb 21 15:49:19 CST 2006
Hello. My name is Brian Chang and I'm a resident of Los Angeles, CA, USA currently attending UCLA. I hereby certify that I wrote this code without copying from anyone else's sources, and I've never seen any secret Microsoft source code.
---
changelog: EM_SETOPTIONS and EM_GETOPTIONS base implementation. ECO_READONLY implemented and tested.
---
editor.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++----
tests/editor.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 105 insertions(+), 4 deletions(-)
Index: dlls/riched20/editor.c
===================================================================
RCS file: /home/wine/wine/dlls/riched20/editor.c,v
retrieving revision 1.92
diff -a -u -r1.92 editor.c
--- dlls/riched20/editor.c 21 Feb 2006 11:06:12 -0000 1.92
+++ dlls/riched20/editor.c 21 Feb 2006 17:41:25 -0000
@@ -56,7 +56,7 @@
+ EM_GETLINECOUNT returns number of rows, not of paragraphs
+ EM_GETMODIFY
- EM_GETOLEINTERFACE
- - EM_GETOPTIONS
+ + EM_GETOPTIONS
+ EM_GETPARAFORMAT
- EM_GETPASSWORDCHAR 2.0
- EM_GETPUNCTUATION 1.0asian
@@ -102,7 +102,7 @@
- EM_SETLIMITTEXT
+ EM_SETMODIFY (not sure if implementation is correct)
- EM_SETOLECALLBACK
- - EM_SETOPTIONS
+ + EM_SETOPTIONS (partially implemented)
- EM_SETPALETTE 2.0
+ EM_SETPARAFORMAT
- EM_SETPASSWORDCHAR 2.0
@@ -1327,7 +1327,6 @@
UNSUPPORTED_MSG(EM_GETLIMITTEXT)
UNSUPPORTED_MSG(EM_GETLINE)
/* UNSUPPORTED_MSG(EM_GETOLEINTERFACE) separate stub */
- UNSUPPORTED_MSG(EM_GETOPTIONS)
UNSUPPORTED_MSG(EM_GETPASSWORDCHAR)
UNSUPPORTED_MSG(EM_GETREDONAME)
UNSUPPORTED_MSG(EM_GETTEXTMODE)
@@ -1343,7 +1342,6 @@
UNSUPPORTED_MSG(EM_SETEDITSTYLE)
UNSUPPORTED_MSG(EM_SETFONTSIZE)
UNSUPPORTED_MSG(EM_SETLANGOPTIONS)
- UNSUPPORTED_MSG(EM_SETOPTIONS)
UNSUPPORTED_MSG(EM_SETPALETTE)
UNSUPPORTED_MSG(EM_SETPASSWORDCHAR)
UNSUPPORTED_MSG(EM_SETSCROLLPOS)
@@ -1412,6 +1410,59 @@
case EM_REDO:
ME_Redo(editor);
return 0;
+ case EM_GETOPTIONS:
+ {
+ /* these flags are equivalent to the ES_* counterparts */
+ long mask = ECO_VERTICAL | ECO_AUTOHSCROLL | ECO_AUTOVSCROLL |
+ ECO_NOHIDESEL | ECO_READONLY | ECO_WANTRETURN;
+ long settings = GetWindowLongW(hWnd, GWL_STYLE) & mask;
+
+ return settings;
+ }
+ case EM_SETOPTIONS:
+ {
+ /* these flags are equivalent to ES_* counterparts
+ * ECO_READONLY is already implemented in the code, only requires
+ * setting the bit to work
+ */
+ long mask = ECO_VERTICAL | ECO_AUTOHSCROLL | ECO_AUTOVSCROLL |
+ ECO_NOHIDESEL | ECO_READONLY | ECO_WANTRETURN;
+ long raw = GetWindowLongW(hWnd, GWL_STYLE);
+ long settings = mask & raw;
+
+ switch(wParam)
+ {
+ case ECOOP_SET:
+ settings = lParam;
+ break;
+ case ECOOP_OR:
+ settings |= lParam;
+ break;
+ case ECOOP_AND:
+ settings &= lParam;
+ break;
+ case ECOOP_XOR:
+ settings ^= lParam;
+ }
+ SetWindowLongW(hWnd, GWL_STYLE, (raw & ~mask) | (settings & mask));
+
+ if (lParam & ECO_AUTOWORDSELECTION)
+ FIXME("ECO_AUTOWORDSELECTION not implemented yet!\n");
+ if (lParam & ECO_SELECTIONBAR)
+ FIXME("ECO_SELECTIONBAR not implemented yet!\n");
+ if (lParam & ECO_VERTICAL)
+ FIXME("ECO_VERTICAL not implemented yet!\n");
+ if (lParam & ECO_AUTOHSCROLL)
+ FIXME("ECO_AUTOHSCROLL not implemented yet!\n");
+ if (lParam & ECO_AUTOVSCROLL)
+ FIXME("ECO_AUTOVSCROLL not implemented yet!\n");
+ if (lParam & ECO_NOHIDESEL)
+ FIXME("ECO_NOHIDESEL not implemented yet!\n");
+ if (lParam & ECO_WANTRETURN)
+ FIXME("ECO_WANTRETURN not implemented yet!\n");
+
+ return settings;
+ }
case EM_SETSEL:
{
ME_InvalidateSelection(editor);
Index: dlls/riched20/tests/editor.c
===================================================================
RCS file: /home/wine/wine/dlls/riched20/tests/editor.c,v
retrieving revision 1.5
diff -a -u -r1.5 editor.c
--- dlls/riched20/tests/editor.c 21 Feb 2006 11:06:13 -0000 1.5
+++ dlls/riched20/tests/editor.c 21 Feb 2006 17:41:25 -0000
@@ -488,6 +488,54 @@
DestroyWindow(hwndRichEdit);
}
+/* FIXME: Extra '\r' appended at end of gotten text*/
+static void test_WM_GETTEXT()
+{
+ HWND hwndRichEdit = new_richedit(NULL);
+ static const char text[] = "Hello. My name is RichEdit!";
+ char buffer[1024] = {0};
+ int result;
+
+ SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM) text);
+ SendMessage(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM) buffer);
+ result = strcmp(buffer,text);
+ todo_wine{
+ ok(result == 0,
+ "WM_GETTEXT: settext and gettext differ. strcmp: %d\n", result);
+ }
+}
+
+/* FIXME: need to test unimplemented options and robustly test wparam */
+static void test_EM_SETOPTIONS()
+{
+ HWND hwndRichEdit = new_richedit(NULL);
+ static const char text[] = "Hello. My name is RichEdit!";
+ char buffer[1024] = {0};
+
+ /* NEGATIVE TESTING - NO OPTIONS SET */
+ SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM) text);
+ SendMessage(hwndRichEdit, EM_SETOPTIONS, ECOOP_SET, 0);
+
+ /* testing no readonly by sending 'a' to the control*/
+ SetFocus(hwndRichEdit);
+ SendMessage(hwndRichEdit, WM_CHAR, 'a', 0x1E0001);
+ SendMessage(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM) buffer);
+ ok(buffer[0]=='a',
+ "EM_SETOPTIONS: Text not changed! s1:%s s2:%s\n", text, buffer);
+ SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM) text);
+
+ /* READONLY - sending 'a' to the control */
+ SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM) text);
+ SendMessage(hwndRichEdit, EM_SETOPTIONS, ECOOP_SET, ECO_READONLY);
+ SetFocus(hwndRichEdit);
+ SendMessage(hwndRichEdit, WM_CHAR, 'a', 0x1E0001);
+ SendMessage(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM) buffer);
+ ok(buffer[0]==text[0],
+ "EM_SETOPTIONS: Text changed! s1:%s s2:%s\n", text, buffer);
+
+ DestroyWindow(hwndRichEdit);
+}
+
START_TEST( editor )
{
MSG msg;
@@ -502,6 +550,8 @@
test_EM_SCROLLCARET();
test_EM_SETTEXTMODE();
test_TM_PLAINTEXT();
+ test_EM_SETOPTIONS();
+ test_WM_GETTEXT();
/* Set the environment variable WINETEST_RICHED20 to keep windows
* responsive and open for 30 seconds. This is useful for debugging.
More information about the wine-patches
mailing list