diff options
author | Caolán McNamara <caolanm@redhat.com> | 2012-08-10 11:31:09 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2012-09-28 08:48:35 +0100 |
commit | 7d8169706b754d7617cf4a1065dc40e698fa0702 (patch) | |
tree | 106591539718c822d084daa21747f8f01597663f /vcl/source/window/window2.cxx | |
parent | 3f3f96becfb8cd487f96cafccf8932f3f12fe814 (diff) |
move from window.cxx to window2.cxx to build under windows
svsys.h on windows includes stuff that undefines WB_LEFT etc, sigh
Change-Id: I01dea9f1f6a4cf335402b04185047eeb99b07f9a
Diffstat (limited to 'vcl/source/window/window2.cxx')
-rw-r--r-- | vcl/source/window/window2.cxx | 311 |
1 files changed, 311 insertions, 0 deletions
diff --git a/vcl/source/window/window2.cxx b/vcl/source/window/window2.cxx index c71ab2f793b6..b966a19de7cd 100644 --- a/vcl/source/window/window2.cxx +++ b/vcl/source/window/window2.cxx @@ -34,6 +34,7 @@ #include <vcl/bitmap.hxx> #include <vcl/dialog.hxx> #include <vcl/event.hxx> +#include <vcl/layout.hxx> #include <vcl/timer.hxx> #include <vcl/metric.hxx> #include <vcl/virdev.hxx> @@ -51,6 +52,7 @@ #include <salframe.hxx> #include <scrwnd.hxx> +using namespace com::sun::star; // ======================================================================= @@ -1747,4 +1749,313 @@ void Window::SetBackgroundBitmap( const BitmapEx& rBitmapEx ) } } +//When a widget wants to renegotiate size, get toplevel parent dialog and call +//resize on it. Maybe better to just find direct parent and if its a container +//chain it upwards one step at a time until a dialog is found. +void Window::queue_resize() +{ + Dialog *pParent = GetParentDialog(); + if (!pParent || pParent == this) + return; + if (pParent->isLayoutEnabled()) + pParent->Resize(); +} + +void Window::setChildAnyProperty(const rtl::OString &rString, const uno::Any &rValue) +{ + m_aWidgetProperties[rString] <<= rValue; +} + +uno::Any Window::getWidgetAnyProperty(const rtl::OString &rString) const +{ + uno::Any aAny; + ChildPropertyMap::const_iterator aI = m_aWidgetProperties.find(rString); + if (aI != m_aWidgetProperties.end()) + aAny = aI->second; + return aAny; +} + +Size Window::get_preferred_size() const +{ + Size aRet(mpWindowImpl->mnWidthRequest, mpWindowImpl->mnHeightRequest); + if (aRet.Width() == -1 || aRet.Height() == -1) + { + Size aOptimal = GetOptimalSize(WINDOWSIZE_PREFERRED); + if (aRet.Width() == -1) + aRet.Width() = aOptimal.Width(); + if (aRet.Height() == -1) + aRet.Height() = aOptimal.Height(); + } + return aRet; +} + +void Window::take_properties(Window &rOther) +{ + if (!mpWindowImpl) + { + ImplInitWindowData(WINDOW_WINDOW); + ImplInit(rOther.GetParent(), rOther.GetStyle(), NULL); + } + + WindowImpl *pWindowImpl = rOther.mpWindowImpl; + if (!mpWindowImpl->mpRealParent) + ImplInit(pWindowImpl->mpRealParent, rOther.GetStyle(), NULL); + std::swap(mpWindowImpl->mpUserData, pWindowImpl->mpUserData); + std::swap(mpWindowImpl->mpExtImpl, pWindowImpl->mpExtImpl); + std::swap(mpWindowImpl->mpCursor, pWindowImpl->mpCursor); + std::swap(mpWindowImpl->maPointer, pWindowImpl->maPointer); + mpWindowImpl->maZoom = pWindowImpl->maZoom; + mpWindowImpl->maText = pWindowImpl->maText; + std::swap(mpWindowImpl->mpControlFont, pWindowImpl->mpControlFont); + mpWindowImpl->maControlForeground = pWindowImpl->maControlForeground; + mpWindowImpl->maControlBackground = pWindowImpl->maControlBackground; + mpWindowImpl->mnLeftBorder = pWindowImpl->mnLeftBorder; + mpWindowImpl->mnTopBorder = pWindowImpl->mnTopBorder; + mpWindowImpl->mnRightBorder = pWindowImpl->mnRightBorder; + mpWindowImpl->mnBottomBorder = pWindowImpl->mnBottomBorder; + mpWindowImpl->mnWidthRequest = pWindowImpl->mnWidthRequest; + mpWindowImpl->mnHeightRequest = pWindowImpl->mnHeightRequest; + mpWindowImpl->mnX = pWindowImpl->mnX; + mpWindowImpl->mnY = pWindowImpl->mnY; + mpWindowImpl->mnAbsScreenX = pWindowImpl->mnAbsScreenX; + mpWindowImpl->maPos = pWindowImpl->maPos; + mpWindowImpl->maHelpId = pWindowImpl->maHelpId; + mpWindowImpl->maUniqId = pWindowImpl->maUniqId; + mpWindowImpl->maHelpText = pWindowImpl->maHelpText; + mpWindowImpl->maQuickHelpText = pWindowImpl->maQuickHelpText; + std::swap(mpWindowImpl->maInputContext, pWindowImpl->maInputContext); + mpWindowImpl->mnStyle = pWindowImpl->mnStyle; + mpWindowImpl->mnPrevStyle = pWindowImpl->mnPrevStyle; + mpWindowImpl->mnExtendedStyle = pWindowImpl->mnExtendedStyle; + mpWindowImpl->mnPrevExtendedStyle = pWindowImpl->mnPrevExtendedStyle; + mpWindowImpl->mnType = pWindowImpl->mnType; + mpWindowImpl->mnNativeBackground = pWindowImpl->mnNativeBackground; + mpWindowImpl->mnWaitCount = pWindowImpl->mnWaitCount; + mpWindowImpl->mnPaintFlags = pWindowImpl->mnPaintFlags; + mpWindowImpl->mnGetFocusFlags = pWindowImpl->mnGetFocusFlags; + mpWindowImpl->mnParentClipMode = pWindowImpl->mnParentClipMode; + mpWindowImpl->mnActivateMode = pWindowImpl->mnActivateMode; + mpWindowImpl->mnDlgCtrlFlags = pWindowImpl->mnDlgCtrlFlags; + mpWindowImpl->mnLockCount = pWindowImpl->mnLockCount; + mpWindowImpl->meAlwaysInputMode = pWindowImpl->meAlwaysInputMode; + mpWindowImpl->mbFrame = pWindowImpl->mbFrame; + mpWindowImpl->mbBorderWin = pWindowImpl->mbBorderWin; + mpWindowImpl->mbOverlapWin = pWindowImpl->mbOverlapWin; + mpWindowImpl->mbSysWin = pWindowImpl->mbSysWin; + mpWindowImpl->mbDialog = pWindowImpl->mbDialog; + mpWindowImpl->mbDockWin = pWindowImpl->mbDockWin; + mpWindowImpl->mbFloatWin = pWindowImpl->mbFloatWin; + mpWindowImpl->mbPushButton = pWindowImpl->mbPushButton; + mpWindowImpl->mbVisible = pWindowImpl->mbVisible; + mpWindowImpl->mbDisabled = pWindowImpl->mbDisabled; + mpWindowImpl->mbInputDisabled = pWindowImpl->mbInputDisabled; + mpWindowImpl->mbDropDisabled = pWindowImpl->mbDropDisabled; + mpWindowImpl->mbNoUpdate = pWindowImpl->mbNoUpdate; + mpWindowImpl->mbNoParentUpdate = pWindowImpl->mbNoParentUpdate; + mpWindowImpl->mbActive = pWindowImpl->mbActive; + mpWindowImpl->mbParentActive = pWindowImpl->mbParentActive; + mpWindowImpl->mbReallyVisible = pWindowImpl->mbReallyVisible; + mpWindowImpl->mbReallyShown = pWindowImpl->mbReallyShown; + mpWindowImpl->mbInInitShow = pWindowImpl->mbInInitShow; + mpWindowImpl->mbChildNotify = pWindowImpl->mbChildNotify; + mpWindowImpl->mbChildPtrOverwrite = pWindowImpl->mbChildPtrOverwrite; + mpWindowImpl->mbNoPtrVisible = pWindowImpl->mbNoPtrVisible; + mpWindowImpl->mbPaintFrame = pWindowImpl->mbPaintFrame; + mpWindowImpl->mbInPaint = pWindowImpl->mbInPaint; + mpWindowImpl->mbMouseMove = pWindowImpl->mbMouseMove; + mpWindowImpl->mbMouseButtonDown = pWindowImpl->mbMouseButtonDown; + mpWindowImpl->mbMouseButtonUp = pWindowImpl->mbMouseButtonUp; + mpWindowImpl->mbKeyInput = pWindowImpl->mbKeyInput; + mpWindowImpl->mbKeyUp = pWindowImpl->mbKeyUp; + mpWindowImpl->mbCommand = pWindowImpl->mbCommand; + mpWindowImpl->mbDefPos = pWindowImpl->mbDefPos; + mpWindowImpl->mbDefSize = pWindowImpl->mbDefSize; + mpWindowImpl->mbCallMove = pWindowImpl->mbCallMove; + mpWindowImpl->mbCallResize = pWindowImpl->mbCallResize; + mpWindowImpl->mbWaitSystemResize = pWindowImpl->mbWaitSystemResize; + mpWindowImpl->mbInitWinClipRegion = pWindowImpl->mbInitWinClipRegion; + mpWindowImpl->mbInitChildRegion = pWindowImpl->mbInitChildRegion; + mpWindowImpl->mbWinRegion = pWindowImpl->mbWinRegion; + mpWindowImpl->mbClipChildren = pWindowImpl->mbClipChildren; + mpWindowImpl->mbClipSiblings = pWindowImpl->mbClipSiblings; + mpWindowImpl->mbChildTransparent = pWindowImpl->mbChildTransparent; + mpWindowImpl->mbPaintTransparent = pWindowImpl->mbPaintTransparent; + mpWindowImpl->mbMouseTransparent = pWindowImpl->mbMouseTransparent; + mpWindowImpl->mbDlgCtrlStart = pWindowImpl->mbDlgCtrlStart; + mpWindowImpl->mbFocusVisible = pWindowImpl->mbFocusVisible; + mpWindowImpl->mbTrackVisible = pWindowImpl->mbTrackVisible; + mpWindowImpl->mbUseNativeFocus = pWindowImpl->mbUseNativeFocus; + mpWindowImpl->mbNativeFocusVisible = pWindowImpl->mbNativeFocusVisible; + mpWindowImpl->mbInShowFocus = pWindowImpl->mbInShowFocus; + mpWindowImpl->mbInHideFocus = pWindowImpl->mbInHideFocus; + mpWindowImpl->mbControlForeground = pWindowImpl->mbControlForeground; + mpWindowImpl->mbControlBackground = pWindowImpl->mbControlBackground; + mpWindowImpl->mbAlwaysOnTop = pWindowImpl->mbAlwaysOnTop; + mpWindowImpl->mbCompoundControl = pWindowImpl->mbCompoundControl; + mpWindowImpl->mbCompoundControlHasFocus = pWindowImpl->mbCompoundControlHasFocus; + mpWindowImpl->mbPaintDisabled = pWindowImpl->mbPaintDisabled; + mpWindowImpl->mbAllResize = pWindowImpl->mbAllResize; + mpWindowImpl->mbInDtor = pWindowImpl->mbInDtor; + mpWindowImpl->mbExtTextInput = pWindowImpl->mbExtTextInput; + mpWindowImpl->mbInFocusHdl = pWindowImpl->mbInFocusHdl; + mpWindowImpl->mbOverlapVisible = pWindowImpl->mbOverlapVisible; + mpWindowImpl->mbCreatedWithToolkit = pWindowImpl->mbCreatedWithToolkit; + mpWindowImpl->mbToolBox = pWindowImpl->mbToolBox; + mpWindowImpl->mbSplitter = pWindowImpl->mbSplitter; + mpWindowImpl->mbSuppressAccessibilityEvents = pWindowImpl->mbSuppressAccessibilityEvents; + mpWindowImpl->mbMenuFloatingWindow = pWindowImpl->mbMenuFloatingWindow; + mpWindowImpl->mbDrawSelectionBackground = pWindowImpl->mbDrawSelectionBackground; + mpWindowImpl->mbIsInTaskPaneList = pWindowImpl->mbIsInTaskPaneList; + mpWindowImpl->mbToolbarFloatingWindow = pWindowImpl->mbToolbarFloatingWindow; + mpWindowImpl->mbCallHandlersDuringInputDisabled = pWindowImpl->mbCallHandlersDuringInputDisabled; + mpWindowImpl->mbDisableAccessibleLabelForRelation = pWindowImpl->mbDisableAccessibleLabelForRelation; + mpWindowImpl->mbDisableAccessibleLabeledByRelation = pWindowImpl->mbDisableAccessibleLabeledByRelation; + mpWindowImpl->mbHelpTextDynamic = pWindowImpl->mbHelpTextDynamic; + mpWindowImpl->mbFakeFocusSet = pWindowImpl->mbFakeFocusSet; + mpWindowImpl->mbHexpand = pWindowImpl->mbHexpand; + mpWindowImpl->mbVexpand = pWindowImpl->mbVexpand; + mpWindowImpl->meHalign = pWindowImpl->meHalign; + mpWindowImpl->meValign = pWindowImpl->meValign; + + std::swap(m_aWidgetProperties, rOther.m_aWidgetProperties); + + bool bHasBorderWindow = mpWindowImpl->mpBorderWindow; + bool bOtherHasBorderWindow = pWindowImpl->mpBorderWindow; + + assert(bHasBorderWindow == bOtherHasBorderWindow); + + if (bHasBorderWindow && bOtherHasBorderWindow) + mpWindowImpl->mpBorderWindow->take_properties(*pWindowImpl->mpBorderWindow); +} + +namespace +{ + VclAlign toAlign(const rtl::OString &rValue) + { + VclAlign eRet = VCL_ALIGN_FILL; + + if (rValue.equalsL(RTL_CONSTASCII_STRINGPARAM("fill"))) + eRet = VCL_ALIGN_FILL; + else if (rValue.equalsL(RTL_CONSTASCII_STRINGPARAM("start"))) + eRet = VCL_ALIGN_START; + else if (rValue.equalsL(RTL_CONSTASCII_STRINGPARAM("end"))) + eRet = VCL_ALIGN_END; + else if (rValue.equalsL(RTL_CONSTASCII_STRINGPARAM("center"))) + eRet = VCL_ALIGN_CENTER; + return eRet; + } +} + +bool Window::set_property(const rtl::OString &rKey, const rtl::OString &rValue) +{ + if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("label"))) + SetText(rtl::OStringToOUString(rValue, RTL_TEXTENCODING_UTF8)); + else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("visible"))) + Show(toBool(rValue)); + else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("sensitive"))) + Enable(toBool(rValue)); + else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("resizable"))) + { + WinBits nBits = GetStyle(); + nBits &= ~(WB_SIZEMOVE); + if (toBool(rValue)) + nBits |= WB_SIZEMOVE; + SetStyle(nBits); + } + else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("xalign"))) + { + WinBits nBits = GetStyle(); + nBits &= ~(WB_LEFT | WB_CENTER | WB_RIGHT); + + float f = rValue.toFloat(); + if (f == 0.0) + nBits |= WB_LEFT; + else if (f == 1.0) + nBits |= WB_RIGHT; + else if (f == 0.5) + nBits |= WB_CENTER; + + SetStyle(nBits); + } + else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("yalign"))) + { + WinBits nBits = GetStyle(); + nBits &= ~(WB_TOP | WB_VCENTER | WB_BOTTOM); + + float f = rValue.toFloat(); + if (f == 0.0) + nBits |= WB_TOP; + else if (f == 1.0) + nBits |= WB_BOTTOM; + else if (f == 0.5) + nBits |= WB_CENTER; + + SetStyle(nBits); + } + else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("text"))) + SetText(rtl::OStringToOUString(rValue, RTL_TEXTENCODING_UTF8)); + else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("height-request"))) + set_height_request(rValue.toInt32()); + else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("width-request"))) + set_width_request(rValue.toInt32()); + else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("hexpand"))) + set_hexpand(toBool(rValue)); + else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("vexpand"))) + set_vexpand(toBool(rValue)); + else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("halign"))) + set_halign(toAlign(rValue)); + else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("valign"))) + set_valign(toAlign(rValue)); + else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("tooltip-markup"))) + SetQuickHelpText(rtl::OStringToOUString(rValue, RTL_TEXTENCODING_UTF8)); + else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("tooltip-text"))) + SetQuickHelpText(rtl::OStringToOUString(rValue, RTL_TEXTENCODING_UTF8)); + else + { + fprintf(stderr, "unhandled property %s\n", rKey.getStr()); + return false; + } + return true; +} + +VclAlign Window::get_halign() const +{ + return mpWindowImpl->meHalign; +} + +void Window::set_halign(VclAlign eAlign) +{ + mpWindowImpl->meHalign = eAlign; +} + +VclAlign Window::get_valign() const +{ + return mpWindowImpl->meValign; +} + +void Window::set_valign(VclAlign eAlign) +{ + mpWindowImpl->meValign = eAlign; +} + +bool Window::get_hexpand() const +{ + return mpWindowImpl->mbHexpand; +} + +void Window::set_hexpand(bool bExpand) +{ + mpWindowImpl->mbHexpand = bExpand; +} + +bool Window::get_vexpand() const +{ + return mpWindowImpl->mbVexpand; +} + +void Window::set_vexpand(bool bExpand) +{ + mpWindowImpl->mbVexpand = bExpand; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |