changeset 1686:35c5314083a7

Initial verison of self-drawn static text control on OS/2. This works around Unicode issues with the system control. May need work to fill in the background color when set.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Mon, 30 Apr 2012 16:22:03 +0000
parents 96fcc01693cf
children 831aa3a679e6
files os2/dw.c
diffstat 1 files changed, 28 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/os2/dw.c	Mon Apr 30 12:22:37 2012 +0000
+++ b/os2/dw.c	Mon Apr 30 16:22:03 2012 +0000
@@ -2034,7 +2034,34 @@
    {
       PFNWP myfunc = blah->oldproc;
 
-      return myfunc(hWnd, msg, mp1, mp2);
+	  switch(msg)
+	  {
+	  case WM_PAINT:
+		  {
+			  HPS hpsPaint;
+			  RECTL rclPaint;
+			  int len = WinQueryWindowTextLength(hWnd);
+			  ULONG style = WinQueryWindowULong(hWnd, QWL_STYLE) & (DT_TOP|DT_VCENTER|DT_BOTTOM|DT_LEFT|DT_CENTER|DT_RIGHT|DT_WORDBREAK);
+			  char *tempbuf = alloca(len + 2);
+			  ULONG fcolor = DT_TEXTATTRS, bcolor = DT_TEXTATTRS;
+
+			  WinQueryWindowText(hWnd, len + 1, (PSZ)tempbuf);
+
+			  hpsPaint = WinBeginPaint(hWnd, 0, 0);
+			  WinQueryWindowRect(hWnd, &rclPaint);
+			  if(WinQueryPresParam(hWnd, PP_BACKGROUNDCOLOR, 0, NULL, sizeof(bcolor), &bcolor, QPF_NOINHERIT) ||
+                 WinQueryPresParam(hWnd, PP_BACKGROUNDCOLORINDEX, 0, NULL, sizeof(bcolor), &bcolor, QPF_NOINHERIT))
+				  GpiSetBackColor(hpsPaint, bcolor);
+			  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, tempbuf, &rclPaint, DT_TEXTATTRS, DT_TEXTATTRS, style | DT_TEXTATTRS | DT_ERASERECT);
+			  WinEndPaint(hpsPaint);
+			  return (MRESULT)TRUE;
+		  }
+	  default:
+		  return myfunc(hWnd, msg, mp1, mp2);
+	  }
    }
 
    return WinDefWindowProc(hWnd, msg, mp1, mp2);