comparison os2/dw.c @ 1395:e0a66f06501c

Updated the tooltip bubble help on OS/2 to display the tooltip after 2 seconds... Then remove it after 15 seconds of visibility. The old method was okay for bitmap buttons... but this new method is more consistent with other platforms and good for other types of controls tooltips. Also trim trailing newline when using PMPrintf to prevent double spacing.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sun, 27 Nov 2011 10:02:38 +0000
parents a151d45a7041
children 2ccf7eacedf5
comparison
equal deleted inserted replaced
1394:a151d45a7041 1395:e0a66f06501c
1669 } 1669 }
1670 1670
1671 /* Function to handle tooltip messages from a variety of procedures */ 1671 /* Function to handle tooltip messages from a variety of procedures */
1672 MRESULT EXPENTRY _TooltipProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2, WindowData *blah) 1672 MRESULT EXPENTRY _TooltipProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2, WindowData *blah)
1673 { 1673 {
1674 switch(msg) 1674 static HWND hstart, hend;
1675 { 1675
1676 case 0x041f: 1676 switch(msg)
1677 if (hwndBubble) 1677 {
1678 { 1678 case 0x041f:
1679 WinDestroyWindow(hwndBubble); 1679 /* Mouse has left the area.. remove tooltip and stop timer */
1680 hwndBubble = 0; 1680 if(hwndBubble)
1681 } 1681 {
1682 break; 1682 WinDestroyWindow(hwndBubble);
1683 1683 hwndBubble = 0;
1684 case 0x041e: 1684 }
1685 1685 if(hstart)
1686 if(!*blah->bubbletext) 1686 WinStopTimer(dwhab, hstart, 1);
1687 break; 1687 if(hend)
1688 1688 WinStopTimer(dwhab, hend, 2);
1689 if(hwndBubble) 1689 hstart = hend = 0;
1690 { 1690 break;
1691 WinDestroyWindow(hwndBubble); 1691
1692 hwndBubble = 0; 1692 case 0x041e:
1693 } 1693 /* Mouse has entered... stop any pending timer...
1694 1694 * then start a new timer to creat the tooltip delayed.
1695 if(!hwndBubble) 1695 */
1696 { 1696 if(hstart)
1697 HPS hpsTemp = 0; 1697 WinStopTimer(dwhab, hstart, 1);
1698 LONG lHight; 1698 /* Two seconds to create */
1699 LONG lWidth; 1699 WinStartTimer(dwhab, hwnd, 1, 2000);
1700 POINTL txtPointl[TXTBOX_COUNT]; 1700 hstart = hwnd;
1701 POINTL ptlWork = {0,0}; 1701 break;
1702 ULONG ulColor = CLR_YELLOW; 1702 case WM_TIMER:
1703 void *bubbleproc; 1703 if((int)mp1 == 1 || (int)mp1 == 2)
1704 1704 {
1705 hwndBubbleLast = hwnd; 1705 if(hwndBubble)
1706 hwndBubble = WinCreateWindow(HWND_DESKTOP, 1706 {
1707 WC_STATIC, 1707 WinDestroyWindow(hwndBubble);
1708 NULL, 1708 hwndBubble = 0;
1709 SS_TEXT | 1709 }
1710 DT_CENTER | 1710 /* Either starting or ending... remove tooltip and timers */
1711 DT_VCENTER, 1711 if(hstart)
1712 0,0,0,0, 1712 WinStopTimer(dwhab, hstart, 1);
1713 HWND_DESKTOP, 1713 if(hend)
1714 HWND_TOP, 1714 WinStopTimer(dwhab, hend, 2);
1715 0, 1715 hstart = hend = 0;
1716 NULL, 1716 /* If we are starting... create a new tooltip */
1717 NULL); 1717 if((int)mp1 == 1)
1718 1718 {
1719 WinSetPresParam(hwndBubble, 1719 HPS hpsTemp = 0;
1720 PP_FONTNAMESIZE, 1720 LONG lHight;
1721 strlen(DefaultFont)+1, 1721 LONG lWidth;
1722 DefaultFont); 1722 POINTL txtPointl[TXTBOX_COUNT];
1723 1723 POINTL ptlWork = {0,0};
1724 1724 ULONG ulColor = CLR_YELLOW;
1725 WinSetPresParam(hwndBubble, 1725 void *bubbleproc;
1726 PP_BACKGROUNDCOLORINDEX, 1726
1727 sizeof(ulColor), 1727 hwndBubbleLast = hwnd;
1728 &ulColor); 1728 hwndBubble = WinCreateWindow(HWND_DESKTOP,
1729 1729 WC_STATIC,
1730 WinSetWindowText(hwndBubble, 1730 NULL,
1731 (PSZ)blah->bubbletext); 1731 SS_TEXT |
1732 1732 DT_CENTER |
1733 WinMapWindowPoints(hwnd, HWND_DESKTOP, &ptlWork, 1); 1733 DT_VCENTER,
1734 1734 0,0,0,0,
1735 hpsTemp = WinGetPS(hwndBubble); 1735 HWND_DESKTOP,
1736 GpiQueryTextBox(hpsTemp, 1736 HWND_TOP,
1737 strlen(blah->bubbletext), 1737 0,
1738 (PCH)blah->bubbletext, 1738 NULL,
1739 TXTBOX_COUNT, 1739 NULL);
1740
1741 WinSetPresParam(hwndBubble,
1742 PP_FONTNAMESIZE,
1743 strlen(DefaultFont)+1,
1744 DefaultFont);
1745
1746
1747 WinSetPresParam(hwndBubble,
1748 PP_BACKGROUNDCOLORINDEX,
1749 sizeof(ulColor),
1750 &ulColor);
1751
1752 WinSetWindowText(hwndBubble,
1753 (PSZ)blah->bubbletext);
1754
1755 WinMapWindowPoints(hwnd, HWND_DESKTOP, &ptlWork, 1);
1756
1757 hpsTemp = WinGetPS(hwndBubble);
1758 GpiQueryTextBox(hpsTemp,
1759 strlen(blah->bubbletext),
1760 (PCH)blah->bubbletext,
1761 TXTBOX_COUNT,
1740 txtPointl); 1762 txtPointl);
1741 WinReleasePS(hpsTemp); 1763 WinReleasePS(hpsTemp);
1742 1764
1743 lWidth = txtPointl[TXTBOX_TOPRIGHT].x - 1765 lWidth = txtPointl[TXTBOX_TOPRIGHT].x -
1744 txtPointl[TXTBOX_TOPLEFT ].x + 8; 1766 txtPointl[TXTBOX_TOPLEFT ].x + 8;
1745 1767
1746 lHight = txtPointl[TXTBOX_TOPLEFT].y - 1768 lHight = txtPointl[TXTBOX_TOPLEFT].y -
1747 txtPointl[TXTBOX_BOTTOMLEFT].y + 8; 1769 txtPointl[TXTBOX_BOTTOMLEFT].y + 8;
1748 1770
1749 ptlWork.y -= lHight; 1771 ptlWork.y -= lHight;
1750 1772
1751 bubbleproc = (void *)WinSubclassWindow(hwndBubble, _BubbleProc); 1773 bubbleproc = (void *)WinSubclassWindow(hwndBubble, _BubbleProc);
1752 1774
1753 if(bubbleproc) 1775 if(bubbleproc)
1754 WinSetWindowPtr(hwndBubble, QWP_USER, bubbleproc); 1776 WinSetWindowPtr(hwndBubble, QWP_USER, bubbleproc);
1755 1777
1756 WinSetWindowPos(hwndBubble, 1778 WinSetWindowPos(hwndBubble,
1757 HWND_TOP, 1779 HWND_TOP,
1758 ptlWork.x, 1780 ptlWork.x,
1759 ptlWork.y, 1781 ptlWork.y,
1760 lWidth, 1782 lWidth,
1761 lHight, 1783 lHight,
1762 SWP_SIZE | SWP_MOVE | SWP_SHOW); 1784 SWP_SIZE | SWP_MOVE | SWP_SHOW);
1763 } 1785
1764 break; 1786 /* Start a timer to remove it after 15 seconds */
1765 } 1787 WinStartTimer(dwhab, hwnd, 2, 15000);
1788 hend = hwnd;
1789 }
1790 }
1791 break;
1792 }
1766 } 1793 }
1767 1794
1768 #define CALENDAR_BORDER 3 1795 #define CALENDAR_BORDER 3
1769 #define CALENDAR_ARROW 8 1796 #define CALENDAR_ARROW 8
1770 1797
4246 va_start(args, format); 4273 va_start(args, format);
4247 vsprintf(outbuf, format, args); 4274 vsprintf(outbuf, format, args);
4248 va_end(args); 4275 va_end(args);
4249 4276
4250 if(_PmPrintfString) 4277 if(_PmPrintfString)
4278 {
4279 int len = strlen(outbuf);
4280
4281 /* Trim off trailing newline for PMPrintf */
4282 if(len > 0 && outbuf[len-1] == '\n')
4283 outbuf[len-1] = 0;
4251 _PmPrintfString(outbuf); 4284 _PmPrintfString(outbuf);
4285 }
4252 else 4286 else
4253 fprintf(stderr, "%s", outbuf); 4287 fprintf(stderr, "%s", outbuf);
4254 } 4288 }
4255 4289
4256 /* 4290 /*