From ff86ddf59884ab3bd08e6bf33adabf8ca79967df Mon Sep 17 00:00:00 2001 From: Zolnai Tamás Date: Thu, 23 Jan 2014 13:34:48 +0100 Subject: Related fdo#65826: Set StartCenter's min width to display one column of docs If there is document to display. Otherwise set minimum to the width of greating background text. Updating minimum size is needed only when the list is cleared. Change-Id: Ic089571fd21d5ab9ded0f4cde7e1aa72fd508d32 --- include/sfx2/recentdocsview.hxx | 2 ++ include/sfx2/thumbnailview.hxx | 2 +- sfx2/source/control/recentdocsview.cxx | 35 ++++++++++++++++++++++++++-------- sfx2/source/dialog/backingcomp.cxx | 12 ++++++++++++ sfx2/source/dialog/backingwindow.cxx | 1 + 5 files changed, 43 insertions(+), 9 deletions(-) diff --git a/include/sfx2/recentdocsview.hxx b/include/sfx2/recentdocsview.hxx index 63a067d7a0e2..1706935a5ac8 100644 --- a/include/sfx2/recentdocsview.hxx +++ b/include/sfx2/recentdocsview.hxx @@ -56,6 +56,8 @@ public: int mnFileTypes; + virtual void Clear(); + DECL_STATIC_LINK( RecentDocsView, ExecuteHdl_Impl, LoadRecentFile* ); protected: diff --git a/include/sfx2/thumbnailview.hxx b/include/sfx2/thumbnailview.hxx index ccd25dcc3eaf..e21b87b55474 100644 --- a/include/sfx2/thumbnailview.hxx +++ b/include/sfx2/thumbnailview.hxx @@ -192,7 +192,7 @@ public: void RemoveItem( sal_uInt16 nItemId ); - void Clear(); + virtual void Clear(); // Change current thumbnail item list with new one (invalidates all pointers to a thumbnail item) void updateItems(const std::vector &items); diff --git a/sfx2/source/control/recentdocsview.cxx b/sfx2/source/control/recentdocsview.cxx index e815b9741e0b..12a9b7e8466e 100644 --- a/sfx2/source/control/recentdocsview.cxx +++ b/sfx2/source/control/recentdocsview.cxx @@ -53,14 +53,6 @@ RecentDocsView::RecentDocsView( Window* pParent ) SetStyle(GetStyle() | WB_VSCROLL); setItemMaxTextLength( mnItemMaxTextLength ); setItemDimensions( mnItemMaxSize, mnItemMaxSize, mnTextHeight, mnItemPadding ); - - // Set prefered width so text lines will not be cut off - Font aOldFont(GetFont()); - Font aNewFont(aOldFont); - aNewFont.SetHeight(20); - SetFont(aNewFont); - set_width_request(std::max(GetTextWidth(maWelcomeLine1),GetTextWidth(maWelcomeLine2))); - SetFont(aOldFont); } extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeRecentDocsView(Window *pParent, VclBuilder::stringmap &) @@ -184,6 +176,21 @@ void RecentDocsView::loadRecentDocs() CalculateItemPositions(); Invalidate(); + + // Set prefered width + if( mFilteredItemList.empty() ) + { + Font aOldFont(GetFont()); + Font aNewFont(aOldFont); + aNewFont.SetHeight(20); + SetFont(aNewFont); + set_width_request(std::max(GetTextWidth(maWelcomeLine1),GetTextWidth(maWelcomeLine2))); + SetFont(aOldFont); + } + else + { + set_width_request(mnItemMaxSize); + } } void RecentDocsView::MouseButtonDown( const MouseEvent& rMEvt ) @@ -303,6 +310,18 @@ long RecentDocsView::GetThumbnailSize() const return mnItemMaxSize; } +void RecentDocsView::Clear() +{ + Font aOldFont(GetFont()); + Font aNewFont(aOldFont); + aNewFont.SetHeight(20); + SetFont(aNewFont); + set_width_request(std::max(GetTextWidth(maWelcomeLine1),GetTextWidth(maWelcomeLine2))); + SetFont(aOldFont); + + ThumbnailView::Clear(); +} + IMPL_STATIC_LINK_NOINSTANCE( RecentDocsView, ExecuteHdl_Impl, LoadRecentFile*, pLoadRecentFile ) { try diff --git a/sfx2/source/dialog/backingcomp.cxx b/sfx2/source/dialog/backingcomp.cxx index 023d426cd355..f6dd7f06a665 100644 --- a/sfx2/source/dialog/backingcomp.cxx +++ b/sfx2/source/dialog/backingcomp.cxx @@ -850,7 +850,19 @@ void SAL_CALL BackingComp::dispatch( const css::util::URL& aURL, const css::uno: Window* pWindow = VCLUnoHelper::GetWindow(m_xWindow); BackingWindow* pBack = dynamic_cast(pWindow ); if( pBack ) + { pBack->clearRecentFileList(); + + // Recalculate minimum width + css::uno::Reference< css::awt::XWindow > xParentWindow = m_xFrame->getContainerWindow(); + WorkWindow* pParent = (WorkWindow*)VCLUnoHelper::GetWindow(xParentWindow); + if( pParent ) + { + pParent->SetMinOutputSizePixel( Size( + pBack->get_width_request(), + pParent->GetMinOutputSizePixel().Height()) ); + } + } } } diff --git a/sfx2/source/dialog/backingwindow.cxx b/sfx2/source/dialog/backingwindow.cxx index b02f3e3eb95b..a8114d67858b 100644 --- a/sfx2/source/dialog/backingwindow.cxx +++ b/sfx2/source/dialog/backingwindow.cxx @@ -550,5 +550,6 @@ Size BackingWindow::GetOptimalSize() const void BackingWindow::clearRecentFileList() { mpAllRecentThumbnails->Clear(); + set_width_request(mpAllRecentThumbnails->get_width_request() + mpAllButtonsBox->GetOptimalSize().Width()); } /* vim:set shiftwidth=4 softtabstop=4 expandtab:*/ -- cgit v1.2.3