DrawText upgrade - step 1

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

 




Bill Medland (medbi01@accpac.com)
First stage of DrawText upgrade.
1. Rearrange code into three distinct areas; DrawText, GrayString, TabbedText
2. Remove unused macros
3. Modify treatment of Tab arguments to fit with observed behaviour.
   e.g. DrawTextEx with DT_TABSTOP but null dtp will not take the setting
   from the flags.  Also only uses bits 15 to 8, not the higher bits.

Index: wine/dlls/user/text.c
===================================================================
RCS file: /home/wine/wine/dlls/user/text.c,v
retrieving revision 1.17
diff -u -r1.17 text.c
--- wine/dlls/user/text.c	2002/01/07 21:16:47	1.17
+++ wine/dlls/user/text.c	2002/01/15 17:10:32
@@ -3,6 +3,10 @@
  *
  * Copyright 1993, 1994 Alexandre Julliard
  *
+ * Contains 
+ *   1.  DrawText functions
+ *   2.  GrayString functions
+ *   3.  TabbedText functions
  */
 
 #include <string.h>
@@ -19,6 +23,11 @@
 
 DEFAULT_DEBUG_CHANNEL(text);
 
+/*********************************************************************
+ *
+ *            DrawText functions
+ */
+
 #define TAB     9
 #define LF     10
 #define CR     13
@@ -34,31 +43,12 @@
 static const WCHAR ELLIPSISW[] = {'.','.','.', 0};
 static const WCHAR FORWARD_SLASHW[] = {'/', 0};
 static const WCHAR BACK_SLASHW[] = {'\\', 0};
-
-#define SWAP_INT(a,b)  { int t = a; a = b; b = t; }
 
-static int tabstop = 8;
+static int tabstop;
 static int tabwidth;
 static int spacewidth;
 static int prefix_offset;
 
-/* ### start build ### */
-extern WORD CALLBACK TEXT_CallTo16_word_wlw(GRAYSTRINGPROC16,WORD,LONG,WORD);
-/* ### stop build ### */
-
-struct gray_string_info
-{
-    GRAYSTRINGPROC16 proc;
-    LPARAM           param;
-};
-
-/* callback for 16-bit gray string proc */
-static BOOL CALLBACK gray_string_callback( HDC hdc, LPARAM param, INT len )
-{
-    const struct gray_string_info *info = (struct gray_string_info *)param;
-    return TEXT_CallTo16_word_wlw( info->proc, hdc, info->param, len );
-}
-
 
 /*********************************************************************
  *  Return next line of text from a string.
@@ -221,25 +211,6 @@
 
 
 /***********************************************************************
- *           DrawText    (USER.85)
- */
-INT16 WINAPI DrawText16( HDC16 hdc, LPCSTR str, INT16 count, LPRECT16 rect, UINT16 flags )
-{
-    INT16 ret;
-
-    if (rect)
-    {
-        RECT rect32;
-        CONV_RECT16TO32( rect, &rect32 );
-        ret = DrawTextA( hdc, str, count, &rect32, flags );
-        CONV_RECT32TO16( &rect32, rect );
-    }
-    else ret = DrawTextA( hdc, str, count, NULL, flags);
-    return ret;
-}
-
-
-/***********************************************************************
  *           DrawTextExW    (USER32.@)
  */
 #define MAX_STATIC_BUFFER 1024
@@ -284,8 +255,7 @@
         dtp->uiLengthDrawn = 0;     /* This param RECEIVES number of chars processed */
     }
 
-    if (flags & DT_TABSTOP)
-	tabstop = dtp ? dtp->iTabLength : flags >> 8;
+    tabstop = ((flags & DT_TABSTOP) && dtp) ? dtp->iTabLength : 8;
 
     if (flags & DT_EXPANDTABS)
     {
@@ -482,18 +452,75 @@
  */
 INT WINAPI DrawTextW( HDC hdc, LPCWSTR str, INT count, LPRECT rect, UINT flags )
 {
-    return DrawTextExW(hdc, (LPWSTR)str, count, rect, flags, NULL);
+    DRAWTEXTPARAMS dtp;
+
+    memset (&dtp, 0, sizeof(dtp));
+    if (flags & DT_TABSTOP)
+    {
+        dtp.iTabLength = (flags >> 8) && 0xff;
+        flags &= 0xffff00ff;
+    }
+    return DrawTextExW(hdc, (LPWSTR)str, count, rect, flags, &dtp);
 }
 
 /***********************************************************************
  *           DrawTextA    (USER32.@)
  */
 INT WINAPI DrawTextA( HDC hdc, LPCSTR str, INT count, LPRECT rect, UINT flags )
+{
+    DRAWTEXTPARAMS dtp;
+
+    memset (&dtp, 0, sizeof(dtp));
+    if (flags & DT_TABSTOP)
+    {
+        dtp.iTabLength = (flags >> 8) && 0xff;
+        flags &= 0xffff00ff;
+    }
+    return DrawTextExA( hdc, (LPSTR)str, count, rect, flags, &dtp );
+}
+
+/***********************************************************************
+ *           DrawText    (USER.85)
+ */
+INT16 WINAPI DrawText16( HDC16 hdc, LPCSTR str, INT16 count, LPRECT16 rect, UINT16 flags )
 {
-    return DrawTextExA( hdc, (LPSTR)str, count, rect, flags, NULL );
+    INT16 ret;
+
+    if (rect)
+    {
+        RECT rect32;
+        CONV_RECT16TO32( rect, &rect32 );
+        ret = DrawTextA( hdc, str, count, &rect32, flags );
+        CONV_RECT32TO16( &rect32, rect );
+    }
+    else ret = DrawTextA( hdc, str, count, NULL, flags);
+    return ret;
 }
 
+
 /***********************************************************************
+ *
+ *           GrayString functions
+ */
+
+/* ### start build ### */
+extern WORD CALLBACK TEXT_CallTo16_word_wlw(GRAYSTRINGPROC16,WORD,LONG,WORD);
+/* ### stop build ### */
+
+struct gray_string_info
+{
+    GRAYSTRINGPROC16 proc;
+    LPARAM           param;
+};
+
+/* callback for 16-bit gray string proc */
+static BOOL CALLBACK gray_string_callback( HDC hdc, LPARAM param, INT len )
+{
+    const struct gray_string_info *info = (struct gray_string_info *)param;
+    return TEXT_CallTo16_word_wlw( info->proc, hdc, info->param, len );
+}
+
+/***********************************************************************
  *           TEXT_GrayString
  *
  * FIXME: The call to 16-bit code only works because the wine GDI is a 16-bit
@@ -636,6 +663,11 @@
     return TEXT_GrayString(hdc, hbr, gsprc, lParam, cch, x, y, cx, cy,
                            TRUE, TRUE);
 }
+
+/***********************************************************************
+ *
+ *           TabbedText functions
+ */
 
 /***********************************************************************
  *           TEXT_TabbedTextOut

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

  Powered by Linux