Changeset 282 for trunk/src/3rdparty/os2/xsystray
- Timestamp:
- Nov 3, 2009, 2:39:49 AM (16 years ago)
- Location:
- trunk/src/3rdparty/os2/xsystray
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/3rdparty/os2/xsystray/xsystray.c
r281 r282 75 75 #pragma hdrstop // VAC++ keeps crashing otherwise 76 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 77 101 // primitive debug logging to a file 78 102 #if 0 … … 123 147 PSZ pszToolTip; 124 148 // icon tooltip (NULL if none) 149 150 125 151 BOOL bMemoryPoolGiven; 126 152 // TRUE if SYSTRAYDATA::pvMemoryPool is already given to … … 150 176 size_t cIconsMax; 151 177 // maximum number of icons pIcons can fit 178 179 152 180 PVOID pvMemoryPool; 153 181 // memory pool for NOTIFYDATA structures … … 207 235 INTCLASS_WIDGET_XSYSTRAY, // internal widget class name 208 236 HUMANSTR_WIDGET_XSYSTRAY, // widget class name displayed to user 209 WGTF_UNIQUEGLOBAL, // widget class flags 237 WGTF_UNIQUEGLOBAL | // widget class flags 238 WGTF_TOOLTIP, 210 239 NULL // no settings dialog 211 240 } … … 360 389 *pIdx = i; 361 390 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 362 478 } 363 479 … … 558 674 break; 559 675 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 } 562 725 563 726 return brc; … … 571 734 * the XCenter's center, icons go left to right. Otherwise, they go right 572 735 * to left. 736 737 738 573 739 */ 574 740 /* … … 695 861 696 862 POINTL ptl; 697 SWP swp;698 RECTL rcl;699 BOOL bLeftToRight;700 LONG y, lIconStep;701 size_t i;702 863 703 864 PICONDATA pIconData; … … 709 870 LOGF(("msg %x ptl %ld,%ld\n", msg, ptl.x, ptl.y)); 710 871 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) 716 874 return FALSE; // hit pad space 717 718 // detect the direction719 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 space729 }730 else731 {732 i = (swp.cx - ptl.x - 1) / lIconStep;733 if ((swp.cx - ptl.x - 1) % lIconStep < pSysTrayData->lIconPad)734 return FALSE; // hit pad space735 }736 if (i >= pSysTrayData->cIcons)737 return FALSE; // hit pad space738 739 pIconData = &pSysTrayData->pIcons[i];740 875 741 876 LOGF(("hwnd %x\n", pIconData->hwnd)); … … 785 920 786 921 return TRUE; 787 }788 789 static790 VOID FreeSysTrayData(PSYSTRAYDATA pSysTrayData)791 {792 // destroy the server793 if (pSysTrayData->hwndServer != NULLHANDLE)794 {795 WinDestroyWindow(pSysTrayData->hwndServer);796 pSysTrayData->hwndServer = NULLHANDLE;797 }798 799 // free all system tray data800 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);815 922 } 816 923 … … 1101 1208 1102 1209 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)); 1106 1214 1107 1215 pCtlData->bAcknowledged = TRUE; … … 1120 1228 if (pData) 1121 1229 { 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 1124 1260 WinDestroyPointer(pData->hIcon); 1125 1261 pData->hIcon = hIcon; … … 1156 1292 1157 1293 i = pSysTrayData->cIcons; 1158 ++pSysTrayData->cIcons;1159 1294 1160 1295 pData = &pSysTrayData->pIcons[i]; … … 1166 1301 pData->ulMsgId = pCtlData->u.icon.ulMsgId; 1167 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1168 1313 WgtXSysTrayUpdateAfterIconAddRemove(pWidget); 1314 1315 1169 1316 1170 1317 xrc = XST_OK; 1171 1318 } 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 1172 1361 } 1173 1362 break; … … 1201 1390 1202 1391 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 1203 1440 1204 1441 xrc = XST_OK; -
trunk/src/3rdparty/os2/xsystray/xsystray.h
r281 r282 47 47 SYSTRAYCMD_GETVERSION, 48 48 SYSTRAYCMD_ADDICON, 49 49 50 SYSTRAYCMD_REMOVEICON, 50 51 SYSTRAYCMD_SETTOOLTIP, … … 74 75 // command to execute, must always be set 75 76 HWND hwndSender; 76 // sender window, a must for SYSTRAYCMD_ADDICON, REMOVEICON,77 // SETTOOLTIP, SHOWBALLOON,HIDEBALLOON77 // sender window, a must for SYSTRAYCMD_ADDICON, EICON, 78 // HIDEBALLOON 78 79 union 79 80 { … … 90 91 USHORT usId; 91 92 HPOINTER hIcon; 93 92 94 ULONG ulMsgId; 93 95 } 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 102 97 } u; 103 98 -
trunk/src/3rdparty/os2/xsystray/xsystray_api.c
r281 r282 316 316 * Mouse wheel event in the icon area. param2 is a pointer to the 317 317 * XSTWHEELTMSG structure containing full message details. 318 319 320 321 318 322 */ 319 323 … … 321 325 USHORT usId, // in: icon ID to add 322 326 HPOINTER hIcon, // in: icon handle 327 323 328 ULONG ulMsgId, // in: message ID for notifications 324 329 ULONG ulFlags) // in: flags (not currently used, must be 0) … … 366 371 pData->ulCommand = SYSTRAYCMD_ADDICON; 367 372 pData->hwndSender = hwnd; 373 368 374 pData->u.icon.usId = usId; 369 375 pData->u.icon.hIcon = hIcon; 370 376 pData->u.icon.ulMsgId = ulMsgId; 377 378 379 380 381 382 383 384 385 386 371 387 372 388 xrc = SendSysTrayCtlMsg(pData); … … 425 441 426 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 478 479 480 481 482 483 484 427 485 *@@ xstRemoveSysTrayIcon: 428 486 * … … 498 556 */ 499 557 500 BOOL xstSetSysTrayIconToolTip(HWND hwnd, // in: window handle associated with the icon501 USHORT usId, // in: icon ID to set the tooltip for502 P SZ pszText)// in: tooltip text558 BOOL 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 503 561 { 504 562 BOOL brc; … … 509 567 pData->ulCommand = SYSTRAYCMD_SETTOOLTIP; 510 568 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'; 515 574 else 516 575 { 517 strncpy(pData->u. tooltip.szText, pszText,518 sizeof(pData->u. tooltip.szText) - 1);576 strncpy(pData->u., 577 sizeof(pData->u.) - 1); 519 578 // be on the safe side 520 pData->u. tooltip.szText[sizeof(pData->u.tooltip.szText) - 1] = '\0';579 pData->u.) - 1] = '\0'; 521 580 } 522 581 … … 528 587 } 529 588 530 BOOL xstShowSysTrayIconBalloon(HWND hwnd, USHORT usId, P SZ pszTitle, PSZ pszText,531 ULONG ulFlags, ULONG ulTimeout)589 BOOL xstShowSysTrayIconBalloon(HWND hwnd, USHORT usId, P, 590 ULONG ulFlags, ULONG ulTimeout) 532 591 { 533 592 // @todo implement … … 595 654 ULONG xstGetSysTrayMaxTextLen() 596 655 { 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 76 76 77 77 BOOL xstQuerySysTrayVersion(PULONG pulMajor, PULONG pulMinor, PULONG pulRevision); 78 BOOL xstAddSysTrayIcon(HWND hwnd, USHORT usId, HPOINTER hIcon, ULONG ulMsgId, 79 ULONG ulFlags); 78 BOOL xstAddSysTrayIcon(HWND hwnd, USHORT usId, HPOINTER hIcon, PCSZ pcszToolTip, 79 ULONG ulMsgId, ULONG ulFlags); 80 BOOL xstReplaceSysTrayIcon(HWND hwnd, USHORT usId, HPOINTER hIcon); 80 81 BOOL xstRemoveSysTrayIcon(HWND hwnd, USHORT usId); 81 BOOL xstSetSysTrayIconToolTip(HWND hwnd, USHORT usId, P SZ pszText);82 BOOL xstShowSysTrayIconBalloon(HWND hwnd, USHORT usId, P SZ pszTitle, PSZ pszText,83 ULONG ulFlags, ULONG ulTimeout);82 BOOL xstSetSysTrayIconToolTip(HWND hwnd, USHORT usId, P); 83 BOOL xstShowSysTrayIconBalloon(HWND hwnd, USHORT usId, P, 84 ULONG ulFlags, ULONG ulTimeout); 84 85 BOOL xstHideSysTrayIconBalloon(HWND hwnd, USHORT usId); 85 86
Note:
See TracChangeset
for help on using the changeset viewer.