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 317a32b0c8SAndre Fischer #include "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 namespace { 4922de8995SAndre Fischer static const char* VerticalStackLayouterName("vertical-stack"); 5022de8995SAndre Fischer } 5122de8995SAndre Fischer 5222de8995SAndre Fischer 53ff12d537SAndre Fischer namespace sfx2 { namespace sidebar { 5422de8995SAndre Fischer 5522de8995SAndre Fischer Panel::Panel ( 56ff12d537SAndre Fischer const PanelDescriptor& rPanelDescriptor, 57ff12d537SAndre Fischer Window* pParentWindow, 58ff12d537SAndre Fischer const ::boost::function<void(void)>& rDeckLayoutTrigger) 5922de8995SAndre Fischer : Window(pParentWindow), 6095a18594SAndre Fischer msPanelId(rPanelDescriptor.msId), 617a32b0c8SAndre Fischer mpTitleBar(new PanelTitleBar( 627a32b0c8SAndre Fischer rPanelDescriptor.msTitle, 637a32b0c8SAndre Fischer pParentWindow, 647a32b0c8SAndre Fischer this, 657a32b0c8SAndre Fischer rPanelDescriptor.mbHasMenu 667a32b0c8SAndre Fischer ? ::boost::bind(&Panel::ShowMenu, this) 677a32b0c8SAndre Fischer : ::boost::function<void(void)>())), 6822de8995SAndre Fischer mbIsTitleBarOptional(rPanelDescriptor.mbIsTitleBarOptional), 6922de8995SAndre Fischer mxElement(), 707a32b0c8SAndre Fischer mxPanelComponent(), 71ff12d537SAndre Fischer mbIsExpanded(true), 72ff12d537SAndre Fischer maDeckLayoutTrigger(rDeckLayoutTrigger) 7322de8995SAndre Fischer { 74b9e67834SAndre Fischer SetBackground(Theme::GetPaint(Theme::Paint_PanelBackground).GetWallpaper()); 757a32b0c8SAndre Fischer 767a32b0c8SAndre Fischer #ifdef DEBUG 777a32b0c8SAndre Fischer OSL_TRACE("creating Panel at %x", this); 787a32b0c8SAndre Fischer SetText(A2S("Panel")); 797a32b0c8SAndre Fischer #endif 8022de8995SAndre Fischer } 8122de8995SAndre Fischer 8222de8995SAndre Fischer 8322de8995SAndre Fischer 8422de8995SAndre Fischer 8522de8995SAndre Fischer Panel::~Panel (void) 8622de8995SAndre Fischer { 877a32b0c8SAndre Fischer OSL_TRACE("destroying Panel at %x", this); 887a32b0c8SAndre Fischer Dispose(); 8922de8995SAndre Fischer } 9022de8995SAndre Fischer 9122de8995SAndre Fischer 9222de8995SAndre Fischer 9322de8995SAndre Fischer 94ff12d537SAndre Fischer void Panel::Dispose (void) 95ff12d537SAndre Fischer { 967a32b0c8SAndre Fischer mxPanelComponent = NULL; 9795a18594SAndre Fischer 9895a18594SAndre Fischer if (mxElement.is()) 99ff12d537SAndre Fischer { 10095a18594SAndre Fischer Reference<lang::XComponent> xComponent (mxElement->getRealInterface(), UNO_QUERY); 10195a18594SAndre Fischer if (xComponent.is()) 10295a18594SAndre Fischer xComponent->dispose(); 10395a18594SAndre Fischer } 10495a18594SAndre Fischer 10595a18594SAndre Fischer { 106ff12d537SAndre Fischer Reference<lang::XComponent> xComponent (mxElement, UNO_QUERY); 107ff12d537SAndre Fischer mxElement = NULL; 108ff12d537SAndre Fischer if (xComponent.is()) 109ff12d537SAndre Fischer xComponent->dispose(); 110ff12d537SAndre Fischer } 11195a18594SAndre Fischer 112ff12d537SAndre Fischer { 1137a32b0c8SAndre Fischer Reference<lang::XComponent> xComponent (GetElementWindow(), UNO_QUERY); 114ff12d537SAndre Fischer if (xComponent.is()) 115ff12d537SAndre Fischer xComponent->dispose(); 116ff12d537SAndre Fischer } 117ff12d537SAndre Fischer 1187a32b0c8SAndre Fischer mpTitleBar.reset(); 11922de8995SAndre Fischer } 12022de8995SAndre Fischer 12122de8995SAndre Fischer 12222de8995SAndre Fischer 12322de8995SAndre Fischer 12422de8995SAndre Fischer TitleBar* Panel::GetTitleBar (void) const 12522de8995SAndre Fischer { 1267a32b0c8SAndre Fischer return mpTitleBar.get(); 12722de8995SAndre Fischer } 12822de8995SAndre Fischer 12922de8995SAndre Fischer 13022de8995SAndre Fischer 13122de8995SAndre Fischer 13222de8995SAndre Fischer bool Panel::IsTitleBarOptional (void) const 13322de8995SAndre Fischer { 13422de8995SAndre Fischer return mbIsTitleBarOptional; 13522de8995SAndre Fischer } 13622de8995SAndre Fischer 13722de8995SAndre Fischer 13822de8995SAndre Fischer 13922de8995SAndre Fischer 14022de8995SAndre Fischer void Panel::SetUIElement (const Reference<ui::XUIElement>& rxElement) 14122de8995SAndre Fischer { 14222de8995SAndre Fischer mxElement = rxElement; 14322de8995SAndre Fischer if (mxElement.is()) 14422de8995SAndre Fischer { 1457a32b0c8SAndre Fischer mxPanelComponent.set(mxElement->getRealInterface(), UNO_QUERY); 14622de8995SAndre Fischer } 14722de8995SAndre Fischer } 14822de8995SAndre Fischer 14922de8995SAndre Fischer 15022de8995SAndre Fischer 15122de8995SAndre Fischer 152ff12d537SAndre Fischer void Panel::SetExpanded (const bool bIsExpanded) 153ff12d537SAndre Fischer { 154ff12d537SAndre Fischer if (mbIsExpanded != bIsExpanded) 155ff12d537SAndre Fischer { 156ff12d537SAndre Fischer mbIsExpanded = bIsExpanded; 157ff12d537SAndre Fischer maDeckLayoutTrigger(); 158ff12d537SAndre Fischer } 159ff12d537SAndre Fischer } 160ff12d537SAndre Fischer 161ff12d537SAndre Fischer 162ff12d537SAndre Fischer 163ff12d537SAndre Fischer 164ff12d537SAndre Fischer bool Panel::IsExpanded (void) const 165ff12d537SAndre Fischer { 166ff12d537SAndre Fischer return mbIsExpanded; 167ff12d537SAndre Fischer } 168ff12d537SAndre Fischer 169ff12d537SAndre Fischer 170ff12d537SAndre Fischer 171ff12d537SAndre Fischer 17295a18594SAndre Fischer bool Panel::HasIdPredicate (const ::rtl::OUString& rsId) const 17395a18594SAndre Fischer { 17495a18594SAndre Fischer if (this == NULL) 17595a18594SAndre Fischer return false; 17695a18594SAndre Fischer else 17795a18594SAndre Fischer return msPanelId.equals(rsId); 17895a18594SAndre Fischer } 17995a18594SAndre Fischer 18095a18594SAndre Fischer 18195a18594SAndre Fischer 18295a18594SAndre Fischer 183*02c50d82SAndre Fischer const ::rtl::OUString& Panel::GetId (void) const 184*02c50d82SAndre Fischer { 185*02c50d82SAndre Fischer return msPanelId; 186*02c50d82SAndre Fischer } 187*02c50d82SAndre Fischer 188*02c50d82SAndre Fischer 189*02c50d82SAndre Fischer 190*02c50d82SAndre Fischer 19122de8995SAndre Fischer void Panel::Paint (const Rectangle& rUpdateArea) 19222de8995SAndre Fischer { 19322de8995SAndre Fischer Window::Paint(rUpdateArea); 19422de8995SAndre Fischer } 19522de8995SAndre Fischer 19622de8995SAndre Fischer 19722de8995SAndre Fischer 19822de8995SAndre Fischer 1997a32b0c8SAndre Fischer void Panel::Resize (void) 200ff12d537SAndre Fischer { 2017a32b0c8SAndre Fischer Window::Resize(); 202ff12d537SAndre Fischer 2037a32b0c8SAndre Fischer // Forward new size to window of XUIElement. 2047a32b0c8SAndre Fischer Reference<awt::XWindow> xElementWindow (GetElementWindow()); 2057a32b0c8SAndre Fischer if (xElementWindow.is()) 2067a32b0c8SAndre Fischer { 2077a32b0c8SAndre Fischer const Size aSize (GetSizePixel()); 2087a32b0c8SAndre Fischer xElementWindow->setPosSize( 2097a32b0c8SAndre Fischer 0, 2107a32b0c8SAndre Fischer 0, 2117a32b0c8SAndre Fischer aSize.Width(), 2127a32b0c8SAndre Fischer aSize.Height(), 2137a32b0c8SAndre Fischer awt::PosSize::POSSIZE); 2147a32b0c8SAndre Fischer } 215ff12d537SAndre Fischer } 216ff12d537SAndre Fischer 217ff12d537SAndre Fischer 218ff12d537SAndre Fischer 219ff12d537SAndre Fischer 220b9e67834SAndre Fischer void Panel::Activate (void) 221b9e67834SAndre Fischer { 222b9e67834SAndre Fischer Window::Activate(); 223b9e67834SAndre Fischer } 224b9e67834SAndre Fischer 225b9e67834SAndre Fischer 226b9e67834SAndre Fischer 227b9e67834SAndre Fischer 228b9e67834SAndre Fischer 229b9e67834SAndre Fischer void Panel::DataChanged (const DataChangedEvent& rEvent) 230b9e67834SAndre Fischer { 231b9e67834SAndre Fischer (void)rEvent; 232b9e67834SAndre Fischer SetBackground(Theme::GetPaint(Theme::Paint_PanelBackground).GetWallpaper()); 233b9e67834SAndre Fischer } 234b9e67834SAndre Fischer 235b9e67834SAndre Fischer 236b9e67834SAndre Fischer 237b9e67834SAndre Fischer 2387a32b0c8SAndre Fischer Reference<ui::XSidebarPanel> Panel::GetPanelComponent (void) const 23922de8995SAndre Fischer { 2407a32b0c8SAndre Fischer return mxPanelComponent; 24122de8995SAndre Fischer } 24222de8995SAndre Fischer 243b9e67834SAndre Fischer 244b9e67834SAndre Fischer 245b9e67834SAndre Fischer 2467a32b0c8SAndre Fischer void Panel::ShowMenu (void) 247b9e67834SAndre Fischer { 2487a32b0c8SAndre Fischer if (mxPanelComponent.is()) 2497a32b0c8SAndre Fischer mxPanelComponent->showMenu(); 2507a32b0c8SAndre Fischer } 2517a32b0c8SAndre Fischer 2527a32b0c8SAndre Fischer 2537a32b0c8SAndre Fischer 2547a32b0c8SAndre Fischer void Panel::PrintWindowTree (void) 2557a32b0c8SAndre Fischer { 2567a32b0c8SAndre Fischer #ifdef DEBUG 2577a32b0c8SAndre Fischer Window* pElementWindow = VCLUnoHelper::GetWindow(GetElementWindow()); 2587a32b0c8SAndre Fischer if (pElementWindow != NULL) 259b9e67834SAndre Fischer { 2607a32b0c8SAndre Fischer OSL_TRACE("panel parent is %x", pElementWindow->GetParent()); 2617a32b0c8SAndre Fischer Deck::PrintWindowSubTree(pElementWindow, 2); 2627a32b0c8SAndre Fischer } 2637a32b0c8SAndre Fischer else 2647a32b0c8SAndre Fischer OSL_TRACE(" panel is empty"); 2657a32b0c8SAndre Fischer #endif 2667a32b0c8SAndre Fischer } 2677a32b0c8SAndre Fischer 2687a32b0c8SAndre Fischer 2697a32b0c8SAndre Fischer 2707a32b0c8SAndre Fischer 2717a32b0c8SAndre Fischer Reference<awt::XWindow> Panel::GetElementWindow (void) 2727a32b0c8SAndre Fischer { 2737a32b0c8SAndre Fischer if (mxElement.is()) 2747a32b0c8SAndre Fischer { 2757a32b0c8SAndre Fischer Reference<ui::XToolPanel> xToolPanel(mxElement->getRealInterface(), UNO_QUERY); 2767a32b0c8SAndre Fischer if (xToolPanel.is()) 2777a32b0c8SAndre Fischer return xToolPanel->getWindow(); 278b9e67834SAndre Fischer } 279b9e67834SAndre Fischer 2807a32b0c8SAndre Fischer return NULL; 281b9e67834SAndre Fischer } 282b9e67834SAndre Fischer 283b9e67834SAndre Fischer 284ff12d537SAndre Fischer } } // end of namespace sfx2::sidebar 285