From 48c15285c52f6554f1aadab6068c076c2139ef89 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Tue, 16 Dec 2014 14:07:08 +0000 Subject: implement loading docking windows from .ui format Change-Id: I90375232aefbe40412614ca0f30ba467cf393f2e --- include/sfx2/dockwin.hxx | 4 + include/vcl/dockwin.hxx | 34 ++++-- include/vcl/layout.hxx | 3 +- include/vcl/syswin.hxx | 2 +- include/vcl/window.hxx | 2 +- sfx2/source/dialog/dockwin.cxx | 49 +++++++++ starmath/UIConfig_smath.mk | 1 + starmath/inc/ElementsDockingWindow.hxx | 8 +- starmath/inc/starmath.hrc | 1 - starmath/source/ElementsDockingWindow.cxx | 60 ++++++----- starmath/source/smres.src | 29 ------ starmath/uiconfig/smath/ui/dockingelements.ui | 53 ++++++++++ vcl/source/window/builder.cxx | 17 ++- vcl/source/window/dockmgr.cxx | 2 +- vcl/source/window/dockwin.cxx | 143 ++++++++++++++++++++++++-- vcl/source/window/syswin.cxx | 4 +- vcl/source/window/taskpanelist.cxx | 2 +- vcl/source/window/window2.cxx | 2 +- vcl/source/window/winproc.cxx | 2 +- 19 files changed, 333 insertions(+), 85 deletions(-) create mode 100644 starmath/uiconfig/smath/ui/dockingelements.ui diff --git a/include/sfx2/dockwin.hxx b/include/sfx2/dockwin.hxx index 4e00ab2cc55e..1d50cc430762 100644 --- a/include/sfx2/dockwin.hxx +++ b/include/sfx2/dockwin.hxx @@ -79,6 +79,10 @@ public: SfxChildWindow *pCW, vcl::Window* pParent, const ResId& rResId); + SfxDockingWindow( SfxBindings *pBindings, + SfxChildWindow *pCW, + vcl::Window* pParent, + const OUString& rID, const OUString& rUIXMLDescription ); virtual ~SfxDockingWindow(); void Initialize (SfxChildWinInfo* pInfo); diff --git a/include/vcl/dockwin.hxx b/include/vcl/dockwin.hxx index f683cc83dda2..caf25cd9a782 100644 --- a/include/vcl/dockwin.hxx +++ b/include/vcl/dockwin.hxx @@ -22,6 +22,7 @@ #include #include +#include #include #include @@ -222,7 +223,9 @@ public: // - DockingWindow - -class VCL_DLLPUBLIC DockingWindow : public vcl::Window +class VCL_DLLPUBLIC DockingWindow + : public vcl::Window + , public VclBuilderContainer { class ImplData; private: @@ -256,9 +259,15 @@ private: mbPinned:1, mbRollUp:1, mbDockBtn:1, - mbHideBtn:1; + mbHideBtn:1, + mbIsDefferedInit:1, + mbIsCalculatingInitialLayoutSize:1, + mbInitialLayoutDone:1; + + vcl::Window* mpDialogParent; SAL_DLLPRIVATE void ImplInitDockingWindowData(); + SAL_DLLPRIVATE void setPosSizeOnContainee(Size aSize, Window &rBox); // Copy assignment is forbidden and not implemented. SAL_DLLPRIVATE DockingWindow (const DockingWindow &); @@ -270,16 +279,26 @@ protected: SAL_DLLPRIVATE void ImplInitSettings(); SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId ); + SAL_DLLPRIVATE void DoInitialLayout(); + + void loadUI(vcl::Window* pParent, const OString& rID, const OUString& rUIXMLDescription); + public: - SAL_DLLPRIVATE bool ImplStartDocking( const Point& rPos ); + bool isLayoutEnabled() const; + void setOptimalLayoutSize(); + bool isCalculatingInitialLayoutSize() const { return mbIsCalculatingInitialLayoutSize; } + SAL_DLLPRIVATE bool ImplStartDocking( const Point& rPos ); + SAL_DLLPRIVATE bool isDeferredInit() const { return mbIsDefferedInit; } + void doDeferredInit(WinBits nBits); protected: DockingWindow( WindowType nType ); public: - DockingWindow( vcl::Window* pParent, WinBits nStyle = WB_STDDOCKWIN ); - DockingWindow( vcl::Window* pParent, const ResId& rResId ); - virtual ~DockingWindow(); + DockingWindow(vcl::Window* pParent, WinBits nStyle = WB_STDDOCKWIN); + DockingWindow(vcl::Window* pParent, const ResId& rResId); + DockingWindow(vcl::Window* pParent, const OUString& rID, const OUString& rUIXMLDescription); + virtual ~DockingWindow(); virtual void StartDocking(); virtual bool Docking( const Point& rPos, Rectangle& rRect ); @@ -339,6 +358,9 @@ public: Size GetSizePixel() const SAL_OVERRIDE; void SetOutputSizePixel( const Size& rNewSize ) SAL_OVERRIDE; Size GetOutputSizePixel() const; + + virtual void SetText( const OUString& rStr ) SAL_OVERRIDE; + virtual OUString GetText() const SAL_OVERRIDE; }; inline void DockingWindow::SetPin( bool bPin ) diff --git a/include/vcl/layout.hxx b/include/vcl/layout.hxx index edb8d6b6434a..efeabf858e76 100644 --- a/include/vcl/layout.hxx +++ b/include/vcl/layout.hxx @@ -776,7 +776,8 @@ VCL_DLLPUBLIC bool isLayoutEnabled(const vcl::Window *pWindow); inline bool isContainerWindow(const vcl::Window &rWindow) { WindowType eType = rWindow.GetType(); - return (eType == WINDOW_CONTAINER || eType == WINDOW_SCROLLWINDOW); + return eType == WINDOW_CONTAINER || eType == WINDOW_SCROLLWINDOW || + (eType == WINDOW_DOCKINGWINDOW && ::isLayoutEnabled(&rWindow)); } inline bool isContainerWindow(const vcl::Window *pWindow) diff --git a/include/vcl/syswin.hxx b/include/vcl/syswin.hxx index 1ec6054ca747..f52d54d48e44 100644 --- a/include/vcl/syswin.hxx +++ b/include/vcl/syswin.hxx @@ -164,7 +164,7 @@ public: private: SAL_DLLPRIVATE void Init(); SAL_DLLPRIVATE void ImplMoveToScreen( long& io_rX, long& io_rY, long i_nWidth, long i_nHeight, vcl::Window* i_pConfigureWin ); - SAL_DLLPRIVATE void setPosSizeOnContainee(Size aSize, VclContainer &rBox); + SAL_DLLPRIVATE void setPosSizeOnContainee(Size aSize, Window &rBox); DECL_DLLPRIVATE_LINK( ImplHandleLayoutTimerHdl, void* ); protected: diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx index 7e09b262d0ce..b6874997ed22 100644 --- a/include/vcl/window.hxx +++ b/include/vcl/window.hxx @@ -440,7 +440,6 @@ public: SAL_DLLPRIVATE bool ImplIsFloatingWindow() const; SAL_DLLPRIVATE bool ImplIsPushButton() const; SAL_DLLPRIVATE bool ImplIsSplitter() const; - SAL_DLLPRIVATE bool ImplIsDockingWindow() const; SAL_DLLPRIVATE bool ImplIsOverlapWindow() const; SAL_DLLPRIVATE void ImplIsInTaskPaneList( bool mbIsInTaskList ); @@ -763,6 +762,7 @@ public: void SetType( WindowType nType ); WindowType GetType() const; bool IsSystemWindow() const; + bool IsDockingWindow() const; bool IsDialog() const; bool IsMenuFloatingWindow() const; bool IsToolbarFloatingWindow() const; diff --git a/sfx2/source/dialog/dockwin.cxx b/sfx2/source/dialog/dockwin.cxx index b5fabebb2faf..80839b3cd101 100644 --- a/sfx2/source/dialog/dockwin.cxx +++ b/sfx2/source/dialog/dockwin.cxx @@ -943,7 +943,53 @@ SfxDockingWindow::SfxDockingWindow( SfxBindings *pBindinx, SfxChildWindow *pCW, pImp->aMoveIdle.SetIdleHdl(LINK(this,SfxDockingWindow,TimerHdl)); } +SfxDockingWindow::SfxDockingWindow( SfxBindings *pBindinx, SfxChildWindow *pCW, + vcl::Window* pParent, const OUString& rID, const OUString& rUIXMLDescription) + : DockingWindow(pParent, rID, rUIXMLDescription) + , pBindings(pBindinx) + , pMgr(pCW) + , pImp(NULL) + +/* [Description] + Constructor for the SfxDockingWindow class. A SfxChildWindow will be + required because the docking is implemented in Sfx through SfxChildWindows. +*/ +{ + if ( !GetHelpId().isEmpty() ) + { + SetUniqueId( GetHelpId() ); + SetHelpId(""); + } + else + { + SfxViewFrame* pViewFrame = pBindings->GetDispatcher()->GetFrame(); + SfxSlotPool* pSlotPool = pViewFrame->GetObjectShell()->GetModule()->GetSlotPool(); + const SfxSlot* pSlot = pSlotPool->GetSlot( pCW->GetType() ); + if ( pSlot ) + { + OString aCmd("SFXDOCKINGWINDOW_"); + aCmd += pSlot->GetUnoName(); + SetUniqueId( aCmd ); + } + } + + pImp = new SfxDockingWindow_Impl; + pImp->bConstructed = false; + pImp->pSplitWin = 0; + pImp->bEndDocked = false; + pImp->bDockingPrevented = false; + + pImp->bSplitable = true; + + // Initially set to default, the alignment is set in the subclass + pImp->nLine = pImp->nDockLine = 0; + pImp->nPos = pImp->nDockPos = 0; + pImp->bNewLine = false; + pImp->SetLastAlignment(SFX_ALIGN_NOALIGNMENT); + pImp->aMoveIdle.SetPriority(VCL_IDLE_PRIORITY_RESIZE); + pImp->aMoveIdle.SetIdleHdl(LINK(this,SfxDockingWindow,TimerHdl)); +} void SfxDockingWindow::Initialize(SfxChildWinInfo *pInfo) /* [Description] @@ -1162,6 +1208,9 @@ void SfxDockingWindow::Initialize_Impl() // trick: use VCL method SetWindowState to adjust position and size pFloatWin->SetWindowState( pImp->aWinState ); + Size aSize(pFloatWin->GetSizePixel()); + pFloatWin->set_width_request(aSize.Width()); + pFloatWin->set_height_request(aSize.Height()); // remember floating size for calculating alignment and tracking rectangle SetFloatingSize( pFloatWin->GetSizePixel() ); diff --git a/starmath/UIConfig_smath.mk b/starmath/UIConfig_smath.mk index 0841d47433eb..8eb535d9940c 100644 --- a/starmath/UIConfig_smath.mk +++ b/starmath/UIConfig_smath.mk @@ -26,6 +26,7 @@ $(eval $(call gb_UIConfig_add_toolbarfiles,modules/smath,\ $(eval $(call gb_UIConfig_add_uifiles,modules/smath,\ starmath/uiconfig/smath/ui/alignmentdialog \ starmath/uiconfig/smath/ui/catalogdialog \ + starmath/uiconfig/smath/ui/dockingelements \ starmath/uiconfig/smath/ui/floatingelements \ starmath/uiconfig/smath/ui/fontdialog \ starmath/uiconfig/smath/ui/fontsizedialog \ diff --git a/starmath/inc/ElementsDockingWindow.hxx b/starmath/inc/ElementsDockingWindow.hxx index 013b6cd30e7b..85b27a4f9a6b 100644 --- a/starmath/inc/ElementsDockingWindow.hxx +++ b/starmath/inc/ElementsDockingWindow.hxx @@ -107,13 +107,15 @@ class SmElementsControl : public Control void build(); public: - SmElementsControl(vcl::Window *pParent, const ResId& rResId); + SmElementsControl(vcl::Window *pParent); virtual ~SmElementsControl(); void setElementSetId(sal_uInt16 aSetId); void setVerticalMode(bool bVertical); + Size GetOptimalSize() const SAL_OVERRIDE; + DECL_LINK( ScrollHdl, void* ); void DoScroll(long nDelta); @@ -124,8 +126,8 @@ class SmElementsDockingWindow : public SfxDockingWindow { static const sal_uInt16 aCategories[]; - SmElementsControl maElementsControl; - ListBox maElementListBox; + SmElementsControl* mpElementsControl; + ListBox* mpElementListBox; virtual void Resize() SAL_OVERRIDE; SmViewShell* GetView(); diff --git a/starmath/inc/starmath.hrc b/starmath/inc/starmath.hrc index e5aab1968642..7196b26dd269 100644 --- a/starmath/inc/starmath.hrc +++ b/starmath/inc/starmath.hrc @@ -94,7 +94,6 @@ #define RID_SYMBOLFILESSTR (RID_APP_START + 809) #define RID_ALLFILESSTR (RID_APP_START + 810) #define RID_STATUSBAR (RID_APP_START + 816) -#define RID_ELEMENTSDOCKINGWINDOW (RID_APP_START + 817) #define STR_MATH_DOCUMENT_FULLTYPE_CURRENT (RID_APP_START + 821) #define STR_STATSTR_READING (RID_APP_START + 823) diff --git a/starmath/source/ElementsDockingWindow.cxx b/starmath/source/ElementsDockingWindow.cxx index 3aaac1e4f9c7..4cb086968cb7 100644 --- a/starmath/source/ElementsDockingWindow.cxx +++ b/starmath/source/ElementsDockingWindow.cxx @@ -216,8 +216,8 @@ const sal_uInt16 SmElementsControl::aOthers[][2] = {RID_DOTSUP, RID_DOTSUP_HELP}, {RID_DOTSDOWN, RID_DOTSDOWN_HELP} }; -SmElementsControl::SmElementsControl(vcl::Window *pParent, const ResId& rResId) - : Control(pParent, rResId) +SmElementsControl::SmElementsControl(vcl::Window *pParent) + : Control(pParent, WB_TABSTOP) , mpDocShell(new SmDocShell(SFXOBJECTSHELL_STD_NORMAL)) , maCurrentSetId(0) , mpCurrentElement(NULL) @@ -622,6 +622,11 @@ void SmElementsControl::build() Invalidate(); } +Size SmElementsControl::GetOptimalSize() const +{ + return LogicToPixel(Size(300, 300), MapMode(MAP_APPFONT)); +} + const sal_uInt16 SmElementsDockingWindow::aCategories[] = { RID_CATEGORY_UNARY_BINARY_OPERATORS, RID_CATEGORY_RELATIONS, @@ -636,32 +641,36 @@ const sal_uInt16 SmElementsDockingWindow::aCategories[] = { }; SmElementsDockingWindow::SmElementsDockingWindow(SfxBindings* pInputBindings, SfxChildWindow* pChildWindow, vcl::Window* pParent) : - SfxDockingWindow(pInputBindings, pChildWindow, pParent, SmResId(RID_ELEMENTSDOCKINGWINDOW)), - maElementsControl (this, SmResId(1)), - maElementListBox (this, SmResId(1)) + SfxDockingWindow(pInputBindings, pChildWindow, pParent, "DockingElements", + "modules/smath/ui/dockingelements.ui") { - maElementsControl.SetBorderStyle( WindowBorderStyle::MONO ); + mpElementsControl = new SmElementsControl(get("box")); + mpElementsControl->set_hexpand(true); + mpElementsControl->set_vexpand(true); + mpElementsControl->Show(); + get(mpElementListBox, "listbox"); + + mpElementsControl->SetBorderStyle( WindowBorderStyle::MONO ); - maElementListBox.SetDropDownLineCount( SAL_N_ELEMENTS(aCategories) ); + mpElementListBox->SetDropDownLineCount( SAL_N_ELEMENTS(aCategories) ); for (sal_uInt16 i = 0; i < SAL_N_ELEMENTS(aCategories) ; i++) { - maElementListBox.InsertEntry(SM_RESSTR(aCategories[i])); + mpElementListBox->InsertEntry(SM_RESSTR(aCategories[i])); } - maElementListBox.SetSelectHdl(LINK(this, SmElementsDockingWindow, ElementSelectedHandle)); - maElementListBox.SelectEntry(SM_RESSTR(RID_CATEGORY_UNARY_BINARY_OPERATORS)); + mpElementListBox->SetSelectHdl(LINK(this, SmElementsDockingWindow, ElementSelectedHandle)); + mpElementListBox->SelectEntry(SM_RESSTR(RID_CATEGORY_UNARY_BINARY_OPERATORS)); - maElementsControl.SetBackground( Color( COL_WHITE ) ); - maElementsControl.SetTextColor( Color( COL_BLACK ) ); - maElementsControl.setElementSetId(RID_CATEGORY_UNARY_BINARY_OPERATORS); - maElementsControl.selectedSignal.connect( boost::bind( &SmElementsDockingWindow::SelectClickHandler, this, _1 ) ); - - FreeResource(); + mpElementsControl->SetBackground( Color( COL_WHITE ) ); + mpElementsControl->SetTextColor( Color( COL_BLACK ) ); + mpElementsControl->setElementSetId(RID_CATEGORY_UNARY_BINARY_OPERATORS); + mpElementsControl->selectedSignal.connect( boost::bind( &SmElementsDockingWindow::SelectClickHandler, this, _1 ) ); } SmElementsDockingWindow::~SmElementsDockingWindow () { + delete mpElementsControl; } void SmElementsDockingWindow::ToggleFloatingMode() @@ -678,7 +687,7 @@ void SmElementsDockingWindow::EndDocking( const Rectangle& rReactangle, bool bFl { SfxDockingWindow::EndDocking(rReactangle, bFloatMode); bool bVertical = ( GetAlignment() == SFX_ALIGN_TOP || GetAlignment() == SFX_ALIGN_BOTTOM ); - maElementsControl.setVerticalMode(bVertical); + mpElementsControl->setVerticalMode(bVertical); } void SmElementsDockingWindow::SelectClickHandler( SmElement* pElement ) @@ -701,7 +710,7 @@ IMPL_LINK( SmElementsDockingWindow, ElementSelectedHandle, ListBox*, pList) OUString aCurrentCategoryString = SM_RESSTR(aCurrentCategory); if (aCurrentCategoryString == pList->GetSelectEntry()) { - maElementsControl.setElementSetId(aCurrentCategory); + mpElementsControl->setElementSetId(aCurrentCategory); return 0; } } @@ -717,8 +726,8 @@ SmViewShell* SmElementsDockingWindow::GetView() void SmElementsDockingWindow::Resize() { bool bVertical = ( GetAlignment() == SFX_ALIGN_TOP || GetAlignment() == SFX_ALIGN_BOTTOM ); - maElementsControl.setVerticalMode(bVertical); - + mpElementsControl->setVerticalMode(bVertical); +#if 0 sal_uInt32 aWidth = GetOutputSizePixel().Width(); sal_uInt32 aHeight = GetOutputSizePixel().Height(); @@ -727,12 +736,12 @@ void SmElementsDockingWindow::Resize() Rectangle aRect1 = Rectangle(aPadding, aPadding, aWidth - aPadding, aElementsSetsHeight + aPadding); - maElementListBox.SetPosSizePixel(aRect1.TopLeft(), aRect1.GetSize()); + mpElementListBox->SetPosSizePixel(aRect1.TopLeft(), aRect1.GetSize()); Rectangle aRect = Rectangle(aPadding, aElementsSetsHeight + aPadding + aPadding, aWidth - aPadding, aHeight - aPadding); - maElementsControl.SetPosSizePixel(aRect.TopLeft(), aRect.GetSize()); - + mpElementsControl->SetPosSizePixel(aRect.TopLeft(), aRect.GetSize()); +#endif SfxDockingWindow::Resize(); Invalidate(); } @@ -744,8 +753,9 @@ SmElementsDockingWindowWrapper::SmElementsDockingWindowWrapper( SfxBindings *pBindings, SfxChildWinInfo *pInfo) : SfxChildWindow(pParentWindow, nId) { - pWindow = new SmElementsDockingWindow(pBindings, this, pParentWindow); - SmElementsDockingWindow* pDialog = static_cast(pWindow); + SmElementsDockingWindow* pDialog = new SmElementsDockingWindow(pBindings, this, pParentWindow); + pWindow = pDialog; + pDialog->setDeferredProperties(); pDialog->SetPosSizePixel(Point(0, 0), Size(300, 0)); pDialog->Show(); diff --git a/starmath/source/smres.src b/starmath/source/smres.src index 6f7a2e655122..114d81be6d08 100644 --- a/starmath/source/smres.src +++ b/starmath/source/smres.src @@ -121,35 +121,6 @@ DockingWindow RID_CMDBOXWINDOW\ CMDBOXWINDOW_TEXT }; -DockingWindow RID_ELEMENTSDOCKINGWINDOW -{ - OutputSize = TRUE ; - Hide = FALSE ; - SVLook = TRUE ; - Size = MAP_APPFONT ( 300 , 300 ) ; - Sizeable = TRUE ; - Moveable = TRUE ; - Closeable = TRUE ; - Zoomable = TRUE ; - Dockable = TRUE ; - - Control 1 - { - Border = FALSE ; - }; - - ListBox 1 - { - Border = TRUE ; - TabStop = TRUE ; - Sort = FALSE ; - DropDown = TRUE ; - VScroll = TRUE ; - }; - - Text [ en-US ] = "Elements Dock" ; -}; - String STR_BLACK { Text [ en-US ] = "black" ; diff --git a/starmath/uiconfig/smath/ui/dockingelements.ui b/starmath/uiconfig/smath/ui/dockingelements.ui new file mode 100644 index 000000000000..b9630544eac2 --- /dev/null +++ b/starmath/uiconfig/smath/ui/dockingelements.ui @@ -0,0 +1,53 @@ + + + + + + True + False + True + True + 6 + Elements Dock + dock + + + True + False + True + True + 12 + + + True + False + + + 0 + 0 + 1 + 1 + + + + + True + False + True + True + vertical + + + + + + 0 + 1 + 1 + 1 + + + + + + diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx index e0dba6435e4d..5c9356bff1c8 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -186,7 +186,9 @@ VclBuilder::VclBuilder(vcl::Window *pParent, const OUString& sUIDir, const OUStr , m_pParserState(new ParserState) , m_xFrame(rFrame) { - m_bToplevelHasDeferredInit = pParent && pParent->IsSystemWindow() && static_cast(pParent)->isDeferredInit(); + m_bToplevelHasDeferredInit = pParent && + ((pParent->IsSystemWindow() && static_cast(pParent)->isDeferredInit()) || + (pParent->IsDockingWindow() && static_cast(pParent)->isDeferredInit())); m_bToplevelHasDeferredProperties = m_bToplevelHasDeferredInit; sal_Int32 nIdx = m_sHelpRoot.lastIndexOf('.'); @@ -994,6 +996,8 @@ namespace nBits |= WB_SYSTEMWINDOW | WB_DIALOGCONTROL | WB_MOVEABLE; else if (sType == "popup-menu") nBits |= WB_SYSTEMWINDOW | WB_DIALOGCONTROL | WB_POPUP; + else if (sType == "dock") + nBits |= WB_DOCKABLE; else nBits |= WB_MOVEABLE; return nBits; @@ -1667,7 +1671,10 @@ vcl::Window *VclBuilder::makeObject(vcl::Window *pParent, const OString &name, c else if (name == "GtkWindow") { WinBits nBits = extractDeferredBits(rMap); - pWindow = new FloatingWindow(pParent, nBits|WB_MOVEABLE); + if (nBits | WB_DOCKABLE) + pWindow = new DockingWindow(pParent, nBits|WB_MOVEABLE); + else + pWindow = new FloatingWindow(pParent, nBits|WB_MOVEABLE); } else { @@ -1768,6 +1775,12 @@ vcl::Window *VclBuilder::insertObject(vcl::Window *pParent, const OString &rClas pSysWin->doDeferredInit(extractDeferredBits(rProps)); m_bToplevelHasDeferredInit = false; } + else if (pParent && pParent->IsDockingWindow()) + { + DockingWindow *pDockWin = static_cast(pCurrentChild); + pDockWin->doDeferredInit(extractDeferredBits(rProps)); + m_bToplevelHasDeferredInit = false; + } if (pCurrentChild->GetHelpId().isEmpty()) { diff --git a/vcl/source/window/dockmgr.cxx b/vcl/source/window/dockmgr.cxx index edd309805eb0..722b96da73bf 100644 --- a/vcl/source/window/dockmgr.cxx +++ b/vcl/source/window/dockmgr.cxx @@ -1048,7 +1048,7 @@ void ImplDockingWindowWrapper::ToggleFloatingMode() // notify dockingwindow/toolbox // note: this must be done *before* notifying the // listeners to have the toolbox in the proper state - if( GetWindow()->ImplIsDockingWindow() ) + if( GetWindow()->IsDockingWindow() ) static_cast(GetWindow())->ToggleFloatingMode(); // now notify listeners diff --git a/vcl/source/window/dockwin.cxx b/vcl/source/window/dockwin.cxx index ab3c3a8becb8..8c9641eaab78 100644 --- a/vcl/source/window/dockwin.cxx +++ b/vcl/source/window/dockwin.cxx @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -324,6 +325,10 @@ void DockingWindow::ImplInitDockingWindowData() mbRollUp = false; mbDockBtn = false; mbHideBtn = false; + mbIsDefferedInit = false; + mbIsCalculatingInitialLayoutSize = false; + mbInitialLayoutDone = false; + mpDialogParent = NULL; } void DockingWindow::ImplInit( vcl::Window* pParent, WinBits nStyle ) @@ -426,6 +431,31 @@ DockingWindow::DockingWindow( vcl::Window* pParent, const ResId& rResId ) : Show(); } +//Find the real parent stashed in mpDialogParent. +void DockingWindow::doDeferredInit(WinBits nBits) +{ + vcl::Window *pParent = mpDialogParent; + mpDialogParent = NULL; + ImplInit(pParent, nBits); + mbIsDefferedInit = false; +} + +void DockingWindow::loadUI(vcl::Window* pParent, const OString& rID, const OUString& rUIXMLDescription) +{ + mbIsDefferedInit = true; + mpDialogParent = pParent; //should be unset in doDeferredInit + m_pUIBuilder = new VclBuilder(this, getUIRootDir(), rUIXMLDescription, rID); +} + +DockingWindow::DockingWindow(vcl::Window* pParent, const OUString& rID, + const OUString& rUIXMLDescription) + : Window(WINDOW_DOCKINGWINDOW) +{ + ImplInitDockingWindowData(); + + loadUI(pParent, OUStringToOString(rID, RTL_TEXTENCODING_UTF8), rUIXMLDescription); +} + DockingWindow::~DockingWindow() { if ( IsFloatingMode() ) @@ -434,6 +464,7 @@ DockingWindow::~DockingWindow() SetFloatingMode( false ); } delete mpImplData; + mpImplData = NULL; } void DockingWindow::Tracking( const TrackingEvent& rTEvt ) @@ -687,10 +718,29 @@ void DockingWindow::Resizing( Size& ) { } +void DockingWindow::DoInitialLayout() +{ + if ( GetSettings().GetStyleSettings().GetAutoMnemonic() ) + ImplWindowAutoMnemonic( this ); + + if (isLayoutEnabled()) + { + mbIsCalculatingInitialLayoutSize = true; + setDeferredProperties(); + setOptimalLayoutSize(); + mbIsCalculatingInitialLayoutSize = false; + mbInitialLayoutDone = true; + } +} + void DockingWindow::StateChanged( StateChangedType nType ) { switch(nType) { + case StateChangedType::INITSHOW: + DoInitialLayout(); + break; + case StateChangedType::CONTROLBACKGROUND: ImplInitSettings(); Invalidate(); @@ -737,6 +787,8 @@ void DockingWindow::SetFloatingMode( bool bFloatMode ) { Show( false, SHOW_NOFOCUSCHANGE ); + sal_Int32 nBorderWidth = get_border_width(); + maDockPos = Window::GetPosPixel(); vcl::Window* pRealParent = mpWindowImpl->mpRealParent; @@ -767,7 +819,8 @@ void DockingWindow::SetFloatingMode( bool bFloatMode ) pWin->mpWindowImpl->mpClientWindow = this; mpWindowImpl->mpRealParent = pRealParent; pWin->SetText( Window::GetText() ); - pWin->SetOutputSizePixel( Window::GetSizePixel() ); + Size aSize(Window::GetSizePixel()); + pWin->SetOutputSizePixel(aSize); pWin->SetPosPixel( maFloatPos ); // pass on DockingData to FloatingWindow pWin->ShowTitleButton( TITLE_BUTTON_DOCKING, mbDockBtn ); @@ -779,17 +832,27 @@ void DockingWindow::SetFloatingMode( bool bFloatMode ) pWin->RollDown(); pWin->SetRollUpOutputSizePixel( maRollUpOutSize ); pWin->SetMinOutputSizePixel( maMinOutSize ); + + pWin->set_width_request(std::max(aSize.Width(), maMinOutSize.Width())); + pWin->set_height_request(std::max(aSize.Height(), maMinOutSize.Height())); + pWin->SetMaxOutputSizePixel( mpImplData->maMaxOutSize ); ToggleFloatingMode(); + set_border_width(nBorderWidth); + if ( bVisible ) Show(); + + mpFloatWin->queue_resize(); } else { Show( false, SHOW_NOFOCUSCHANGE ); + sal_Int32 nBorderWidth = get_border_width(); + // store FloatingData in FloatingWindow maFloatPos = mpFloatWin->GetPosPixel(); mbDockBtn = mpFloatWin->IsTitleButtonVisible( TITLE_BUTTON_DOCKING ); @@ -817,6 +880,8 @@ void DockingWindow::SetFloatingMode( bool bFloatMode ) ToggleFloatingMode(); + set_border_width(nBorderWidth); + if ( bVisible ) Show(); } @@ -852,19 +917,31 @@ void DockingWindow::setPosSizePixel( long nX, long nY, sal_uInt16 nFlags ) { ImplDockingWindowWrapper *pWrapper = ImplGetDockingManager()->GetDockingWindowWrapper( this ); - if( pWrapper ) + if (pWrapper) { - if ( pWrapper->mpFloatWin ) - pWrapper->mpFloatWin->setPosSizePixel( nX, nY, nWidth, nHeight, nFlags ); - else + if (!pWrapper->mpFloatWin) Window::setPosSizePixel( nX, nY, nWidth, nHeight, nFlags ); - return; } - - if ( mpFloatWin ) - mpFloatWin->setPosSizePixel( nX, nY, nWidth, nHeight, nFlags ); else - Window::setPosSizePixel( nX, nY, nWidth, nHeight, nFlags ); + { + if (!mpFloatWin) + Window::setPosSizePixel( nX, nY, nWidth, nHeight, nFlags ); + } + + if (::isLayoutEnabled(this)) + { + Size aSize(GetSizePixel()); + + sal_Int32 nBorderWidth = get_border_width(); + + aSize.Width() -= 2 * nBorderWidth; + aSize.Height() -= 2 * nBorderWidth; + + Point aPos(nBorderWidth, nBorderWidth); + Window *pBox = GetWindow(WINDOW_FIRSTCHILD); + assert(pBox); + VclContainer::setLayoutAllocation(*pBox, aPos, aSize); + } } Point DockingWindow::GetPosPixel() const @@ -983,4 +1060,50 @@ void DockingWindow::SetMaxOutputSizePixel( const Size& rSize ) mpImplData->maMaxOutSize = rSize; } +void DockingWindow::SetText(const OUString& rStr) +{ + setDeferredProperties(); + Window::SetText(rStr); +} + +OUString DockingWindow::GetText() const +{ + const_cast(this)->setDeferredProperties(); + return Window::GetText(); +} + +bool DockingWindow::isLayoutEnabled() const +{ + //pre dtor called, and single child is a container => we're layout enabled + return mpImplData && ::isLayoutEnabled(this); +} + +void DockingWindow::setOptimalLayoutSize() +{ + //resize DockingWindow to fit requisition on initial show + Window *pBox = GetWindow(WINDOW_FIRSTCHILD); + + Size aSize = get_preferred_size(); + + Size aMax(bestmaxFrameSizeForScreenSize(GetDesktopRectPixel().GetSize())); + + aSize.Width() = std::min(aMax.Width(), aSize.Width()); + aSize.Height() = std::min(aMax.Height(), aSize.Height()); + + SetMinOutputSizePixel(aSize); + SetSizePixel(aSize); + setPosSizeOnContainee(aSize, *pBox); +} + +void DockingWindow::setPosSizeOnContainee(Size aSize, Window &rBox) +{ + sal_Int32 nBorderWidth = get_border_width(); + + aSize.Width() -= 2 * nBorderWidth; + aSize.Height() -= 2 * nBorderWidth; + + Point aPos(nBorderWidth, nBorderWidth); + VclContainer::setLayoutAllocation(rBox, aPos, aSize); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/window/syswin.cxx b/vcl/source/window/syswin.cxx index 1c258cb81832..538c7c0ff41f 100644 --- a/vcl/source/window/syswin.cxx +++ b/vcl/source/window/syswin.cxx @@ -1028,7 +1028,7 @@ Size SystemWindow::GetOptimalSize() const return Window::CalcWindowSize(aSize); } -void SystemWindow::setPosSizeOnContainee(Size aSize, VclContainer &rBox) +void SystemWindow::setPosSizeOnContainee(Size aSize, Window &rBox) { sal_Int32 nBorderWidth = get_border_width(); @@ -1047,7 +1047,7 @@ IMPL_LINK( SystemWindow, ImplHandleLayoutTimerHdl, void*, EMPTYARG ) return 0; } - VclBox *pBox = static_cast(GetWindow(WINDOW_FIRSTCHILD)); + Window *pBox = GetWindow(WINDOW_FIRSTCHILD); assert(pBox); setPosSizeOnContainee(GetSizePixel(), *pBox); return 0; diff --git a/vcl/source/window/taskpanelist.cxx b/vcl/source/window/taskpanelist.cxx index de4916708728..cc13f1573be0 100644 --- a/vcl/source/window/taskpanelist.cxx +++ b/vcl/source/window/taskpanelist.cxx @@ -31,7 +31,7 @@ Point ImplTaskPaneListGetPos( const vcl::Window *w ) { Point pos; - if( w->ImplIsDockingWindow() ) + if( w->IsDockingWindow() ) { pos = static_cast(w)->GetPosPixel(); vcl::Window *pF = static_cast(w)->GetFloatingWindow(); diff --git a/vcl/source/window/window2.cxx b/vcl/source/window/window2.cxx index 8fe7d9d88416..3f9df5e3b584 100644 --- a/vcl/source/window/window2.cxx +++ b/vcl/source/window/window2.cxx @@ -1019,7 +1019,7 @@ vcl::Window* Window::ImplGetFrameWindow() const return mpWindowImpl->mpFrameWindow; } -bool Window::ImplIsDockingWindow() const +bool Window::IsDockingWindow() const { return mpWindowImpl->mbDockWin; } diff --git a/vcl/source/window/winproc.cxx b/vcl/source/window/winproc.cxx index 6b23fc6bcd99..661426a7faa4 100644 --- a/vcl/source/window/winproc.cxx +++ b/vcl/source/window/winproc.cxx @@ -1841,7 +1841,7 @@ static long DelayedCloseEventLink( void* pCEvent, void* ) // dispatch to correct window type if( pEv->pWindow->IsSystemWindow() ) static_cast(pEv->pWindow)->Close(); - else if( pEv->pWindow->ImplIsDockingWindow() ) + else if( pEv->pWindow->IsDockingWindow() ) static_cast(pEv->pWindow)->Close(); } delete pEv; -- cgit