Ignore:
Timestamp:
Jun 23, 2001, 11:12:49 AM (24 years ago)
Author:
umoeller
Message:

Tons of changes from the last weeks.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/helpers/cctl_tooltip.c

    r68 r81  
    8989 *
    9090 ********************************************************************/
    91 
    92 // screen size
    93 LONG        G_cxScreen = 0,
    94             G_cyScreen = 0;
    9591
    9692// linked list of all tools which were subclassed for tooltip
     
    365361    ULONG       ulTooltipID;        // from WM_CREATE
    366362
     363    LONG        cxScreen,
     364                cyScreen;
     365
    367366    BOOL        fIsActive;          // TRUE per default; changed by TTM_ACTIVATE
    368367
     
    407406 */
    408407
    409 VOID UpdateTooltipPresColors(HWND hwndTooltip,      // in: tooltip control
    410                              PTOOLTIPDATA pttd)     // in/out: tooltip data struct (QWL_USER) with color fields
    411 {
     408VOID UpdateTooltipPresColors(HWND hwndTooltip)      // in: tooltip control
     409{
     410    PTOOLTIPDATA pttd = (PTOOLTIPDATA)WinQueryWindowPtr(hwndTooltip, 1);
     411
    412412    // tooltip background color:
    413413    pttd->lBackColor = winhQueryPresColor(hwndTooltip,
     
    433433
    434434/*
    435  *@@ PaintTooltip:
    436  *      this gets called from ctl_fnwpTooltip upon WM_PAINT.
     435 *@@ TtmCreate:
     436 *      implementation for WM_CREATE in ctl_fnwpTooltip.
     437 *
     438 *@@added V0.9.13 (2001-06-21) [umoeller]
     439 */
     440
     441MRESULT TtmCreate(HWND hwndTooltip,
     442                  MPARAM mp2)
     443{
     444    PTOOLTIPDATA pttd;
     445    PCREATESTRUCT pcs = (PCREATESTRUCT)mp2;
     446
     447    // allocate and initialize tooltip data
     448    pttd = (PTOOLTIPDATA)malloc(sizeof(TOOLTIPDATA));
     449    if (pttd)
     450    {
     451        CHAR        szFont[256];
     452        memset(pttd, 0, sizeof(TOOLTIPDATA));
     453        WinSetWindowPtr(hwndTooltip, 1, pttd);
     454
     455        pttd->hwndOwner = pcs->hwndOwner;
     456        pttd->hab = WinQueryAnchorBlock(hwndTooltip);
     457        pttd->ulTooltipID = pcs->id;
     458
     459        pttd->cxScreen = WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN);
     460        pttd->cyScreen = WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN);
     461
     462        pttd->fIsActive = TRUE;
     463
     464        // default timeouts
     465        pttd->ulTimeoutInitial = 1000;
     466        pttd->ulTimeoutAutopop = 5000;
     467        pttd->ulTimeoutReshow = 500;
     468
     469        // get colors from presparams/syscolors
     470        UpdateTooltipPresColors(hwndTooltip);
     471
     472        // check if font presparam set
     473        if (WinQueryPresParam(hwndTooltip,
     474                              PP_FONTNAMESIZE, 0,
     475                              NULL,
     476                              sizeof(szFont),
     477                              szFont,
     478                              QPF_NOINHERIT)
     479                == 0)
     480        {
     481            // no: set default font presparam
     482            // (we never want the System Proportional font)
     483            winhSetWindowFont(hwndTooltip,
     484                              NULL);      // default (WarpSans or 8.Helv)
     485        }
     486
     487        pttd->pszPaintText = strdup("undefined");
     488
     489        lstInit(&pttd->llTools, TRUE);      // auto-free items
     490
     491        // override CREATESTRUCT
     492        WinSetWindowPos(hwndTooltip,
     493                        HWND_TOP,
     494                        50, 50,
     495                        100, 100,
     496                        SWP_MOVE | SWP_SIZE | SWP_ZORDER | SWP_HIDE);
     497
     498        return (MPARAM)FALSE;
     499    }
     500    else
     501        // malloc failed:
     502        return (MPARAM)TRUE;
     503}
     504
     505/*
     506 *@@ TtmTimer:
     507 *      implementation for WM_TIMER in ctl_fnwpTooltip.
     508 *
     509 *@@added V0.9.13 (2001-06-21) [umoeller]
     510 */
     511
     512BOOL TtmTimer(HWND hwndTooltip, MPARAM mp1)
     513{
     514    PTOOLTIPDATA pttd = (PTOOLTIPDATA)WinQueryWindowPtr(hwndTooltip, 1);
     515    USHORT  usTimer = SHORT1FROMMP(mp1);
     516
     517    switch (usTimer)
     518    {
     519        case TOOLTIP_ID_TIMER_INITIAL:
     520            // _Pmpf(("WM_TIMER: Stopping initial timer: %d", usTimer));
     521            // _Pmpf((__FUNCTION__ ": TOOLTIP_ID_TIMER_INITIAL"));
     522            WinStopTimer(pttd->hab,
     523                         hwndTooltip,
     524                         usTimer);
     525            pttd->idTimerInitial = 0;
     526
     527            if (pttd->fIsActive)
     528                // show tooltip
     529                WinPostMsg(hwndTooltip, TTM_SHOWTOOLTIPNOW, (MPARAM)TRUE, 0);
     530        break;
     531
     532        case TOOLTIP_ID_TIMER_AUTOPOP:
     533            // _Pmpf(("WM_TIMER: Stopping autopop timer: %d", usTimer));
     534            WinStopTimer(pttd->hab,
     535                         hwndTooltip,
     536                         usTimer);
     537            pttd->idTimerAutopop = 0;
     538            WinPostMsg(hwndTooltip, TTM_SHOWTOOLTIPNOW, (MPARAM)FALSE, 0);
     539        break;
     540
     541        default:
     542            return FALSE;
     543    } // end switch
     544
     545    return (TRUE);
     546}
     547
     548/*
     549 *@@ TtmPaint:
     550 *      implementation for WM_PAINT in ctl_fnwpTooltip.
    437551 *
    438552 *@@added V0.9.1 (99-11-30) [umoeller]
    439553 */
    440554
    441 VOID PaintTooltip(HWND hwndTooltip,
    442                   PTOOLTIPDATA pttd)
    443 {
     555VOID TtmPaint(HWND hwndTooltip)
     556{
     557    PTOOLTIPDATA pttd = (PTOOLTIPDATA)WinQueryWindowPtr(hwndTooltip, 1);
    444558    HPS         hps = WinBeginPaint(hwndTooltip, NULLHANDLE, NULL);
    445559    POINTL      ptl = {0, 0};
     
    525639
    526640/*
     641 *@@ TtmDestroy:
     642 *      implementation for WM_DESTROY in ctl_fnwpTooltip.
     643 *
     644 *@@added V0.9.13 (2001-06-21) [umoeller]
     645 */
     646
     647VOID TtmDestroy(HWND hwndTooltip)
     648{
     649    PTOOLTIPDATA pttd = (PTOOLTIPDATA)WinQueryWindowPtr(hwndTooltip, 1);
     650    // stop timers
     651    if (pttd->idTimerInitial)
     652        WinStopTimer(pttd->hab,
     653                     hwndTooltip,
     654                     pttd->idTimerInitial);
     655    if (pttd->idTimerAutopop)
     656        WinStopTimer(pttd->hab,
     657                     hwndTooltip,
     658                     pttd->idTimerAutopop);
     659    if (pttd->pszPaintText)
     660        free(pttd->pszPaintText);
     661
     662    // un-subclass all tools that we subclassed
     663    // V0.9.12 (2001-04-28) [umoeller]
     664    if (LockSubclassedTools())
     665    {
     666        PLISTNODE pNode;
     667        PSUBCLASSEDTOOL pst;
     668        for (pNode = lstQueryFirstNode(&pttd->llTools);
     669             pNode;
     670             pNode = pNode->pNext)
     671        {
     672            PTOOLINFO pti = (PTOOLINFO)pNode->pItemData;
     673            if (pst = FindSubclassedTool(pti->hwndTool))
     674                UnSubclassTool(pti->hwndTool);
     675        }
     676
     677        UnlockSubclassedTools();
     678    }
     679    // end V0.9.12 (2001-04-28) [umoeller]
     680
     681    lstClear(&pttd->llTools);
     682
     683    free(pttd);
     684}
     685
     686/*
     687 *@@ TtmAddTool:
     688 *      implementation for TTM_ADDTOOL in ctl_fnwpTooltip.
     689 *
     690 *@@added V0.9.13 (2001-06-21) [umoeller]
     691 */
     692
     693MRESULT TtmAddTool(HWND hwndTooltip, MPARAM mp2)
     694{
     695    PTOOLTIPDATA pttd = (PTOOLTIPDATA)WinQueryWindowPtr(hwndTooltip, 1);
     696    if (mp2)
     697    {
     698        PTOOLINFO ptiPassed = (PTOOLINFO)mp2,
     699                  ptiNew = (PTOOLINFO)malloc(sizeof(TOOLINFO));
     700        if (ptiNew)
     701        {
     702            memcpy(ptiNew, ptiPassed, sizeof(TOOLINFO));
     703            lstAppendItem(&pttd->llTools,
     704                          ptiNew);
     705
     706            if (    (ptiPassed->ulFlags & TTF_SUBCLASS)
     707                 && (LockSubclassedTools()) // V0.9.12 (2001-04-28) [umoeller]
     708               )
     709            {
     710                // caller wants this tool to be subclassed:
     711                // well, do it then
     712                SubclassTool(hwndTooltip,
     713                             ptiPassed->hwndTool);
     714
     715                UnlockSubclassedTools();
     716            }
     717
     718            return ((MPARAM)TRUE);
     719        }
     720    }
     721
     722    return (MPARAM)FALSE;
     723}
     724
     725/*
     726 *@@ TtmDelTool:
     727 *      implementation for TTM_DELTOOL in ctl_fnwpTooltip.
     728 *
     729 *@@added V0.9.13 (2001-06-21) [umoeller]
     730 *@@changed V0.9.13 (2001-06-21) [umoeller]: fixed missing unlock
     731 *@@changed V0.9.13 (2001-06-21) [umoeller]: fixed endless loop
     732 */
     733
     734VOID TtmDelTool(HWND hwndTooltip, MPARAM mp2)
     735{
     736    PTOOLTIPDATA pttd = (PTOOLTIPDATA)WinQueryWindowPtr(hwndTooltip, 1);
     737    PTOOLINFO ptiSearch = (PTOOLINFO)mp2;
     738    if (ptiSearch)
     739    {
     740        PLISTNODE pToolNode = lstQueryFirstNode(&pttd->llTools);
     741        while (pToolNode)
     742        {
     743            PTOOLINFO ptiThis = (PTOOLINFO)pToolNode->pItemData;
     744            if (    (ptiThis->hwndToolOwner == ptiSearch->hwndToolOwner)
     745                 && (ptiThis->hwndTool == ptiSearch->hwndTool)
     746               )
     747            {
     748                // found:
     749
     750                // V0.9.12 (2001-04-28) [umoeller]
     751                // unsubclass if this was subclassed
     752                if (ptiThis->ulFlags & TTF_SUBCLASS)
     753                {
     754                    if (LockSubclassedTools())
     755                    {
     756                        UnSubclassTool(ptiSearch->hwndTool);
     757
     758                        UnlockSubclassedTools();
     759                                // was missing V0.9.13 (2001-06-21) [umoeller]
     760                    }
     761                }
     762
     763                // remove the tool from the list
     764                lstRemoveNode(&pttd->llTools, pToolNode);
     765
     766                break;
     767            }
     768
     769            pToolNode = pToolNode->pNext;
     770                    // fixed endless loop V0.9.13 (2001-06-21) [umoeller]
     771        }
     772    }
     773}
     774
     775/*
     776 *@@ TtmRelayEvent:
     777 *      implementation for TTM_RELAYEVENT in ctl_fnwpTooltip.
     778 *
     779 *@@added V0.9.13 (2001-06-21) [umoeller]
     780 */
     781
     782VOID TtmRelayEvent(HWND hwndTooltip, MPARAM mp2)
     783{
     784    PTOOLTIPDATA pttd = (PTOOLTIPDATA)WinQueryWindowPtr(hwndTooltip, 1);
     785    PQMSG pqmsg = (PQMSG)mp2;
     786    if (pqmsg)
     787    {
     788        POINTL      ptlPointer;
     789        PLISTNODE   pToolNode;
     790
     791        if (pttd->idTimerInitial)
     792        {
     793            // _Pmpf(("TTM_RELAYEVENT: Stopping timer: %d", pttd->idTimerInitial));
     794            WinStopTimer(pttd->hab,
     795                         hwndTooltip,
     796                         TOOLTIP_ID_TIMER_INITIAL);
     797            pttd->idTimerInitial = 0;
     798        }
     799
     800        WinQueryPointerPos(HWND_DESKTOP, &ptlPointer);
     801
     802        // find TOOLINFO from mouse position
     803        pttd->ptiMouseOver = NULL;
     804        pToolNode = lstQueryFirstNode(&pttd->llTools);
     805        while (pToolNode)
     806        {
     807            PTOOLINFO pti = (PTOOLINFO)pToolNode->pItemData;
     808            if (pti->hwndTool == pqmsg->hwnd)
     809            {
     810                // _Pmpf((__FUNCTION__ ": found tool"));
     811                pttd->ptiMouseOver = pti;
     812                break;
     813            }
     814            pToolNode = pToolNode->pNext;
     815        }
     816
     817        if (    (ptlPointer.x != pttd->ptlPointerLast.x)
     818             || (ptlPointer.y != pttd->ptlPointerLast.y)
     819             || (pqmsg->msg == WM_BUTTON1DOWN)
     820             || (pqmsg->msg == WM_BUTTON2DOWN)
     821             || (pqmsg->msg == WM_BUTTON3DOWN)
     822           )
     823        {
     824            // mouse pos changed:
     825            // hide tooltip
     826            WinPostMsg(hwndTooltip,
     827                       TTM_SHOWTOOLTIPNOW,
     828                       (MPARAM)FALSE,
     829                       0);
     830            memcpy(&pttd->ptlPointerLast, &ptlPointer, sizeof(POINTL));
     831
     832            // _Pmpf((__FUNCTION__ ": pttd->ptiMouseOver: 0x%lX", pttd->ptiMouseOver));
     833            // _Pmpf((__FUNCTION__ ": pttd->fIsActive: 0x%lX", pttd->fIsActive));
     834            if (    (pttd->ptiMouseOver)
     835                 && (pttd->fIsActive)
     836               )
     837            {
     838                // tool found and tooltip is activated:
     839                pttd->idTimerInitial = WinStartTimer(pttd->hab,
     840                                                     hwndTooltip,
     841                                                     TOOLTIP_ID_TIMER_INITIAL,
     842                                                     pttd->ulTimeoutInitial);
     843                // _Pmpf(("TTM_RELAYEVENT: Started timer: %d", pttd->idTimerInitial));
     844            }
     845        }
     846    } // end if (pqmsg)
     847}
     848
     849/*
     850 *@@ TtmGetDelayTime:
     851 *      implementation for TTM_GETDELAYTIME in ctl_fnwpTooltip.
     852 *
     853 *@@added V0.9.13 (2001-06-21) [umoeller]
     854 */
     855
     856MRESULT TtmGetDelayTime(HWND hwndTooltip, MPARAM mp1)
     857{
     858    PTOOLTIPDATA pttd = (PTOOLTIPDATA)WinQueryWindowPtr(hwndTooltip, 1);
     859    switch ((ULONG)mp1)
     860    {
     861        case TTDT_AUTOPOP:
     862            return (MRESULT)pttd->ulTimeoutAutopop;
     863
     864        case TTDT_INITIAL:
     865            return (MRESULT)pttd->ulTimeoutInitial;
     866
     867        case TTDT_RESHOW:
     868            return (MRESULT)pttd->ulTimeoutReshow;
     869    }
     870
     871    return (0);
     872}
     873
     874/*
     875 *@@ TtmSetDelayTime:
     876 *      implementation for TTM_SETDELAYTIME in ctl_fnwpTooltip.
     877 *
     878 *@@added V0.9.13 (2001-06-21) [umoeller]
     879 */
     880
     881VOID TtmSetDelayTime(HWND hwndTooltip, MPARAM mp1, MPARAM mp2)
     882{
     883    PTOOLTIPDATA pttd = (PTOOLTIPDATA)WinQueryWindowPtr(hwndTooltip, 1);
     884    ULONG   iDelay = (ULONG)mp2;
     885    switch (SHORT1FROMMP(mp1))
     886    {
     887        case TTDT_AUTOMATIC:
     888            pttd->ulTimeoutInitial = iDelay;
     889            pttd->ulTimeoutAutopop = iDelay * 5;
     890            pttd->ulTimeoutReshow = iDelay / 2;
     891        break;
     892
     893        case TTDT_AUTOPOP:
     894            pttd->ulTimeoutAutopop = iDelay;
     895        break;
     896
     897        case TTDT_INITIAL:
     898            pttd->ulTimeoutInitial = iDelay;
     899        break;
     900
     901        case TTDT_RESHOW:
     902            pttd->ulTimeoutReshow = iDelay;
     903        break;
     904    }
     905}
     906
     907/*
     908 *@@ TtmGetText:
     909 *      implementation for TTM_GETTEXT in ctl_fnwpTooltip.
     910 *
     911 *@@added V0.9.13 (2001-06-21) [umoeller]
     912 */
     913
     914VOID TtmGetText(HWND hwndTooltip, MPARAM mp2)
     915{
     916    PTOOLTIPDATA pttd = (PTOOLTIPDATA)WinQueryWindowPtr(hwndTooltip, 1);
     917    PTOOLINFO pti = (PTOOLINFO)mp2;
     918
     919    if (pti->pszText == PSZ_TEXTCALLBACK)
     920    {
     921        // TTN_NEEDTEXT notification desired:
     922        // compose values for that msg
     923        TOOLTIPTEXT ttt = {0};
     924        // _Pmpf(("TTM_GETTEXT: PSZ_TEXTCALLBACK... sending TTN_NEEDTEXT"));
     925        ttt.hwndTooltip = hwndTooltip;
     926        ttt.hwndTool = pti->hwndTool;
     927        WinSendMsg(pti->hwndToolOwner,
     928                   WM_CONTROL,
     929                   MPFROM2SHORT(pttd->ulTooltipID,  // tooltip control wnd ID
     930                                TTN_NEEDTEXT),
     931                   &ttt);
     932
     933        // in case of error: set lpszText to NULL; this
     934        // is not specified in the docs however.
     935        pti->pszText = NULL;
     936
     937        switch (ttt.ulFormat)
     938        {
     939            case TTFMT_PSZ:
     940                if (ttt.pszText)
     941                    pti->pszText = ttt.pszText;
     942            break;
     943
     944            case TTFMT_STRINGRES:
     945                    // @@todo
     946            break;
     947        }
     948    }
     949}
     950
     951/*
     952 *@@ TtmEnumTools:
     953 *      implementation for TTM_ENUMTOOLS in ctl_fnwpTooltip.
     954 *
     955 *@@added V0.9.13 (2001-06-21) [umoeller]
     956 */
     957
     958MRESULT TtmEnumTools(HWND hwndTooltip, MPARAM mp1, MPARAM mp2)
     959{
     960    PTOOLTIPDATA pttd = (PTOOLTIPDATA)WinQueryWindowPtr(hwndTooltip, 1);
     961    PTOOLINFO ptiTarget = (PTOOLINFO)mp2;
     962    if (ptiTarget)
     963    {
     964        PTOOLINFO ptiFound = (PTOOLINFO)lstItemFromIndex(&pttd->llTools,
     965                                                         SHORT1FROMMP(mp1));
     966        if (ptiFound)
     967        {
     968            memcpy(ptiTarget, ptiFound, sizeof(TOOLINFO));
     969            return (MRESULT)TRUE;
     970        }
     971    }
     972
     973    return (MRESULT)FALSE;
     974}
     975
     976/*
     977 *@@ TtmGetCurrentTool:
     978 *      implementation for TTM_GETCURRENTTOOL in ctl_fnwpTooltip.
     979 *
     980 *@@added V0.9.13 (2001-06-21) [umoeller]
     981 */
     982
     983MRESULT TtmGetCurrentTool(HWND hwndTooltip, MPARAM mp2)
     984{
     985    PTOOLTIPDATA pttd = (PTOOLTIPDATA)WinQueryWindowPtr(hwndTooltip, 1);
     986    PTOOLINFO ptiTarget = (PTOOLINFO)mp2;
     987    if (ptiTarget)
     988    {
     989        if (pttd->ptiMouseOver)
     990        {
     991            memcpy(ptiTarget, pttd->ptiMouseOver, sizeof(TOOLINFO));
     992            return (MPARAM)TRUE;
     993        }
     994    }
     995
     996    return ((MPARAM)FALSE);
     997}
     998
     999/*
     1000 *@@ TtmGetToolInfo:
     1001 *      implementation for TTM_GETTOOLINFO in ctl_fnwpTooltip.
     1002 *
     1003 *@@added V0.9.13 (2001-06-21) [umoeller]
     1004 */
     1005
     1006MRESULT TtmGetToolInfo(HWND hwndTooltip, MPARAM mp2)
     1007{
     1008    PTOOLTIPDATA pttd = (PTOOLTIPDATA)WinQueryWindowPtr(hwndTooltip, 1);
     1009    PTOOLINFO ptiSearch = (PTOOLINFO)mp2;
     1010    if (ptiSearch)
     1011    {
     1012        PLISTNODE pToolNode = lstQueryFirstNode(&pttd->llTools);
     1013        while (pToolNode)
     1014        {
     1015            PTOOLINFO ptiThis = (PTOOLINFO)pToolNode->pItemData;
     1016            if (    (ptiThis->hwndToolOwner == ptiSearch->hwndToolOwner)
     1017                 && (ptiThis->hwndTool == ptiSearch->hwndTool)
     1018               )
     1019            {
     1020                // found:
     1021                memcpy(ptiSearch, ptiThis, sizeof(TOOLINFO));
     1022                return (MPARAM)TRUE;
     1023            }
     1024            pToolNode = pToolNode->pNext;
     1025        }
     1026    }
     1027
     1028    return ((MPARAM)FALSE);
     1029}
     1030
     1031/*
     1032 *@@ FormatTooltip:
     1033 *      formats the tooltip window according to
     1034 *      its text (which is assumed to be in
     1035 *      pttd->pszPaintText) and positions it
     1036 *      on the screen.
     1037 *
     1038 *      This does not change the visibility
     1039 *      of the tooltip; if it is not yet visible,
     1040 *      you must show it afterwards.
     1041 *
     1042 *@@added V0.9.13 (2001-06-21) [umoeller]
     1043 */
     1044
     1045VOID FormatTooltip(HWND hwndTooltip,
     1046                   PTOOLTIPDATA pttd,
     1047                   PPOINTL pptlPointer)      // in: current pointer pos or NULL
     1048{
     1049    // find out how much space we need
     1050    RECTL   rcl = { 0, 0, 300, 1000 };
     1051    POINTL  ptlTooltip;
     1052    LONG    cx, cy;
     1053    ULONG   ulStyle = WinQueryWindowULong(hwndTooltip, QWL_STYLE);
     1054
     1055    HPS hps = WinGetPS(hwndTooltip);
     1056
     1057    winhDrawFormattedText(hps,
     1058                          &rcl,
     1059                          pttd->pszPaintText,
     1060                          DT_LEFT | DT_TOP | DT_WORDBREAK | DT_QUERYEXTENT);
     1061    WinReleasePS(hps);
     1062
     1063    // calc width and height of tooltip
     1064    cx = rcl.xRight + 2*TOOLTIP_CX_BORDER;
     1065    cy = (rcl.yTop - rcl.yBottom) + 2*TOOLTIP_CY_BORDER;
     1066
     1067    // calc x and y pos of tooltip:
     1068
     1069    // per default, use pointer pos
     1070    ptlTooltip.x = pptlPointer->x - cx/2;
     1071    ptlTooltip.y = pptlPointer->y - cy;
     1072
     1073    // do we need the tool's position?
     1074    if (    pttd->ptiMouseOver->ulFlags
     1075                & (TTF_CENTER_X_ON_TOOL | TTF_POS_Y_ABOVE_TOOL | TTF_POS_Y_BELOW_TOOL)
     1076       )
     1077    {
     1078        // yes:
     1079        SWP     swpTool;
     1080        POINTL  ptlTool;
     1081        WinQueryWindowPos(pttd->ptiMouseOver->hwndTool, &swpTool);
     1082        ptlTool.x = swpTool.x;
     1083        ptlTool.y = swpTool.y;
     1084        // convert x, y to desktop points
     1085        WinMapWindowPoints(WinQueryWindow(pttd->ptiMouseOver->hwndTool,
     1086                                          QW_PARENT), // hwndFrom
     1087                           HWND_DESKTOP,            // hwndTo
     1088                           &ptlTool,
     1089                           1);
     1090
     1091        // X
     1092        if (pttd->ptiMouseOver->ulFlags & TTF_CENTER_X_ON_TOOL)
     1093            // center X on tool:
     1094            ptlTooltip.x = ptlTool.x + ((swpTool.cx - cx) / 2L);
     1095
     1096        // Y
     1097        if (pttd->ptiMouseOver->ulFlags & TTF_POS_Y_ABOVE_TOOL)
     1098            ptlTooltip.y = ptlTool.y + swpTool.cy;
     1099        else if (pttd->ptiMouseOver->ulFlags & TTF_POS_Y_BELOW_TOOL)
     1100            ptlTooltip.y = ptlTool.y - cy;
     1101    }
     1102
     1103    // if "shy mouse" is enabled, make
     1104    // sure the tool tip is not under the
     1105    // mouse pointer
     1106    if (ulStyle & TTF_SHYMOUSE)
     1107    {
     1108        // we need to subtract the current mouse
     1109        // pointer's hot spot from the current
     1110        // pointer position
     1111        HPOINTER    hptr = WinQueryPointer(HWND_DESKTOP);
     1112        POINTERINFO pi;
     1113        if (WinQueryPointerInfo(hptr, &pi))
     1114        {
     1115            // calc bottom edge of mouse pointer rect
     1116            ULONG yBottomPointer = (pptlPointer->y - pi.yHotspot);
     1117            // _Pmpf(("yHotspot: %d", pi.yHotspot));
     1118            if (   (ptlTooltip.y + cy) // top edge of tool tip
     1119                 > yBottomPointer
     1120               )
     1121            {
     1122                ptlTooltip.y = pptlPointer->y - cy - pi.yHotspot;
     1123            }
     1124        }
     1125    }
     1126
     1127    // constrain to screen
     1128    if (ptlTooltip.x < 0)
     1129        ptlTooltip.x = 0;
     1130    if (ptlTooltip.y < 0)
     1131        ptlTooltip.y = 0;
     1132    if (ptlTooltip.x + cx > pttd->cxScreen)
     1133        ptlTooltip.x = pttd->cxScreen-cx;
     1134    if (ptlTooltip.y + cy > pttd->cyScreen)
     1135        ptlTooltip.y = pttd->cyScreen-cy;
     1136
     1137    // if shadow is enabled,
     1138    // enlarge; the shadow might by
     1139    // off-screen now, but that's OK
     1140    if (ulStyle & TTS_SHADOW)
     1141    {
     1142        cx += TT_SHADOWOFS;
     1143        cy += TT_SHADOWOFS;
     1144        ptlTooltip.y -= TT_SHADOWOFS;
     1145    }
     1146
     1147    // set tooltip position at the pos we calculated
     1148    // and show tooltip
     1149    WinSetWindowPos(hwndTooltip,
     1150                    HWND_TOP,
     1151                    ptlTooltip.x,
     1152                    ptlTooltip.y,
     1153                    cx,
     1154                    cy,
     1155                    SWP_MOVE | SWP_SIZE | SWP_ZORDER);
     1156}
     1157
     1158/*
     1159 *@@ TtmUpdateTipText:
     1160 *      implementation for TTM_UPDATETIPTEXT in ctl_fnwpTooltip.
     1161 *
     1162 *@@added V0.9.13 (2001-06-21) [umoeller]
     1163 */
     1164
     1165VOID TtmUpdateTipText(HWND hwndTooltip,
     1166                      const char *pcszNewText)
     1167{
     1168    PTOOLTIPDATA pttd = (PTOOLTIPDATA)WinQueryWindowPtr(hwndTooltip, 1);
     1169
     1170    // has text really changed?
     1171    if (    (    (pttd->pszPaintText)
     1172              && (pcszNewText)
     1173              && (strcmp(pttd->pszPaintText, pcszNewText))
     1174            )
     1175         || (pttd->pszPaintText && !pcszNewText)
     1176         || (!pttd->pszPaintText && pcszNewText)
     1177       )
     1178    {
     1179        // yes:
     1180        if (pttd->pszPaintText)
     1181        {
     1182            free(pttd->pszPaintText);
     1183            pttd->pszPaintText = NULL;
     1184        }
     1185
     1186        if (pcszNewText)
     1187            pttd->pszPaintText = strdup(pcszNewText);
     1188
     1189        if (pttd->fIsVisible)
     1190        {
     1191            // currently showing:
     1192            // reformat
     1193            POINTL ptlPointer;
     1194            WinQueryPointerPos(HWND_DESKTOP, &ptlPointer);
     1195            FormatTooltip(hwndTooltip,
     1196                          pttd,
     1197                          &ptlPointer);
     1198            WinInvalidateRect(hwndTooltip, NULL, FALSE);
     1199        }
     1200    }
     1201}
     1202
     1203/*
    5271204 *@@ TtmShowTooltip:
    5281205 *      implementation for TTM_SHOW_TOOLTIP.
     
    5371214
    5381215VOID TtmShowTooltip(HWND hwndTooltip,
    539                     PTOOLTIPDATA pttd,
    5401216                    BOOL fShow)  // if TRUE: show, else: HIDE
    5411217{
    542     // _Pmpf((__FUNCTION__ ": fShow %d", fShow));
     1218    PTOOLTIPDATA pttd = (PTOOLTIPDATA)WinQueryWindowPtr(hwndTooltip, 1);
    5431219    if (fShow)
    5441220    {
     
    5661242            // mouse not moved since timer was started:
    5671243            // find the current TOOLINFO
    568             // _Pmpf((__FUNCTION__ ": mouse not moved... pttd->ptiMouseOver 0x%lX", pttd->ptiMouseOver));
    5691244            if (pttd->ptiMouseOver)
    5701245            {
     
    5821257            }
    5831258
    584             // _Pmpf((__FUNCTION__ ": pttd->pszPaintText %s",
    585                //      (pttd->pszPaintText) ? pttd->pszPaintText : "NULL"));
    586 
    5871259            if (pttd->pszPaintText)
    5881260            {
    589                 // find out how much space we need
    590                 RECTL   rcl = { 0, 0, 300, 1000 };
    591                 POINTL  ptlTooltip;
    592                 LONG    cx, cy;
    593                 ULONG   ulStyle = WinQueryWindowULong(hwndTooltip, QWL_STYLE);
    594 
    595                 G_cxScreen = WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN),
    596                 G_cyScreen = WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN);
    597 
    598                 hps = WinGetPS(hwndTooltip);
    599                 winhDrawFormattedText(hps,
    600                                       &rcl,
    601                                       pttd->pszPaintText,
    602                                       DT_LEFT | DT_TOP | DT_WORDBREAK | DT_QUERYEXTENT);
    603                 WinReleasePS(hps);
    604 
    605                 // calc width and height of tooltip
    606                 cx = rcl.xRight + 2*TOOLTIP_CX_BORDER;
    607                 cy = (rcl.yTop - rcl.yBottom) + 2*TOOLTIP_CY_BORDER;
    608 
    609                 // calc x and y pos of tooltip:
    610 
    611                 // per default, use pointer pos
    612                 ptlTooltip.x = ptlPointer.x - cx/2;
    613                 ptlTooltip.y = ptlPointer.y - cy;
    614 
    615                 // do we need the tool's position?
    616                 if (    pttd->ptiMouseOver->ulFlags
    617                      & (TTF_CENTER_X_ON_TOOL | TTF_POS_Y_ABOVE_TOOL | TTF_POS_Y_BELOW_TOOL)
    618                    )
    619                 {
    620                     // yes:
    621                     SWP     swpTool;
    622                     POINTL  ptlTool;
    623                     WinQueryWindowPos(pttd->ptiMouseOver->hwndTool, &swpTool);
    624                     ptlTool.x = swpTool.x;
    625                     ptlTool.y = swpTool.y;
    626                     // convert x, y to desktop points
    627                     WinMapWindowPoints(WinQueryWindow(pttd->ptiMouseOver->hwndTool,
    628                                                       QW_PARENT), // hwndFrom
    629                                        HWND_DESKTOP,            // hwndTo
    630                                        &ptlTool,
    631                                        1);
    632 
    633                     // X
    634                     if (pttd->ptiMouseOver->ulFlags & TTF_CENTER_X_ON_TOOL)
    635                         // center X on tool:
    636                         ptlTooltip.x = ptlTool.x + ((swpTool.cx - cx) / 2L);
    637 
    638                     // Y
    639                     if (pttd->ptiMouseOver->ulFlags & TTF_POS_Y_ABOVE_TOOL)
    640                         ptlTooltip.y = ptlTool.y + swpTool.cy;
    641                     else if (pttd->ptiMouseOver->ulFlags & TTF_POS_Y_BELOW_TOOL)
    642                         ptlTooltip.y = ptlTool.y - cy;
    643                 }
    644 
    645                 // if "shy mouse" is enabled, make
    646                 // sure the tool tip is not under the
    647                 // mouse pointer
    648                 if (ulStyle & TTF_SHYMOUSE)
    649                 {
    650                     // we need to subtract the current mouse
    651                     // pointer's hot spot from the current
    652                     // pointer position
    653                     HPOINTER    hptr = WinQueryPointer(HWND_DESKTOP);
    654                     POINTERINFO pi;
    655                     if (WinQueryPointerInfo(hptr, &pi))
    656                     {
    657                         /* ULONG cyPointer = WinQuerySysValue(HWND_DESKTOP,
    658                                                            SV_CYPOINTER); */
    659                         // calc bottom edge of mouse pointer rect
    660                         ULONG yBottomPointer = (ptlPointer.y - pi.yHotspot);
    661                         // _Pmpf(("yHotspot: %d", pi.yHotspot));
    662                         if (   (ptlTooltip.y + cy) // top edge of tool tip
    663                              > yBottomPointer
    664                            )
    665                         {
    666                             ptlTooltip.y = ptlPointer.y - cy - pi.yHotspot;
    667                         }
    668                     }
    669                 }
    670 
    671                 // constrain to screen
    672                 if (ptlTooltip.x < 0)
    673                     ptlTooltip.x = 0;
    674                 if (ptlTooltip.y < 0)
    675                     ptlTooltip.y = 0;
    676                 if (ptlTooltip.x + cx > G_cxScreen)
    677                     ptlTooltip.x = G_cxScreen-cx;
    678                 if (ptlTooltip.y + cy > G_cyScreen)
    679                     ptlTooltip.y = G_cyScreen-cy;
    680 
    681                 // if shadow is enabled,
    682                 // enlarge; the shadow might by
    683                 // off-screen now, but that's OK
    684                 if (ulStyle & TTS_SHADOW)
    685                 {
    686                     cx += TT_SHADOWOFS;
    687                     cy += TT_SHADOWOFS;
    688                     ptlTooltip.y -= TT_SHADOWOFS;
    689                 }
    690 
    691                 // notify owner
     1261                FormatTooltip(hwndTooltip,
     1262                              pttd,
     1263                              &ptlPointer);
     1264
     1265                // notify owner (TTN_SHOW)
    6921266                WinSendMsg(pttd->hwndOwner,
    6931267                           WM_CONTROL,
    6941268                           MPFROM2SHORT(pttd->ulTooltipID,  // tooltip control wnd ID
    6951269                                        TTN_SHOW),
    696                            0);
    697 
    698                 // set tooltip position at the pos we calculated
    699                 // and show tooltip
    700                 WinSetWindowPos(hwndTooltip,
    701                                 HWND_TOP,
    702                                 ptlTooltip.x,
    703                                 ptlTooltip.y,
    704                                 cx, cy,
    705                                 SWP_MOVE | SWP_SIZE | SWP_ZORDER | SWP_SHOW);
     1270                           pttd->ptiMouseOver);
     1271
     1272                WinShowWindow(hwndTooltip, TRUE);
    7061273                pttd->fIsVisible = TRUE;
    7071274
     
    7231290        if (pttd->fIsVisible)
    7241291        {
     1292            // notify owner (TTN_POP)
    7251293            WinSendMsg(pttd->hwndOwner,
    7261294                       WM_CONTROL,
    7271295                       MPFROM2SHORT(pttd->ulTooltipID,  // tooltip control wnd ID
    7281296                                    TTN_POP),
    729                        0);
     1297                       pttd->ptiMouseOver);
    7301298            WinShowWindow(hwndTooltip, FALSE);
    7311299        }
     
    8401408    MRESULT mrc = 0;
    8411409
    842     PTOOLTIPDATA pttd = (PTOOLTIPDATA)WinQueryWindowPtr(hwndTooltip, 1);
    843 
    8441410    TRY_LOUD(excpt1)
    8451411    {
     
    8571423
    8581424            case WM_CREATE:
    859             {
    860                 PCREATESTRUCT pcs = (PCREATESTRUCT)mp2;
    861 
    862                 // allocate and initialize tooltip data
    863                 pttd = (PTOOLTIPDATA)malloc(sizeof(TOOLTIPDATA));
    864                 if (pttd)
    865                 {
    866                     CHAR        szFont[256];
    867                     memset(pttd, 0, sizeof(TOOLTIPDATA));
    868                     WinSetWindowPtr(hwndTooltip, 1, pttd);
    869 
    870                     pttd->hwndOwner = pcs->hwndOwner;
    871                     pttd->hab = WinQueryAnchorBlock(hwndTooltip);
    872                     pttd->ulTooltipID = pcs->id;
    873 
    874                     pttd->fIsActive = TRUE;
    875 
    876                     // default timeouts
    877                     pttd->ulTimeoutInitial = 1000;
    878                     pttd->ulTimeoutAutopop = 5000;
    879                     pttd->ulTimeoutReshow = 500;
    880 
    881                     // get colors from presparams/syscolors
    882                     UpdateTooltipPresColors(hwndTooltip, pttd);
    883 
    884                     // check if font presparam set
    885                     if (WinQueryPresParam(hwndTooltip,
    886                                           PP_FONTNAMESIZE, 0,
    887                                           NULL,
    888                                           sizeof(szFont),
    889                                           szFont,
    890                                           QPF_NOINHERIT)
    891                             == 0)
    892                     {
    893                         // no: set default font presparam
    894                         // (we never want the System Proportional font)
    895                         winhSetWindowFont(hwndTooltip,
    896                                           NULL);      // default (WarpSans or 8.Helv)
    897                     }
    898 
    899                     pttd->pszPaintText = strdup("undefined");
    900 
    901                     lstInit(&pttd->llTools, TRUE);      // auto-free items
    902 
    903                     // override CREATESTRUCT
    904                     WinSetWindowPos(hwndTooltip,
    905                                     HWND_TOP,
    906                                     50, 50,
    907                                     100, 100,
    908                                     SWP_MOVE | SWP_SIZE | SWP_ZORDER | SWP_HIDE);
    909 
    910                     mrc = (MPARAM)FALSE;
    911                 }
    912                 else
    913                     // malloc failed:
    914                     mrc = (MPARAM)TRUE;
    915             break; }
    916 
    917             /*
    918              * WM_DESTROY:
    919              *      clean up upon destruction.
    920              */
    921 
    922             case WM_DESTROY:
    923                 // stop timers
    924                 if (pttd->idTimerInitial)
    925                     WinStopTimer(pttd->hab,
    926                                  hwndTooltip,
    927                                  pttd->idTimerInitial);
    928                 if (pttd->idTimerAutopop)
    929                     WinStopTimer(pttd->hab,
    930                                  hwndTooltip,
    931                                  pttd->idTimerAutopop);
    932                 if (pttd->pszPaintText)
    933                     free(pttd->pszPaintText);
    934 
    935                 // un-subclass all tools that we subclassed
    936                 // V0.9.12 (2001-04-28) [umoeller]
    937                 if (LockSubclassedTools())
    938                 {
    939                     PLISTNODE pNode;
    940                     PSUBCLASSEDTOOL pst;
    941                     for (pNode = lstQueryFirstNode(&pttd->llTools);
    942                          pNode;
    943                          pNode = pNode->pNext)
    944                     {
    945                         PTOOLINFO pti = (PTOOLINFO)pNode->pItemData;
    946                         if (pst = FindSubclassedTool(pti->hwndTool))
    947                             UnSubclassTool(pti->hwndTool);
    948                     }
    949 
    950                     UnlockSubclassedTools();
    951                 }
    952                 // end V0.9.12 (2001-04-28) [umoeller]
    953 
    954                 lstClear(&pttd->llTools);
    955 
    956                 free(pttd);
    957 
    958                 mrc = (MPARAM)0;
     1425                mrc = TtmCreate(hwndTooltip, mp2);
    9591426            break;
    9601427
     
    9791446
    9801447            case WM_TIMER:      // done
    981             {
    982                 USHORT  usTimer = SHORT1FROMMP(mp1);
    983 
    984                 switch (usTimer)
    985                 {
    986                     case TOOLTIP_ID_TIMER_INITIAL:
    987                         // _Pmpf(("WM_TIMER: Stopping initial timer: %d", usTimer));
    988                         // _Pmpf((__FUNCTION__ ": TOOLTIP_ID_TIMER_INITIAL"));
    989                         WinStopTimer(pttd->hab,
    990                                      hwndTooltip,
    991                                      usTimer);
    992                         pttd->idTimerInitial = 0;
    993 
    994                         if (pttd->fIsActive)
    995                             // show tooltip
    996                             WinPostMsg(hwndTooltip, TTM_SHOWTOOLTIPNOW, (MPARAM)TRUE, 0);
    997                     break;
    998 
    999                     case TOOLTIP_ID_TIMER_AUTOPOP:
    1000                         // _Pmpf(("WM_TIMER: Stopping autopop timer: %d", usTimer));
    1001                         WinStopTimer(pttd->hab,
    1002                                      hwndTooltip,
    1003                                      usTimer);
    1004                         pttd->idTimerAutopop = 0;
    1005                         WinPostMsg(hwndTooltip, TTM_SHOWTOOLTIPNOW, (MPARAM)FALSE, 0);
    1006                     break;
    1007 
    1008                     default:
    1009                         mrc = WinDefWindowProc(hwndTooltip, msg, mp1, mp2);
    1010                 } // end switch
    1011 
    1012             break; }
     1448                if (!TtmTimer(hwndTooltip, mp1))
     1449                    mrc = WinDefWindowProc(hwndTooltip, msg, mp1, mp2);
     1450            break;
    10131451
    10141452            /*
     
    10181456
    10191457            case WM_PAINT:      // done
    1020                 PaintTooltip(hwndTooltip, pttd);
     1458                TtmPaint(hwndTooltip);
    10211459            break;
    10221460
     
    10371475                    case PP_MENUHILITEBGNDCOLOR:
    10381476                        // re-query our presparams
    1039                         UpdateTooltipPresColors(hwndTooltip, pttd);
     1477                        UpdateTooltipPresColors(hwndTooltip);
    10401478                }
    10411479            break; }
     
    10471485
    10481486            case WM_SYSCOLORCHANGE:
    1049                 UpdateTooltipPresColors(hwndTooltip, pttd);
     1487                UpdateTooltipPresColors(hwndTooltip);
     1488            break;
     1489
     1490            /*
     1491             * WM_DESTROY:
     1492             *      clean up upon destruction.
     1493             */
     1494
     1495            case WM_DESTROY:
     1496                TtmDestroy(hwndTooltip);
    10501497            break;
    10511498
     
    10621509
    10631510            case TTM_ACTIVATE:      // done
    1064                 pttd->fIsActive = (BOOL)mp1;
    1065                 if (!pttd->fIsActive)
     1511            {
     1512                PTOOLTIPDATA pttd = (PTOOLTIPDATA)WinQueryWindowPtr(hwndTooltip, 1);
     1513                if (!(pttd->fIsActive = (BOOL)mp1))
    10661514                    // disable: hide tooltip
    10671515                    WinPostMsg(hwndTooltip, TTM_SHOWTOOLTIPNOW, (MPARAM)FALSE, 0);
     1516            }
    10681517            break;
    10691518
     
    11211570
    11221571            case TTM_ADDTOOL:       // done
    1123                 mrc = (MPARAM)FALSE;
    1124                 if (mp2)
    1125                 {
    1126                     PTOOLINFO ptiPassed = (PTOOLINFO)mp2,
    1127                               ptiNew = (PTOOLINFO)malloc(sizeof(TOOLINFO));
    1128                     if (ptiNew)
    1129                     {
    1130                         memcpy(ptiNew, ptiPassed, sizeof(TOOLINFO));
    1131                         lstAppendItem(&pttd->llTools,
    1132                                       ptiNew);
    1133 
    1134                         if (    (ptiPassed->ulFlags & TTF_SUBCLASS)
    1135                              && (LockSubclassedTools()) // V0.9.12 (2001-04-28) [umoeller]
    1136                            )
    1137                         {
    1138                             // caller wants this tool to be subclassed:
    1139                             // well, do it then
    1140                             SubclassTool(hwndTooltip,
    1141                                          ptiPassed->hwndTool);
    1142 
    1143                             UnlockSubclassedTools();
    1144                         }
    1145 
    1146                         mrc = (MPARAM)TRUE;
    1147                     }
    1148                 }
     1572                mrc = TtmAddTool(hwndTooltip, mp2);
    11491573            break;
    11501574
     
    11561580             *      --  mp1: always 0.
    11571581             *      --  PTOOLINFO mp2: information about the tool;
    1158              *              all fields except cbSize, hwnd, uID are
    1159              *              ignored.
     1582             *              all fields except cbSize, hwndToolOwner,
     1583             *              and hwndTool are ignored.
    11601584             *
    11611585             *      Return value: 0 always.
     
    11631587
    11641588            case TTM_DELTOOL:       // done
    1165             {
    1166                 PTOOLINFO ptiSearch = (PTOOLINFO)mp2;
    1167                 if (ptiSearch)
    1168                 {
    1169                     PLISTNODE pToolNode = lstQueryFirstNode(&pttd->llTools);
    1170                     while (pToolNode)
    1171                     {
    1172                         PTOOLINFO ptiThis = (PTOOLINFO)pToolNode->pItemData;
    1173                         if (    (ptiThis->hwndToolOwner == ptiSearch->hwndToolOwner)
    1174                              && (ptiThis->hwndTool == ptiSearch->hwndTool)
    1175                            )
    1176                         {
    1177                             // found:
    1178 
    1179                             // V0.9.12 (2001-04-28) [umoeller]
    1180                             // unsubclass if this was subclassed
    1181                             if (ptiThis->ulFlags & TTF_SUBCLASS)
    1182                             {
    1183                                 if (LockSubclassedTools())
    1184                                 {
    1185                                     UnSubclassTool(ptiSearch->hwndTool);
    1186                                 }
    1187                             }
    1188 
    1189                             // remove the tool from the list
    1190                             lstRemoveNode(&pttd->llTools, pToolNode);
    1191 
    1192                             break;
    1193                         }
    1194                     }
    1195                     pToolNode = pToolNode->pNext;
    1196                 }
    1197             break; }
     1589                TtmDelTool(hwndTooltip, mp2);
     1590            break;
    11981591
    11991592            /*
     
    12931686
    12941687            case TTM_RELAYEVENT:
    1295             {
    1296                 PQMSG pqmsg = (PQMSG)mp2;
    1297                 if (pqmsg)
    1298                 {
    1299                     POINTL      ptlPointer;
    1300                     PLISTNODE   pToolNode;
    1301 
    1302                     if (pttd->idTimerInitial)
    1303                     {
    1304                         // _Pmpf(("TTM_RELAYEVENT: Stopping timer: %d", pttd->idTimerInitial));
    1305                         WinStopTimer(pttd->hab,
    1306                                      hwndTooltip,
    1307                                      TOOLTIP_ID_TIMER_INITIAL);
    1308                         pttd->idTimerInitial = 0;
    1309                     }
    1310 
    1311                     WinQueryPointerPos(HWND_DESKTOP, &ptlPointer);
    1312 
    1313                     // find TOOLINFO from mouse position
    1314                     pttd->ptiMouseOver = NULL;
    1315                     pToolNode = lstQueryFirstNode(&pttd->llTools);
    1316                     while (pToolNode)
    1317                     {
    1318                         PTOOLINFO pti = (PTOOLINFO)pToolNode->pItemData;
    1319                         if (pti->hwndTool == pqmsg->hwnd)
    1320                         {
    1321                             // _Pmpf((__FUNCTION__ ": found tool"));
    1322                             pttd->ptiMouseOver = pti;
    1323                             break;
    1324                         }
    1325                         pToolNode = pToolNode->pNext;
    1326                     }
    1327 
    1328                     if (    (ptlPointer.x != pttd->ptlPointerLast.x)
    1329                          || (ptlPointer.y != pttd->ptlPointerLast.y)
    1330                          || (pqmsg->msg == WM_BUTTON1DOWN)
    1331                          || (pqmsg->msg == WM_BUTTON2DOWN)
    1332                          || (pqmsg->msg == WM_BUTTON3DOWN)
    1333                        )
    1334                     {
    1335                         // mouse pos changed:
    1336                         // hide tooltip
    1337                         WinPostMsg(hwndTooltip,
    1338                                    TTM_SHOWTOOLTIPNOW,
    1339                                    (MPARAM)FALSE,
    1340                                    0);
    1341                         memcpy(&pttd->ptlPointerLast, &ptlPointer, sizeof(POINTL));
    1342 
    1343                         // _Pmpf((__FUNCTION__ ": pttd->ptiMouseOver: 0x%lX", pttd->ptiMouseOver));
    1344                         // _Pmpf((__FUNCTION__ ": pttd->fIsActive: 0x%lX", pttd->fIsActive));
    1345                         if (    (pttd->ptiMouseOver)
    1346                              && (pttd->fIsActive)
    1347                            )
    1348                         {
    1349                             // tool found and tooltip is activated:
    1350                             pttd->idTimerInitial = WinStartTimer(pttd->hab,
    1351                                                                  hwndTooltip,
    1352                                                                  TOOLTIP_ID_TIMER_INITIAL,
    1353                                                                  pttd->ulTimeoutInitial);
    1354                             // _Pmpf(("TTM_RELAYEVENT: Started timer: %d", pttd->idTimerInitial));
    1355                         }
    1356                     }
    1357                 } // end if (pqmsg)
    1358             break; }
     1688                TtmRelayEvent(hwndTooltip, mp2);
     1689            break;
    13591690
    13601691            /*
     
    13761707
    13771708            case TTM_GETDELAYTIME:
    1378                 switch ((ULONG)mp1)
    1379                 {
    1380                     case TTDT_AUTOPOP:
    1381                         mrc = (MRESULT)pttd->ulTimeoutAutopop;
    1382                     break;
    1383 
    1384                     case TTDT_INITIAL:
    1385                         mrc = (MRESULT)pttd->ulTimeoutInitial;
    1386                     break;
    1387 
    1388                     case TTDT_RESHOW:
    1389                         mrc = (MRESULT)pttd->ulTimeoutReshow;
    1390                     break;
    1391                 }
     1709                mrc = TtmGetDelayTime(hwndTooltip, mp1);
    13921710            break;
    13931711
     
    14331751
    14341752            case TTM_SETDELAYTIME:  // done
    1435             {
    1436                 ULONG   iDelay = (ULONG)mp2;
    1437                 switch (SHORT1FROMMP(mp1))
    1438                 {
    1439                     case TTDT_AUTOMATIC:
    1440                         pttd->ulTimeoutInitial = iDelay;
    1441                         pttd->ulTimeoutAutopop = iDelay * 5;
    1442                         pttd->ulTimeoutReshow = iDelay / 2;
    1443                     break;
    1444 
    1445                     case TTDT_AUTOPOP:
    1446                         pttd->ulTimeoutAutopop = iDelay;
    1447                     break;
    1448 
    1449                     case TTDT_INITIAL:
    1450                         pttd->ulTimeoutInitial = iDelay;
    1451                     break;
    1452 
    1453                     case TTDT_RESHOW:
    1454                         pttd->ulTimeoutReshow = iDelay;
    1455                     break;
    1456                 }
    1457             break; }
     1753                TtmSetDelayTime(hwndTooltip, mp1, mp2);
     1754            break;
    14581755
    14591756            /*
     
    14641761             *      -- mp1: always 0
    14651762             *      -- PTOOLINFO mp2: pointer to a TOOLINFO structure.
    1466              *         When sending the message, the hwnd and uId members
    1467              *         identify a tool. If the tooltip control includes
    1468              *         the tool, the lpszText member receives the pointer
    1469              *         to the string.
     1763             *         hwndTool identifies a tool. If the tooltip control
     1764             *         includes the tool, the pszText member receives
     1765             *         the pointer to the string on output.
    14701766             *
    14711767             *      Return value: 0 always.
     
    14771773
    14781774            case TTM_GETTEXT:       // done, I think
    1479             {
    1480                 PTOOLINFO pti = (PTOOLINFO)mp2;
    1481 
    1482                 if (pti->pszText == PSZ_TEXTCALLBACK)
    1483                 {
    1484                     // TTN_NEEDTEXT notification desired:
    1485                     // compose values for that msg
    1486                     TOOLTIPTEXT ttt = {0};
    1487                     // _Pmpf(("TTM_GETTEXT: PSZ_TEXTCALLBACK... sending TTN_NEEDTEXT"));
    1488                     ttt.hwndTooltip = hwndTooltip;
    1489                     ttt.hwndTool = pti->hwndTool;
    1490                     WinSendMsg(pti->hwndToolOwner,
    1491                                WM_CONTROL,
    1492                                MPFROM2SHORT(pttd->ulTooltipID,  // tooltip control wnd ID
    1493                                             TTN_NEEDTEXT),
    1494                                &ttt);
    1495 
    1496                     // in case of error: set lpszText to NULL; this
    1497                     // is not specified in the docs however.
    1498                     pti->pszText = NULL;
    1499 
    1500                     switch (ttt.ulFormat)
    1501                     {
    1502                         case TTFMT_PSZ:
    1503                             if (ttt.pszText)
    1504                                 pti->pszText = ttt.pszText;
    1505                         break;
    1506 
    1507                         case TTFMT_STRINGRES:
    1508                                 // @@todo
    1509                         break;
    1510                     }
    1511                 }
    1512             break; }
     1775                TtmGetText(hwndTooltip, mp2);
     1776            break;
    15131777
    15141778            /*
    15151779             *@@ TTM_UPDATETIPTEXT:
    1516              *      sets the tooltip text for a tool.
     1780             *      sets the current tooltip text explicitly,
     1781             *      no matter for what tool the tooltip is
     1782             *      currently being displayed. This might be
     1783             *      useful if you want to dynamically update
     1784             *      the tooltip display.
     1785             *
     1786             *      If the tooltip is currently showing,
     1787             *      it is reformatted with the new text.
     1788             *
     1789             *      Note that the change is not permanent;
     1790             *      if the mouse moves over a different
     1791             *      tool next, the change will be lost.
    15171792             *
    15181793             *      Parameters:
    1519              *      -- mp1: always 0.
    1520              *      -- PTOOLINFO mp2: pointer to a TOOLINFO structure.
    1521              *         The "hinst" and "lpszText" members must specify
    1522              *         the instance handle and the pointer to the text.
    1523              *         The "hwnd" and "uId" members identify the tool
    1524              *         to update.
     1794             *      -- PSZ mp1: new text to display.
     1795             *
     1796             *@@added V0.9.13 (2001-06-21) [umoeller]
    15251797             */
    15261798
    15271799            case TTM_UPDATETIPTEXT:
     1800                TtmUpdateTipText(hwndTooltip, (PSZ)mp1);
    15281801            break;
    15291802
     
    15931866
    15941867            case TTM_ENUMTOOLS:         // done
    1595             {
    1596                 PTOOLINFO ptiTarget = (PTOOLINFO)mp2;
    1597                 mrc = (MPARAM)FALSE;
    1598                 if (ptiTarget)
    1599                 {
    1600                     PTOOLINFO ptiFound = (PTOOLINFO)lstItemFromIndex(&pttd->llTools,
    1601                                                                      SHORT1FROMMP(mp1));
    1602                     if (ptiFound)
    1603                     {
    1604                         memcpy(ptiTarget, ptiFound, sizeof(TOOLINFO));
    1605                         mrc = (MRESULT)TRUE;
    1606                     }
    1607                 }
    1608             break; }
     1868                mrc = TtmEnumTools(hwndTooltip, mp1, mp2);
     1869            break;
    16091870
    16101871            /*
    16111872             *@@ TTM_GETCURRENTTOOL:
    1612              *      this message retrieves the information that the tooltip control
    1613              *      maintains for the _current_ tool; that is, the one for which
    1614              *      the tooltip control is currently displaying text.
     1873             *      this message retrieves the information that the
     1874             *      tooltip control maintains for the _current_ tool;
     1875             *      that is, the one for which the tooltip control
     1876             *      is currently displaying text.
    16151877             *
    16161878             *      Parameters:
     
    16231885
    16241886            case TTM_GETCURRENTTOOL:        // done
    1625             {
    1626                 PTOOLINFO ptiTarget = (PTOOLINFO)mp2;
    1627                 mrc = (MPARAM)FALSE;
    1628                 if (ptiTarget)
    1629                 {
    1630                     if (pttd->ptiMouseOver)
    1631                     {
    1632                         memcpy(ptiTarget, pttd->ptiMouseOver, sizeof(TOOLINFO));
    1633                         mrc = (MPARAM)TRUE;
    1634                     }
    1635                 }
    1636             break; }
     1887                mrc = TtmGetCurrentTool(hwndTooltip, mp2);
     1888            break;
    16371889
    16381890            /*
     
    16441896
    16451897            case TTM_GETTOOLCOUNT:          // done
     1898            {
     1899                PTOOLTIPDATA pttd = (PTOOLTIPDATA)WinQueryWindowPtr(hwndTooltip, 1);
    16461900                mrc = (MPARAM)lstCountItems(&pttd->llTools);
    1647             break;
     1901            break; }
    16481902
    16491903            /*
     
    16651919
    16661920            case TTM_GETTOOLINFO:       // done
    1667             {
    1668                 PTOOLINFO ptiSearch = (PTOOLINFO)mp2;
    1669                 mrc = (MPARAM)FALSE;
    1670                 if (ptiSearch)
    1671                 {
    1672                     PLISTNODE pToolNode = lstQueryFirstNode(&pttd->llTools);
    1673                     while (pToolNode)
    1674                     {
    1675                         PTOOLINFO ptiThis = (PTOOLINFO)pToolNode->pItemData;
    1676                         if (    (ptiThis->hwndToolOwner == ptiSearch->hwndToolOwner)
    1677                              && (ptiThis->hwndTool == ptiSearch->hwndTool)
    1678                            )
    1679                         {
    1680                             // found:
    1681                             memcpy(ptiSearch, ptiThis, sizeof(TOOLINFO));
    1682                             mrc = (MPARAM)TRUE;
    1683                             break;
    1684                         }
    1685                         pToolNode = pToolNode->pNext;
    1686                     }
    1687                 }
    1688             break; }
     1921                mrc = TtmGetToolInfo(hwndTooltip, mp2);
     1922            break;
    16891923
    16901924            /*
     
    17121946             *
    17131947             *      This is not part of the Win95 message set but used
    1714              *      in the OS/2 implementation only. This calls TtmShowTooltip
    1715              *      in turn.
     1948             *      in the OS/2 implementation only. This calls
     1949             *      TtmShowTooltip in turn.
    17161950             */
    17171951
    17181952            case TTM_SHOWTOOLTIPNOW:
    1719                 // _Pmpf((__FUNCTION__ ": TTM_SHOWTOOLTIPNOW %d", mp1));
    1720                 TtmShowTooltip(hwndTooltip, pttd, (BOOL)mp1);
     1953                TtmShowTooltip(hwndTooltip, (BOOL)mp1);
    17211954            break;
    17221955
Note: See TracChangeset for help on using the changeset viewer.