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" 26*7a32b0c8SAndre Fischer #include "DeckLayouter.hxx" 27ff12d537SAndre Fischer #include "DrawHelper.hxx" 28ff12d537SAndre Fischer #include "DeckTitleBar.hxx" 29b9e67834SAndre Fischer #include "Paint.hxx" 30ff12d537SAndre Fischer #include "Panel.hxx" 31*7a32b0c8SAndre Fischer #include "ToolBoxBackground.hxx" 32*7a32b0c8SAndre Fischer #include "Tools.hxx" 33b9e67834SAndre Fischer #include "sfx2/sidebar/Theme.hxx" 34ff12d537SAndre Fischer 35*7a32b0c8SAndre Fischer #include <vcl/dockwin.hxx> 36*7a32b0c8SAndre Fischer #include <vcl/scrbar.hxx> 3795a18594SAndre Fischer #include <tools/svborder.hxx> 3822de8995SAndre Fischer 39*7a32b0c8SAndre Fischer #include <boost/bind.hpp> 40*7a32b0c8SAndre Fischer 41*7a32b0c8SAndre Fischer using namespace ::com::sun::star; 42*7a32b0c8SAndre Fischer using namespace ::com::sun::star::uno; 43*7a32b0c8SAndre 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, 55*7a32b0c8SAndre Fischer Window* pParentWindow, 56*7a32b0c8SAndre Fischer const ::boost::function<void(void)>& rCloserAction) 5722de8995SAndre Fischer : Window(pParentWindow), 5822de8995SAndre Fischer msId(rDeckDescriptor.msId), 59ff12d537SAndre Fischer maIcon(), 60ff12d537SAndre Fischer msIconURL(rDeckDescriptor.msIconURL), 61ff12d537SAndre Fischer msHighContrastIconURL(rDeckDescriptor.msHighContrastIconURL), 62b9e67834SAndre Fischer maPanels(), 63*7a32b0c8SAndre Fischer mpTitleBar(new DeckTitleBar(rDeckDescriptor.msTitle, this, rCloserAction)), 64*7a32b0c8SAndre Fischer mpScrollClipWindow(new Window(this)), 65*7a32b0c8SAndre Fischer mpScrollContainer(new ScrollContainerWindow(mpScrollClipWindow.get())), 66*7a32b0c8SAndre Fischer mpFiller(new Window(this)), 67*7a32b0c8SAndre Fischer mpVerticalScrollBar(new ScrollBar(this)) 6822de8995SAndre Fischer { 6922de8995SAndre Fischer SetBackground(Wallpaper()); 70*7a32b0c8SAndre Fischer 71*7a32b0c8SAndre Fischer mpScrollClipWindow->Show(); 72*7a32b0c8SAndre Fischer mpScrollClipWindow->SetBackground(Wallpaper()); 73*7a32b0c8SAndre Fischer mpScrollContainer->Show(); 74*7a32b0c8SAndre Fischer mpScrollContainer->SetBackground(Wallpaper()); 75*7a32b0c8SAndre Fischer 76*7a32b0c8SAndre Fischer mpVerticalScrollBar->SetScrollHdl(LINK(this, Deck, HandleVerticalScrollBarChange)); 77*7a32b0c8SAndre Fischer 78*7a32b0c8SAndre Fischer #ifdef DEBUG 79*7a32b0c8SAndre Fischer OSL_TRACE("creating Deck at %x", this); 80*7a32b0c8SAndre Fischer SetText(A2S("Deck")); 81*7a32b0c8SAndre Fischer mpScrollClipWindow->SetText(A2S("ScrollClipWindow")); 82*7a32b0c8SAndre Fischer mpFiller->SetText(A2S("Filler")); 83*7a32b0c8SAndre Fischer mpVerticalScrollBar->SetText(A2S("VerticalScrollBar")); 84*7a32b0c8SAndre Fischer #endif 8522de8995SAndre Fischer } 8622de8995SAndre Fischer 8722de8995SAndre Fischer 8822de8995SAndre Fischer 8922de8995SAndre Fischer 9022de8995SAndre Fischer Deck::~Deck (void) 9122de8995SAndre Fischer { 92*7a32b0c8SAndre Fischer OSL_TRACE("destroying Deck at %x", this); 93ff12d537SAndre Fischer Dispose(); 94ff12d537SAndre Fischer } 95ff12d537SAndre Fischer 96ff12d537SAndre Fischer 97ff12d537SAndre Fischer 98ff12d537SAndre Fischer 99ff12d537SAndre Fischer void Deck::Dispose (void) 100ff12d537SAndre Fischer { 101*7a32b0c8SAndre Fischer PanelContainer aPanels; 102ff12d537SAndre Fischer aPanels.swap(maPanels); 103*7a32b0c8SAndre Fischer for (PanelContainer::const_iterator 104ff12d537SAndre Fischer iPanel(aPanels.begin()), 105ff12d537SAndre Fischer iEnd(aPanels.end()); 106ff12d537SAndre Fischer iPanel!=iEnd; 107ff12d537SAndre Fischer ++iPanel) 108ff12d537SAndre Fischer { 10995a18594SAndre Fischer if (*iPanel != NULL) 110ff12d537SAndre Fischer (*iPanel)->Dispose(); 111ff12d537SAndre Fischer } 112*7a32b0c8SAndre Fischer 113*7a32b0c8SAndre Fischer mpTitleBar.reset(); 114*7a32b0c8SAndre Fischer mpFiller.reset(); 115*7a32b0c8SAndre Fischer mpVerticalScrollBar.reset(); 11622de8995SAndre Fischer } 11722de8995SAndre Fischer 11822de8995SAndre Fischer 11922de8995SAndre Fischer 12022de8995SAndre Fischer 12122de8995SAndre Fischer const ::rtl::OUString& Deck::GetId (void) const 12222de8995SAndre Fischer { 12322de8995SAndre Fischer return msId; 12422de8995SAndre Fischer } 12522de8995SAndre Fischer 12622de8995SAndre Fischer 12722de8995SAndre Fischer 12822de8995SAndre Fischer 129*7a32b0c8SAndre Fischer DeckTitleBar* Deck::GetTitleBar (void) const 13022de8995SAndre Fischer { 131*7a32b0c8SAndre Fischer return mpTitleBar.get(); 13222de8995SAndre Fischer } 13322de8995SAndre Fischer 13422de8995SAndre Fischer 13522de8995SAndre Fischer 13622de8995SAndre Fischer 137ff12d537SAndre Fischer Rectangle Deck::GetContentArea (void) const 13822de8995SAndre Fischer { 139ff12d537SAndre Fischer const Size aWindowSize (GetSizePixel()); 140b9e67834SAndre Fischer const int nBorderSize (Theme::GetInteger(Theme::Int_DeckBorderSize)); 141ff12d537SAndre Fischer 142ff12d537SAndre Fischer return Rectangle( 143b9e67834SAndre Fischer Theme::GetInteger(Theme::Int_DeckLeftPadding) + nBorderSize, 144b9e67834SAndre Fischer Theme::GetInteger(Theme::Int_DeckTopPadding) + nBorderSize, 145b9e67834SAndre Fischer aWindowSize.Width() - 1 - Theme::GetInteger(Theme::Int_DeckRightPadding) - nBorderSize, 146b9e67834SAndre Fischer aWindowSize.Height() - 1 - Theme::GetInteger(Theme::Int_DeckBottomPadding) - nBorderSize); 14722de8995SAndre Fischer } 14822de8995SAndre Fischer 14922de8995SAndre Fischer 150ff12d537SAndre Fischer 151ff12d537SAndre Fischer 152ff12d537SAndre Fischer ::rtl::OUString Deck::GetIconURL (const bool bIsHighContrastModeActive) const 153ff12d537SAndre Fischer { 154ff12d537SAndre Fischer if (bIsHighContrastModeActive) 155ff12d537SAndre Fischer return msHighContrastIconURL; 156ff12d537SAndre Fischer else 157ff12d537SAndre Fischer return msIconURL; 158ff12d537SAndre Fischer } 159ff12d537SAndre Fischer 160ff12d537SAndre Fischer 161ff12d537SAndre Fischer 162ff12d537SAndre Fischer 163ff12d537SAndre Fischer void Deck::Paint (const Rectangle& rUpdateArea) 164ff12d537SAndre Fischer { 16595a18594SAndre Fischer (void) rUpdateArea; 16695a18594SAndre Fischer 167ff12d537SAndre Fischer const Size aWindowSize (GetSizePixel()); 168b9e67834SAndre Fischer const SvBorder aPadding ( 169b9e67834SAndre Fischer Theme::GetInteger(Theme::Int_DeckLeftPadding), 170b9e67834SAndre Fischer Theme::GetInteger(Theme::Int_DeckTopPadding), 171b9e67834SAndre Fischer Theme::GetInteger(Theme::Int_DeckRightPadding), 172b9e67834SAndre Fischer Theme::GetInteger(Theme::Int_DeckBottomPadding)); 173ff12d537SAndre Fischer 174ff12d537SAndre Fischer // Paint deck background outside the border. 175b9e67834SAndre Fischer Rectangle aBox( 176ff12d537SAndre Fischer 0, 177ff12d537SAndre Fischer 0, 178ff12d537SAndre Fischer aWindowSize.Width() - 1, 179b9e67834SAndre Fischer aWindowSize.Height() - 1); 180ff12d537SAndre Fischer DrawHelper::DrawBorder( 181ff12d537SAndre Fischer *this, 182b9e67834SAndre Fischer aBox, 183b9e67834SAndre Fischer aPadding, 184b9e67834SAndre Fischer Theme::GetPaint(Theme::Paint_DeckBackground), 185b9e67834SAndre Fischer Theme::GetPaint(Theme::Paint_DeckBackground)); 186b9e67834SAndre Fischer 187b9e67834SAndre Fischer // Paint the border. 188b9e67834SAndre Fischer const int nBorderSize (Theme::GetInteger(Theme::Int_DeckBorderSize)); 189b9e67834SAndre Fischer aBox.Left() += aPadding.Left(); 190b9e67834SAndre Fischer aBox.Top() += aPadding.Top(); 191b9e67834SAndre Fischer aBox.Right() -= aPadding.Right(); 192b9e67834SAndre Fischer aBox.Bottom() -= aPadding.Bottom(); 193b9e67834SAndre Fischer const sfx2::sidebar::Paint& rHorizontalBorderPaint (Theme::GetPaint(Theme::Paint_HorizontalBorder)); 194b9e67834SAndre Fischer DrawHelper::DrawBorder( 195b9e67834SAndre Fischer *this, 196b9e67834SAndre Fischer aBox, 197ff12d537SAndre Fischer SvBorder(nBorderSize, nBorderSize, nBorderSize, nBorderSize), 198b9e67834SAndre Fischer rHorizontalBorderPaint, 199b9e67834SAndre Fischer Theme::GetPaint(Theme::Paint_VerticalBorder)); 200b9e67834SAndre Fischer } 201b9e67834SAndre Fischer 202b9e67834SAndre Fischer 203b9e67834SAndre Fischer 204b9e67834SAndre Fischer 205b9e67834SAndre Fischer void Deck::DataChanged (const DataChangedEvent& rEvent) 206b9e67834SAndre Fischer { 207b9e67834SAndre Fischer (void)rEvent; 208b9e67834SAndre Fischer RequestLayout(); 209ff12d537SAndre Fischer } 210ff12d537SAndre Fischer 211ff12d537SAndre Fischer 212ff12d537SAndre Fischer 213ff12d537SAndre Fischer 214ff12d537SAndre Fischer void Deck::SetPanels (const ::std::vector<Panel*>& rPanels) 215ff12d537SAndre Fischer { 216*7a32b0c8SAndre Fischer maPanels.clear(); 217*7a32b0c8SAndre Fischer maPanels.reserve(rPanels.size()); 218*7a32b0c8SAndre Fischer for (::std::vector<Panel*>::const_iterator iPanel(rPanels.begin()),iEnd(rPanels.end()); 219*7a32b0c8SAndre Fischer iPanel!=iEnd; 220*7a32b0c8SAndre Fischer ++iPanel) 221*7a32b0c8SAndre Fischer { 222*7a32b0c8SAndre Fischer maPanels.push_back(*iPanel); 223*7a32b0c8SAndre Fischer } 224ff12d537SAndre Fischer 225ff12d537SAndre Fischer RequestLayout(); 226ff12d537SAndre Fischer } 227ff12d537SAndre Fischer 228ff12d537SAndre Fischer 229ff12d537SAndre Fischer 230ff12d537SAndre Fischer 231ff12d537SAndre Fischer void Deck::RequestLayout (void) 232ff12d537SAndre Fischer { 233*7a32b0c8SAndre Fischer PrintWindowTree(); 234ff12d537SAndre Fischer 235*7a32b0c8SAndre Fischer DeckLayouter::LayoutDeck( 236*7a32b0c8SAndre Fischer GetContentArea(), 237*7a32b0c8SAndre Fischer maPanels, 238*7a32b0c8SAndre Fischer *GetTitleBar(), 239*7a32b0c8SAndre Fischer *mpScrollClipWindow, 240*7a32b0c8SAndre Fischer *mpScrollContainer, 241*7a32b0c8SAndre Fischer *mpFiller, 242*7a32b0c8SAndre Fischer *mpVerticalScrollBar); 243ff12d537SAndre Fischer 244ff12d537SAndre Fischer Invalidate(); 245ff12d537SAndre Fischer } 246ff12d537SAndre Fischer 247ff12d537SAndre Fischer 248ff12d537SAndre Fischer 249ff12d537SAndre Fischer 250*7a32b0c8SAndre Fischer ::Window* Deck::GetPanelParentWindow (void) 251ff12d537SAndre Fischer { 252*7a32b0c8SAndre Fischer return mpScrollContainer.get(); 253*7a32b0c8SAndre Fischer } 254ff12d537SAndre Fischer 255b9e67834SAndre Fischer 256*7a32b0c8SAndre Fischer 257*7a32b0c8SAndre Fischer 258*7a32b0c8SAndre Fischer const char* GetWindowClassification (const Window* pWindow) 259ff12d537SAndre Fischer { 260*7a32b0c8SAndre Fischer const String& rsName (pWindow->GetText()); 261*7a32b0c8SAndre Fischer if (rsName.Len() > 0) 262*7a32b0c8SAndre Fischer { 263*7a32b0c8SAndre Fischer return ::rtl::OUStringToOString(rsName, RTL_TEXTENCODING_ASCII_US).getStr(); 264ff12d537SAndre Fischer } 265ff12d537SAndre Fischer else 266ff12d537SAndre Fischer { 267*7a32b0c8SAndre Fischer static char msWindow[] = "window"; 268*7a32b0c8SAndre Fischer return msWindow; 269ff12d537SAndre Fischer } 270ff12d537SAndre Fischer } 271ff12d537SAndre Fischer 272ff12d537SAndre Fischer 273*7a32b0c8SAndre Fischer void Deck::PrintWindowSubTree (Window* pRoot, int nIndentation) 274ff12d537SAndre Fischer { 275*7a32b0c8SAndre Fischer static char* sIndentation = " "; 276*7a32b0c8SAndre Fischer const Point aLocation (pRoot->GetPosPixel()); 277*7a32b0c8SAndre Fischer const Size aSize (pRoot->GetSizePixel()); 278*7a32b0c8SAndre Fischer const char* sClassification = GetWindowClassification(pRoot); 279*7a32b0c8SAndre Fischer const char* sVisible = pRoot->IsVisible() ? "visible" : "hidden"; 280*7a32b0c8SAndre Fischer OSL_TRACE("%s%x %s %s +%d+%d x%dx%d", 281*7a32b0c8SAndre Fischer sIndentation+strlen(sIndentation)-nIndentation*4, 282*7a32b0c8SAndre Fischer pRoot, 283*7a32b0c8SAndre Fischer sClassification, 284*7a32b0c8SAndre Fischer sVisible, 285*7a32b0c8SAndre Fischer aLocation.X(),aLocation.Y(), 286*7a32b0c8SAndre Fischer aSize.Width(),aSize.Height()); 287b9e67834SAndre Fischer 288*7a32b0c8SAndre Fischer const sal_uInt16 nChildCount (pRoot->GetChildCount()); 289*7a32b0c8SAndre Fischer for (sal_uInt16 nIndex=0; nIndex<nChildCount; ++nIndex) 290*7a32b0c8SAndre Fischer PrintWindowSubTree(pRoot->GetChild(nIndex), nIndentation+1); 291*7a32b0c8SAndre Fischer } 292ff12d537SAndre Fischer 293*7a32b0c8SAndre Fischer 294*7a32b0c8SAndre Fischer 295*7a32b0c8SAndre Fischer 296*7a32b0c8SAndre Fischer void Deck::PrintWindowTree (void) 297ff12d537SAndre Fischer { 298*7a32b0c8SAndre Fischer PrintWindowSubTree(this, 0); 299*7a32b0c8SAndre Fischer } 30095a18594SAndre Fischer 301ff12d537SAndre Fischer 302ff12d537SAndre Fischer 303*7a32b0c8SAndre Fischer 304*7a32b0c8SAndre Fischer void Deck::PrintWindowTree (const ::std::vector<Panel*>& rPanels) 305ff12d537SAndre Fischer { 306*7a32b0c8SAndre Fischer (void)rPanels; 307*7a32b0c8SAndre Fischer 308*7a32b0c8SAndre Fischer PrintWindowTree(); 309*7a32b0c8SAndre Fischer } 310*7a32b0c8SAndre Fischer 311*7a32b0c8SAndre Fischer 312*7a32b0c8SAndre Fischer 313*7a32b0c8SAndre Fischer 314*7a32b0c8SAndre Fischer IMPL_LINK(Deck, HandleVerticalScrollBarChange,void*, EMPTYARG) 315ff12d537SAndre Fischer { 316*7a32b0c8SAndre Fischer const sal_Int32 nYOffset (-mpVerticalScrollBar->GetThumbPos()); 317*7a32b0c8SAndre Fischer mpScrollContainer->SetPosPixel( 318*7a32b0c8SAndre Fischer Point( 319*7a32b0c8SAndre Fischer mpScrollContainer->GetPosPixel().X(), 320*7a32b0c8SAndre Fischer nYOffset)); 321*7a32b0c8SAndre Fischer return sal_True; 322*7a32b0c8SAndre Fischer } 323*7a32b0c8SAndre Fischer 324*7a32b0c8SAndre Fischer 325*7a32b0c8SAndre Fischer 326*7a32b0c8SAndre Fischer 327*7a32b0c8SAndre Fischer //----- Deck::ScrollContainerWindow ------------------------------------------- 328*7a32b0c8SAndre Fischer 329*7a32b0c8SAndre Fischer Deck::ScrollContainerWindow::ScrollContainerWindow (Window* pParentWindow) 330*7a32b0c8SAndre Fischer : Window(pParentWindow), 331*7a32b0c8SAndre Fischer maSeparators() 33295a18594SAndre Fischer { 333*7a32b0c8SAndre Fischer #ifdef DEBUG 334*7a32b0c8SAndre Fischer SetText(A2S("ScrollContainerWindow")); 335*7a32b0c8SAndre Fischer #endif 336ff12d537SAndre Fischer } 337*7a32b0c8SAndre Fischer 338*7a32b0c8SAndre Fischer 339*7a32b0c8SAndre Fischer 340*7a32b0c8SAndre Fischer 341*7a32b0c8SAndre Fischer Deck::ScrollContainerWindow::~ScrollContainerWindow (void) 342ff12d537SAndre Fischer { 34395a18594SAndre Fischer } 344*7a32b0c8SAndre Fischer 345*7a32b0c8SAndre Fischer 346*7a32b0c8SAndre Fischer 347*7a32b0c8SAndre Fischer 348*7a32b0c8SAndre Fischer void Deck::ScrollContainerWindow::Paint (const Rectangle& rUpdateArea) 34995a18594SAndre Fischer { 350*7a32b0c8SAndre Fischer (void)rUpdateArea; 351ff12d537SAndre Fischer 352*7a32b0c8SAndre Fischer // Paint the separators. 353*7a32b0c8SAndre Fischer const sal_Int32 nSeparatorHeight (Theme::GetInteger(Theme::Int_DeckSeparatorHeight)); 354*7a32b0c8SAndre Fischer const sal_Int32 nLeft (0); 355*7a32b0c8SAndre Fischer const sal_Int32 nRight (GetSizePixel().Width()-1); 356*7a32b0c8SAndre Fischer const sfx2::sidebar::Paint& rHorizontalBorderPaint (Theme::GetPaint(Theme::Paint_HorizontalBorder)); 357*7a32b0c8SAndre Fischer for (::std::vector<sal_Int32>::const_iterator iY(maSeparators.begin()), iEnd(maSeparators.end()); 358*7a32b0c8SAndre Fischer iY!=iEnd; 359*7a32b0c8SAndre Fischer ++iY) 360ff12d537SAndre Fischer { 361*7a32b0c8SAndre Fischer DrawHelper::DrawHorizontalLine( 362*7a32b0c8SAndre Fischer *this, 363*7a32b0c8SAndre Fischer nLeft, 364*7a32b0c8SAndre Fischer nRight, 365*7a32b0c8SAndre Fischer *iY, 366*7a32b0c8SAndre Fischer nSeparatorHeight, 367*7a32b0c8SAndre Fischer rHorizontalBorderPaint); 368*7a32b0c8SAndre Fischer } 369ff12d537SAndre Fischer } 370ff12d537SAndre Fischer 371*7a32b0c8SAndre Fischer 372*7a32b0c8SAndre Fischer 373*7a32b0c8SAndre Fischer 374*7a32b0c8SAndre Fischer void Deck::ScrollContainerWindow::SetSeparators (const ::std::vector<sal_Int32>& rSeparators) 375ff12d537SAndre Fischer { 376*7a32b0c8SAndre Fischer maSeparators = rSeparators; 377ff12d537SAndre Fischer } 378ff12d537SAndre Fischer 379ff12d537SAndre Fischer } } // end of namespace sfx2::sidebar 380