tooltip.cpp 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. //#include <precomp.h>
  2. #include "./api.h"
  3. #include <api/wnd/api_wnd.h>
  4. #include "tooltip.h"
  5. #ifdef WASABI_COMPILE_CONFIG
  6. #include <api/config/items/attrint.h>
  7. #include <api/config/items/cfgitem.h>
  8. #endif
  9. #include <api/service/svc_enum.h>
  10. Tooltip::Tooltip(const wchar_t *txt)
  11. {
  12. WASABI_API_WND->appdeactivation_push_disallow(NULL);
  13. svc = NULL;
  14. if (!txt || !*txt) return ;
  15. #ifdef WASABI_COMPILE_CONFIG
  16. // {9149C445-3C30-4e04-8433-5A518ED0FDDE}
  17. const GUID uioptions_guid =
  18. { 0x9149c445, 0x3c30, 0x4e04, { 0x84, 0x33, 0x5a, 0x51, 0x8e, 0xd0, 0xfd, 0xde } };
  19. if (!_intVal(WASABI_API_CONFIG->config_getCfgItemByGuid(uioptions_guid), L"Enable tooltips"))
  20. {
  21. // tooltips disabled
  22. return ;
  23. }
  24. #endif
  25. waServiceFactory *svf = WASABI_API_SVC->service_enumService(WaSvc::TOOLTIPSRENDERER, 0);
  26. svc = castService<svc_toolTipsRenderer>(svf);
  27. if (!svc)
  28. {
  29. // no tooltips available!
  30. return ;
  31. }
  32. svc->spawnTooltip(txt);
  33. }
  34. Tooltip::~Tooltip()
  35. {
  36. if (svc != NULL)
  37. WASABI_API_SVC->service_release(svc);
  38. WASABI_API_WND->appdeactivation_pop_disallow(NULL);
  39. }