diff options
author | Jef <jef@targetspot.com> | 2024-09-24 08:54:57 -0400 |
---|---|---|
committer | Jef <jef@targetspot.com> | 2024-09-24 08:54:57 -0400 |
commit | 20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (patch) | |
tree | 12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/Wasabi/api/wnd/wndclass/virtualhostwnd.cpp | |
parent | 537bcbc86291b32fc04ae4133ce4d7cac8ebe9a7 (diff) | |
download | winamp-20d28e80a5c861a9d5f449ea911ab75b4f37ad0d.tar.gz |
Initial community commit
Diffstat (limited to 'Src/Wasabi/api/wnd/wndclass/virtualhostwnd.cpp')
-rw-r--r-- | Src/Wasabi/api/wnd/wndclass/virtualhostwnd.cpp | 198 |
1 files changed, 198 insertions, 0 deletions
diff --git a/Src/Wasabi/api/wnd/wndclass/virtualhostwnd.cpp b/Src/Wasabi/api/wnd/wndclass/virtualhostwnd.cpp new file mode 100644 index 00000000..ef91ebc1 --- /dev/null +++ b/Src/Wasabi/api/wnd/wndclass/virtualhostwnd.cpp @@ -0,0 +1,198 @@ +#include "precomp.h" +#include "virtualhostwnd.h" +#include <tataki/canvas/ifc_canvas.h> +#include <tataki/region/api_region.h> + +VirtualHostWnd::VirtualHostWnd() { + group = new GuiObjectWnd(); + fittoclient = 0; + xoffset = 0; + yoffset = 0; + groupwidth = 0; + groupheight = 0; + scripts_enabled = 1; +} + +VirtualHostWnd::~VirtualHostWnd() { + delete group; +} + +int VirtualHostWnd::onInit() { + GuiObjectWnd::onInit(); + group->setVirtual(0); + group->setStartHidden(1); + group->setParent(this); + group->init(this); + group->deferedInvalidate(); + group->setCloaked(1); // magic! + group->setVisible(1); + return 1; +} + +void VirtualHostWnd::virtualhostwnd_setContent(const char *_groupname) { + group->setContent(_groupname); + if (isPostOnInit()) + virtualhostwnd_onNewContent(); +} + +void VirtualHostWnd::virtualhostwnd_setContent(SkinItem *groupitem) { + group->setContentBySkinItem(groupitem); + if (isPostOnInit()) + virtualhostwnd_onNewContent(); +} + +void VirtualHostWnd::virtualhostwnd_onNewContent() { +} + +#ifdef WASABI_COMPILE_SCRIPT +ScriptObject *VirtualHostWnd::virtualhostwnd_findScriptObject(const char *object_id) { + return group->findScriptObject(object_id); +} +#endif + +#ifdef WASABI_COMPILE_SKIN +GuiObject *VirtualHostWnd::virtualhostwnd_getContent() { + return group->getContent(); +} + +ScriptObject *VirtualHostWnd::virtualhostwnd_getContentScriptObject() { + return group->getContentScriptObject(); +} + +GuiObject *VirtualHostWnd::virtualhostwnd_findObject(const char *object_id) { + return group->findObject(object_id); +} +#endif + +api_window *VirtualHostWnd::virtualhostwnd_getContentRootWnd() { + return group->getContentRootWnd(); +} + +int VirtualHostWnd::onPaint(Canvas *c) { + GuiObjectWnd::onPaint(c); + + virtualhostwnd_onPaintBackground(c); + + if (group == NULL) return 1; + + RECT wr; + Canvas *cv = NULL; + + group->getNonClientRect(&wr); + group->paint(NULL, NULL); + + cv = group->getFrameBuffer(); + + if (cv != NULL) { + BltCanvas *bltcanvas = static_cast<BltCanvas *>(cv); // HACK! + bltcanvas->/*getSkinBitmap()->*/blitAlpha(c, xoffset, yoffset); + } + return 1; +} + +void VirtualHostWnd::virtualhostwnd_onPaintBackground(Canvas *c) { + RECT r; + getClientRect(&r); + c->fillRect(&r, RGB(255,255,255)); +} + +int VirtualHostWnd::onResize() { + GuiObjectWnd::onResize(); + if (group != NULL) { + RECT r; + getClientRect(&r); + if (fittoclient) { + xoffset = 0; + yoffset = 0; + groupwidth = r.right-r.left; + groupheight = r.bottom-r.top; + } else { + groupwidth = group->getGuiObject()->guiobject_getAutoWidth(); + groupheight = group->getGuiObject()->guiobject_getAutoHeight(); + if (groupwidth == AUTOWH) groupwidth = 320; + if (groupheight == AUTOWH) groupheight = 200; + int cw = r.right-r.left; + int ch = r.bottom-r.top; + xoffset = (cw - groupwidth)/2; + yoffset = (ch - groupheight)/2; + } + group->resize(xoffset+r.left, yoffset+r.top, groupwidth, groupheight); + } + return 1; +} + +void VirtualHostWnd::virtualhostwnd_getContentRect(RECT *r) { + ASSERT(r != NULL); + getClientRect(r); + r->left += xoffset; + r->top += yoffset; + r->right = r->left + groupwidth; + r->bottom = r->top + groupheight; +} + + +void VirtualHostWnd::virtualhostwnd_fitToClient(int fit) { + fittoclient = fit; + if (isPostOnInit()) { + onResize(); + invalidate(); + } +} + +void VirtualHostWnd::onChildInvalidate(api_region *r, api_window *who) { + GuiObjectWnd::onChildInvalidate(r, who); + api_region *clone = r->clone(); + clone->offset(xoffset, yoffset); + invalidateRgn(clone); + r->disposeClone(clone); +} + +int VirtualHostWnd::onLeftButtonDown(int x, int y) { + // DO NOT CALL GuiObjectWnd::onLeftButtonDown(x, y); + x -= xoffset; + y -= yoffset; + return group->wndProc(group->gethWnd(), WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM(x, y)); +} + +int VirtualHostWnd::onLeftButtonUp(int x, int y){ + // DO NOT CALL GuiObjectWnd::onLeftButtonUp(x, y); + x -= xoffset; + y -= yoffset; + return group->wndProc(group->gethWnd(), WM_LBUTTONUP, 0, MAKELPARAM(x, y)); +} + +int VirtualHostWnd::onRightButtonDown(int x, int y){ + // DO NOT CALL GuiObjectWnd::onRightButtonDown(x, y); + x -= xoffset; + y -= yoffset; + return group->wndProc(group->gethWnd(), WM_RBUTTONDOWN, MK_RBUTTON, MAKELPARAM(x, y)); +} + +int VirtualHostWnd::onRightButtonUp(int x, int y){ + // DO NOT CALL GuiObjectWnd::onRightButtonUp(x, y); + x -= xoffset; + y -= yoffset; + return group->wndProc(group->gethWnd(), WM_RBUTTONUP, 0, MAKELPARAM(x, y)); +} + +int VirtualHostWnd::onLeftButtonDblClk(int x, int y){ + // DO NOT CALL GuiObjectWnd::onLeftButtonDblClk(x, y); + x -= xoffset; + y -= yoffset; + return group->wndProc(group->gethWnd(), WM_RBUTTONDBLCLK, 0, MAKELPARAM(x, y)); +} + +int VirtualHostWnd::onRightButtonDblClk(int x, int y){ + // DO NOT CALL GuiObjectWnd::onRightButtonDblClk(x, y); + x -= xoffset; + y -= yoffset; + return group->wndProc(group->gethWnd(), WM_LBUTTONDBLCLK, 0, MAKELPARAM(x, y)); +} + +int VirtualHostWnd::onMouseMove(int x, int y){ + // DO NOT CALL GuiObjectWnd::onMouseMove(x, y); + x -= xoffset; + y -= yoffset; + return group->wndProc(group->gethWnd(), WM_MOUSEMOVE, 0, MAKELPARAM(x, y)); +} + |