1
0

bucketitem.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #ifndef __BUCKETITEM_H
  2. #define __BUCKETITEM_H
  3. #include <bfc/common.h>
  4. #include <api/syscb/callbacks/wndcb.h>
  5. #include <api/wnd/wndclass/buttwnd.h>
  6. #include <bfc/depend.h>
  7. #include <api/wnd/notifmsg.h>
  8. template <class T> class BucketItemT : public T {
  9. public:
  10. BucketItemT(GUID g=INVALID_GUID, const wchar_t *text=NULL) : guid_target(g), target_txt(text) {
  11. setBorders(0);
  12. setHInstanceColorGroup(L"Thinger icons");
  13. }
  14. virtual ~BucketItemT() {
  15. }
  16. virtual void setBucketText(const wchar_t *txt) {
  17. notifyParent(ChildNotify::COMPONENTBUCKET_SETTEXT, reinterpret_cast<intptr_t>(txt), 0);
  18. }
  19. virtual void onLeftPush(int x, int y) {
  20. T::onLeftPush(x, y);
  21. if (guid_target != INVALID_GUID) {
  22. RECT r;
  23. getClientRect(&r);
  24. clientToScreen(&r);
  25. int newstatus = WASABI_API_WNDMGR->skinwnd_toggleByGuid(guid_target);
  26. setActivatedButton(newstatus);
  27. }
  28. }
  29. virtual int onShowWindow(GUID g, const wchar_t *groupid) {
  30. if (g == guid_target) setActivatedButton(1);
  31. return 1;
  32. }
  33. virtual int onHideWindow(GUID g, const wchar_t *groupid) {
  34. if (g == guid_target) setActivatedButton(0);
  35. return 1;
  36. }
  37. virtual void onEnterArea() {
  38. T::onEnterArea();
  39. if (!target_txt.isempty()) setBucketText(target_txt);
  40. }
  41. virtual void onLeaveArea() {
  42. T::onLeaveArea();
  43. if (!target_txt.isempty()) setBucketText(NULL);
  44. }
  45. void setAutoOpen(GUID g) {
  46. guid_target = g;
  47. }
  48. void setAutoText(const wchar_t *txt) {
  49. target_txt = txt;
  50. }
  51. private:
  52. GUID guid_target;
  53. StringW target_txt;
  54. };
  55. #define BUCKETITEM_PARENT ButtonWnd
  56. class BucketItem : public BucketItemT<BUCKETITEM_PARENT> {
  57. public:
  58. BucketItem(GUID g=INVALID_GUID, const wchar_t *text=NULL) : BucketItemT<ButtonWnd> (g, text) {}
  59. virtual ~BucketItem() {}
  60. };
  61. #endif // __BUCKETITEM_H