changeset 1789:a640714f9087

Fix handling the DW_DT_WORDBREAK flag on OS/2 to cause static text to word wrap.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sat, 04 Aug 2012 01:14:17 +0000
parents 9d499b162fe1
children 209c57a14b09
files os2/dw.c
diffstat 1 files changed, 23 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/os2/dw.c	Sat Aug 04 00:05:47 2012 +0000
+++ b/os2/dw.c	Sat Aug 04 01:14:17 2012 +0000
@@ -1616,7 +1616,27 @@
     if(WinQueryPresParam(hWnd, PP_FOREGROUNDCOLOR, 0, NULL, sizeof(fcolor), &fcolor, QPF_NOINHERIT) ||
        WinQueryPresParam(hWnd, PP_FOREGROUNDCOLORINDEX, 0, NULL, sizeof(fcolor), &fcolor, QPF_NOINHERIT))
         GpiSetColor(hpsPaint, fcolor);
-    WinDrawText(hpsPaint, -1, (PCH)tempbuf, &rclPaint, DT_TEXTATTRS, DT_TEXTATTRS, style | DT_TEXTATTRS | DT_ERASERECT);
+    if(style & DT_WORDBREAK)
+    {
+        int thisheight;
+        LONG drawn, totaldrawn = 0;
+
+        dw_font_text_extents_get(hWnd, NULL, tempbuf, NULL, &thisheight);
+
+        /* until all chars drawn */
+        for(; totaldrawn !=  len; rclPaint.yTop -= thisheight)
+        {
+            /* draw the text */
+            drawn = WinDrawText(hpsPaint, len -  totaldrawn, (PCH)tempbuf +  totaldrawn,
+                                &rclPaint, DT_TEXTATTRS, DT_TEXTATTRS, style | DT_TEXTATTRS | DT_ERASERECT);
+            if(drawn)
+                totaldrawn += drawn;
+            else
+                break;
+        }
+    }
+    else
+        WinDrawText(hpsPaint, -1, (PCH)tempbuf, &rclPaint, DT_TEXTATTRS, DT_TEXTATTRS, style | DT_TEXTATTRS | DT_ERASERECT);
 }
 
 /* Function: BubbleProc
@@ -6492,6 +6512,7 @@
 {
 
    WindowData *blah = calloc(1, sizeof(WindowData));
+   ENTRYFDATA efd = { sizeof(ENTRYFDATA), 32000, 0, 0 };
    HWND tmp = WinCreateWindow(HWND_OBJECT,
                         WC_ENTRYFIELD,
                         (PSZ)text,
@@ -6501,7 +6522,7 @@
                         NULLHANDLE,
                         HWND_TOP,
                         id,
-                        NULL,
+                        (PVOID)&efd,
                         NULL);
    blah->oldproc = WinSubclassWindow(tmp, _entryproc);
    WinSetWindowPtr(tmp, QWP_USER, blah);