[Libreoffice-commits] .: Branch 'feature/cmclayouttrans' - vcl/inc vcl/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Thu Aug 23 08:43:45 PDT 2012
vcl/inc/vcl/layout.hxx | 10 -----
vcl/inc/vcl/window.hxx | 16 ++++++++
vcl/inc/window.h | 5 ++
vcl/source/window/layout.cxx | 37 +++++++++-----------
vcl/source/window/window.cxx | 5 ++
vcl/source/window/window2.cxx | 75 ++++++++++++++++++++++++++++++++++++++++++
6 files changed, 117 insertions(+), 31 deletions(-)
New commits:
commit 6bbcb2efa300b285e6fcfb545641d530c47cc173
Author: Caolán McNamara <caolanm at redhat.com>
Date: Thu Aug 23 16:43:09 2012 +0100
add left/right/top/bottom margin support
Change-Id: Ia43941071f3e1f1a364558e93928bce094d4c81f
diff --git a/vcl/inc/vcl/layout.hxx b/vcl/inc/vcl/layout.hxx
index c7af5b9..1d1653a 100644
--- a/vcl/inc/vcl/layout.hxx
+++ b/vcl/inc/vcl/layout.hxx
@@ -42,16 +42,7 @@ public:
virtual void SetPosSizePixel(const Point& rNewPos, const Size& rNewSize);
virtual void SetPosPixel(const Point& rAllocPos);
virtual void SetSizePixel(const Size& rAllocation);
- virtual bool set_property(const rtl::OString &rKey, const rtl::OString &rValue);
- void set_border_width(int nBorderWidth)
- {
- m_nBorderWidth = nBorderWidth;
- }
- int get_border_width() const
- {
- return m_nBorderWidth;
- }
void markLayoutDirty()
{
m_bLayoutDirty = true;
@@ -60,7 +51,6 @@ protected:
virtual Size calculateRequisition() const = 0;
virtual void setAllocation(const Size &rAllocation) = 0;
private:
- int m_nBorderWidth;
bool m_bLayoutDirty;
};
diff --git a/vcl/inc/vcl/window.hxx b/vcl/inc/vcl/window.hxx
index 0f9c8a5..8ef3ce4 100644
--- a/vcl/inc/vcl/window.hxx
+++ b/vcl/inc/vcl/window.hxx
@@ -1187,6 +1187,21 @@ public:
*/
void set_fill(bool bFill);
+ void set_border_width(sal_Int32 nBorderWidth);
+ sal_Int32 get_border_width() const;
+
+ void set_margin_left(sal_Int32 nWidth);
+ sal_Int32 get_margin_left() const;
+
+ void set_margin_right(sal_Int32 nWidth);
+ sal_Int32 get_margin_right() const;
+
+ void set_margin_top(sal_Int32 nWidth);
+ sal_Int32 get_margin_top() const;
+
+ void set_margin_bottom(sal_Int32 nWidth);
+ sal_Int32 get_margin_bottom() const;
+
/*
* Gets how the widget is packed with reference to the start or end of the parent
*/
@@ -1247,7 +1262,6 @@ public:
*/
void set_grid_top_attach(sal_Int32 nAttach);
-
/*
* Sets a widget property
*
diff --git a/vcl/inc/window.h b/vcl/inc/window.h
index cf27c16..dd7718b 100644
--- a/vcl/inc/window.h
+++ b/vcl/inc/window.h
@@ -323,6 +323,11 @@ public:
sal_Int32 mnGridLeftAttach;
sal_Int32 mnGridTopAttach;
sal_Int32 mnGridWidth;
+ sal_Int32 mnBorderWidth;
+ sal_Int32 mnMarginLeft;
+ sal_Int32 mnMarginRight;
+ sal_Int32 mnMarginTop;
+ sal_Int32 mnMarginBottom;
sal_uInt8 mbFrame:1,
mbBorderWin:1,
mbOverlapWin:1,
diff --git a/vcl/source/window/layout.cxx b/vcl/source/window/layout.cxx
index 2290edd..303f057 100644
--- a/vcl/source/window/layout.cxx
+++ b/vcl/source/window/layout.cxx
@@ -32,7 +32,6 @@
VclContainer::VclContainer(Window *pParent)
: Window(WINDOW_CONTAINER)
- , m_nBorderWidth(0)
, m_bLayoutDirty(true)
{
ImplInit(pParent, 0, NULL);
@@ -44,20 +43,25 @@ Size VclContainer::GetOptimalSize(WindowSizeType eType) const
return Window::GetOptimalSize(eType);
Size aSize = calculateRequisition();
- aSize.Width() += m_nBorderWidth*2;
- aSize.Height() += m_nBorderWidth*2;
+ sal_Int32 nBorderWidth = get_border_width();
+ aSize.Width() += nBorderWidth*2 + get_margin_left() + get_margin_right();
+ aSize.Height() += nBorderWidth*2 + get_margin_top() + get_margin_top();
return aSize;
}
void VclContainer::SetPosSizePixel(const Point& rAllocPos, const Size& rAllocation)
{
Size aAllocation = rAllocation;
- aAllocation.Width() -= m_nBorderWidth*2;
- aAllocation.Height() -= m_nBorderWidth*2;
+ sal_Int32 nBorderWidth = get_border_width();
+ sal_Int32 nLeft = get_margin_left();
+ sal_Int32 nTop = get_margin_top();
+
+ aAllocation.Width() -= nBorderWidth*2 + nLeft + get_margin_right();
+ aAllocation.Height() -= nBorderWidth*2 + nTop + get_margin_bottom();
Point aAllocPos = rAllocPos;
- aAllocPos.X() += m_nBorderWidth;
- aAllocPos.Y() += m_nBorderWidth;
+ aAllocPos.X() += nBorderWidth + nLeft;
+ aAllocPos.Y() += nBorderWidth + nTop;
bool bPosChanged = aAllocPos != GetPosPixel();
bool bSizeChanged = aAllocation != GetSizePixel();
@@ -78,8 +82,9 @@ void VclContainer::SetPosSizePixel(const Point& rAllocPos, const Size& rAllocati
void VclContainer::SetPosPixel(const Point& rAllocPos)
{
Point aAllocPos = rAllocPos;
- aAllocPos.X() += m_nBorderWidth;
- aAllocPos.Y() += m_nBorderWidth;
+ sal_Int32 nBorderWidth = get_border_width();
+ aAllocPos.X() += nBorderWidth + get_margin_left();
+ aAllocPos.Y() += nBorderWidth + get_margin_top();
if (aAllocPos != GetPosPixel())
Window::SetPosPixel(aAllocPos);
@@ -88,8 +93,9 @@ void VclContainer::SetPosPixel(const Point& rAllocPos)
void VclContainer::SetSizePixel(const Size& rAllocation)
{
Size aAllocation = rAllocation;
- aAllocation.Width() -= m_nBorderWidth*2;
- aAllocation.Height() -= m_nBorderWidth*2;
+ sal_Int32 nBorderWidth = get_border_width();
+ aAllocation.Width() -= nBorderWidth*2 + get_margin_left() + get_margin_right();
+ aAllocation.Height() -= nBorderWidth*2 + get_margin_top() + get_margin_bottom();
bool bSizeChanged = aAllocation != GetSizePixel();
if (bSizeChanged)
Window::SetSizePixel(aAllocation);
@@ -100,15 +106,6 @@ void VclContainer::SetSizePixel(const Size& rAllocation)
}
}
-bool VclContainer::set_property(const rtl::OString &rKey, const rtl::OString &rValue)
-{
- if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("border-width")))
- set_border_width(rValue.toInt32());
- else
- return Window::set_property(rKey, rValue);
- return true;
-}
-
Size VclBox::calculateRequisition() const
{
long nMaxChildDimension = 0;
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index 9753af5..8fc4948 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -642,6 +642,11 @@ void Window::ImplInitWindowData( WindowType nType )
mpWindowImpl->mnGridLeftAttach = 0;
mpWindowImpl->mnGridTopAttach = 0;
mpWindowImpl->mnGridWidth = 1;
+ mpWindowImpl->mnBorderWidth = 0;
+ mpWindowImpl->mnMarginLeft = 0;
+ mpWindowImpl->mnMarginRight = 0;
+ mpWindowImpl->mnMarginTop = 0;
+ mpWindowImpl->mnMarginBottom = 0;
mpWindowImpl->mbFrame = sal_False; // sal_True: Window is a frame window
mpWindowImpl->mbBorderWin = sal_False; // sal_True: Window is a border window
mpWindowImpl->mbOverlapWin = sal_False; // sal_True: Window is a overlap window
diff --git a/vcl/source/window/window2.cxx b/vcl/source/window/window2.cxx
index 5cdf4d3..4ebad1f 100644
--- a/vcl/source/window/window2.cxx
+++ b/vcl/source/window/window2.cxx
@@ -1844,6 +1844,11 @@ void Window::take_properties(Window &rOther)
mpWindowImpl->mnGridLeftAttach = pWindowImpl->mnGridLeftAttach;
mpWindowImpl->mnGridTopAttach = pWindowImpl->mnGridTopAttach;
mpWindowImpl->mnGridWidth = pWindowImpl->mnGridWidth;
+ mpWindowImpl->mnBorderWidth = pWindowImpl->mnBorderWidth;
+ mpWindowImpl->mnMarginLeft = pWindowImpl->mnMarginLeft;
+ mpWindowImpl->mnMarginRight = pWindowImpl->mnMarginRight;
+ mpWindowImpl->mnMarginTop = pWindowImpl->mnMarginTop;
+ mpWindowImpl->mnMarginBottom = pWindowImpl->mnMarginBottom;
mpWindowImpl->mbFrame = pWindowImpl->mbFrame;
mpWindowImpl->mbBorderWin = pWindowImpl->mbBorderWin;
mpWindowImpl->mbOverlapWin = pWindowImpl->mbOverlapWin;
@@ -2014,6 +2019,16 @@ bool Window::set_property(const rtl::OString &rKey, const rtl::OString &rValue)
SetQuickHelpText(rtl::OStringToOUString(rValue, RTL_TEXTENCODING_UTF8));
else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("tooltip-text")))
SetQuickHelpText(rtl::OStringToOUString(rValue, RTL_TEXTENCODING_UTF8));
+ else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("border-width")))
+ set_border_width(rValue.toInt32());
+ else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("margin-left")))
+ set_margin_left(rValue.toInt32());
+ else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("margin-right")))
+ set_margin_right(rValue.toInt32());
+ else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("margin-top")))
+ set_margin_top(rValue.toInt32());
+ else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("margin-bottom")))
+ set_margin_bottom(rValue.toInt32());
else
{
fprintf(stderr, "unhandled property %s\n", rKey.getStr());
@@ -2208,4 +2223,64 @@ void Window::set_grid_top_attach(sal_Int32 nAttach)
pWindowImpl->mnGridTopAttach = nAttach;
}
+void Window::set_border_width(sal_Int32 nBorderWidth)
+{
+ WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
+ pWindowImpl->mnBorderWidth = nBorderWidth;
+}
+
+sal_Int32 Window::get_border_width() const
+{
+ WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
+ return pWindowImpl->mnBorderWidth;
+}
+
+void Window::set_margin_left(sal_Int32 nWidth)
+{
+ WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
+ pWindowImpl->mnMarginLeft = nWidth;
+}
+
+sal_Int32 Window::get_margin_left() const
+{
+ WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
+ return pWindowImpl->mnMarginLeft;
+}
+
+void Window::set_margin_right(sal_Int32 nWidth)
+{
+ WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
+ pWindowImpl->mnMarginRight = nWidth;
+}
+
+sal_Int32 Window::get_margin_right() const
+{
+ WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
+ return pWindowImpl->mnMarginRight;
+}
+
+void Window::set_margin_top(sal_Int32 nWidth)
+{
+ WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
+ pWindowImpl->mnMarginTop = nWidth;
+}
+
+sal_Int32 Window::get_margin_top() const
+{
+ WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
+ return pWindowImpl->mnMarginTop;
+}
+
+void Window::set_margin_bottom(sal_Int32 nWidth)
+{
+ WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
+ pWindowImpl->mnMarginBottom = nWidth;
+}
+
+sal_Int32 Window::get_margin_bottom() const
+{
+ WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
+ return pWindowImpl->mnMarginBottom;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list