experimental framework for investigating DrawTextEx behaviour

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




Bill Medland (medbi01@accpac.com)
An experimental testbed for the DrawText(Ex) functions

Index: wine/libtest/Makefile.in
===================================================================
RCS file: /home/wine/wine/libtest/Makefile.in,v
retrieving revision 1.23
diff -u -r1.23 Makefile.in
--- wine/libtest/Makefile.in	2002/01/14 18:34:01	1.23
+++ wine/libtest/Makefile.in	2002/01/17 17:51:28
@@ -5,7 +5,8 @@
 SRCDIR     = @srcdir@
 VPATH      = @srcdir@
 MODULE     = none
-PROGRAMS   = expand hello hello2 hello3 hello4 hello5 new rolex vartest volinfo
+PROGRAMS   = expand hello hello2 hello3 hello4 hello5 new rolex vartest volinfo\
+             drawtext
 ALL_LIBS   = $(LIBWINE) $(LIBS)
 
 C_SRCS = \
@@ -18,7 +19,8 @@
 	new.c \
 	rolex.c \
 	vartest.c \
-	volinfo.c
+	volinfo.c \
+	drawtext.c
 
 SPEC_SRCS = \
 	expand.spec \
@@ -30,7 +32,8 @@
 	new.spec \
 	rolex.spec \
 	vartest.spec \
-	volinfo.spec
+	volinfo.spec \
+	drawtext.spec
 
 RC_SRCS = \
 	hello3res.rc
@@ -89,6 +92,12 @@
 volinfo.so: volinfo.o volinfo.spec.o
 	$(LDSHARED) $(LDDLLFLAGS) -o volinfo.so $+ $(ALL_LIBS)
 
+drawtext.spec.c: drawtext.spec drawtext.o $(WINEBUILD)
+	$(LDPATH) $(WINEBUILD) @DLLFLAGS@ -L $(DLLDIR) -sym drawtext.o -o drawtext.spec.c -spec drawtext.spec
+drawtext.so: drawtext.o drawtext.spec.o
+	$(LDSHARED) $(LDDLLFLAGS) -o drawtext.so $+ $(ALL_LIBS)
+
+$(PROGRAMS):
 $(PROGRAMS):
 	$(LN_S) $(TOPOBJDIR)/wine $@
 
--- /dev/null	Fri Mar 23 20:37:44 2001
+++ wine/libtest/drawtext.spec	Thu Jan 17 10:58:16 2002
@@ -0,0 +1,8 @@
+name	drawtext
+mode	guiexe
+type	win32
+
+import	user32.dll
+import	gdi32.dll
+import	kernel32.dll
+import	ntdll.dll

