# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1335823893 0 # Node ID 0bf3946153721cce98aacaecd998f4d60e78db06 # Parent 0f4bbb78f149b75921c8292a5528e64a4fc8002a Fixed bubble help/tooltips with UTF-8 encoded characters on OS/2. diff -r 0f4bbb78f149 -r 0bf394615372 os2/dw.c --- a/os2/dw.c Mon Apr 30 17:16:19 2012 +0000 +++ b/os2/dw.c Mon Apr 30 22:11:33 2012 +0000 @@ -1496,20 +1496,33 @@ GpiLine(hpsPaint, &ptl2); } +void _drawtext(HWND hWnd, 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); + 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); +} /* Function: BubbleProc * Abstract: Subclass procedure for bubble help */ MRESULT EXPENTRY _BubbleProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { - MRESULT res; PFNWP proc = (PFNWP)WinQueryWindowPtr(hwnd, QWL_USER); - if(proc) - res = proc(hwnd, msg, mp1, mp2); - else - res = WinDefWindowProc(hwnd, msg, mp1, mp2); - if(msg == WM_PAINT) { POINTL ptl; @@ -1522,7 +1535,9 @@ width = rcl.xRight - rcl.xLeft - 1; /* Draw a border around the bubble help */ - hpsTemp = WinGetPS(hwnd); + hpsTemp = WinBeginPaint(hwnd, 0, 0); + + _drawtext(hwnd, hpsTemp); GpiSetColor(hpsTemp, CLR_BLACK); ptl.x = ptl.y = 0; GpiMove(hpsTemp, &ptl); @@ -1546,9 +1561,12 @@ ptl.y = 0; ptl.x = width; GpiLine(hpsTemp, &ptl); - WinReleasePS(hpsTemp); - } - return res; + WinEndPaint(hpsTemp); + return (MRESULT)TRUE; + } + if(proc) + return proc(hwnd, msg, mp1, mp2); + return WinDefWindowProc(hwnd, msg, mp1, mp2); } /* Function to handle tooltip messages from a variety of procedures */ @@ -2038,24 +2056,9 @@ { 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); - WinQueryWindowRect(hWnd, &rclPaint); - - hpsPaint = WinBeginPaint(hWnd, 0, 0); - 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); + HPS hpsPaint = WinBeginPaint(hWnd, 0, 0); + + _drawtext(hWnd, hpsPaint); WinEndPaint(hpsPaint); return (MRESULT)TRUE; }