From 20d28e80a5c861a9d5f449ea911ab75b4f37ad0d Mon Sep 17 00:00:00 2001 From: Jef Date: Tue, 24 Sep 2024 14:54:57 +0200 Subject: Initial community commit --- Src/Wasabi/api/wnd/bucketitem.h | 76 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 Src/Wasabi/api/wnd/bucketitem.h (limited to 'Src/Wasabi/api/wnd/bucketitem.h') diff --git a/Src/Wasabi/api/wnd/bucketitem.h b/Src/Wasabi/api/wnd/bucketitem.h new file mode 100644 index 00000000..4f0455d1 --- /dev/null +++ b/Src/Wasabi/api/wnd/bucketitem.h @@ -0,0 +1,76 @@ +#ifndef __BUCKETITEM_H +#define __BUCKETITEM_H + +#include +#include +#include +#include +#include + +template class BucketItemT : public T { + public: + BucketItemT(GUID g=INVALID_GUID, const wchar_t *text=NULL) : guid_target(g), target_txt(text) { + setBorders(0); + setHInstanceColorGroup(L"Thinger icons"); + } + + virtual ~BucketItemT() { + } + + virtual void setBucketText(const wchar_t *txt) { + notifyParent(ChildNotify::COMPONENTBUCKET_SETTEXT, reinterpret_cast(txt), 0); + } + virtual void onLeftPush(int x, int y) { + T::onLeftPush(x, y); + if (guid_target != INVALID_GUID) { + RECT r; + getClientRect(&r); + clientToScreen(&r); + int newstatus = WASABI_API_WNDMGR->skinwnd_toggleByGuid(guid_target); + setActivatedButton(newstatus); + } + } + + virtual int onShowWindow(GUID g, const wchar_t *groupid) { + if (g == guid_target) setActivatedButton(1); + return 1; + } + + virtual int onHideWindow(GUID g, const wchar_t *groupid) { + if (g == guid_target) setActivatedButton(0); + return 1; + } + + virtual void onEnterArea() { + T::onEnterArea(); + if (!target_txt.isempty()) setBucketText(target_txt); + } + + virtual void onLeaveArea() { + T::onLeaveArea(); + if (!target_txt.isempty()) setBucketText(NULL); + } + + void setAutoOpen(GUID g) { + guid_target = g; + } + + void setAutoText(const wchar_t *txt) { + target_txt = txt; + } + + private: + GUID guid_target; + StringW target_txt; +}; + +#define BUCKETITEM_PARENT ButtonWnd +class BucketItem : public BucketItemT { + public: + BucketItem(GUID g=INVALID_GUID, const wchar_t *text=NULL) : BucketItemT (g, text) {} + virtual ~BucketItem() {} +}; + + +#endif // __BUCKETITEM_H + -- cgit