Ignore:
Timestamp:
Nov 3, 2009, 2:39:49 AM (16 years ago)
Author:
Dmitry A. Kuminov
Message:

3rdparty: os2/xsystray: Added new xstReplaceSysTrayIcon() API call, implemented xstSetSysTrayIconToolTip() API call.

Location:
trunk/src/3rdparty/os2/xsystray
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/3rdparty/os2/xsystray/xsystray.c

    r281 r282  
    7575#pragma hdrstop                     // VAC++ keeps crashing otherwise
    7676
     77
     78
     79
     80
     81
     82
     83
     84
     85
     86
     87
     88
     89
     90
     91
     92
     93
     94
     95
     96
     97
     98
     99
     100
    77101// primitive debug logging to a file
    78102#if 0
     
    123147    PSZ         pszToolTip;
    124148                // icon tooltip (NULL if none)
     149
     150
    125151    BOOL        bMemoryPoolGiven;
    126152                // TRUE if SYSTRAYDATA::pvMemoryPool is already given to
     
    150176    size_t      cIconsMax;
    151177                // maximum number of icons pIcons can fit
     178
     179
    152180    PVOID       pvMemoryPool;
    153181                // memory pool for NOTIFYDATA structures
     
    207235        INTCLASS_WIDGET_XSYSTRAY,   // internal widget class name
    208236        HUMANSTR_WIDGET_XSYSTRAY,   // widget class name displayed to user
    209         WGTF_UNIQUEGLOBAL,          // widget class flags
     237        WGTF_UNIQUEGLOBAL |         // widget class flags
     238        WGTF_TOOLTIP,
    210239        NULL                        // no settings dialog
    211240    }
     
    360389        *pIdx = i;
    361390    return NULL;
     391
     392
     393
     394
     395
     396
     397
     398
     399
     400
     401
     402
     403
     404
     405
     406
     407
     408
     409
     410
     411
     412
     413
     414
     415
     416
     417
     418
     419
     420
     421
     422
     423
     424
     425
     426
     427
     428
     429
     430
     431
     432
     433
     434
     435
     436
     437
     438
     439
     440
     441
     442
     443
     444
     445
     446
     447
     448
     449
     450
     451
     452
     453
     454
     455
     456
     457
     458
     459
     460
     461
     462
     463
     464
     465
     466
     467
     468
     469
     470
     471
     472
     473
     474
     475
     476
     477
    362478}
    363479
     
    558674            break;
    559675
    560         } // end switch (usNotifyCode)
    561     } // end if (usID == ID_XCENTER_CLIENT)
     676        }
     677    }
     678    else if (usID == ID_XCENTER_TOOLTIP)
     679    {
     680        PICONDATA pIconData;
     681        POINTL ptl;
     682
     683        WinQueryMsgPos(pWidget->habWidget, &ptl);
     684        // make the coordinates systray-relative
     685        WinMapWindowPoints(HWND_DESKTOP, pWidget->hwndWidget, &ptl, 1);
     686
     687        pIconData = FindIconDataAtPt(pWidget, &ptl, NULL);
     688
     689        switch (usNotifyCode)
     690        {
     691            case TTN_NEEDTEXT:
     692            {
     693                LOGF(("TTN_NEEDTEXT\n"));
     694
     695                PTOOLTIPTEXT pttt = (PTOOLTIPTEXT)mp2;
     696                pttt->ulFormat = TTFMT_PSZ;
     697
     698                if (!pIconData || !pIconData->pszToolTip)
     699                    pttt->pszText = NULL;
     700                else
     701                {
     702                    strncpy(pSysTrayData->szToolTip, pIconData->pszToolTip,
     703                            sizeof(pSysTrayData->szToolTip) - 1);
     704                    // be on the safe side
     705                    pSysTrayData->szToolTip[sizeof(pSysTrayData->szToolTip) - 1] = '\0';
     706
     707                    pttt->pszText = pSysTrayData->szToolTip;
     708                }
     709
     710                LOGF((" pszText '%s'\n", pttt->pszText));
     711            }
     712            break;
     713
     714            case TTN_SHOW:
     715                if (pIconData)
     716                    pIconData->bIsToolTipShowing = TRUE;
     717            break;
     718
     719            case TTN_POP:
     720                if (pIconData)
     721                    pIconData->bIsToolTipShowing = FALSE;
     722            break;
     723        }
     724    }
    562725
    563726    return brc;
     
    571734 *      the XCenter's center, icons go left to right. Otherwise, they go right
    572735 *      to left.
     736
     737
     738
    573739 */
    574740/*
     
    695861
    696862    POINTL  ptl;
    697     SWP     swp;
    698     RECTL   rcl;
    699     BOOL    bLeftToRight;
    700     LONG    y, lIconStep;
    701     size_t  i;
    702863
    703864    PICONDATA   pIconData;
     
    709870    LOGF(("msg %x ptl %ld,%ld\n", msg, ptl.x, ptl.y));
    710871
    711     WinQueryWindowPos(hwnd, &swp);
    712     WinQueryWindowRect(pWidget->pGlobals->hwndClient, &rcl);
    713 
    714     y = (swp.cy - pSysTrayData->lIconHeight) / 2;
    715     if (ptl.y < y || ptl.y >= y + pSysTrayData->lIconHeight)
     872    pIconData = FindIconDataAtPt(pWidget, &ptl, NULL);
     873    if (!pIconData)
    716874        return FALSE; // hit pad space
    717 
    718     // detect the direction
    719     bLeftToRight = swp.x + swp.cx / 2 < (rcl.xRight / 2);
    720 
    721     lIconStep = pSysTrayData->lIconWidth + pSysTrayData->lIconPad;
    722 
    723     // which icon is that?
    724     if (bLeftToRight)
    725     {
    726         i = ptl.x / lIconStep;
    727         if (ptl.x % lIconStep < pSysTrayData->lIconPad)
    728             return FALSE; // hit pad space
    729     }
    730     else
    731     {
    732         i = (swp.cx - ptl.x - 1) / lIconStep;
    733         if ((swp.cx - ptl.x - 1) % lIconStep < pSysTrayData->lIconPad)
    734             return FALSE; // hit pad space
    735     }
    736     if (i >= pSysTrayData->cIcons)
    737         return FALSE; // hit pad space
    738 
    739     pIconData = &pSysTrayData->pIcons[i];
    740875
    741876    LOGF(("hwnd  %x\n", pIconData->hwnd));
     
    785920
    786921    return TRUE;
    787 }
    788 
    789 static
    790 VOID FreeSysTrayData(PSYSTRAYDATA pSysTrayData)
    791 {
    792     // destroy the server
    793     if (pSysTrayData->hwndServer != NULLHANDLE)
    794     {
    795         WinDestroyWindow(pSysTrayData->hwndServer);
    796         pSysTrayData->hwndServer = NULLHANDLE;
    797     }
    798 
    799     // free all system tray data
    800     if (pSysTrayData->pvMemoryPool)
    801     {
    802         DosFreeMem(pSysTrayData->pvMemoryPool);
    803     }
    804     if (pSysTrayData->pIcons)
    805     {
    806         size_t i;
    807         for (i = 0; i < pSysTrayData->cIcons; ++i)
    808             FreeIconData(&pSysTrayData->pIcons[i]);
    809         pSysTrayData->cIcons = 0;
    810         free(pSysTrayData->pIcons);
    811         pSysTrayData->pIcons = NULL;
    812     }
    813 
    814     free(pSysTrayData);
    815922}
    816923
     
    11011208
    11021209            LOGF(("SYSTRAYCMD_ADDICON\n"));
    1103             LOGF((" hwnd  %x\n", pCtlData->hwndSender));
    1104             LOGF((" usId  %d\n", pCtlData->u.icon.usId));
    1105             LOGF((" hIcon %x\n", pCtlData->u.icon.hIcon));
     1210            LOGF((" hwnd       %x\n", pCtlData->hwndSender));
     1211            LOGF((" usId       %d\n", pCtlData->u.icon.usId));
     1212            LOGF((" hIcon      %x\n", pCtlData->u.icon.hIcon));
     1213            LOGF((" szToolTip  '%s'\n", pCtlData->u.icon.szToolTip));
    11061214
    11071215            pCtlData->bAcknowledged = TRUE;
     
    11201228            if (pData)
    11211229            {
    1122                 LOGF((" Updating hIcon %x\n", hIcon));
    1123 
     1230                LOGF((" Replacing with hIcon %x\n", hIcon));
     1231
     1232                // try update the tooltip first
     1233                free(pData->pszToolTip);
     1234                pData->pszToolTip = NULL;
     1235                if (pCtlData->u.icon.szToolTip[0] != '\0')
     1236                {
     1237                    pData->pszToolTip = strdup(pCtlData->u.icon.szToolTip);
     1238                    if (!pData->pszToolTip)
     1239                    {
     1240                        WinDestroyPointer(hIcon);
     1241                        break;
     1242                    }
     1243                }
     1244
     1245                if (pData->bIsToolTipShowing)
     1246                {
     1247                    if (pData->pszToolTip)
     1248                        // update the tooltip on screen
     1249                        WinSendMsg(pWidget->pGlobals->hwndTooltip,
     1250                                   TTM_UPDATETIPTEXT,
     1251                                   (MPARAM)pData->pszToolTip, 0);
     1252                    else
     1253                        // hide the tooltip
     1254                        WinSendMsg(pWidget->pGlobals->hwndTooltip,
     1255                                   TTM_SHOWTOOLTIPNOW,
     1256                                   (MPARAM)FALSE, 0);
     1257                }
     1258
     1259                // now update the icon
    11241260                WinDestroyPointer(pData->hIcon);
    11251261                pData->hIcon = hIcon;
     
    11561292
    11571293                i = pSysTrayData->cIcons;
    1158                 ++pSysTrayData->cIcons;
    11591294
    11601295                pData = &pSysTrayData->pIcons[i];
     
    11661301                pData->ulMsgId = pCtlData->u.icon.ulMsgId;
    11671302
     1303
     1304
     1305
     1306
     1307
     1308
     1309
     1310
     1311
     1312
    11681313                WgtXSysTrayUpdateAfterIconAddRemove(pWidget);
     1314
     1315
    11691316
    11701317                xrc = XST_OK;
    11711318            }
     1319
     1320
     1321
     1322
     1323
     1324
     1325
     1326
     1327
     1328
     1329
     1330
     1331
     1332
     1333
     1334
     1335
     1336
     1337
     1338
     1339
     1340
     1341
     1342
     1343
     1344
     1345
     1346
     1347
     1348
     1349
     1350
     1351
     1352
     1353
     1354
     1355
     1356
     1357
     1358
     1359
     1360
    11721361        }
    11731362        break;
     
    12011390
    12021391                WgtXSysTrayUpdateAfterIconAddRemove(pWidget);
     1392
     1393
     1394
     1395
     1396
     1397
     1398
     1399
     1400
     1401
     1402
     1403
     1404
     1405
     1406
     1407
     1408
     1409
     1410
     1411
     1412
     1413
     1414
     1415
     1416
     1417
     1418
     1419
     1420
     1421
     1422
     1423
     1424
     1425
     1426
     1427
     1428
     1429
     1430
     1431
     1432
     1433
     1434
     1435
     1436
     1437
     1438
     1439
    12031440
    12041441                xrc = XST_OK;
  • trunk/src/3rdparty/os2/xsystray/xsystray.h

    r281 r282  
    4747    SYSTRAYCMD_GETVERSION,
    4848    SYSTRAYCMD_ADDICON,
     49
    4950    SYSTRAYCMD_REMOVEICON,
    5051    SYSTRAYCMD_SETTOOLTIP,
     
    7475                // command to execute, must always be set
    7576    HWND        hwndSender;
    76                 // sender window, a must for SYSTRAYCMD_ADDICON, REMOVEICON,
    77                 // SETTOOLTIP, SHOWBALLOON, HIDEBALLOON
     77                // sender window, a must for SYSTRAYCMD_ADDICON, EICON,
     78                // HIDEBALLOON
    7879    union
    7980    {
     
    9091            USHORT      usId;
    9192            HPOINTER    hIcon;
     93
    9294            ULONG       ulMsgId;
    9395        } icon;
    94           // used by SYSTRAYCMD_ADDICON, SYSTRAYCMD_REMOVEICON
    95 
    96         struct
    97         {
    98             USHORT  usId;
    99             CHAR    szText[512];
    100         } tooltip;
    101 
     96          // used by SYSTRAYCMD_ADDICON, _CHANGEICON, _REMOVEICON, _SETTOOLTIP
    10297    } u;
    10398
  • trunk/src/3rdparty/os2/xsystray/xsystray_api.c

    r281 r282  
    316316 *              Mouse wheel event in the icon area. param2 is a pointer to the
    317317 *              XSTWHEELTMSG structure containing full message details.
     318
     319
     320
     321
    318322 */
    319323
     
    321325                       USHORT usId,     // in: icon ID to add
    322326                       HPOINTER hIcon,  // in: icon handle
     327
    323328                       ULONG ulMsgId,   // in: message ID for notifications
    324329                       ULONG ulFlags)   // in: flags (not currently used, must be 0)
     
    366371        pData->ulCommand = SYSTRAYCMD_ADDICON;
    367372        pData->hwndSender = hwnd;
     373
    368374        pData->u.icon.usId = usId;
    369375        pData->u.icon.hIcon = hIcon;
    370376        pData->u.icon.ulMsgId = ulMsgId;
     377
     378
     379
     380
     381
     382
     383
     384
     385
     386
    371387
    372388        xrc = SendSysTrayCtlMsg(pData);
     
    425441
    426442/*
     443
     444
     445
     446
     447
     448
     449
     450
     451
     452
     453
     454
     455
     456
     457
     458
     459
     460
     461
     462
     463
     464
     465
     466
     467
     468
     469
     470
     471
     472
     473
     474
     475
     476
     477
     478
     479
     480
     481
     482
     483
     484
    427485 *@@ xstRemoveSysTrayIcon:
    428486 *
     
    498556 */
    499557
    500 BOOL xstSetSysTrayIconToolTip(HWND hwnd,    // in: window handle associated with the icon
    501                               USHORT usId,  // in: icon ID to set the tooltip for
    502                               PSZ pszText) // in: tooltip text
     558BOOL xstSetSysTrayIconToolTip(HWND hwnd,    // in: window handle associated with the icon
     559                              USHORT usId,  // in: icon ID to set the tooltip for
     560                              P // in: tooltip text
    503561{
    504562    BOOL brc;
     
    509567    pData->ulCommand = SYSTRAYCMD_SETTOOLTIP;
    510568    pData->hwndSender = hwnd;
    511     pData->u.tooltip.usId = usId;
    512 
    513     if (pszText == NULL)
    514         pData->u.tooltip.szText[0] = '\0';
     569    pData->u.icon.usId = usId;
     570
     571
     572    if (!pcszToolTip)
     573        pData->u.icon.szToolTip[0] = '\0';
    515574    else
    516575    {
    517         strncpy(pData->u.tooltip.szText, pszText,
    518                 sizeof(pData->u.tooltip.szText) - 1);
     576        strncpy(pData->u.,
     577                sizeof(pData->u.) - 1);
    519578        // be on the safe side
    520         pData->u.tooltip.szText[sizeof(pData->u.tooltip.szText) - 1] = '\0';
     579        pData->u.) - 1] = '\0';
    521580    }
    522581
     
    528587}
    529588
    530 BOOL xstShowSysTrayIconBalloon(HWND hwnd, USHORT usId, PSZ pszTitle, PSZ pszText,
    531                                ULONG ulFlags, ULONG ulTimeout)
     589BOOL xstShowSysTrayIconBalloon(HWND hwnd, USHORT usId, P,
     590                               ULONG ulFlags, ULONG ulTimeout)
    532591{
    533592    // @todo implement
     
    595654ULONG xstGetSysTrayMaxTextLen()
    596655{
    597     return sizeof(((PSYSTRAYCTLDATA)0)->u.tooltip.szText);
    598 }
    599 
     656    return sizeof(((PSYSTRAYCTLDATA)0)->u.);
     657}
     658
  • trunk/src/3rdparty/os2/xsystray/xsystray_api.h

    r280 r282  
    7676
    7777BOOL xstQuerySysTrayVersion(PULONG pulMajor, PULONG pulMinor, PULONG pulRevision);
    78 BOOL xstAddSysTrayIcon(HWND hwnd, USHORT usId, HPOINTER hIcon, ULONG ulMsgId,
    79                        ULONG ulFlags);
     78BOOL xstAddSysTrayIcon(HWND hwnd, USHORT usId, HPOINTER hIcon, PCSZ pcszToolTip,
     79                       ULONG ulMsgId, ULONG ulFlags);
     80BOOL xstReplaceSysTrayIcon(HWND hwnd, USHORT usId, HPOINTER hIcon);
    8081BOOL xstRemoveSysTrayIcon(HWND hwnd, USHORT usId);
    81 BOOL xstSetSysTrayIconToolTip(HWND hwnd, USHORT usId, PSZ pszText);
    82 BOOL xstShowSysTrayIconBalloon(HWND hwnd, USHORT usId, PSZ pszTitle, PSZ pszText,
    83                                ULONG ulFlags, ULONG ulTimeout);
     82BOOL xstSetSysTrayIconToolTip(HWND hwnd, USHORT usId, P);
     83BOOL xstShowSysTrayIconBalloon(HWND hwnd, USHORT usId, P,
     84                               ULONG ulFlags, ULONG ulTimeout);
    8485BOOL xstHideSysTrayIconBalloon(HWND hwnd, USHORT usId);
    8586
Note: See TracChangeset for help on using the changeset viewer.