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 3022de8995SAndre Fischer #include <tools/svborder.hxx> 3122de8995SAndre Fischer 32*95a18594SAndre Fischer #include <com/sun/star/awt/XWindowPeer.hpp> 33ff12d537SAndre Fischer #include <com/sun/star/ui/XToolPanel.hpp> 34ff12d537SAndre Fischer 3522de8995SAndre Fischer 3622de8995SAndre Fischer using namespace css; 3722de8995SAndre Fischer using namespace cssu; 3822de8995SAndre Fischer 3922de8995SAndre Fischer namespace { 4022de8995SAndre Fischer static const char* VerticalStackLayouterName("vertical-stack"); 4122de8995SAndre Fischer } 4222de8995SAndre Fischer 4322de8995SAndre Fischer 44ff12d537SAndre Fischer namespace sfx2 { namespace sidebar { 4522de8995SAndre Fischer 4622de8995SAndre Fischer Panel::Panel ( 47ff12d537SAndre Fischer const PanelDescriptor& rPanelDescriptor, 48ff12d537SAndre Fischer Window* pParentWindow, 49ff12d537SAndre Fischer const ::boost::function<void(void)>& rDeckLayoutTrigger) 5022de8995SAndre Fischer : Window(pParentWindow), 51*95a18594SAndre Fischer msPanelId(rPanelDescriptor.msId), 5222de8995SAndre Fischer msLayoutHint(rPanelDescriptor.msLayout), 53ff12d537SAndre Fischer mpTitleBar(new PanelTitleBar(rPanelDescriptor.msTitle, pParentWindow, this)), 5422de8995SAndre Fischer mbIsTitleBarOptional(rPanelDescriptor.mbIsTitleBarOptional), 5522de8995SAndre Fischer mxElement(), 56ff12d537SAndre Fischer mxVerticalStackLayoutElement(), 57ff12d537SAndre Fischer mbIsExpanded(true), 58ff12d537SAndre Fischer maDeckLayoutTrigger(rDeckLayoutTrigger) 5922de8995SAndre Fischer { 60b9e67834SAndre Fischer SetBackground(Theme::GetPaint(Theme::Paint_PanelBackground).GetWallpaper()); 61b9e67834SAndre Fischer AddEventListener(LINK(this,Panel,WindowEventHandler)); 6222de8995SAndre Fischer } 6322de8995SAndre Fischer 6422de8995SAndre Fischer 6522de8995SAndre Fischer 6622de8995SAndre Fischer 6722de8995SAndre Fischer Panel::~Panel (void) 6822de8995SAndre Fischer { 6922de8995SAndre Fischer } 7022de8995SAndre Fischer 7122de8995SAndre Fischer 7222de8995SAndre Fischer 7322de8995SAndre Fischer 74ff12d537SAndre Fischer void Panel::Dispose (void) 75ff12d537SAndre Fischer { 76ff12d537SAndre Fischer mxVerticalStackLayoutElement = NULL; 77*95a18594SAndre Fischer 78*95a18594SAndre Fischer 79*95a18594SAndre Fischer if (mxElement.is()) 80*95a18594SAndre Fischer { 81*95a18594SAndre Fischer Reference<lang::XComponent> xComponent (mxElement->getRealInterface(), UNO_QUERY); 82*95a18594SAndre Fischer if (xComponent.is()) 83*95a18594SAndre Fischer xComponent->dispose(); 84*95a18594SAndre Fischer } 85*95a18594SAndre Fischer 86ff12d537SAndre Fischer { 87ff12d537SAndre Fischer Reference<lang::XComponent> xComponent (mxElement, UNO_QUERY); 88ff12d537SAndre Fischer mxElement = NULL; 89ff12d537SAndre Fischer if (xComponent.is()) 90ff12d537SAndre Fischer xComponent->dispose(); 91ff12d537SAndre Fischer } 92*95a18594SAndre Fischer 93ff12d537SAndre Fischer { 94ff12d537SAndre Fischer Reference<lang::XComponent> xComponent (mxElementWindow, UNO_QUERY); 95ff12d537SAndre Fischer mxElementWindow = NULL; 96ff12d537SAndre Fischer if (xComponent.is()) 97ff12d537SAndre Fischer xComponent->dispose(); 98ff12d537SAndre Fischer } 99ff12d537SAndre Fischer } 100ff12d537SAndre Fischer 101ff12d537SAndre Fischer 102ff12d537SAndre Fischer 103ff12d537SAndre Fischer 10422de8995SAndre Fischer const ::rtl::OUString& Panel::GetLayoutHint (void) const 10522de8995SAndre Fischer { 10622de8995SAndre Fischer return msLayoutHint; 10722de8995SAndre Fischer } 10822de8995SAndre Fischer 10922de8995SAndre Fischer 11022de8995SAndre Fischer 11122de8995SAndre Fischer 11222de8995SAndre Fischer TitleBar* Panel::GetTitleBar (void) const 11322de8995SAndre Fischer { 11422de8995SAndre Fischer return mpTitleBar; 11522de8995SAndre Fischer } 11622de8995SAndre Fischer 11722de8995SAndre Fischer 11822de8995SAndre Fischer 11922de8995SAndre Fischer 12022de8995SAndre Fischer bool Panel::IsTitleBarOptional (void) const 12122de8995SAndre Fischer { 12222de8995SAndre Fischer return mbIsTitleBarOptional; 12322de8995SAndre Fischer } 12422de8995SAndre Fischer 12522de8995SAndre Fischer 12622de8995SAndre Fischer 12722de8995SAndre Fischer 12822de8995SAndre Fischer void Panel::SetUIElement (const Reference<ui::XUIElement>& rxElement) 12922de8995SAndre Fischer { 13022de8995SAndre Fischer mxElement = rxElement; 13122de8995SAndre Fischer if (mxElement.is()) 13222de8995SAndre Fischer { 133ff12d537SAndre Fischer Reference<ui::XToolPanel> xToolPanel(mxElement->getRealInterface(), UNO_QUERY); 134ff12d537SAndre Fischer if (xToolPanel.is()) 135ff12d537SAndre Fischer mxElementWindow = xToolPanel->getWindow(); 13622de8995SAndre Fischer 13722de8995SAndre Fischer if (msLayoutHint.equalsAscii(VerticalStackLayouterName)) 13822de8995SAndre Fischer mxVerticalStackLayoutElement.set(mxElement->getRealInterface(), UNO_QUERY); 13922de8995SAndre Fischer } 14022de8995SAndre Fischer } 14122de8995SAndre Fischer 14222de8995SAndre Fischer 14322de8995SAndre Fischer 14422de8995SAndre Fischer 145ff12d537SAndre Fischer void Panel::SetExpanded (const bool bIsExpanded) 146ff12d537SAndre Fischer { 147ff12d537SAndre Fischer if (mbIsExpanded != bIsExpanded) 148ff12d537SAndre Fischer { 149ff12d537SAndre Fischer mbIsExpanded = bIsExpanded; 150ff12d537SAndre Fischer maDeckLayoutTrigger(); 151ff12d537SAndre Fischer } 152ff12d537SAndre Fischer } 153ff12d537SAndre Fischer 154ff12d537SAndre Fischer 155ff12d537SAndre Fischer 156ff12d537SAndre Fischer 157ff12d537SAndre Fischer bool Panel::IsExpanded (void) const 158ff12d537SAndre Fischer { 159ff12d537SAndre Fischer return mbIsExpanded; 160ff12d537SAndre Fischer } 161ff12d537SAndre Fischer 162ff12d537SAndre Fischer 163ff12d537SAndre Fischer 164ff12d537SAndre Fischer 165*95a18594SAndre Fischer bool Panel::HasIdPredicate (const ::rtl::OUString& rsId) const 166*95a18594SAndre Fischer { 167*95a18594SAndre Fischer if (this == NULL) 168*95a18594SAndre Fischer return false; 169*95a18594SAndre Fischer else 170*95a18594SAndre Fischer return msPanelId.equals(rsId); 171*95a18594SAndre Fischer } 172*95a18594SAndre Fischer 173*95a18594SAndre Fischer 174*95a18594SAndre Fischer 175*95a18594SAndre Fischer 17622de8995SAndre Fischer void Panel::Paint (const Rectangle& rUpdateArea) 17722de8995SAndre Fischer { 17822de8995SAndre Fischer Window::Paint(rUpdateArea); 17922de8995SAndre Fischer } 18022de8995SAndre Fischer 18122de8995SAndre Fischer 18222de8995SAndre Fischer 18322de8995SAndre Fischer 184ff12d537SAndre Fischer void Panel::SetPosSizePixel ( 185ff12d537SAndre Fischer long nX, 186ff12d537SAndre Fischer long nY, 187ff12d537SAndre Fischer long nWidth, 188ff12d537SAndre Fischer long nHeight, 189ff12d537SAndre Fischer sal_uInt16 nFlags) 190ff12d537SAndre Fischer { 191b9e67834SAndre Fischer maBoundingBox = Rectangle(Point(nX,nY),Size(nWidth,nHeight)); 192b9e67834SAndre Fischer 193b9e67834SAndre Fischer if ( ! IsReallyVisible()) 194b9e67834SAndre Fischer return; 195b9e67834SAndre Fischer 196ff12d537SAndre Fischer Window::SetPosSizePixel(nX, nY, nWidth, nHeight, nFlags); 197ff12d537SAndre Fischer 198ff12d537SAndre Fischer if (mxElementWindow.is()) 199ff12d537SAndre Fischer mxElementWindow->setPosSize(0, 0, nWidth, nHeight, nFlags); 200ff12d537SAndre Fischer } 201ff12d537SAndre Fischer 202ff12d537SAndre Fischer 203ff12d537SAndre Fischer 204ff12d537SAndre Fischer 205b9e67834SAndre Fischer void Panel::Activate (void) 206b9e67834SAndre Fischer { 207b9e67834SAndre Fischer Window::Activate(); 208b9e67834SAndre Fischer } 209b9e67834SAndre Fischer 210b9e67834SAndre Fischer 211b9e67834SAndre Fischer 212b9e67834SAndre Fischer 213b9e67834SAndre Fischer 214b9e67834SAndre Fischer void Panel::DataChanged (const DataChangedEvent& rEvent) 215b9e67834SAndre Fischer { 216b9e67834SAndre Fischer (void)rEvent; 217b9e67834SAndre Fischer SetBackground(Theme::GetPaint(Theme::Paint_PanelBackground).GetWallpaper()); 218b9e67834SAndre Fischer } 219b9e67834SAndre Fischer 220b9e67834SAndre Fischer 221b9e67834SAndre Fischer 222b9e67834SAndre Fischer 22322de8995SAndre Fischer Reference<ui::XVerticalStackLayoutElement> Panel::GetVerticalStackElement (void) const 22422de8995SAndre Fischer { 22522de8995SAndre Fischer return mxVerticalStackLayoutElement; 22622de8995SAndre Fischer } 22722de8995SAndre Fischer 22822de8995SAndre Fischer 229b9e67834SAndre Fischer 230b9e67834SAndre Fischer 231b9e67834SAndre Fischer IMPL_LINK(Panel, WindowEventHandler, VclWindowEvent*, pEvent) 232b9e67834SAndre Fischer { 233b9e67834SAndre Fischer if (pEvent != NULL) 234b9e67834SAndre Fischer { 235b9e67834SAndre Fischer switch (pEvent->GetId()) 236b9e67834SAndre Fischer { 237b9e67834SAndre Fischer case VCLEVENT_WINDOW_SHOW: 238b9e67834SAndre Fischer case VCLEVENT_WINDOW_RESIZE: 239b9e67834SAndre Fischer SetPosSizePixel( 240b9e67834SAndre Fischer maBoundingBox.Left(), 241b9e67834SAndre Fischer maBoundingBox.Top(), 242b9e67834SAndre Fischer maBoundingBox.GetWidth(), 243b9e67834SAndre Fischer maBoundingBox.GetHeight()); 244b9e67834SAndre Fischer break; 245b9e67834SAndre Fischer 246b9e67834SAndre Fischer default: 247b9e67834SAndre Fischer break; 248b9e67834SAndre Fischer } 249b9e67834SAndre Fischer } 250b9e67834SAndre Fischer 251b9e67834SAndre Fischer return sal_True; 252b9e67834SAndre Fischer } 253b9e67834SAndre Fischer 254b9e67834SAndre Fischer 255ff12d537SAndre Fischer } } // end of namespace sfx2::sidebar 256