xref: /aoo41x/main/sfx2/source/sidebar/Panel.cxx (revision b9e67834)
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"
27*b9e67834SAndre Fischer #include "sfx2/sidebar/Theme.hxx"
28ff12d537SAndre Fischer #include "Paint.hxx"
2922de8995SAndre Fischer 
3022de8995SAndre Fischer #include <tools/svborder.hxx>
3122de8995SAndre Fischer 
32ff12d537SAndre Fischer #include <com/sun/star/ui/XToolPanel.hpp>
33ff12d537SAndre Fischer 
3422de8995SAndre Fischer 
3522de8995SAndre Fischer using namespace css;
3622de8995SAndre Fischer using namespace cssu;
3722de8995SAndre Fischer 
3822de8995SAndre Fischer namespace {
3922de8995SAndre Fischer     static const char* VerticalStackLayouterName("vertical-stack");
4022de8995SAndre Fischer }
4122de8995SAndre Fischer 
4222de8995SAndre Fischer 
43ff12d537SAndre Fischer namespace sfx2 { namespace sidebar {
4422de8995SAndre Fischer 
4522de8995SAndre Fischer Panel::Panel (
46ff12d537SAndre Fischer     const PanelDescriptor& rPanelDescriptor,
47ff12d537SAndre Fischer     Window* pParentWindow,
48ff12d537SAndre Fischer     const ::boost::function<void(void)>& rDeckLayoutTrigger)
4922de8995SAndre Fischer     : Window(pParentWindow),
5022de8995SAndre Fischer       msLayoutHint(rPanelDescriptor.msLayout),
51ff12d537SAndre Fischer       mpTitleBar(new PanelTitleBar(rPanelDescriptor.msTitle, pParentWindow, this)),
5222de8995SAndre Fischer       mbIsTitleBarOptional(rPanelDescriptor.mbIsTitleBarOptional),
5322de8995SAndre Fischer       mxElement(),
54ff12d537SAndre Fischer       mxVerticalStackLayoutElement(),
55ff12d537SAndre Fischer       mbIsExpanded(true),
56ff12d537SAndre Fischer       maDeckLayoutTrigger(rDeckLayoutTrigger)
5722de8995SAndre Fischer {
58*b9e67834SAndre Fischer     SetBackground(Theme::GetPaint(Theme::Paint_PanelBackground).GetWallpaper());
59*b9e67834SAndre Fischer     AddEventListener(LINK(this,Panel,WindowEventHandler));
6022de8995SAndre Fischer }
6122de8995SAndre Fischer 
6222de8995SAndre Fischer 
6322de8995SAndre Fischer 
6422de8995SAndre Fischer 
6522de8995SAndre Fischer Panel::~Panel (void)
6622de8995SAndre Fischer {
6722de8995SAndre Fischer }
6822de8995SAndre Fischer 
6922de8995SAndre Fischer 
7022de8995SAndre Fischer 
7122de8995SAndre Fischer 
72ff12d537SAndre Fischer void Panel::Dispose (void)
73ff12d537SAndre Fischer {
74ff12d537SAndre Fischer     mxVerticalStackLayoutElement = NULL;
75ff12d537SAndre Fischer     {
76ff12d537SAndre Fischer         Reference<lang::XComponent> xComponent (mxElement, UNO_QUERY);
77ff12d537SAndre Fischer         mxElement = NULL;
78ff12d537SAndre Fischer         if (xComponent.is())
79ff12d537SAndre Fischer             xComponent->dispose();
80ff12d537SAndre Fischer     }
81ff12d537SAndre Fischer     {
82ff12d537SAndre Fischer         Reference<lang::XComponent> xComponent (mxElementWindow, UNO_QUERY);
83ff12d537SAndre Fischer         mxElementWindow = NULL;
84ff12d537SAndre Fischer         if (xComponent.is())
85ff12d537SAndre Fischer             xComponent->dispose();
86ff12d537SAndre Fischer     }
87ff12d537SAndre Fischer }
88ff12d537SAndre Fischer 
89ff12d537SAndre Fischer 
90ff12d537SAndre Fischer 
91ff12d537SAndre Fischer 
9222de8995SAndre Fischer const ::rtl::OUString& Panel::GetLayoutHint (void) const
9322de8995SAndre Fischer {
9422de8995SAndre Fischer     return msLayoutHint;
9522de8995SAndre Fischer }
9622de8995SAndre Fischer 
9722de8995SAndre Fischer 
9822de8995SAndre Fischer 
9922de8995SAndre Fischer 
10022de8995SAndre Fischer TitleBar* Panel::GetTitleBar (void) const
10122de8995SAndre Fischer {
10222de8995SAndre Fischer     return mpTitleBar;
10322de8995SAndre Fischer }
10422de8995SAndre Fischer 
10522de8995SAndre Fischer 
10622de8995SAndre Fischer 
10722de8995SAndre Fischer 
10822de8995SAndre Fischer bool Panel::IsTitleBarOptional (void) const
10922de8995SAndre Fischer {
11022de8995SAndre Fischer     return mbIsTitleBarOptional;
11122de8995SAndre Fischer }
11222de8995SAndre Fischer 
11322de8995SAndre Fischer 
11422de8995SAndre Fischer 
11522de8995SAndre Fischer 
11622de8995SAndre Fischer void Panel::SetUIElement (const Reference<ui::XUIElement>& rxElement)
11722de8995SAndre Fischer {
11822de8995SAndre Fischer     mxElement = rxElement;
11922de8995SAndre Fischer     if (mxElement.is())
12022de8995SAndre Fischer     {
121ff12d537SAndre Fischer         Reference<ui::XToolPanel> xToolPanel(mxElement->getRealInterface(), UNO_QUERY);
122ff12d537SAndre Fischer         if (xToolPanel.is())
123ff12d537SAndre Fischer             mxElementWindow = xToolPanel->getWindow();
12422de8995SAndre Fischer 
12522de8995SAndre Fischer         if (msLayoutHint.equalsAscii(VerticalStackLayouterName))
12622de8995SAndre Fischer             mxVerticalStackLayoutElement.set(mxElement->getRealInterface(), UNO_QUERY);
12722de8995SAndre Fischer     }
12822de8995SAndre Fischer }
12922de8995SAndre Fischer 
13022de8995SAndre Fischer 
13122de8995SAndre Fischer 
13222de8995SAndre Fischer 
133ff12d537SAndre Fischer void Panel::SetExpanded (const bool bIsExpanded)
134ff12d537SAndre Fischer {
135ff12d537SAndre Fischer     if (mbIsExpanded != bIsExpanded)
136ff12d537SAndre Fischer     {
137ff12d537SAndre Fischer         mbIsExpanded = bIsExpanded;
138ff12d537SAndre Fischer         maDeckLayoutTrigger();
139ff12d537SAndre Fischer     }
140ff12d537SAndre Fischer }
141ff12d537SAndre Fischer 
142ff12d537SAndre Fischer 
143ff12d537SAndre Fischer 
144ff12d537SAndre Fischer 
145ff12d537SAndre Fischer bool Panel::IsExpanded (void) const
146ff12d537SAndre Fischer {
147ff12d537SAndre Fischer     return mbIsExpanded;
148ff12d537SAndre Fischer }
149ff12d537SAndre Fischer 
150ff12d537SAndre Fischer 
151ff12d537SAndre Fischer 
152ff12d537SAndre Fischer 
15322de8995SAndre Fischer void Panel::Paint (const Rectangle& rUpdateArea)
15422de8995SAndre Fischer {
15522de8995SAndre Fischer     Window::Paint(rUpdateArea);
15622de8995SAndre Fischer }
15722de8995SAndre Fischer 
15822de8995SAndre Fischer 
15922de8995SAndre Fischer 
16022de8995SAndre Fischer 
161ff12d537SAndre Fischer void Panel::SetPosSizePixel (
162ff12d537SAndre Fischer     long nX,
163ff12d537SAndre Fischer     long nY,
164ff12d537SAndre Fischer     long nWidth,
165ff12d537SAndre Fischer     long nHeight,
166ff12d537SAndre Fischer     sal_uInt16 nFlags)
167ff12d537SAndre Fischer {
168*b9e67834SAndre Fischer     maBoundingBox = Rectangle(Point(nX,nY),Size(nWidth,nHeight));
169*b9e67834SAndre Fischer 
170*b9e67834SAndre Fischer     if ( ! IsReallyVisible())
171*b9e67834SAndre Fischer         return;
172*b9e67834SAndre Fischer 
173ff12d537SAndre Fischer     Window::SetPosSizePixel(nX, nY, nWidth, nHeight, nFlags);
174ff12d537SAndre Fischer 
175ff12d537SAndre Fischer     if (mxElementWindow.is())
176ff12d537SAndre Fischer         mxElementWindow->setPosSize(0, 0, nWidth, nHeight, nFlags);
177ff12d537SAndre Fischer }
178ff12d537SAndre Fischer 
179ff12d537SAndre Fischer 
180ff12d537SAndre Fischer 
181ff12d537SAndre Fischer 
182*b9e67834SAndre Fischer void Panel::Activate (void)
183*b9e67834SAndre Fischer {
184*b9e67834SAndre Fischer     Window::Activate();
185*b9e67834SAndre Fischer }
186*b9e67834SAndre Fischer 
187*b9e67834SAndre Fischer 
188*b9e67834SAndre Fischer 
189*b9e67834SAndre Fischer 
190*b9e67834SAndre Fischer 
191*b9e67834SAndre Fischer void Panel::DataChanged (const DataChangedEvent& rEvent)
192*b9e67834SAndre Fischer {
193*b9e67834SAndre Fischer     (void)rEvent;
194*b9e67834SAndre Fischer     SetBackground(Theme::GetPaint(Theme::Paint_PanelBackground).GetWallpaper());
195*b9e67834SAndre Fischer }
196*b9e67834SAndre Fischer 
197*b9e67834SAndre Fischer 
198*b9e67834SAndre Fischer 
199*b9e67834SAndre Fischer 
20022de8995SAndre Fischer Reference<ui::XVerticalStackLayoutElement> Panel::GetVerticalStackElement (void) const
20122de8995SAndre Fischer {
20222de8995SAndre Fischer     return mxVerticalStackLayoutElement;
20322de8995SAndre Fischer }
20422de8995SAndre Fischer 
205*b9e67834SAndre Fischer 
206*b9e67834SAndre Fischer 
207*b9e67834SAndre Fischer 
208*b9e67834SAndre Fischer IMPL_LINK(Panel, WindowEventHandler, VclWindowEvent*, pEvent)
209*b9e67834SAndre Fischer {
210*b9e67834SAndre Fischer     if (pEvent != NULL)
211*b9e67834SAndre Fischer     {
212*b9e67834SAndre Fischer         switch (pEvent->GetId())
213*b9e67834SAndre Fischer         {
214*b9e67834SAndre Fischer             case VCLEVENT_WINDOW_SHOW:
215*b9e67834SAndre Fischer             case VCLEVENT_WINDOW_RESIZE:
216*b9e67834SAndre Fischer                 SetPosSizePixel(
217*b9e67834SAndre Fischer                     maBoundingBox.Left(),
218*b9e67834SAndre Fischer                     maBoundingBox.Top(),
219*b9e67834SAndre Fischer                     maBoundingBox.GetWidth(),
220*b9e67834SAndre Fischer                     maBoundingBox.GetHeight());
221*b9e67834SAndre Fischer                 break;
222*b9e67834SAndre Fischer 
223*b9e67834SAndre Fischer             default:
224*b9e67834SAndre Fischer                 break;
225*b9e67834SAndre Fischer         }
226*b9e67834SAndre Fischer     }
227*b9e67834SAndre Fischer 
228*b9e67834SAndre Fischer     return sal_True;
229*b9e67834SAndre Fischer }
230*b9e67834SAndre Fischer 
231*b9e67834SAndre Fischer 
232ff12d537SAndre Fischer } } // end of namespace sfx2::sidebar
233