122de8995SAndre Fischer /************************************************************** 222de8995SAndre Fischer * 322de8995SAndre Fischer * Licensed to the Apache Software Foundation (ASF) under one 422de8995SAndre Fischer * or more contributor license agreements. See the NOTICE file 522de8995SAndre Fischer * distributed with this work for additional information 622de8995SAndre Fischer * regarding copyright ownership. The ASF licenses this file 722de8995SAndre Fischer * to you under the Apache License, Version 2.0 (the 822de8995SAndre Fischer * "License"); you may not use this file except in compliance 922de8995SAndre Fischer * with the License. You may obtain a copy of the License at 1022de8995SAndre Fischer * 1122de8995SAndre Fischer * http://www.apache.org/licenses/LICENSE-2.0 1222de8995SAndre Fischer * 1322de8995SAndre Fischer * Unless required by applicable law or agreed to in writing, 1422de8995SAndre Fischer * software distributed under the License is distributed on an 1522de8995SAndre Fischer * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 1622de8995SAndre Fischer * KIND, either express or implied. See the License for the 1722de8995SAndre Fischer * specific language governing permissions and limitations 1822de8995SAndre Fischer * under the License. 1922de8995SAndre Fischer * 2022de8995SAndre Fischer *************************************************************/ 2122de8995SAndre Fischer 2222de8995SAndre Fischer #include "precompiled_sfx2.hxx" 2322de8995SAndre Fischer 2422de8995SAndre Fischer #include "Deck.hxx" 2522de8995SAndre Fischer #include "DeckDescriptor.hxx" 267a32b0c8SAndre Fischer #include "DeckLayouter.hxx" 27ff12d537SAndre Fischer #include "DrawHelper.hxx" 28ff12d537SAndre Fischer #include "DeckTitleBar.hxx" 29b9e67834SAndre Fischer #include "Paint.hxx" 30ff12d537SAndre Fischer #include "Panel.hxx" 317a32b0c8SAndre Fischer #include "ToolBoxBackground.hxx" 32*f35c6d02SAndre Fischer #include "sfx2/sidebar/Tools.hxx" 33b9e67834SAndre Fischer #include "sfx2/sidebar/Theme.hxx" 34ff12d537SAndre Fischer 357a32b0c8SAndre Fischer #include <vcl/dockwin.hxx> 367a32b0c8SAndre Fischer #include <vcl/scrbar.hxx> 3795a18594SAndre Fischer #include <tools/svborder.hxx> 3822de8995SAndre Fischer 397a32b0c8SAndre Fischer #include <boost/bind.hpp> 407a32b0c8SAndre Fischer 417a32b0c8SAndre Fischer using namespace ::com::sun::star; 427a32b0c8SAndre Fischer using namespace ::com::sun::star::uno; 437a32b0c8SAndre Fischer 4422de8995SAndre Fischer 45ff12d537SAndre Fischer namespace sfx2 { namespace sidebar { 46ff12d537SAndre Fischer 47ff12d537SAndre Fischer 48ff12d537SAndre Fischer namespace { 49ff12d537SAndre Fischer static const sal_Int32 MinimalPanelHeight (25); 50ff12d537SAndre Fischer } 51ff12d537SAndre Fischer 52ff12d537SAndre Fischer 5322de8995SAndre Fischer Deck::Deck ( 5422de8995SAndre Fischer const DeckDescriptor& rDeckDescriptor, 557a32b0c8SAndre Fischer Window* pParentWindow, 567a32b0c8SAndre Fischer const ::boost::function<void(void)>& rCloserAction) 5765908a7eSAndre Fischer : Window(pParentWindow, 0), 5822de8995SAndre Fischer msId(rDeckDescriptor.msId), 59ff12d537SAndre Fischer maIcon(), 60ff12d537SAndre Fischer msIconURL(rDeckDescriptor.msIconURL), 61ff12d537SAndre Fischer msHighContrastIconURL(rDeckDescriptor.msHighContrastIconURL), 62b9e67834SAndre Fischer maPanels(), 637a32b0c8SAndre Fischer mpTitleBar(new DeckTitleBar(rDeckDescriptor.msTitle, this, rCloserAction)), 647a32b0c8SAndre Fischer mpScrollClipWindow(new Window(this)), 657a32b0c8SAndre Fischer mpScrollContainer(new ScrollContainerWindow(mpScrollClipWindow.get())), 667a32b0c8SAndre Fischer mpFiller(new Window(this)), 677a32b0c8SAndre Fischer mpVerticalScrollBar(new ScrollBar(this)) 6822de8995SAndre Fischer { 6922de8995SAndre Fischer SetBackground(Wallpaper()); 707a32b0c8SAndre Fischer 717a32b0c8SAndre Fischer mpScrollClipWindow->SetBackground(Wallpaper()); 7265908a7eSAndre Fischer mpScrollClipWindow->Show(); 7365908a7eSAndre Fischer 7465908a7eSAndre Fischer mpScrollContainer->SetStyle(mpScrollContainer->GetStyle() | WB_DIALOGCONTROL); 757a32b0c8SAndre Fischer mpScrollContainer->SetBackground(Wallpaper()); 7665908a7eSAndre Fischer mpScrollContainer->Show(); 777a32b0c8SAndre Fischer 787a32b0c8SAndre Fischer mpVerticalScrollBar->SetScrollHdl(LINK(this, Deck, HandleVerticalScrollBarChange)); 797a32b0c8SAndre Fischer 807a32b0c8SAndre Fischer #ifdef DEBUG 817a32b0c8SAndre Fischer SetText(A2S("Deck")); 827a32b0c8SAndre Fischer mpScrollClipWindow->SetText(A2S("ScrollClipWindow")); 837a32b0c8SAndre Fischer mpFiller->SetText(A2S("Filler")); 847a32b0c8SAndre Fischer mpVerticalScrollBar->SetText(A2S("VerticalScrollBar")); 857a32b0c8SAndre Fischer #endif 8622de8995SAndre Fischer } 8722de8995SAndre Fischer 8822de8995SAndre Fischer 8922de8995SAndre Fischer 9022de8995SAndre Fischer 9122de8995SAndre Fischer Deck::~Deck (void) 9222de8995SAndre Fischer { 93ff12d537SAndre Fischer Dispose(); 94f120fe41SAndre Fischer 95f120fe41SAndre Fischer // We have to explicitly trigger the destruction of panels. 96f120fe41SAndre Fischer // Otherwise that is done by one of our base class destructors 97f120fe41SAndre Fischer // without updating maPanels. 98f120fe41SAndre Fischer maPanels.clear(); 99ff12d537SAndre Fischer } 100ff12d537SAndre Fischer 101ff12d537SAndre Fischer 102ff12d537SAndre Fischer 103ff12d537SAndre Fischer 104ff12d537SAndre Fischer void Deck::Dispose (void) 105ff12d537SAndre Fischer { 106f120fe41SAndre Fischer SharedPanelContainer aPanels; 107ff12d537SAndre Fischer aPanels.swap(maPanels); 108f120fe41SAndre Fischer for (SharedPanelContainer::iterator 109ff12d537SAndre Fischer iPanel(aPanels.begin()), 110ff12d537SAndre Fischer iEnd(aPanels.end()); 111ff12d537SAndre Fischer iPanel!=iEnd; 112ff12d537SAndre Fischer ++iPanel) 113ff12d537SAndre Fischer { 114f120fe41SAndre Fischer if (*iPanel) 115f120fe41SAndre Fischer { 116ff12d537SAndre Fischer (*iPanel)->Dispose(); 117f120fe41SAndre Fischer OSL_ASSERT(iPanel->unique()); 118f120fe41SAndre Fischer iPanel->reset(); 119f120fe41SAndre Fischer } 120ff12d537SAndre Fischer } 1217a32b0c8SAndre Fischer 1227a32b0c8SAndre Fischer mpTitleBar.reset(); 1237a32b0c8SAndre Fischer mpFiller.reset(); 1247a32b0c8SAndre Fischer mpVerticalScrollBar.reset(); 12522de8995SAndre Fischer } 12622de8995SAndre Fischer 12722de8995SAndre Fischer 12822de8995SAndre Fischer 12922de8995SAndre Fischer 13022de8995SAndre Fischer const ::rtl::OUString& Deck::GetId (void) const 13122de8995SAndre Fischer { 13222de8995SAndre Fischer return msId; 13322de8995SAndre Fischer } 13422de8995SAndre Fischer 13522de8995SAndre Fischer 13622de8995SAndre Fischer 13722de8995SAndre Fischer 1387a32b0c8SAndre Fischer DeckTitleBar* Deck::GetTitleBar (void) const 13922de8995SAndre Fischer { 1407a32b0c8SAndre Fischer return mpTitleBar.get(); 14122de8995SAndre Fischer } 14222de8995SAndre Fischer 14322de8995SAndre Fischer 14422de8995SAndre Fischer 14522de8995SAndre Fischer 146ff12d537SAndre Fischer Rectangle Deck::GetContentArea (void) const 14722de8995SAndre Fischer { 148ff12d537SAndre Fischer const Size aWindowSize (GetSizePixel()); 149b9e67834SAndre Fischer const int nBorderSize (Theme::GetInteger(Theme::Int_DeckBorderSize)); 150ff12d537SAndre Fischer 151ff12d537SAndre Fischer return Rectangle( 152b9e67834SAndre Fischer Theme::GetInteger(Theme::Int_DeckLeftPadding) + nBorderSize, 153b9e67834SAndre Fischer Theme::GetInteger(Theme::Int_DeckTopPadding) + nBorderSize, 154b9e67834SAndre Fischer aWindowSize.Width() - 1 - Theme::GetInteger(Theme::Int_DeckRightPadding) - nBorderSize, 155b9e67834SAndre Fischer aWindowSize.Height() - 1 - Theme::GetInteger(Theme::Int_DeckBottomPadding) - nBorderSize); 15622de8995SAndre Fischer } 15722de8995SAndre Fischer 15822de8995SAndre Fischer 159ff12d537SAndre Fischer 160ff12d537SAndre Fischer 161ff12d537SAndre Fischer ::rtl::OUString Deck::GetIconURL (const bool bIsHighContrastModeActive) const 162ff12d537SAndre Fischer { 163ff12d537SAndre Fischer if (bIsHighContrastModeActive) 164ff12d537SAndre Fischer return msHighContrastIconURL; 165ff12d537SAndre Fischer else 166ff12d537SAndre Fischer return msIconURL; 167ff12d537SAndre Fischer } 168ff12d537SAndre Fischer 169ff12d537SAndre Fischer 170ff12d537SAndre Fischer 171ff12d537SAndre Fischer 172ff12d537SAndre Fischer void Deck::Paint (const Rectangle& rUpdateArea) 173ff12d537SAndre Fischer { 17495a18594SAndre Fischer (void) rUpdateArea; 17595a18594SAndre Fischer 176ff12d537SAndre Fischer const Size aWindowSize (GetSizePixel()); 177b9e67834SAndre Fischer const SvBorder aPadding ( 178b9e67834SAndre Fischer Theme::GetInteger(Theme::Int_DeckLeftPadding), 179b9e67834SAndre Fischer Theme::GetInteger(Theme::Int_DeckTopPadding), 180b9e67834SAndre Fischer Theme::GetInteger(Theme::Int_DeckRightPadding), 181b9e67834SAndre Fischer Theme::GetInteger(Theme::Int_DeckBottomPadding)); 182ff12d537SAndre Fischer 183ff12d537SAndre Fischer // Paint deck background outside the border. 184b9e67834SAndre Fischer Rectangle aBox( 185ff12d537SAndre Fischer 0, 186ff12d537SAndre Fischer 0, 187ff12d537SAndre Fischer aWindowSize.Width() - 1, 188b9e67834SAndre Fischer aWindowSize.Height() - 1); 189ff12d537SAndre Fischer DrawHelper::DrawBorder( 190ff12d537SAndre Fischer *this, 191b9e67834SAndre Fischer aBox, 192b9e67834SAndre Fischer aPadding, 193b9e67834SAndre Fischer Theme::GetPaint(Theme::Paint_DeckBackground), 194b9e67834SAndre Fischer Theme::GetPaint(Theme::Paint_DeckBackground)); 195b9e67834SAndre Fischer 196b9e67834SAndre Fischer // Paint the border. 197b9e67834SAndre Fischer const int nBorderSize (Theme::GetInteger(Theme::Int_DeckBorderSize)); 198b9e67834SAndre Fischer aBox.Left() += aPadding.Left(); 199b9e67834SAndre Fischer aBox.Top() += aPadding.Top(); 200b9e67834SAndre Fischer aBox.Right() -= aPadding.Right(); 201b9e67834SAndre Fischer aBox.Bottom() -= aPadding.Bottom(); 202b9e67834SAndre Fischer const sfx2::sidebar::Paint& rHorizontalBorderPaint (Theme::GetPaint(Theme::Paint_HorizontalBorder)); 203b9e67834SAndre Fischer DrawHelper::DrawBorder( 204b9e67834SAndre Fischer *this, 205b9e67834SAndre Fischer aBox, 206ff12d537SAndre Fischer SvBorder(nBorderSize, nBorderSize, nBorderSize, nBorderSize), 207b9e67834SAndre Fischer rHorizontalBorderPaint, 208b9e67834SAndre Fischer Theme::GetPaint(Theme::Paint_VerticalBorder)); 209b9e67834SAndre Fischer } 210b9e67834SAndre Fischer 211b9e67834SAndre Fischer 212b9e67834SAndre Fischer 213b9e67834SAndre Fischer 214b9e67834SAndre Fischer void Deck::DataChanged (const DataChangedEvent& rEvent) 215b9e67834SAndre Fischer { 216b9e67834SAndre Fischer (void)rEvent; 217b9e67834SAndre Fischer RequestLayout(); 218ff12d537SAndre Fischer } 219ff12d537SAndre Fischer 220ff12d537SAndre Fischer 221ff12d537SAndre Fischer 222ff12d537SAndre Fischer 223f120fe41SAndre Fischer void Deck::SetPanels (const SharedPanelContainer& rPanels) 224ff12d537SAndre Fischer { 225f120fe41SAndre Fischer maPanels = rPanels; 226ff12d537SAndre Fischer 227ff12d537SAndre Fischer RequestLayout(); 228ff12d537SAndre Fischer } 229ff12d537SAndre Fischer 230ff12d537SAndre Fischer 231ff12d537SAndre Fischer 232ff12d537SAndre Fischer 233f120fe41SAndre Fischer const SharedPanelContainer& Deck::GetPanels (void) const 234f120fe41SAndre Fischer { 235f120fe41SAndre Fischer return maPanels; 236f120fe41SAndre Fischer } 237f120fe41SAndre Fischer 238f120fe41SAndre Fischer 239f120fe41SAndre Fischer 240f120fe41SAndre Fischer 241ff12d537SAndre Fischer void Deck::RequestLayout (void) 242ff12d537SAndre Fischer { 2438403f08eSAndre Fischer // PrintWindowTree(); 244ff12d537SAndre Fischer 2457a32b0c8SAndre Fischer DeckLayouter::LayoutDeck( 2467a32b0c8SAndre Fischer GetContentArea(), 2477a32b0c8SAndre Fischer maPanels, 2487a32b0c8SAndre Fischer *GetTitleBar(), 2497a32b0c8SAndre Fischer *mpScrollClipWindow, 2507a32b0c8SAndre Fischer *mpScrollContainer, 2517a32b0c8SAndre Fischer *mpFiller, 2527a32b0c8SAndre Fischer *mpVerticalScrollBar); 253ff12d537SAndre Fischer 254ff12d537SAndre Fischer Invalidate(); 255ff12d537SAndre Fischer } 256ff12d537SAndre Fischer 257ff12d537SAndre Fischer 258ff12d537SAndre Fischer 259ff12d537SAndre Fischer 2607a32b0c8SAndre Fischer ::Window* Deck::GetPanelParentWindow (void) 261ff12d537SAndre Fischer { 2627a32b0c8SAndre Fischer return mpScrollContainer.get(); 2637a32b0c8SAndre Fischer } 264ff12d537SAndre Fischer 265b9e67834SAndre Fischer 2667a32b0c8SAndre Fischer 2677a32b0c8SAndre Fischer 2687a32b0c8SAndre Fischer const char* GetWindowClassification (const Window* pWindow) 269ff12d537SAndre Fischer { 2707a32b0c8SAndre Fischer const String& rsName (pWindow->GetText()); 2717a32b0c8SAndre Fischer if (rsName.Len() > 0) 2727a32b0c8SAndre Fischer { 2737a32b0c8SAndre Fischer return ::rtl::OUStringToOString(rsName, RTL_TEXTENCODING_ASCII_US).getStr(); 274ff12d537SAndre Fischer } 275ff12d537SAndre Fischer else 276ff12d537SAndre Fischer { 2777a32b0c8SAndre Fischer static char msWindow[] = "window"; 2787a32b0c8SAndre Fischer return msWindow; 279ff12d537SAndre Fischer } 280ff12d537SAndre Fischer } 281ff12d537SAndre Fischer 282ff12d537SAndre Fischer 2837a32b0c8SAndre Fischer void Deck::PrintWindowSubTree (Window* pRoot, int nIndentation) 284ff12d537SAndre Fischer { 28545da7d5eSAndre Fischer static const char* sIndentation = " "; 2867a32b0c8SAndre Fischer const Point aLocation (pRoot->GetPosPixel()); 2877a32b0c8SAndre Fischer const Size aSize (pRoot->GetSizePixel()); 2887a32b0c8SAndre Fischer const char* sClassification = GetWindowClassification(pRoot); 2897a32b0c8SAndre Fischer const char* sVisible = pRoot->IsVisible() ? "visible" : "hidden"; 2907a32b0c8SAndre Fischer OSL_TRACE("%s%x %s %s +%d+%d x%dx%d", 2917a32b0c8SAndre Fischer sIndentation+strlen(sIndentation)-nIndentation*4, 2927a32b0c8SAndre Fischer pRoot, 2937a32b0c8SAndre Fischer sClassification, 2947a32b0c8SAndre Fischer sVisible, 2957a32b0c8SAndre Fischer aLocation.X(),aLocation.Y(), 2967a32b0c8SAndre Fischer aSize.Width(),aSize.Height()); 297b9e67834SAndre Fischer 2987a32b0c8SAndre Fischer const sal_uInt16 nChildCount (pRoot->GetChildCount()); 2997a32b0c8SAndre Fischer for (sal_uInt16 nIndex=0; nIndex<nChildCount; ++nIndex) 3007a32b0c8SAndre Fischer PrintWindowSubTree(pRoot->GetChild(nIndex), nIndentation+1); 3017a32b0c8SAndre Fischer } 302ff12d537SAndre Fischer 3037a32b0c8SAndre Fischer 3047a32b0c8SAndre Fischer 3057a32b0c8SAndre Fischer 3067a32b0c8SAndre Fischer void Deck::PrintWindowTree (void) 307ff12d537SAndre Fischer { 3087a32b0c8SAndre Fischer PrintWindowSubTree(this, 0); 3097a32b0c8SAndre Fischer } 31095a18594SAndre Fischer 311ff12d537SAndre Fischer 312ff12d537SAndre Fischer 3137a32b0c8SAndre Fischer 3147a32b0c8SAndre Fischer void Deck::PrintWindowTree (const ::std::vector<Panel*>& rPanels) 315ff12d537SAndre Fischer { 3167a32b0c8SAndre Fischer (void)rPanels; 3177a32b0c8SAndre Fischer 3187a32b0c8SAndre Fischer PrintWindowTree(); 3197a32b0c8SAndre Fischer } 3207a32b0c8SAndre Fischer 3217a32b0c8SAndre Fischer 3227a32b0c8SAndre Fischer 3237a32b0c8SAndre Fischer 3247a32b0c8SAndre Fischer IMPL_LINK(Deck, HandleVerticalScrollBarChange,void*, EMPTYARG) 325ff12d537SAndre Fischer { 3267a32b0c8SAndre Fischer const sal_Int32 nYOffset (-mpVerticalScrollBar->GetThumbPos()); 3277a32b0c8SAndre Fischer mpScrollContainer->SetPosPixel( 3287a32b0c8SAndre Fischer Point( 3297a32b0c8SAndre Fischer mpScrollContainer->GetPosPixel().X(), 3307a32b0c8SAndre Fischer nYOffset)); 3317a32b0c8SAndre Fischer return sal_True; 3327a32b0c8SAndre Fischer } 3337a32b0c8SAndre Fischer 3347a32b0c8SAndre Fischer 3357a32b0c8SAndre Fischer 3367a32b0c8SAndre Fischer 3377a32b0c8SAndre Fischer //----- Deck::ScrollContainerWindow ------------------------------------------- 3387a32b0c8SAndre Fischer 3397a32b0c8SAndre Fischer Deck::ScrollContainerWindow::ScrollContainerWindow (Window* pParentWindow) 3407a32b0c8SAndre Fischer : Window(pParentWindow), 3417a32b0c8SAndre Fischer maSeparators() 34295a18594SAndre Fischer { 3437a32b0c8SAndre Fischer #ifdef DEBUG 3447a32b0c8SAndre Fischer SetText(A2S("ScrollContainerWindow")); 3457a32b0c8SAndre Fischer #endif 346ff12d537SAndre Fischer } 3477a32b0c8SAndre Fischer 3487a32b0c8SAndre Fischer 3497a32b0c8SAndre Fischer 3507a32b0c8SAndre Fischer 3517a32b0c8SAndre Fischer Deck::ScrollContainerWindow::~ScrollContainerWindow (void) 352ff12d537SAndre Fischer { 35395a18594SAndre Fischer } 3547a32b0c8SAndre Fischer 3557a32b0c8SAndre Fischer 3567a32b0c8SAndre Fischer 3577a32b0c8SAndre Fischer 3587a32b0c8SAndre Fischer void Deck::ScrollContainerWindow::Paint (const Rectangle& rUpdateArea) 35995a18594SAndre Fischer { 3607a32b0c8SAndre Fischer (void)rUpdateArea; 361ff12d537SAndre Fischer 3627a32b0c8SAndre Fischer // Paint the separators. 3637a32b0c8SAndre Fischer const sal_Int32 nSeparatorHeight (Theme::GetInteger(Theme::Int_DeckSeparatorHeight)); 3647a32b0c8SAndre Fischer const sal_Int32 nLeft (0); 3657a32b0c8SAndre Fischer const sal_Int32 nRight (GetSizePixel().Width()-1); 3667a32b0c8SAndre Fischer const sfx2::sidebar::Paint& rHorizontalBorderPaint (Theme::GetPaint(Theme::Paint_HorizontalBorder)); 3677a32b0c8SAndre Fischer for (::std::vector<sal_Int32>::const_iterator iY(maSeparators.begin()), iEnd(maSeparators.end()); 3687a32b0c8SAndre Fischer iY!=iEnd; 3697a32b0c8SAndre Fischer ++iY) 370ff12d537SAndre Fischer { 3717a32b0c8SAndre Fischer DrawHelper::DrawHorizontalLine( 3727a32b0c8SAndre Fischer *this, 3737a32b0c8SAndre Fischer nLeft, 3747a32b0c8SAndre Fischer nRight, 3757a32b0c8SAndre Fischer *iY, 3767a32b0c8SAndre Fischer nSeparatorHeight, 3777a32b0c8SAndre Fischer rHorizontalBorderPaint); 3787a32b0c8SAndre Fischer } 379ff12d537SAndre Fischer } 380ff12d537SAndre Fischer 3817a32b0c8SAndre Fischer 3827a32b0c8SAndre Fischer 3837a32b0c8SAndre Fischer 3847a32b0c8SAndre Fischer void Deck::ScrollContainerWindow::SetSeparators (const ::std::vector<sal_Int32>& rSeparators) 385ff12d537SAndre Fischer { 3867a32b0c8SAndre Fischer maSeparators = rSeparators; 387ff12d537SAndre Fischer } 388ff12d537SAndre Fischer 389ff12d537SAndre Fischer } } // end of namespace sfx2::sidebar 390