--- /dev/null	Fri Mar 23 20:37:44 2001
+++ wine/libtest/drawtext.c	Thu Jan 17 11:48:43 2002
@@ -0,0 +1,282 @@
+/*------------------------------------------------------------
+   drawtext.c -- Test the DrawText functions - Based on
+   HELLOWIN.C -- Displays "Hello, Windows 95!" in client area
+                 (c) Charles Petzold, 1996
+
+drawtext is a program that exercises the capabilities of the DrawText and
+DrawTextEx functions in order to provide information for and testing of the
+Wine product.
+
+Calling:
+drawtext ?
+or
+drawtext [<page setting>[<Tab setting>[<Left Margin>[<Right Margin>]]] "Text"
+
+To be done:
+1. Add the flags e.g. reset_text to the arguments
+2. Improve the text modification reporting especially to see what happens
+   after the \0 inserted during word ellipsification.
+
+  ------------------------------------------------------------*/
+
+#include <windows.h>
+#include <stdio.h>
+
+#define countof(a) (sizeof(a)/sizeof(a[0]))
+
+LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;
+
+static int page_settings = 0;
+static int tab_setting = 8;
+static int left_margin = 0;
+static int right_margin = 0;
+static int helpmode;
+static int reset_rect = 1; // If DT_CALCRECT then reset the rectangle before
+                           // doing the display
+static int reset_text = 1;
+static int widen_chars = 0; // Set to widen each character
+static char argText[512];
+static char *pText;
+static int modify_noted [32];
+static int modify_noted_c [32];
+static FILE *log = NULL;
+
+
+/* Read the next integer from **p and update **p past it and any trailing space
+ */
+int NextInt (const char **p, int def_val)
+{
+    while (**p && isspace(**p)) (*p)++;
+
+    if (**p && isdigit (**p))
+    {
+        def_val = atoi (*p);
+        while (**p && isdigit (**p)) (*p)++;
+        while (**p && isspace(**p)) (*p)++;
+    }
+    return def_val;
+}
+
+int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
+                    PSTR szCmdLine, int iCmdShow)
+{
+    static char szAppName[] = "drawtext 1.0" ;
+    HWND        hwnd ;
+    MSG         msg ;
+    WNDCLASSEX  wndclass ;
+
+    {
+        int i;
+        for (i=32; i--;) {modify_noted[i] = 0; modify_noted_c[i] = 0;}
+    }
+
+    log = fopen ("drawtext.log","w");
+    if (!log) exit(1);
+
+    if (! (helpmode = (szCmdLine[0] == '?')))
+    {
+        const char *pCmd = szCmdLine;
+
+        page_settings = NextInt (&pCmd, 0);
+        tab_setting = NextInt (&pCmd, 8);
+        left_margin = NextInt (&pCmd, 0);
+        right_margin = NextInt (&pCmd, 0);
+
+        pCmd= strchr (pCmd, '\"');
+        if (pCmd)
+        {
+            char *paText = argText;
+
+            pCmd++;
+            while (*pCmd && *pCmd != '\"')
+            {
+                if (paText - argText >= countof (argText) -1) exit (2);
+                if (*pCmd == '\\')
+                {
+                    pCmd++;
+                    *paText = (*pCmd == 'n') ? '\n' :
+                              (*pCmd == 'r') ? '\r' :
+                              (*pCmd == 't') ? '\t' :
+                              (*pCmd == '\"') ? '\"' :
+                              (*pCmd == '\'') ? '\'' :
+                              (*pCmd == '\\') ? '\\' :
+                              *pCmd;
+                    pCmd++; paText++;
+                }
+                else
+                    *paText++ = *pCmd++;
+            }
+            *paText = '\0';
+            pText = argText;
+        }
+        else
+        {
+            pText = NULL;
+        }
+    }
+
+    wndclass.cbSize        = sizeof (wndclass) ;
+    wndclass.style         = CS_HREDRAW | CS_VREDRAW ;
+    wndclass.lpfnWndProc   = WndProc ;
+    wndclass.cbClsExtra    = 0 ;
+    wndclass.cbWndExtra    = 0 ;
+    wndclass.hInstance     = hInstance ;
+    wndclass.hIcon         = LoadIcon (NULL, IDI_APPLICATION) ;
+    wndclass.hCursor       = LoadCursor (NULL, IDC_ARROW) ;
+    wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ;
+    wndclass.lpszMenuName  = NULL ;
+    wndclass.lpszClassName = szAppName ;
+    wndclass.hIconSm       = LoadIcon (NULL, IDI_APPLICATION) ;
+
+    RegisterClassEx (&wndclass) ;
+
+    hwnd = CreateWindow (szAppName,         // window class name
+                    "The drawtext Program V1.0",     // window caption
+                    WS_OVERLAPPEDWINDOW,     // window style
+                    CW_USEDEFAULT,           // initial x position
+                    CW_USEDEFAULT,           // initial y position
+                    CW_USEDEFAULT,           // initial x size
+                    CW_USEDEFAULT,           // initial y size
+                    NULL,                    // parent window handle
+                    NULL,                    // window menu handle
+                    hInstance,               // program instance handle
+                    NULL) ;                     // creation parameters
+
+    ShowWindow (hwnd, iCmdShow) ;
+    UpdateWindow (hwnd) ;
+
+    while (GetMessage (&msg, NULL, 0, 0))
+    {
+        TranslateMessage (&msg) ;
+        DispatchMessage (&msg) ;
+    }
+    return msg.wParam ;
+}
+
+LRESULT CALLBACK WndProc (HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
+{
+     HDC         hdc ;
+     PAINTSTRUCT ps ;
+     RECT        rect ;
+     static CHAR str1 [] = "Hello To Everyone\n OutThere, Wine!";
+     int row, column, settings;
+     static char helptext [] = 
+"drawtext [n [t [l [r]]]] [\"text\"]\n"
+"will call DrawTextEx with the 32 patterns of DT_EDITCONTROL, DT_WORDBREAK,"
+" DT_NOCLIP, DT_WORD_ELLIPSIS and DT_END_ELLIPSIS combined with the settings"
+" defined by n.  For example set n to 32 for DT_SINGLELINE, 1 for DT_CENTER"
+" etc. \n"
+"t, l and r are respectively the tab setting, left and right margins,\n"
+"You may add your own text within double quotes, using \\n, \\r, \\t, \\\","
+" \\' and \\\\ for newline, tab etc.\n"
+"Depending on the state of the Wine argument processing you may need to escape"
+" the first and last \" and accept that you will get a trailing \" displayed.\n"
+"If the settings include DT_CALCRECT then the dimensions will be displayed"
+" in a column to the right and the text will then be displayed without the"
+" DT_CALCRECT.\n"
+"Certain log messages may be written to drawtext.log, especially if"
+" DT_MODIFYSTRING is specified."
+;
+     DRAWTEXTPARAMS dtp;
+     char TmpText [countof(argText)]; /* in case DT_MODIFYSTRING is used */
+
+     switch (iMsg)
+          {
+          case WM_PAINT :
+               hdc = BeginPaint (hwnd, &ps) ;
+
+               if (helpmode)
+               {
+                   GetClientRect (hwnd, &rect);
+                   DrawText (hdc, helptext, -1, &rect,
+                             DT_EDITCONTROL | DT_WORDBREAK);
+               }
+               else
+               {
+
+               TextOut (hdc, 0, 0, "drawtext ? for help", 19);
+               TextOut (hdc, 400, 0, "DT_EDITCONTROL", 14);
+               TextOut (hdc, 200, 15, "DT_WORDBREAK", 12);
+               TextOut (hdc, 500, 15, "DT_WORDBREAK", 12);
+               TextOut (hdc, 0,  40, "------",6);
+               TextOut (hdc, 0, 104, "----ee",6);
+               TextOut (hdc, 0, 168, "--we--",6);
+               TextOut (hdc, 0, 232, "--weee",6);
+               TextOut (hdc, 0, 316, "nc----",6);
+               TextOut (hdc, 0, 360, "nc--ee",6);
+               TextOut (hdc, 0, 424, "ncwe--",6);
+               TextOut (hdc, 0, 488, "ncweee",6);
+
+               if (widen_chars) SetTextCharacterExtra (hdc, 5);
+               SetBkColor (hdc, RGB (0,0,255));
+               SetTextColor (hdc, RGB (255,255,255));
+               dtp.cbSize = sizeof (dtp);
+               dtp.iTabLength = tab_setting;
+               dtp.iLeftMargin = left_margin;
+               dtp.iRightMargin = right_margin;
+               for (settings = 0; settings < 32; settings++)
+               {
+                   row = settings % 8; column = settings / 8;
+
+                   SetRect (&rect,  50 + 150*column, 40 + 64 * row,
+                                   150 + 150*column, 72 + 64 * row); 
+
+                   strcpy (TmpText, pText ? pText : str1);
+                   DrawTextEx (hdc, TmpText, -1, &rect,
+                               (column / 2 ? DT_EDITCONTROL : 0) |
+                               (column % 2 ? DT_WORDBREAK : 0) |
+                               (row / 4 ? DT_NOCLIP : 0) |
+                               ((row / 2) % 2 ? DT_WORD_ELLIPSIS : 0) |
+                               (row % 2 ? DT_END_ELLIPSIS : 0) |
+                               page_settings,
+                               &dtp); 
+                   if (!modify_noted[settings] &&
+                       strcmp (TmpText, pText ? pText : str1) != 0)
+                   {
+                       const char *pWhen;
+                       modify_noted[settings] = 1;
+                       if (page_settings & DT_CALCRECT)
+                           pWhen = "during calcrect";
+                       else
+                           pWhen = "during display";
+                       fprintf (log, "Modified %s on setting %d to %s\n",
+                                pWhen, settings, TmpText);
+                   }
+                   if (page_settings & DT_CALCRECT)
+                   {
+                       char buf[12];
+                       sprintf (buf, "%4.dx%4.d", rect.right - rect.left, rect.bottom - rect.top);
+                       TextOut (hdc, 600, 40+64*row+16*column, buf, strlen(buf));
+                       if (reset_rect)
+                           SetRect (&rect,  50 + 150*column, 40 + 64 * row,
+                                           150 + 150*column, 72 + 64 * row); 
+                       if (reset_text) strcpy (TmpText, pText ? pText : str1);
+                       DrawTextEx (hdc, TmpText, -1, &rect, (
+                                   (column / 2 ? DT_EDITCONTROL : 0) |
+                                   (column % 2 ? DT_WORDBREAK : 0) |
+                                   (row / 4 ? DT_NOCLIP : 0) |
+                                   ((row / 2) % 2 ? DT_WORD_ELLIPSIS : 0) |
+                                   (row % 2 ? DT_END_ELLIPSIS : 0) |
+                                   page_settings) & ~DT_CALCRECT,
+                                   &dtp); 
+                       if (!modify_noted_c[settings] &&
+                           strcmp (TmpText, pText ? pText : str1) != 0)
+                       {
+                           modify_noted_c[settings] = 1;
+                           fprintf (log, "Modified during display on setting %d to %s\n",
+                                    settings, TmpText);
+                       }
+                   }
+               }
+               }
+
+               EndPaint (hwnd, &ps) ;
+               return 0 ;
+
+          case WM_DESTROY :
+               PostQuitMessage (0) ;
+               return 0 ;
+          }
+
+     return DefWindowProc (hwnd, iMsg, wParam, lParam) ;
+}

[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux