Mercurial > dwindows
comparison os2/dw.c @ 1691:0bf394615372
Fixed bubble help/tooltips with UTF-8 encoded characters on OS/2.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Mon, 30 Apr 2012 22:11:33 +0000 |
parents | 0f4bbb78f149 |
children | 6e26c9ead2fe |
comparison
equal
deleted
inserted
replaced
1690:0f4bbb78f149 | 1691:0bf394615372 |
---|---|
1494 ptl2.y = rclPaint.yTop - 1; | 1494 ptl2.y = rclPaint.yTop - 1; |
1495 GpiMove(hpsPaint, &ptl1); | 1495 GpiMove(hpsPaint, &ptl1); |
1496 GpiLine(hpsPaint, &ptl2); | 1496 GpiLine(hpsPaint, &ptl2); |
1497 } | 1497 } |
1498 | 1498 |
1499 void _drawtext(HWND hWnd, HPS hpsPaint) | |
1500 { | |
1501 RECTL rclPaint; | |
1502 int len = WinQueryWindowTextLength(hWnd); | |
1503 ULONG style = WinQueryWindowULong(hWnd, QWL_STYLE) & (DT_TOP|DT_VCENTER|DT_BOTTOM|DT_LEFT|DT_CENTER|DT_RIGHT|DT_WORDBREAK); | |
1504 char *tempbuf = alloca(len + 2); | |
1505 ULONG fcolor = DT_TEXTATTRS, bcolor = DT_TEXTATTRS; | |
1506 | |
1507 WinQueryWindowText(hWnd, len + 1, (PSZ)tempbuf); | |
1508 WinQueryWindowRect(hWnd, &rclPaint); | |
1509 | |
1510 if(WinQueryPresParam(hWnd, PP_BACKGROUNDCOLOR, 0, NULL, sizeof(bcolor), &bcolor, QPF_NOINHERIT) || | |
1511 WinQueryPresParam(hWnd, PP_BACKGROUNDCOLORINDEX, 0, NULL, sizeof(bcolor), &bcolor, QPF_NOINHERIT)) | |
1512 GpiSetBackColor(hpsPaint, bcolor); | |
1513 if(WinQueryPresParam(hWnd, PP_FOREGROUNDCOLOR, 0, NULL, sizeof(fcolor), &fcolor, QPF_NOINHERIT) || | |
1514 WinQueryPresParam(hWnd, PP_FOREGROUNDCOLORINDEX, 0, NULL, sizeof(fcolor), &fcolor, QPF_NOINHERIT)) | |
1515 GpiSetColor(hpsPaint, fcolor); | |
1516 WinDrawText(hpsPaint, -1, tempbuf, &rclPaint, DT_TEXTATTRS, DT_TEXTATTRS, style | DT_TEXTATTRS | DT_ERASERECT); | |
1517 } | |
1499 | 1518 |
1500 /* Function: BubbleProc | 1519 /* Function: BubbleProc |
1501 * Abstract: Subclass procedure for bubble help | 1520 * Abstract: Subclass procedure for bubble help |
1502 */ | 1521 */ |
1503 MRESULT EXPENTRY _BubbleProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) | 1522 MRESULT EXPENTRY _BubbleProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) |
1504 { | 1523 { |
1505 MRESULT res; | |
1506 PFNWP proc = (PFNWP)WinQueryWindowPtr(hwnd, QWL_USER); | 1524 PFNWP proc = (PFNWP)WinQueryWindowPtr(hwnd, QWL_USER); |
1507 | |
1508 if(proc) | |
1509 res = proc(hwnd, msg, mp1, mp2); | |
1510 else | |
1511 res = WinDefWindowProc(hwnd, msg, mp1, mp2); | |
1512 | 1525 |
1513 if(msg == WM_PAINT) | 1526 if(msg == WM_PAINT) |
1514 { | 1527 { |
1515 POINTL ptl; | 1528 POINTL ptl; |
1516 HPS hpsTemp; | 1529 HPS hpsTemp; |
1520 WinQueryWindowRect(hwnd, &rcl); | 1533 WinQueryWindowRect(hwnd, &rcl); |
1521 height = rcl.yTop - rcl.yBottom - 1; | 1534 height = rcl.yTop - rcl.yBottom - 1; |
1522 width = rcl.xRight - rcl.xLeft - 1; | 1535 width = rcl.xRight - rcl.xLeft - 1; |
1523 | 1536 |
1524 /* Draw a border around the bubble help */ | 1537 /* Draw a border around the bubble help */ |
1525 hpsTemp = WinGetPS(hwnd); | 1538 hpsTemp = WinBeginPaint(hwnd, 0, 0); |
1539 | |
1540 _drawtext(hwnd, hpsTemp); | |
1526 GpiSetColor(hpsTemp, CLR_BLACK); | 1541 GpiSetColor(hpsTemp, CLR_BLACK); |
1527 ptl.x = ptl.y = 0; | 1542 ptl.x = ptl.y = 0; |
1528 GpiMove(hpsTemp, &ptl); | 1543 GpiMove(hpsTemp, &ptl); |
1529 ptl.x = 0; | 1544 ptl.x = 0; |
1530 ptl.y = height; | 1545 ptl.y = height; |
1544 ptl.y = height; | 1559 ptl.y = height; |
1545 GpiMove(hpsTemp, &ptl); | 1560 GpiMove(hpsTemp, &ptl); |
1546 ptl.y = 0; | 1561 ptl.y = 0; |
1547 ptl.x = width; | 1562 ptl.x = width; |
1548 GpiLine(hpsTemp, &ptl); | 1563 GpiLine(hpsTemp, &ptl); |
1549 WinReleasePS(hpsTemp); | 1564 WinEndPaint(hpsTemp); |
1550 } | 1565 return (MRESULT)TRUE; |
1551 return res; | 1566 } |
1567 if(proc) | |
1568 return proc(hwnd, msg, mp1, mp2); | |
1569 return WinDefWindowProc(hwnd, msg, mp1, mp2); | |
1552 } | 1570 } |
1553 | 1571 |
1554 /* Function to handle tooltip messages from a variety of procedures */ | 1572 /* Function to handle tooltip messages from a variety of procedures */ |
1555 MRESULT EXPENTRY _TooltipProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2, WindowData *blah) | 1573 MRESULT EXPENTRY _TooltipProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2, WindowData *blah) |
1556 { | 1574 { |
2036 | 2054 |
2037 switch(msg) | 2055 switch(msg) |
2038 { | 2056 { |
2039 case WM_PAINT: | 2057 case WM_PAINT: |
2040 { | 2058 { |
2041 HPS hpsPaint; | 2059 HPS hpsPaint = WinBeginPaint(hWnd, 0, 0); |
2042 RECTL rclPaint; | 2060 |
2043 int len = WinQueryWindowTextLength(hWnd); | 2061 _drawtext(hWnd, hpsPaint); |
2044 ULONG style = WinQueryWindowULong(hWnd, QWL_STYLE) & (DT_TOP|DT_VCENTER|DT_BOTTOM|DT_LEFT|DT_CENTER|DT_RIGHT|DT_WORDBREAK); | |
2045 char *tempbuf = alloca(len + 2); | |
2046 ULONG fcolor = DT_TEXTATTRS, bcolor = DT_TEXTATTRS; | |
2047 | |
2048 WinQueryWindowText(hWnd, len + 1, (PSZ)tempbuf); | |
2049 WinQueryWindowRect(hWnd, &rclPaint); | |
2050 | |
2051 hpsPaint = WinBeginPaint(hWnd, 0, 0); | |
2052 if(WinQueryPresParam(hWnd, PP_BACKGROUNDCOLOR, 0, NULL, sizeof(bcolor), &bcolor, QPF_NOINHERIT) || | |
2053 WinQueryPresParam(hWnd, PP_BACKGROUNDCOLORINDEX, 0, NULL, sizeof(bcolor), &bcolor, QPF_NOINHERIT)) | |
2054 GpiSetBackColor(hpsPaint, bcolor); | |
2055 if(WinQueryPresParam(hWnd, PP_FOREGROUNDCOLOR, 0, NULL, sizeof(fcolor), &fcolor, QPF_NOINHERIT) || | |
2056 WinQueryPresParam(hWnd, PP_FOREGROUNDCOLORINDEX, 0, NULL, sizeof(fcolor), &fcolor, QPF_NOINHERIT)) | |
2057 GpiSetColor(hpsPaint, fcolor); | |
2058 WinDrawText(hpsPaint, -1, tempbuf, &rclPaint, DT_TEXTATTRS, DT_TEXTATTRS, style | DT_TEXTATTRS | DT_ERASERECT); | |
2059 WinEndPaint(hpsPaint); | 2062 WinEndPaint(hpsPaint); |
2060 return (MRESULT)TRUE; | 2063 return (MRESULT)TRUE; |
2061 } | 2064 } |
2062 default: | 2065 default: |
2063 return myfunc(hWnd, msg, mp1, mp2); | 2066 return myfunc(hWnd, msg, mp1, mp2); |