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 "Panel.hxx" 25ff12d537SAndre Fischer #include "PanelTitleBar.hxx" 26ff12d537SAndre Fischer #include "PanelDescriptor.hxx" 27b9e67834SAndre Fischer #include "sfx2/sidebar/Theme.hxx" 28ff12d537SAndre Fischer #include "Paint.hxx" 29*7e429a12SAndre Fischer #include "ResourceManager.hxx" 3022de8995SAndre Fischer 317a32b0c8SAndre Fischer #ifdef DEBUG 32f35c6d02SAndre Fischer #include "sfx2/sidebar/Tools.hxx" 337a32b0c8SAndre Fischer #include "Deck.hxx" 347a32b0c8SAndre Fischer #endif 357a32b0c8SAndre Fischer 3622de8995SAndre Fischer #include <tools/svborder.hxx> 377a32b0c8SAndre Fischer #include <toolkit/helper/vclunohelper.hxx> 3822de8995SAndre Fischer 3995a18594SAndre Fischer #include <com/sun/star/awt/XWindowPeer.hpp> 407a32b0c8SAndre Fischer #include <com/sun/star/awt/PosSize.hpp> 41ff12d537SAndre Fischer #include <com/sun/star/ui/XToolPanel.hpp> 42ff12d537SAndre Fischer 437a32b0c8SAndre Fischer #include <boost/bind.hpp> 447a32b0c8SAndre Fischer 4522de8995SAndre Fischer 4622de8995SAndre Fischer using namespace css; 4722de8995SAndre Fischer using namespace cssu; 4822de8995SAndre Fischer 4922de8995SAndre Fischer 5022de8995SAndre Fischer 51ff12d537SAndre Fischer namespace sfx2 { namespace sidebar { 5222de8995SAndre Fischer 5322de8995SAndre Fischer Panel::Panel ( 54ff12d537SAndre Fischer const PanelDescriptor& rPanelDescriptor, 55ff12d537SAndre Fischer Window* pParentWindow, 56*7e429a12SAndre Fischer const bool bIsInitiallyExpanded, 57*7e429a12SAndre Fischer const ::boost::function<void(void)>& rDeckLayoutTrigger, 58*7e429a12SAndre Fischer const ::boost::function<Context(void)>& rContextAccess) 5922de8995SAndre Fischer : Window(pParentWindow), 6095a18594SAndre Fischer msPanelId(rPanelDescriptor.msId), 617a32b0c8SAndre Fischer mpTitleBar(new PanelTitleBar( 627a32b0c8SAndre Fischer rPanelDescriptor.msTitle, 637a32b0c8SAndre Fischer pParentWindow, 64c545150fSOliver-Rainer Wittmann this)), 6522de8995SAndre Fischer mbIsTitleBarOptional(rPanelDescriptor.mbIsTitleBarOptional), 6622de8995SAndre Fischer mxElement(), 677a32b0c8SAndre Fischer mxPanelComponent(), 68*7e429a12SAndre Fischer mbIsExpanded(bIsInitiallyExpanded), 69*7e429a12SAndre Fischer maDeckLayoutTrigger(rDeckLayoutTrigger), 70*7e429a12SAndre Fischer maContextAccess(rContextAccess) 7122de8995SAndre Fischer { 72b9e67834SAndre Fischer SetBackground(Theme::GetPaint(Theme::Paint_PanelBackground).GetWallpaper()); 737a32b0c8SAndre Fischer 747a32b0c8SAndre Fischer #ifdef DEBUG 757a32b0c8SAndre Fischer SetText(A2S("Panel")); 767a32b0c8SAndre Fischer #endif 7722de8995SAndre Fischer } 7822de8995SAndre Fischer 7922de8995SAndre Fischer 8022de8995SAndre Fischer 8122de8995SAndre Fischer 8222de8995SAndre Fischer Panel::~Panel (void) 8322de8995SAndre Fischer { 847a32b0c8SAndre Fischer Dispose(); 8522de8995SAndre Fischer } 8622de8995SAndre Fischer 8722de8995SAndre Fischer 8822de8995SAndre Fischer 8922de8995SAndre Fischer 90c545150fSOliver-Rainer Wittmann void Panel::SetShowMenuFunctor( const ::boost::function<void(void)>& rShowMenuFunctor ) 91c545150fSOliver-Rainer Wittmann { 92c545150fSOliver-Rainer Wittmann if ( mpTitleBar.get() ) 93c545150fSOliver-Rainer Wittmann { 94c545150fSOliver-Rainer Wittmann mpTitleBar->SetMenuAction( rShowMenuFunctor ); 95c545150fSOliver-Rainer Wittmann } 96c545150fSOliver-Rainer Wittmann } 97c545150fSOliver-Rainer Wittmann 98c545150fSOliver-Rainer Wittmann 99c545150fSOliver-Rainer Wittmann 100c545150fSOliver-Rainer Wittmann 101ff12d537SAndre Fischer void Panel::Dispose (void) 102ff12d537SAndre Fischer { 1037a32b0c8SAndre Fischer mxPanelComponent = NULL; 10495a18594SAndre Fischer 10595a18594SAndre Fischer if (mxElement.is()) 106ff12d537SAndre Fischer { 10795a18594SAndre Fischer Reference<lang::XComponent> xComponent (mxElement->getRealInterface(), UNO_QUERY); 10895a18594SAndre Fischer if (xComponent.is()) 10995a18594SAndre Fischer xComponent->dispose(); 11095a18594SAndre Fischer } 11195a18594SAndre Fischer 11295a18594SAndre Fischer { 113ff12d537SAndre Fischer Reference<lang::XComponent> xComponent (mxElement, UNO_QUERY); 114ff12d537SAndre Fischer mxElement = NULL; 115ff12d537SAndre Fischer if (xComponent.is()) 116ff12d537SAndre Fischer xComponent->dispose(); 117ff12d537SAndre Fischer } 11895a18594SAndre Fischer 119ff12d537SAndre Fischer { 1207a32b0c8SAndre Fischer Reference<lang::XComponent> xComponent (GetElementWindow(), UNO_QUERY); 121ff12d537SAndre Fischer if (xComponent.is()) 122ff12d537SAndre Fischer xComponent->dispose(); 123ff12d537SAndre Fischer } 124ff12d537SAndre Fischer 1257a32b0c8SAndre Fischer mpTitleBar.reset(); 12622de8995SAndre Fischer } 12722de8995SAndre Fischer 12822de8995SAndre Fischer 12922de8995SAndre Fischer 13022de8995SAndre Fischer 13122de8995SAndre Fischer TitleBar* Panel::GetTitleBar (void) const 13222de8995SAndre Fischer { 1337a32b0c8SAndre Fischer return mpTitleBar.get(); 13422de8995SAndre Fischer } 13522de8995SAndre Fischer 13622de8995SAndre Fischer 13722de8995SAndre Fischer 13822de8995SAndre Fischer 13922de8995SAndre Fischer bool Panel::IsTitleBarOptional (void) const 14022de8995SAndre Fischer { 14122de8995SAndre Fischer return mbIsTitleBarOptional; 14222de8995SAndre Fischer } 14322de8995SAndre Fischer 14422de8995SAndre Fischer 14522de8995SAndre Fischer 14622de8995SAndre Fischer 14722de8995SAndre Fischer void Panel::SetUIElement (const Reference<ui::XUIElement>& rxElement) 14822de8995SAndre Fischer { 14922de8995SAndre Fischer mxElement = rxElement; 15022de8995SAndre Fischer if (mxElement.is()) 15122de8995SAndre Fischer { 1527a32b0c8SAndre Fischer mxPanelComponent.set(mxElement->getRealInterface(), UNO_QUERY); 15322de8995SAndre Fischer } 15422de8995SAndre Fischer } 15522de8995SAndre Fischer 15622de8995SAndre Fischer 15722de8995SAndre Fischer 15822de8995SAndre Fischer 159ff12d537SAndre Fischer void Panel::SetExpanded (const bool bIsExpanded) 160ff12d537SAndre Fischer { 161ff12d537SAndre Fischer if (mbIsExpanded != bIsExpanded) 162ff12d537SAndre Fischer { 163ff12d537SAndre Fischer mbIsExpanded = bIsExpanded; 164ff12d537SAndre Fischer maDeckLayoutTrigger(); 165*7e429a12SAndre Fischer 166*7e429a12SAndre Fischer if (maContextAccess) 167*7e429a12SAndre Fischer ResourceManager::Instance().StorePanelExpansionState( 168*7e429a12SAndre Fischer msPanelId, 169*7e429a12SAndre Fischer bIsExpanded, 170*7e429a12SAndre Fischer maContextAccess()); 171ff12d537SAndre Fischer } 172ff12d537SAndre Fischer } 173ff12d537SAndre Fischer 174ff12d537SAndre Fischer 175ff12d537SAndre Fischer 176ff12d537SAndre Fischer 177ff12d537SAndre Fischer bool Panel::IsExpanded (void) const 178ff12d537SAndre Fischer { 179ff12d537SAndre Fischer return mbIsExpanded; 180ff12d537SAndre Fischer } 181ff12d537SAndre Fischer 182ff12d537SAndre Fischer 183ff12d537SAndre Fischer 184ff12d537SAndre Fischer 18595a18594SAndre Fischer bool Panel::HasIdPredicate (const ::rtl::OUString& rsId) const 18695a18594SAndre Fischer { 18795a18594SAndre Fischer if (this == NULL) 18895a18594SAndre Fischer return false; 18995a18594SAndre Fischer else 19095a18594SAndre Fischer return msPanelId.equals(rsId); 19195a18594SAndre Fischer } 19295a18594SAndre Fischer 19395a18594SAndre Fischer 19495a18594SAndre Fischer 19595a18594SAndre Fischer 19602c50d82SAndre Fischer const ::rtl::OUString& Panel::GetId (void) const 19702c50d82SAndre Fischer { 19802c50d82SAndre Fischer return msPanelId; 19902c50d82SAndre Fischer } 20002c50d82SAndre Fischer 20102c50d82SAndre Fischer 20202c50d82SAndre Fischer 20302c50d82SAndre Fischer 20422de8995SAndre Fischer void Panel::Paint (const Rectangle& rUpdateArea) 20522de8995SAndre Fischer { 20622de8995SAndre Fischer Window::Paint(rUpdateArea); 20722de8995SAndre Fischer } 20822de8995SAndre Fischer 20922de8995SAndre Fischer 21022de8995SAndre Fischer 21122de8995SAndre Fischer 2127a32b0c8SAndre Fischer void Panel::Resize (void) 213ff12d537SAndre Fischer { 2147a32b0c8SAndre Fischer Window::Resize(); 215ff12d537SAndre Fischer 2167a32b0c8SAndre Fischer // Forward new size to window of XUIElement. 2177a32b0c8SAndre Fischer Reference<awt::XWindow> xElementWindow (GetElementWindow()); 2187a32b0c8SAndre Fischer if (xElementWindow.is()) 2197a32b0c8SAndre Fischer { 2207a32b0c8SAndre Fischer const Size aSize (GetSizePixel()); 2217a32b0c8SAndre Fischer xElementWindow->setPosSize( 2227a32b0c8SAndre Fischer 0, 2237a32b0c8SAndre Fischer 0, 2247a32b0c8SAndre Fischer aSize.Width(), 2257a32b0c8SAndre Fischer aSize.Height(), 2267a32b0c8SAndre Fischer awt::PosSize::POSSIZE); 2277a32b0c8SAndre Fischer } 228ff12d537SAndre Fischer } 229ff12d537SAndre Fischer 230ff12d537SAndre Fischer 231ff12d537SAndre Fischer 232ff12d537SAndre Fischer 233b9e67834SAndre Fischer void Panel::Activate (void) 234b9e67834SAndre Fischer { 235b9e67834SAndre Fischer Window::Activate(); 236b9e67834SAndre Fischer } 237b9e67834SAndre Fischer 238b9e67834SAndre Fischer 239b9e67834SAndre Fischer 240b9e67834SAndre Fischer 241b9e67834SAndre Fischer 242b9e67834SAndre Fischer void Panel::DataChanged (const DataChangedEvent& rEvent) 243b9e67834SAndre Fischer { 244b9e67834SAndre Fischer (void)rEvent; 245b9e67834SAndre Fischer SetBackground(Theme::GetPaint(Theme::Paint_PanelBackground).GetWallpaper()); 246b9e67834SAndre Fischer } 247b9e67834SAndre Fischer 248b9e67834SAndre Fischer 249b9e67834SAndre Fischer 250b9e67834SAndre Fischer 2517a32b0c8SAndre Fischer Reference<ui::XSidebarPanel> Panel::GetPanelComponent (void) const 25222de8995SAndre Fischer { 2537a32b0c8SAndre Fischer return mxPanelComponent; 25422de8995SAndre Fischer } 25522de8995SAndre Fischer 256b9e67834SAndre Fischer 257b9e67834SAndre Fischer 258b9e67834SAndre Fischer 2597a32b0c8SAndre Fischer void Panel::PrintWindowTree (void) 2607a32b0c8SAndre Fischer { 2617a32b0c8SAndre Fischer #ifdef DEBUG 2627a32b0c8SAndre Fischer Window* pElementWindow = VCLUnoHelper::GetWindow(GetElementWindow()); 2637a32b0c8SAndre Fischer if (pElementWindow != NULL) 264b9e67834SAndre Fischer { 2657a32b0c8SAndre Fischer OSL_TRACE("panel parent is %x", pElementWindow->GetParent()); 2667a32b0c8SAndre Fischer Deck::PrintWindowSubTree(pElementWindow, 2); 2677a32b0c8SAndre Fischer } 2687a32b0c8SAndre Fischer else 2697a32b0c8SAndre Fischer OSL_TRACE(" panel is empty"); 2707a32b0c8SAndre Fischer #endif 2717a32b0c8SAndre Fischer } 2727a32b0c8SAndre Fischer 2737a32b0c8SAndre Fischer 2747a32b0c8SAndre Fischer 2757a32b0c8SAndre Fischer 2767a32b0c8SAndre Fischer Reference<awt::XWindow> Panel::GetElementWindow (void) 2777a32b0c8SAndre Fischer { 2787a32b0c8SAndre Fischer if (mxElement.is()) 2797a32b0c8SAndre Fischer { 2807a32b0c8SAndre Fischer Reference<ui::XToolPanel> xToolPanel(mxElement->getRealInterface(), UNO_QUERY); 2817a32b0c8SAndre Fischer if (xToolPanel.is()) 2827a32b0c8SAndre Fischer return xToolPanel->getWindow(); 283b9e67834SAndre Fischer } 284b9e67834SAndre Fischer 2857a32b0c8SAndre Fischer return NULL; 286b9e67834SAndre Fischer } 287b9e67834SAndre Fischer 288b9e67834SAndre Fischer 289ff12d537SAndre Fischer } } // end of namespace sfx2::sidebar 290