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" 2922de8995SAndre Fischer 307a32b0c8SAndre Fischer #ifdef DEBUG 31*f35c6d02SAndre Fischer #include "sfx2/sidebar/Tools.hxx" 327a32b0c8SAndre Fischer #include "Deck.hxx" 337a32b0c8SAndre Fischer #endif 347a32b0c8SAndre Fischer 3522de8995SAndre Fischer #include <tools/svborder.hxx> 367a32b0c8SAndre Fischer #include <toolkit/helper/vclunohelper.hxx> 3722de8995SAndre Fischer 3895a18594SAndre Fischer #include <com/sun/star/awt/XWindowPeer.hpp> 397a32b0c8SAndre Fischer #include <com/sun/star/awt/PosSize.hpp> 40ff12d537SAndre Fischer #include <com/sun/star/ui/XToolPanel.hpp> 41ff12d537SAndre Fischer 427a32b0c8SAndre Fischer #include <boost/bind.hpp> 437a32b0c8SAndre Fischer 4422de8995SAndre Fischer 4522de8995SAndre Fischer using namespace css; 4622de8995SAndre Fischer using namespace cssu; 4722de8995SAndre Fischer 4822de8995SAndre Fischer 4922de8995SAndre Fischer 50ff12d537SAndre Fischer namespace sfx2 { namespace sidebar { 5122de8995SAndre Fischer 5222de8995SAndre Fischer Panel::Panel ( 53ff12d537SAndre Fischer const PanelDescriptor& rPanelDescriptor, 54ff12d537SAndre Fischer Window* pParentWindow, 55c545150fSOliver-Rainer Wittmann const ::boost::function<void(void)>& rDeckLayoutTrigger ) 5622de8995SAndre Fischer : Window(pParentWindow), 5795a18594SAndre Fischer msPanelId(rPanelDescriptor.msId), 587a32b0c8SAndre Fischer mpTitleBar(new PanelTitleBar( 597a32b0c8SAndre Fischer rPanelDescriptor.msTitle, 607a32b0c8SAndre Fischer pParentWindow, 61c545150fSOliver-Rainer Wittmann this)), 6222de8995SAndre Fischer mbIsTitleBarOptional(rPanelDescriptor.mbIsTitleBarOptional), 6322de8995SAndre Fischer mxElement(), 647a32b0c8SAndre Fischer mxPanelComponent(), 65ff12d537SAndre Fischer mbIsExpanded(true), 66ff12d537SAndre Fischer maDeckLayoutTrigger(rDeckLayoutTrigger) 6722de8995SAndre Fischer { 68b9e67834SAndre Fischer SetBackground(Theme::GetPaint(Theme::Paint_PanelBackground).GetWallpaper()); 697a32b0c8SAndre Fischer 707a32b0c8SAndre Fischer #ifdef DEBUG 717a32b0c8SAndre Fischer OSL_TRACE("creating Panel at %x", this); 727a32b0c8SAndre Fischer SetText(A2S("Panel")); 737a32b0c8SAndre Fischer #endif 7422de8995SAndre Fischer } 7522de8995SAndre Fischer 7622de8995SAndre Fischer 7722de8995SAndre Fischer 7822de8995SAndre Fischer 7922de8995SAndre Fischer Panel::~Panel (void) 8022de8995SAndre Fischer { 817a32b0c8SAndre Fischer OSL_TRACE("destroying Panel at %x", this); 827a32b0c8SAndre Fischer Dispose(); 8322de8995SAndre Fischer } 8422de8995SAndre Fischer 8522de8995SAndre Fischer 8622de8995SAndre Fischer 8722de8995SAndre Fischer 88c545150fSOliver-Rainer Wittmann void Panel::SetShowMenuFunctor( const ::boost::function<void(void)>& rShowMenuFunctor ) 89c545150fSOliver-Rainer Wittmann { 90c545150fSOliver-Rainer Wittmann if ( mpTitleBar.get() ) 91c545150fSOliver-Rainer Wittmann { 92c545150fSOliver-Rainer Wittmann mpTitleBar->SetMenuAction( rShowMenuFunctor ); 93c545150fSOliver-Rainer Wittmann } 94c545150fSOliver-Rainer Wittmann } 95c545150fSOliver-Rainer Wittmann 96c545150fSOliver-Rainer Wittmann 97c545150fSOliver-Rainer Wittmann 98c545150fSOliver-Rainer Wittmann 99ff12d537SAndre Fischer void Panel::Dispose (void) 100ff12d537SAndre Fischer { 1017a32b0c8SAndre Fischer mxPanelComponent = NULL; 10295a18594SAndre Fischer 10395a18594SAndre Fischer if (mxElement.is()) 10495a18594SAndre Fischer { 10595a18594SAndre Fischer Reference<lang::XComponent> xComponent (mxElement->getRealInterface(), UNO_QUERY); 10695a18594SAndre Fischer if (xComponent.is()) 10795a18594SAndre Fischer xComponent->dispose(); 10895a18594SAndre Fischer } 10995a18594SAndre Fischer 110ff12d537SAndre Fischer { 111ff12d537SAndre Fischer Reference<lang::XComponent> xComponent (mxElement, UNO_QUERY); 112ff12d537SAndre Fischer mxElement = NULL; 113ff12d537SAndre Fischer if (xComponent.is()) 114ff12d537SAndre Fischer xComponent->dispose(); 115ff12d537SAndre Fischer } 11695a18594SAndre Fischer 117ff12d537SAndre Fischer { 1187a32b0c8SAndre Fischer Reference<lang::XComponent> xComponent (GetElementWindow(), UNO_QUERY); 119ff12d537SAndre Fischer if (xComponent.is()) 120ff12d537SAndre Fischer xComponent->dispose(); 121ff12d537SAndre Fischer } 122ff12d537SAndre Fischer 1237a32b0c8SAndre Fischer mpTitleBar.reset(); 12422de8995SAndre Fischer } 12522de8995SAndre Fischer 12622de8995SAndre Fischer 12722de8995SAndre Fischer 12822de8995SAndre Fischer 12922de8995SAndre Fischer TitleBar* Panel::GetTitleBar (void) const 13022de8995SAndre Fischer { 1317a32b0c8SAndre Fischer return mpTitleBar.get(); 13222de8995SAndre Fischer } 13322de8995SAndre Fischer 13422de8995SAndre Fischer 13522de8995SAndre Fischer 13622de8995SAndre Fischer 13722de8995SAndre Fischer bool Panel::IsTitleBarOptional (void) const 13822de8995SAndre Fischer { 13922de8995SAndre Fischer return mbIsTitleBarOptional; 14022de8995SAndre Fischer } 14122de8995SAndre Fischer 14222de8995SAndre Fischer 14322de8995SAndre Fischer 14422de8995SAndre Fischer 14522de8995SAndre Fischer void Panel::SetUIElement (const Reference<ui::XUIElement>& rxElement) 14622de8995SAndre Fischer { 14722de8995SAndre Fischer mxElement = rxElement; 14822de8995SAndre Fischer if (mxElement.is()) 14922de8995SAndre Fischer { 1507a32b0c8SAndre Fischer mxPanelComponent.set(mxElement->getRealInterface(), UNO_QUERY); 15122de8995SAndre Fischer } 15222de8995SAndre Fischer } 15322de8995SAndre Fischer 15422de8995SAndre Fischer 15522de8995SAndre Fischer 15622de8995SAndre Fischer 157ff12d537SAndre Fischer void Panel::SetExpanded (const bool bIsExpanded) 158ff12d537SAndre Fischer { 159ff12d537SAndre Fischer if (mbIsExpanded != bIsExpanded) 160ff12d537SAndre Fischer { 161ff12d537SAndre Fischer mbIsExpanded = bIsExpanded; 162ff12d537SAndre Fischer maDeckLayoutTrigger(); 163ff12d537SAndre Fischer } 164ff12d537SAndre Fischer } 165ff12d537SAndre Fischer 166ff12d537SAndre Fischer 167ff12d537SAndre Fischer 168ff12d537SAndre Fischer 169ff12d537SAndre Fischer bool Panel::IsExpanded (void) const 170ff12d537SAndre Fischer { 171ff12d537SAndre Fischer return mbIsExpanded; 172ff12d537SAndre Fischer } 173ff12d537SAndre Fischer 174ff12d537SAndre Fischer 175ff12d537SAndre Fischer 176ff12d537SAndre Fischer 17795a18594SAndre Fischer bool Panel::HasIdPredicate (const ::rtl::OUString& rsId) const 17895a18594SAndre Fischer { 17995a18594SAndre Fischer if (this == NULL) 18095a18594SAndre Fischer return false; 18195a18594SAndre Fischer else 18295a18594SAndre Fischer return msPanelId.equals(rsId); 18395a18594SAndre Fischer } 18495a18594SAndre Fischer 18595a18594SAndre Fischer 18695a18594SAndre Fischer 18795a18594SAndre Fischer 18802c50d82SAndre Fischer const ::rtl::OUString& Panel::GetId (void) const 18902c50d82SAndre Fischer { 19002c50d82SAndre Fischer return msPanelId; 19102c50d82SAndre Fischer } 19202c50d82SAndre Fischer 19302c50d82SAndre Fischer 19402c50d82SAndre Fischer 19502c50d82SAndre Fischer 19622de8995SAndre Fischer void Panel::Paint (const Rectangle& rUpdateArea) 19722de8995SAndre Fischer { 19822de8995SAndre Fischer Window::Paint(rUpdateArea); 19922de8995SAndre Fischer } 20022de8995SAndre Fischer 20122de8995SAndre Fischer 20222de8995SAndre Fischer 20322de8995SAndre Fischer 2047a32b0c8SAndre Fischer void Panel::Resize (void) 205ff12d537SAndre Fischer { 2067a32b0c8SAndre Fischer Window::Resize(); 207b9e67834SAndre Fischer 2087a32b0c8SAndre Fischer // Forward new size to window of XUIElement. 2097a32b0c8SAndre Fischer Reference<awt::XWindow> xElementWindow (GetElementWindow()); 2107a32b0c8SAndre Fischer if (xElementWindow.is()) 2117a32b0c8SAndre Fischer { 2127a32b0c8SAndre Fischer const Size aSize (GetSizePixel()); 2137a32b0c8SAndre Fischer xElementWindow->setPosSize( 2147a32b0c8SAndre Fischer 0, 2157a32b0c8SAndre Fischer 0, 2167a32b0c8SAndre Fischer aSize.Width(), 2177a32b0c8SAndre Fischer aSize.Height(), 2187a32b0c8SAndre Fischer awt::PosSize::POSSIZE); 2197a32b0c8SAndre Fischer } 220ff12d537SAndre Fischer } 221ff12d537SAndre Fischer 222ff12d537SAndre Fischer 223ff12d537SAndre Fischer 224ff12d537SAndre Fischer 225b9e67834SAndre Fischer void Panel::Activate (void) 226b9e67834SAndre Fischer { 227b9e67834SAndre Fischer Window::Activate(); 228b9e67834SAndre Fischer } 229b9e67834SAndre Fischer 230b9e67834SAndre Fischer 231b9e67834SAndre Fischer 232b9e67834SAndre Fischer 233b9e67834SAndre Fischer 234b9e67834SAndre Fischer void Panel::DataChanged (const DataChangedEvent& rEvent) 235b9e67834SAndre Fischer { 236b9e67834SAndre Fischer (void)rEvent; 237b9e67834SAndre Fischer SetBackground(Theme::GetPaint(Theme::Paint_PanelBackground).GetWallpaper()); 238b9e67834SAndre Fischer } 239b9e67834SAndre Fischer 240b9e67834SAndre Fischer 241b9e67834SAndre Fischer 242b9e67834SAndre Fischer 2437a32b0c8SAndre Fischer Reference<ui::XSidebarPanel> Panel::GetPanelComponent (void) const 24422de8995SAndre Fischer { 2457a32b0c8SAndre Fischer return mxPanelComponent; 24622de8995SAndre Fischer } 24722de8995SAndre Fischer 24822de8995SAndre Fischer 249b9e67834SAndre Fischer 250b9e67834SAndre Fischer 2517a32b0c8SAndre Fischer void Panel::PrintWindowTree (void) 2527a32b0c8SAndre Fischer { 2537a32b0c8SAndre Fischer #ifdef DEBUG 2547a32b0c8SAndre Fischer Window* pElementWindow = VCLUnoHelper::GetWindow(GetElementWindow()); 2557a32b0c8SAndre Fischer if (pElementWindow != NULL) 2567a32b0c8SAndre Fischer { 2577a32b0c8SAndre Fischer OSL_TRACE("panel parent is %x", pElementWindow->GetParent()); 2587a32b0c8SAndre Fischer Deck::PrintWindowSubTree(pElementWindow, 2); 2597a32b0c8SAndre Fischer } 2607a32b0c8SAndre Fischer else 2617a32b0c8SAndre Fischer OSL_TRACE(" panel is empty"); 2627a32b0c8SAndre Fischer #endif 2637a32b0c8SAndre Fischer } 2647a32b0c8SAndre Fischer 2657a32b0c8SAndre Fischer 2667a32b0c8SAndre Fischer 2677a32b0c8SAndre Fischer 2687a32b0c8SAndre Fischer Reference<awt::XWindow> Panel::GetElementWindow (void) 2697a32b0c8SAndre Fischer { 2707a32b0c8SAndre Fischer if (mxElement.is()) 2717a32b0c8SAndre Fischer { 2727a32b0c8SAndre Fischer Reference<ui::XToolPanel> xToolPanel(mxElement->getRealInterface(), UNO_QUERY); 2737a32b0c8SAndre Fischer if (xToolPanel.is()) 2747a32b0c8SAndre Fischer return xToolPanel->getWindow(); 2757a32b0c8SAndre Fischer } 2767a32b0c8SAndre Fischer 2777a32b0c8SAndre Fischer return NULL; 278b9e67834SAndre Fischer } 279b9e67834SAndre Fischer 280b9e67834SAndre Fischer 281ff12d537SAndre Fischer } } // end of namespace sfx2::sidebar 282