summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2013-01-09 11:25:31 +0000
committerCaolán McNamara <caolanm@redhat.com>2013-01-09 11:40:54 +0000
commit7e2b1e9218b194ba244dfa23089ec30fd978f3de (patch)
treef4f6ae6b80d6b6e2a762bd55c85aa30512d25236 /vcl
parent397722b55e06223377f812e29f3b51d997b837f5 (diff)
implement a VclEventBox akin to GtkEventBox and map
rework EventBox to inherit from VclBin and rebase SwFrmCtrlWindow on top of it Change-Id: I25f037b33bf244d3d39f57bfe11cabfaf992bf1c
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/vcl/layout.hxx44
-rw-r--r--vcl/source/window/builder.cxx4
-rw-r--r--vcl/source/window/layout.cxx49
3 files changed, 96 insertions, 1 deletions
diff --git a/vcl/inc/vcl/layout.hxx b/vcl/inc/vcl/layout.hxx
index d9c5e6352a7f..9beee36e76f7 100644
--- a/vcl/inc/vcl/layout.hxx
+++ b/vcl/inc/vcl/layout.hxx
@@ -529,6 +529,50 @@ private:
ScrollBar m_aHScroll;
};
+//Enforces that its children are always the same size as itself.
+//Intercepts any Commands intended for its children.
+//
+//by default the Commands are discarded, inherit from this
+//and implement "Command" to get them
+class VCL_DLLPUBLIC VclEventBox : public VclBin
+{
+private:
+ //Any Commands an EventBoxHelper receives are forwarded to its parent
+ //The VclEventBox ensures that m_aEventBoxHelper is the
+ //first child and is transparent, but covers the rest of the children
+ class EventBoxHelper : public Window
+ {
+ public:
+ EventBoxHelper(Window* pParent)
+ : Window(pParent, 0)
+ {
+ SetSizePixel(pParent->GetSizePixel());
+ EnableChildTransparentMode();
+ SetPaintTransparent(true);
+ SetBackground();
+ }
+ virtual void Command(const CommandEvent& rCEvt)
+ {
+ GetParent()->Command(rCEvt);
+ }
+ };
+
+ EventBoxHelper m_aEventBoxHelper;
+public:
+ VclEventBox(Window* pParent)
+ : VclBin(pParent)
+ , m_aEventBoxHelper(this)
+ {
+ m_aEventBoxHelper.Show();
+ }
+ virtual Window *get_child();
+ virtual const Window *get_child() const;
+ virtual Size calculateRequisition() const;
+ virtual void setAllocation(const Size &rAllocation);
+
+ virtual void Command(const CommandEvent& rCEvt);
+};
+
// retro-fitting utilities //
//Get a Size which is large enough to contain all children with
diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index 5e6fc5ce9672..18731987e236 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -937,6 +937,10 @@ Window *VclBuilder::makeObject(Window *pParent, const OString &name, const OStri
{
pWindow = new VclScrolledWindow(pParent);
}
+ else if (name == "GtkEventBox")
+ {
+ pWindow = new VclEventBox(pParent);
+ }
else if (name == "GtkEntry")
{
pWindow = new Edit(pParent, WB_LEFT|WB_VCENTER|WB_BORDER|WB_3DLOOK);
diff --git a/vcl/source/window/layout.cxx b/vcl/source/window/layout.cxx
index 0b01c6acbd3b..6a071b188124 100644
--- a/vcl/source/window/layout.cxx
+++ b/vcl/source/window/layout.cxx
@@ -17,7 +17,7 @@ VclContainer::VclContainer(Window *pParent, WinBits nStyle)
{
ImplInit(pParent, nStyle, NULL);
EnableChildTransparentMode();
- SetPaintTransparent(sal_True);
+ SetPaintTransparent(true);
SetBackground();
}
@@ -1331,6 +1331,53 @@ bool VclScrolledWindow::set_property(const rtl::OString &rKey, const rtl::OStrin
return bRet;
}
+const Window *VclEventBox::get_child() const
+{
+ const WindowImpl* pWindowImpl = ImplGetWindowImpl();
+
+ assert(pWindowImpl->mpFirstChild == &m_aEventBoxHelper);
+
+ return pWindowImpl->mpFirstChild->GetWindow(WINDOW_NEXT);
+}
+
+Window *VclEventBox::get_child()
+{
+ return const_cast<Window*>(const_cast<const VclEventBox*>(this)->get_child());
+}
+
+void VclEventBox::setAllocation(const Size& rAllocation)
+{
+ Point aChildPos(0, 0);
+ for (Window *pChild = GetWindow(WINDOW_FIRSTCHILD); pChild; pChild = pChild->GetWindow(WINDOW_NEXT))
+ {
+ if (!pChild->IsVisible())
+ continue;
+ setLayoutAllocation(*pChild, aChildPos, rAllocation);
+ }
+}
+
+Size VclEventBox::calculateRequisition() const
+{
+ Size aRet(0, 0);
+
+ for (const Window* pChild = get_child(); pChild;
+ pChild = pChild->GetWindow(WINDOW_NEXT))
+ {
+ if (!pChild->IsVisible())
+ continue;
+ Size aChildSize = getLayoutRequisition(*pChild);
+ aRet.Width() = std::max(aRet.Width(), aChildSize.Width());
+ aRet.Height() = std::max(aRet.Height(), aChildSize.Height());
+ }
+
+ return aRet;
+}
+
+void VclEventBox::Command(const CommandEvent&)
+{
+ //discard events by default to block them reaching children
+}
+
Size getLegacyBestSizeForChildren(const Window &rWindow)
{
Rectangle aBounds;