xref: /AOO41X/main/sd/source/ui/slidesorter/view/SlsButtonBar.cxx (revision 0ca1f90083be799139e54eeb1fe0c8e6842f2a84)
15b190011SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
35b190011SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
45b190011SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
55b190011SAndrew Rist  * distributed with this work for additional information
65b190011SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
75b190011SAndrew Rist  * to you under the Apache License, Version 2.0 (the
85b190011SAndrew Rist  * "License"); you may not use this file except in compliance
95b190011SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
115b190011SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
135b190011SAndrew Rist  * Unless required by applicable law or agreed to in writing,
145b190011SAndrew Rist  * software distributed under the License is distributed on an
155b190011SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
165b190011SAndrew Rist  * KIND, either express or implied.  See the License for the
175b190011SAndrew Rist  * specific language governing permissions and limitations
185b190011SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
205b190011SAndrew Rist  *************************************************************/
215b190011SAndrew Rist 
225b190011SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #include "precompiled_sd.hxx"
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include "view/SlsButtonBar.hxx"
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #include "SlideSorter.hxx"
29cdf0e10cSrcweir #include "model/SlsPageDescriptor.hxx"
30cdf0e10cSrcweir #include "model/SlideSorterModel.hxx"
31cdf0e10cSrcweir #include "view/SlsTheme.hxx"
32cdf0e10cSrcweir #include "view/SlideSorterView.hxx"
33cdf0e10cSrcweir #include "view/SlsToolTip.hxx"
34cdf0e10cSrcweir #include "controller/SlideSorterController.hxx"
35cdf0e10cSrcweir #include "controller/SlsSlotManager.hxx"
36cdf0e10cSrcweir #include "controller/SlsCurrentSlideManager.hxx"
37cdf0e10cSrcweir #include "controller/SlsPageSelector.hxx"
38cdf0e10cSrcweir #include "controller/SlsAnimator.hxx"
39cdf0e10cSrcweir #include "controller/SlsAnimationFunction.hxx"
40cdf0e10cSrcweir #include "app.hrc"
41cdf0e10cSrcweir #include "drawdoc.hxx"
4217673424SMichael Stahl #include "sddll.hxx"
4317673424SMichael Stahl #include "optsitem.hxx"
44cdf0e10cSrcweir #include <svx/svxids.hrc>
45cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
46cdf0e10cSrcweir #include <vcl/bmpacc.hxx>
47cdf0e10cSrcweir #include <vcl/virdev.hxx>
48cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygontools.hxx>
49cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygon.hxx>
50117a7820SMichael Stahl #include <basegfx/numeric/ftools.hxx>
51cdf0e10cSrcweir #include <com/sun/star/presentation/XPresentation2.hpp>
52cdf0e10cSrcweir #include <boost/bind.hpp>
53cdf0e10cSrcweir 
54cdf0e10cSrcweir using ::com::sun::star::uno::Any;
55cdf0e10cSrcweir using ::com::sun::star::uno::Reference;
56cdf0e10cSrcweir using ::com::sun::star::uno::Sequence;
57cdf0e10cSrcweir using ::com::sun::star::beans::PropertyValue;
58cdf0e10cSrcweir using ::com::sun::star::presentation::XPresentation2;
59cdf0e10cSrcweir 
60cdf0e10cSrcweir namespace sd { namespace slidesorter { namespace view {
61cdf0e10cSrcweir 
62cdf0e10cSrcweir /** Base class for the painter of the background bar onto which the buttons
63cdf0e10cSrcweir     are painted.  It also provides some size information.
64cdf0e10cSrcweir */
65cdf0e10cSrcweir class ButtonBar::BackgroundTheme
66cdf0e10cSrcweir {
67cdf0e10cSrcweir public:
68cdf0e10cSrcweir     BackgroundTheme(
69cdf0e10cSrcweir         const ::boost::shared_ptr<Theme>& rpTheme,
70cdf0e10cSrcweir         const ::std::vector<SharedButton>& rButtons);
71cdf0e10cSrcweir     /** Set the preview bounding box, the maximal area in which to display
72cdf0e10cSrcweir         buttons.  A call to this method triggers a call to Layout().
73cdf0e10cSrcweir     */
74cdf0e10cSrcweir     void SetPreviewBoundingBox (const Rectangle& rPreviewBoundingBox);
75cdf0e10cSrcweir     Button::IconSize GetIconSize (void) const;
76cdf0e10cSrcweir 
77cdf0e10cSrcweir     virtual BitmapEx CreateBackground (
78cdf0e10cSrcweir         const OutputDevice& rTemplateDevice,
79cdf0e10cSrcweir         const bool bIsButtonDown) const = 0;
80cdf0e10cSrcweir     virtual Point GetBackgroundLocation (void) = 0;
81cdf0e10cSrcweir     virtual Rectangle GetButtonArea (void) = 0;
82cdf0e10cSrcweir 
83cdf0e10cSrcweir protected:
84cdf0e10cSrcweir     ::boost::shared_ptr<Theme> mpTheme;
85cdf0e10cSrcweir     Rectangle maPreviewBoundingBox;
86cdf0e10cSrcweir     Size maMinimumLargeButtonAreaSize;
87cdf0e10cSrcweir     Size maMinimumMediumButtonAreaSize;
88cdf0e10cSrcweir     Size maMinimumSmallButtonAreaSize;
89cdf0e10cSrcweir     Button::IconSize meIconSize;
90cdf0e10cSrcweir 
91cdf0e10cSrcweir     virtual void Layout (void) = 0;
92cdf0e10cSrcweir 
93cdf0e10cSrcweir private:
94cdf0e10cSrcweir     void UpdateMinimumIconSizes(const ::std::vector<SharedButton>& rButtons);
95cdf0e10cSrcweir };
96cdf0e10cSrcweir 
97cdf0e10cSrcweir 
98cdf0e10cSrcweir namespace {
99cdf0e10cSrcweir     /** Rectangular button bar that covers the whole width of the preview.
100cdf0e10cSrcweir     */
101cdf0e10cSrcweir     class RectangleBackgroundTheme : public ButtonBar::BackgroundTheme
102cdf0e10cSrcweir     {
103cdf0e10cSrcweir     public:
104cdf0e10cSrcweir         RectangleBackgroundTheme(
105cdf0e10cSrcweir             const ::boost::shared_ptr<Theme>& rpTheme,
106cdf0e10cSrcweir             const ::std::vector<SharedButton>& rButtons);
107cdf0e10cSrcweir         virtual BitmapEx CreateBackground (
108cdf0e10cSrcweir             const OutputDevice& rTemplateDevice,
109cdf0e10cSrcweir             const bool bIsButtonDown) const;
110cdf0e10cSrcweir         virtual Point GetBackgroundLocation (void);
111cdf0e10cSrcweir         virtual Rectangle GetButtonArea (void);
112cdf0e10cSrcweir     protected:
113cdf0e10cSrcweir         virtual void Layout (void);
114cdf0e10cSrcweir     private:
115cdf0e10cSrcweir         sal_Int32 mnBarHeight;
116cdf0e10cSrcweir     };
117cdf0e10cSrcweir 
118cdf0e10cSrcweir     /** Button bar is composed of three images, the left and right end of
119cdf0e10cSrcweir         the bar and the center image.  Buttons are only placed over the
120cdf0e10cSrcweir         center image.  The center image is painted as is, it is not scaled.
121cdf0e10cSrcweir     */
122cdf0e10cSrcweir     class BitmapBackgroundTheme : public ButtonBar::BackgroundTheme
123cdf0e10cSrcweir     {
124cdf0e10cSrcweir     public:
125cdf0e10cSrcweir         BitmapBackgroundTheme(
126cdf0e10cSrcweir             const ::boost::shared_ptr<Theme>& rpTheme,
127cdf0e10cSrcweir             const ::std::vector<SharedButton>& rButtons);
128cdf0e10cSrcweir         virtual BitmapEx CreateBackground (
129cdf0e10cSrcweir             const OutputDevice& rTemplateDevice,
130cdf0e10cSrcweir             const bool bIsButtonDown) const;
131cdf0e10cSrcweir         virtual Point GetBackgroundLocation (void);
132cdf0e10cSrcweir         virtual Rectangle GetButtonArea (void);
133cdf0e10cSrcweir     protected:
134cdf0e10cSrcweir         virtual void Layout (void);
135cdf0e10cSrcweir     private:
136cdf0e10cSrcweir         Rectangle maButtonArea;
137cdf0e10cSrcweir         Point maBackgroundLocation;
138cdf0e10cSrcweir     };
139cdf0e10cSrcweir 
140cdf0e10cSrcweir     /** The source mask is essentially multiplied with the given alpha value.
141cdf0e10cSrcweir         The result is writen to the result mask.
142cdf0e10cSrcweir     */
AdaptTransparency(AlphaMask & rMask,const AlphaMask & rSourceMask,const double nAlpha)143cdf0e10cSrcweir     void AdaptTransparency (AlphaMask& rMask, const AlphaMask& rSourceMask, const double nAlpha)
144cdf0e10cSrcweir     {
145cdf0e10cSrcweir         BitmapWriteAccess* pBitmap = rMask.AcquireWriteAccess();
146cdf0e10cSrcweir         const BitmapReadAccess* pSourceBitmap = const_cast<AlphaMask&>(rSourceMask).AcquireReadAccess();
147cdf0e10cSrcweir 
148cdf0e10cSrcweir         if (pBitmap!=NULL && pSourceBitmap!=NULL)
149cdf0e10cSrcweir         {
150cdf0e10cSrcweir             const sal_Int32 nWidth (pBitmap->Width());
151cdf0e10cSrcweir             const sal_Int32 nHeight (pBitmap->Height());
152cdf0e10cSrcweir 
153cdf0e10cSrcweir             for (sal_Int32 nY = 0; nY<nHeight; ++nY)
154cdf0e10cSrcweir                 for (sal_Int32 nX = 0; nX<nWidth; ++nX)
155cdf0e10cSrcweir                 {
156cdf0e10cSrcweir                     const sal_uInt8 nValue (255 - pSourceBitmap->GetPixel(nY, nX).GetBlueOrIndex());
157117a7820SMichael Stahl                     const sal_Int32 nNewValue (::basegfx::clamp<sal_Int32>(
158117a7820SMichael Stahl                             static_cast<sal_Int32>(nValue * (1-nAlpha)),
159117a7820SMichael Stahl                             0,
160117a7820SMichael Stahl                             255));
16187bc88d3SHerbert Dürr                     pBitmap->SetPixelIndex(nY, nX, static_cast<sal_uInt8>(255-nNewValue));
162cdf0e10cSrcweir                 }
163cdf0e10cSrcweir         }
164cdf0e10cSrcweir     }
165cdf0e10cSrcweir 
166cdf0e10cSrcweir } // end of anonymous namespace
167cdf0e10cSrcweir 
168cdf0e10cSrcweir 
169cdf0e10cSrcweir //===== ButtonBar::Lock =======================================================
170cdf0e10cSrcweir 
Lock(SlideSorter & rSlideSorter)171cdf0e10cSrcweir ButtonBar::Lock::Lock (SlideSorter& rSlideSorter)
172cdf0e10cSrcweir     : mrButtonBar(rSlideSorter.GetView().GetButtonBar())
173cdf0e10cSrcweir {
174cdf0e10cSrcweir     mrButtonBar.AcquireLock();
175cdf0e10cSrcweir }
176cdf0e10cSrcweir 
177cdf0e10cSrcweir 
178cdf0e10cSrcweir 
179cdf0e10cSrcweir 
~Lock(void)180cdf0e10cSrcweir ButtonBar::Lock::~Lock (void)
181cdf0e10cSrcweir {
182cdf0e10cSrcweir     mrButtonBar.ReleaseLock();
183cdf0e10cSrcweir }
184cdf0e10cSrcweir 
185cdf0e10cSrcweir 
186cdf0e10cSrcweir 
187cdf0e10cSrcweir 
188cdf0e10cSrcweir //===== ButtonBar =============================================================
189cdf0e10cSrcweir 
ButtonBar(SlideSorter & rSlideSorter)190cdf0e10cSrcweir ButtonBar::ButtonBar (SlideSorter& rSlideSorter)
191cdf0e10cSrcweir     : mrSlideSorter(rSlideSorter),
192cdf0e10cSrcweir       maPageObjectSize(0,0),
193cdf0e10cSrcweir       maButtonBoundingBox(),
194cdf0e10cSrcweir       maBackgroundLocation(),
195cdf0e10cSrcweir       mpDescriptor(),
196cdf0e10cSrcweir       mbIsExcluded(false),
197cdf0e10cSrcweir       mpButtonUnderMouse(),
198cdf0e10cSrcweir       mpDownButton(),
199cdf0e10cSrcweir       maRegularButtons(),
200cdf0e10cSrcweir       maExcludedButtons(),
201cdf0e10cSrcweir       maNormalBackground(),
202cdf0e10cSrcweir       maButtonDownBackground(),
203cdf0e10cSrcweir       mbIsMouseOverBar(false),
204cdf0e10cSrcweir       mpBackgroundTheme(),
205cdf0e10cSrcweir       mnLockCount(0)
206cdf0e10cSrcweir {
207cdf0e10cSrcweir     HandleDataChangeEvent();
208cdf0e10cSrcweir }
209cdf0e10cSrcweir 
210cdf0e10cSrcweir 
211cdf0e10cSrcweir 
212cdf0e10cSrcweir 
~ButtonBar(void)213cdf0e10cSrcweir ButtonBar::~ButtonBar (void)
214cdf0e10cSrcweir {
215cdf0e10cSrcweir }
216cdf0e10cSrcweir 
217cdf0e10cSrcweir 
218cdf0e10cSrcweir 
219cdf0e10cSrcweir 
ProcessButtonDownEvent(const model::SharedPageDescriptor & rpDescriptor,const Point aMouseModelLocation)220cdf0e10cSrcweir void ButtonBar::ProcessButtonDownEvent (
221cdf0e10cSrcweir     const model::SharedPageDescriptor& rpDescriptor,
222cdf0e10cSrcweir     const Point aMouseModelLocation)
223cdf0e10cSrcweir {
224cdf0e10cSrcweir     SetButtonUnderMouse(GetButtonAt(aMouseModelLocation));
225cdf0e10cSrcweir     if (mpButtonUnderMouse)
226cdf0e10cSrcweir         mpButtonUnderMouse->SetState(Button::State_Down);
227cdf0e10cSrcweir     mpDownButton = mpButtonUnderMouse;
228cdf0e10cSrcweir 
229cdf0e10cSrcweir     mrSlideSorter.GetView().RequestRepaint(rpDescriptor);
230cdf0e10cSrcweir }
231cdf0e10cSrcweir 
232cdf0e10cSrcweir 
233cdf0e10cSrcweir 
234cdf0e10cSrcweir 
ProcessButtonUpEvent(const model::SharedPageDescriptor & rpDescriptor,const Point aMouseModelLocation)235cdf0e10cSrcweir void ButtonBar::ProcessButtonUpEvent (
236cdf0e10cSrcweir     const model::SharedPageDescriptor& rpDescriptor,
237cdf0e10cSrcweir     const Point aMouseModelLocation)
238cdf0e10cSrcweir {
239cdf0e10cSrcweir     SetButtonUnderMouse(GetButtonAt(aMouseModelLocation));
240cdf0e10cSrcweir     if (mpButtonUnderMouse)
241cdf0e10cSrcweir     {
242cdf0e10cSrcweir         mpButtonUnderMouse->SetState(Button::State_Hover);
243cdf0e10cSrcweir         if (mpButtonUnderMouse == mpDownButton)
244cdf0e10cSrcweir         {
245cdf0e10cSrcweir             // This is done only when the buttons are sufficiently visible.
246cdf0e10cSrcweir             if (mpDescriptor->GetVisualState().GetButtonAlpha()<0.7)
247cdf0e10cSrcweir             {
248cdf0e10cSrcweir                 mpButtonUnderMouse->ProcessClick(mpDescriptor);
249cdf0e10cSrcweir                 mbIsExcluded = mpDescriptor->HasState(model::PageDescriptor::ST_Excluded);
250cdf0e10cSrcweir                 ProcessMouseMotionEvent (rpDescriptor, aMouseModelLocation, false);
251cdf0e10cSrcweir             }
252cdf0e10cSrcweir         }
253cdf0e10cSrcweir     }
254cdf0e10cSrcweir     mpDownButton.reset();
255cdf0e10cSrcweir     mrSlideSorter.GetView().RequestRepaint(rpDescriptor);
256cdf0e10cSrcweir }
257cdf0e10cSrcweir 
258cdf0e10cSrcweir 
259cdf0e10cSrcweir 
260cdf0e10cSrcweir 
ProcessMouseMotionEvent(const model::SharedPageDescriptor & rpDescriptor,const Point aMouseModelLocation,const bool bIsMouseButtonDown)261cdf0e10cSrcweir void ButtonBar::ProcessMouseMotionEvent (
262cdf0e10cSrcweir     const model::SharedPageDescriptor& rpDescriptor,
263cdf0e10cSrcweir     const Point aMouseModelLocation,
264cdf0e10cSrcweir     const bool bIsMouseButtonDown)
265cdf0e10cSrcweir {
266cdf0e10cSrcweir     model::SharedPageDescriptor pOldDescriptor (mpDescriptor);
267cdf0e10cSrcweir     bool bPageHasChanged (false);
268cdf0e10cSrcweir     bool bButtonHasChanged (false);
269cdf0e10cSrcweir     bool bButtonStateHasChanged (false);
270cdf0e10cSrcweir 
271cdf0e10cSrcweir     // Update the page object for which to manage the buttons.
272cdf0e10cSrcweir     bPageHasChanged = SetPage(rpDescriptor);
273cdf0e10cSrcweir     mbIsMouseOverBar = IsMouseOverBar(aMouseModelLocation);
274cdf0e10cSrcweir 
275cdf0e10cSrcweir     // Update button under mouse.
276cdf0e10cSrcweir     if (rpDescriptor)
277cdf0e10cSrcweir     {
278cdf0e10cSrcweir         bButtonHasChanged = SetButtonUnderMouse(GetButtonAt(aMouseModelLocation));
279cdf0e10cSrcweir 
280cdf0e10cSrcweir         if (mpButtonUnderMouse)
281cdf0e10cSrcweir         {
282cdf0e10cSrcweir             // When the mouse button is down, mark the button under the
283cdf0e10cSrcweir             // mouse only as pressed when it is the same button the mouse
284cdf0e10cSrcweir             // button was pressed over, and where the button release would
285cdf0e10cSrcweir             // lead to a click action.
286cdf0e10cSrcweir             if (bIsMouseButtonDown)
287cdf0e10cSrcweir             {
288cdf0e10cSrcweir                 if (mpButtonUnderMouse==mpDownButton)
289cdf0e10cSrcweir                     bButtonStateHasChanged = mpButtonUnderMouse->SetState(Button::State_Down);
290cdf0e10cSrcweir             }
291cdf0e10cSrcweir             else
292cdf0e10cSrcweir                 bButtonStateHasChanged = mpButtonUnderMouse->SetState(Button::State_Hover);
293cdf0e10cSrcweir         }
294cdf0e10cSrcweir     }
295cdf0e10cSrcweir 
296cdf0e10cSrcweir     // Show a quick help text when the mouse is over a button.
297cdf0e10cSrcweir     if (bButtonHasChanged)
298cdf0e10cSrcweir     {
299cdf0e10cSrcweir         SharedSdWindow pWindow (mrSlideSorter.GetContentWindow());
300cdf0e10cSrcweir         if (pWindow)
301cdf0e10cSrcweir         {
302cdf0e10cSrcweir             if (mpButtonUnderMouse)
303cdf0e10cSrcweir                 mrSlideSorter.GetView().GetToolTip().ShowHelpText(mpButtonUnderMouse->GetHelpText());
304cdf0e10cSrcweir             else
305cdf0e10cSrcweir                 mrSlideSorter.GetView().GetToolTip().ShowDefaultHelpText();
306cdf0e10cSrcweir         }
307cdf0e10cSrcweir     }
308cdf0e10cSrcweir 
309cdf0e10cSrcweir     if (bPageHasChanged || bButtonHasChanged || bButtonStateHasChanged)
310cdf0e10cSrcweir     {
311cdf0e10cSrcweir         if (pOldDescriptor)
312cdf0e10cSrcweir             mrSlideSorter.GetView().RequestRepaint(pOldDescriptor);
313cdf0e10cSrcweir         if (mpDescriptor && pOldDescriptor!=mpDescriptor)
314cdf0e10cSrcweir             mrSlideSorter.GetView().RequestRepaint(mpDescriptor);
315cdf0e10cSrcweir     }
316cdf0e10cSrcweir }
317cdf0e10cSrcweir 
318cdf0e10cSrcweir 
319cdf0e10cSrcweir 
320cdf0e10cSrcweir 
ResetPage(void)321cdf0e10cSrcweir void ButtonBar::ResetPage (void)
322cdf0e10cSrcweir {
323cdf0e10cSrcweir     SetPage(model::SharedPageDescriptor());
324cdf0e10cSrcweir }
325cdf0e10cSrcweir 
326cdf0e10cSrcweir 
327cdf0e10cSrcweir 
328cdf0e10cSrcweir 
SetPage(const model::SharedPageDescriptor & rpDescriptor)329cdf0e10cSrcweir bool ButtonBar::SetPage (const model::SharedPageDescriptor& rpDescriptor)
330cdf0e10cSrcweir {
331cdf0e10cSrcweir     if (mpDescriptor != rpDescriptor)
332cdf0e10cSrcweir     {
333cdf0e10cSrcweir         mpDescriptor = rpDescriptor;
334cdf0e10cSrcweir 
335cdf0e10cSrcweir         if (mpDescriptor)
336cdf0e10cSrcweir             mbIsExcluded = mpDescriptor->HasState(model::PageDescriptor::ST_Excluded);
337cdf0e10cSrcweir         else
338cdf0e10cSrcweir             mbIsExcluded = false;
339cdf0e10cSrcweir         SetButtonUnderMouse();
340cdf0e10cSrcweir         mpDownButton.reset();
341cdf0e10cSrcweir 
342cdf0e10cSrcweir         return true;
343cdf0e10cSrcweir     }
344cdf0e10cSrcweir     else
345cdf0e10cSrcweir         return false;
346cdf0e10cSrcweir }
347cdf0e10cSrcweir 
348cdf0e10cSrcweir 
349cdf0e10cSrcweir 
350cdf0e10cSrcweir 
GetButtonCount(const bool bIsExcluded) const351cdf0e10cSrcweir sal_Int32 ButtonBar::GetButtonCount (const bool bIsExcluded) const
352cdf0e10cSrcweir {
353cdf0e10cSrcweir     if (bIsExcluded)
354cdf0e10cSrcweir         return maExcludedButtons.size();
355cdf0e10cSrcweir     else
356cdf0e10cSrcweir         return maRegularButtons.size();
357cdf0e10cSrcweir }
358cdf0e10cSrcweir 
359cdf0e10cSrcweir 
360cdf0e10cSrcweir 
361cdf0e10cSrcweir 
GetButton(const bool bIsExcluded,const sal_Int32 nIndex) const362cdf0e10cSrcweir ::boost::shared_ptr<Button> ButtonBar::GetButton (
363cdf0e10cSrcweir     const bool bIsExcluded,
364cdf0e10cSrcweir     const sal_Int32 nIndex) const
365cdf0e10cSrcweir {
366cdf0e10cSrcweir     const ::std::vector<boost::shared_ptr<Button> >& rButtons (bIsExcluded
367cdf0e10cSrcweir         ? maExcludedButtons
368cdf0e10cSrcweir         : maRegularButtons);
369cdf0e10cSrcweir 
370cdf0e10cSrcweir     if (nIndex<0 || sal_uInt32(nIndex)>=rButtons.size())
371cdf0e10cSrcweir     {
372cdf0e10cSrcweir         OSL_ASSERT(nIndex<0 || sal_uInt32(nIndex)>=rButtons.size());
373cdf0e10cSrcweir         return ::boost::shared_ptr<Button>();
374cdf0e10cSrcweir     }
375cdf0e10cSrcweir     else
376cdf0e10cSrcweir         return rButtons[sal_uInt32(nIndex)];
377cdf0e10cSrcweir }
378cdf0e10cSrcweir 
379cdf0e10cSrcweir 
380cdf0e10cSrcweir 
381cdf0e10cSrcweir 
GetButtonAt(const Point aModelLocation)382cdf0e10cSrcweir SharedButton ButtonBar::GetButtonAt (const Point aModelLocation)
383cdf0e10cSrcweir {
384cdf0e10cSrcweir     if (IsMouseOverBar(aModelLocation))
385cdf0e10cSrcweir     {
386cdf0e10cSrcweir         const Point aLocalLocation (aModelLocation - mpDescriptor->GetBoundingBox().TopLeft());
387cdf0e10cSrcweir         ::std::vector<SharedButton>& rButtons (
388cdf0e10cSrcweir             mbIsExcluded ? maExcludedButtons : maRegularButtons);
389cdf0e10cSrcweir         for (sal_uInt32 nIndex=0; nIndex<rButtons.size(); ++nIndex)
390cdf0e10cSrcweir         {
391cdf0e10cSrcweir             if (rButtons[sal_uInt32(nIndex)]->GetBoundingBox().IsInside(aLocalLocation))
392cdf0e10cSrcweir             {
393cdf0e10cSrcweir                 if (rButtons[sal_uInt32(nIndex)]->IsEnabled())
394cdf0e10cSrcweir                     return rButtons[sal_uInt32(nIndex)];
395cdf0e10cSrcweir                 else
396cdf0e10cSrcweir                     return SharedButton();
397cdf0e10cSrcweir             }
398cdf0e10cSrcweir         }
399cdf0e10cSrcweir     }
400cdf0e10cSrcweir 
401cdf0e10cSrcweir     return SharedButton();
402cdf0e10cSrcweir }
403cdf0e10cSrcweir 
404cdf0e10cSrcweir 
405cdf0e10cSrcweir 
406cdf0e10cSrcweir 
IsMouseOverBar(void) const407cdf0e10cSrcweir bool ButtonBar::IsMouseOverBar (void) const
408cdf0e10cSrcweir {
409cdf0e10cSrcweir     return mbIsMouseOverBar;
410cdf0e10cSrcweir }
411cdf0e10cSrcweir 
412cdf0e10cSrcweir 
413cdf0e10cSrcweir 
414cdf0e10cSrcweir 
SetButtonUnderMouse(const SharedButton & rButton)415cdf0e10cSrcweir bool ButtonBar::SetButtonUnderMouse (const SharedButton& rButton)
416cdf0e10cSrcweir {
417cdf0e10cSrcweir     if (mpButtonUnderMouse != rButton)
418cdf0e10cSrcweir     {
419cdf0e10cSrcweir         if (mpButtonUnderMouse)
420cdf0e10cSrcweir             mpButtonUnderMouse->SetState(Button::State_Normal);
421cdf0e10cSrcweir 
422cdf0e10cSrcweir         mpButtonUnderMouse = rButton;
423cdf0e10cSrcweir 
424cdf0e10cSrcweir         return true;
425cdf0e10cSrcweir     }
426cdf0e10cSrcweir     else
427cdf0e10cSrcweir         return false;
428cdf0e10cSrcweir }
429cdf0e10cSrcweir 
430cdf0e10cSrcweir 
431cdf0e10cSrcweir 
432cdf0e10cSrcweir 
Paint(OutputDevice & rDevice,const model::SharedPageDescriptor & rpDescriptor)433cdf0e10cSrcweir void ButtonBar::Paint (
434cdf0e10cSrcweir     OutputDevice& rDevice,
435cdf0e10cSrcweir     const model::SharedPageDescriptor& rpDescriptor)
436cdf0e10cSrcweir {
437cdf0e10cSrcweir     if ( ! rpDescriptor)
438cdf0e10cSrcweir         return;
439cdf0e10cSrcweir 
440cdf0e10cSrcweir     const double nButtonBarAlpha (rpDescriptor->GetVisualState().GetButtonBarAlpha());
441cdf0e10cSrcweir     if (nButtonBarAlpha >= 1)
442cdf0e10cSrcweir         return;
443cdf0e10cSrcweir 
444cdf0e10cSrcweir     LayoutButtons(rpDescriptor->GetBoundingBox().GetSize());
445cdf0e10cSrcweir 
446cdf0e10cSrcweir     const Point aOffset (rpDescriptor->GetBoundingBox().TopLeft());
447cdf0e10cSrcweir 
448cdf0e10cSrcweir     // Paint the background.
449cdf0e10cSrcweir     PaintButtonBackground(rDevice, rpDescriptor, aOffset);
450cdf0e10cSrcweir 
451cdf0e10cSrcweir     // Paint the buttons.
452cdf0e10cSrcweir     const ::std::vector<SharedButton>& rButtons (
453cdf0e10cSrcweir         rpDescriptor->HasState(model::PageDescriptor::ST_Excluded)
454cdf0e10cSrcweir             ? maExcludedButtons
455cdf0e10cSrcweir             : maRegularButtons);
456cdf0e10cSrcweir 
457cdf0e10cSrcweir 
458cdf0e10cSrcweir     const double nButtonAlpha (rpDescriptor->GetVisualState().GetButtonAlpha());
459cdf0e10cSrcweir     for (sal_uInt32 nIndex=0; nIndex<rButtons.size(); ++nIndex)
460cdf0e10cSrcweir         rButtons[nIndex]->Paint(
461cdf0e10cSrcweir             rDevice,
462cdf0e10cSrcweir             aOffset,
463cdf0e10cSrcweir             nButtonAlpha,
464cdf0e10cSrcweir             mrSlideSorter.GetTheme());
465cdf0e10cSrcweir }
466cdf0e10cSrcweir 
467cdf0e10cSrcweir 
468cdf0e10cSrcweir 
469cdf0e10cSrcweir 
IsMouseOverButton(void) const470cdf0e10cSrcweir bool ButtonBar::IsMouseOverButton (void) const
471cdf0e10cSrcweir {
472*0ca1f900SHerbert Dürr     return (mpButtonUnderMouse.get() != NULL);
473cdf0e10cSrcweir }
474cdf0e10cSrcweir 
475cdf0e10cSrcweir 
476cdf0e10cSrcweir 
477cdf0e10cSrcweir 
PaintButtonBackground(OutputDevice & rDevice,const model::SharedPageDescriptor & rpDescriptor,const Point aOffset)478cdf0e10cSrcweir void ButtonBar::PaintButtonBackground (
479cdf0e10cSrcweir     OutputDevice& rDevice,
480cdf0e10cSrcweir     const model::SharedPageDescriptor& rpDescriptor,
481cdf0e10cSrcweir     const Point aOffset)
482cdf0e10cSrcweir {
483cdf0e10cSrcweir     BitmapEx* pBitmap = NULL;
484cdf0e10cSrcweir     if (maButtonDownBackground.IsEmpty() || maNormalBackground.IsEmpty())
485cdf0e10cSrcweir     {
486cdf0e10cSrcweir         if (mpBackgroundTheme)
487cdf0e10cSrcweir         {
488cdf0e10cSrcweir             maButtonDownBackground = mpBackgroundTheme->CreateBackground(rDevice, true);
489cdf0e10cSrcweir             maNormalBackground = mpBackgroundTheme->CreateBackground(rDevice, false);
490cdf0e10cSrcweir         }
491cdf0e10cSrcweir     }
492cdf0e10cSrcweir     if (mpButtonUnderMouse && mpButtonUnderMouse->IsDown())
493cdf0e10cSrcweir         pBitmap = &maButtonDownBackground;
494cdf0e10cSrcweir     else
495cdf0e10cSrcweir         pBitmap = &maNormalBackground;
496cdf0e10cSrcweir     if (pBitmap != NULL)
497cdf0e10cSrcweir     {
498cdf0e10cSrcweir         AlphaMask aMask (pBitmap->GetSizePixel());
499cdf0e10cSrcweir         AdaptTransparency(
500cdf0e10cSrcweir             aMask,
501cdf0e10cSrcweir             pBitmap->GetAlpha(),
502cdf0e10cSrcweir             rpDescriptor->GetVisualState().GetButtonBarAlpha());
503cdf0e10cSrcweir         rDevice.DrawBitmapEx(maBackgroundLocation+aOffset, BitmapEx(pBitmap->GetBitmap(), aMask));
504cdf0e10cSrcweir     }
505cdf0e10cSrcweir }
506cdf0e10cSrcweir 
507cdf0e10cSrcweir 
508cdf0e10cSrcweir 
509cdf0e10cSrcweir 
IsMouseOverBar(const Point aModelLocation) const510cdf0e10cSrcweir bool ButtonBar::IsMouseOverBar (const Point aModelLocation) const
511cdf0e10cSrcweir {
512cdf0e10cSrcweir     if ( ! mpDescriptor || ! mpDescriptor->GetBoundingBox().IsInside(aModelLocation))
513cdf0e10cSrcweir         return false;
514cdf0e10cSrcweir 
515cdf0e10cSrcweir     if ( ! maButtonBoundingBox.IsInside(aModelLocation - mpDescriptor->GetBoundingBox().TopLeft()))
516cdf0e10cSrcweir         return false;
517cdf0e10cSrcweir 
518cdf0e10cSrcweir     return true;
519cdf0e10cSrcweir }
520cdf0e10cSrcweir 
521cdf0e10cSrcweir 
522cdf0e10cSrcweir 
523cdf0e10cSrcweir 
RequestLayout(void)524cdf0e10cSrcweir void ButtonBar::RequestLayout (void)
525cdf0e10cSrcweir {
526cdf0e10cSrcweir     maPageObjectSize = Size(0,0);
527cdf0e10cSrcweir }
528cdf0e10cSrcweir 
529cdf0e10cSrcweir 
530cdf0e10cSrcweir 
531cdf0e10cSrcweir 
LayoutButtons(const Size aPageObjectSize)532cdf0e10cSrcweir void ButtonBar::LayoutButtons (const Size aPageObjectSize)
533cdf0e10cSrcweir {
534cdf0e10cSrcweir     if (maPageObjectSize != aPageObjectSize)
535cdf0e10cSrcweir     {
536cdf0e10cSrcweir         maPageObjectSize = aPageObjectSize;
537cdf0e10cSrcweir 
538cdf0e10cSrcweir         if (mpBackgroundTheme)
539cdf0e10cSrcweir         {
540cdf0e10cSrcweir             mpBackgroundTheme->SetPreviewBoundingBox(
541cdf0e10cSrcweir                 mrSlideSorter.GetView().GetLayouter().GetPageObjectLayouter()->GetBoundingBox(
542cdf0e10cSrcweir                     Point(0,0),
543cdf0e10cSrcweir                     PageObjectLayouter::Preview,
544cdf0e10cSrcweir                     PageObjectLayouter::ModelCoordinateSystem));
545cdf0e10cSrcweir             LayoutButtons();
546cdf0e10cSrcweir         }
547cdf0e10cSrcweir 
548cdf0e10cSrcweir         // Release the background bitmaps so that on the next paint
549cdf0e10cSrcweir         // they are created anew in the right size.
550cdf0e10cSrcweir         maNormalBackground.SetEmpty();
551cdf0e10cSrcweir         maButtonDownBackground.SetEmpty();
552cdf0e10cSrcweir     }
553cdf0e10cSrcweir }
554cdf0e10cSrcweir 
555cdf0e10cSrcweir 
556cdf0e10cSrcweir 
557cdf0e10cSrcweir 
LayoutButtons(void)558cdf0e10cSrcweir bool ButtonBar::LayoutButtons (void)
559cdf0e10cSrcweir {
560cdf0e10cSrcweir     const sal_Int32 nGap (mrSlideSorter.GetTheme()->GetIntegerValue(Theme::Integer_ButtonGap));
561cdf0e10cSrcweir     const sal_Int32 nBorder (mrSlideSorter.GetTheme()->GetIntegerValue(Theme::Integer_ButtonBorder));
562cdf0e10cSrcweir 
563cdf0e10cSrcweir     const Button::IconSize eIconSize (mpBackgroundTheme->GetIconSize());
564cdf0e10cSrcweir 
565cdf0e10cSrcweir     // Tell buttons which size they are.
566cdf0e10cSrcweir     for (sal_uInt32 nIndex=0; nIndex<maExcludedButtons.size(); ++nIndex)
567cdf0e10cSrcweir         maExcludedButtons[nIndex]->SetIconSize(eIconSize);
568cdf0e10cSrcweir     for (sal_uInt32 nIndex=0; nIndex<maRegularButtons.size(); ++nIndex)
569cdf0e10cSrcweir         maRegularButtons[nIndex]->SetIconSize(eIconSize);
570cdf0e10cSrcweir 
571cdf0e10cSrcweir     // Determine maximal height and total width of the buttons.
572cdf0e10cSrcweir     // Start with the buttons used for the excluded state.
573cdf0e10cSrcweir     sal_Int32 nMaximumHeight (0);
574cdf0e10cSrcweir     sal_Int32 nExcludedTotalWidth ((maExcludedButtons.size()-1) * nGap + 2*nBorder);
575cdf0e10cSrcweir     for (sal_uInt32 nIndex=0; nIndex<maExcludedButtons.size(); ++nIndex)
576cdf0e10cSrcweir     {
577cdf0e10cSrcweir         const Size aSize (maExcludedButtons[nIndex]->GetSize());
578cdf0e10cSrcweir         if (aSize.Height() > nMaximumHeight)
579cdf0e10cSrcweir             nMaximumHeight = aSize.Height();
580cdf0e10cSrcweir         nExcludedTotalWidth += aSize.Width();
581cdf0e10cSrcweir     }
582cdf0e10cSrcweir 
583cdf0e10cSrcweir     // Do the same for the regular buttons.
584cdf0e10cSrcweir     sal_Int32 nRegularTotalWidth ((maRegularButtons.size()-1) * nGap + 2*nBorder);
585cdf0e10cSrcweir     for (sal_uInt32 nIndex=0; nIndex<maRegularButtons.size(); ++nIndex)
586cdf0e10cSrcweir     {
587cdf0e10cSrcweir         const Size aSize (maRegularButtons[nIndex]->GetSize());
588cdf0e10cSrcweir         if (aSize.Height() > nMaximumHeight)
589cdf0e10cSrcweir             nMaximumHeight = aSize.Height();
590cdf0e10cSrcweir         nRegularTotalWidth += aSize.Width();
591cdf0e10cSrcweir     }
592cdf0e10cSrcweir     nMaximumHeight += 2*nBorder;
593cdf0e10cSrcweir 
594cdf0e10cSrcweir     // Set up the bounding box of the button bar.
595cdf0e10cSrcweir     maButtonBoundingBox = mpBackgroundTheme->GetButtonArea();
596cdf0e10cSrcweir     maBackgroundLocation = mpBackgroundTheme->GetBackgroundLocation();
597cdf0e10cSrcweir     if (mrSlideSorter.GetTheme()->GetIntegerValue(Theme::Integer_ButtonPaintType) == 1)
598cdf0e10cSrcweir     {
599cdf0e10cSrcweir         // Center the buttons.
600cdf0e10cSrcweir         maButtonBoundingBox.Left() += (maButtonBoundingBox.GetWidth() - nRegularTotalWidth)/2;
601cdf0e10cSrcweir         maButtonBoundingBox.Right() = maButtonBoundingBox.Left() + nRegularTotalWidth - 1;
602cdf0e10cSrcweir     }
603cdf0e10cSrcweir 
604cdf0e10cSrcweir     // Place the buttons.
605cdf0e10cSrcweir     Rectangle aBox (maButtonBoundingBox);
606cdf0e10cSrcweir     aBox.Right() -= nBorder;
607cdf0e10cSrcweir     for (sal_Int32 nIndex=maRegularButtons.size()-1; nIndex>=0; --nIndex)
608cdf0e10cSrcweir     {
609cdf0e10cSrcweir         maRegularButtons[nIndex]->Place(aBox);
610cdf0e10cSrcweir         aBox.Right() = maRegularButtons[nIndex]->GetBoundingBox().Left() - nGap;
611cdf0e10cSrcweir     }
612cdf0e10cSrcweir 
613cdf0e10cSrcweir     // For slides excluded from the show there is only one icon placed
614cdf0e10cSrcweir     // exactly like the second of the regular icons.
615cdf0e10cSrcweir     if (maRegularButtons.size()>=2 && maExcludedButtons.size()>=1)
616cdf0e10cSrcweir     {
617cdf0e10cSrcweir         aBox = maRegularButtons[1]->GetBoundingBox();
618cdf0e10cSrcweir         maExcludedButtons[0]->Place(aBox);
619cdf0e10cSrcweir     }
620cdf0e10cSrcweir 
621cdf0e10cSrcweir     // We return true only when there is no inactive button.
622cdf0e10cSrcweir     for (sal_uInt32 nIndex=0; nIndex<maExcludedButtons.size(); ++nIndex)
623cdf0e10cSrcweir         if ( ! maExcludedButtons[nIndex]->IsActive())
624cdf0e10cSrcweir             return false;
625cdf0e10cSrcweir     for (sal_uInt32 nIndex=0; nIndex<maRegularButtons.size(); ++nIndex)
626cdf0e10cSrcweir         if ( ! maRegularButtons[nIndex]->IsActive())
627cdf0e10cSrcweir             return false;
628cdf0e10cSrcweir 
629cdf0e10cSrcweir     return true;
630cdf0e10cSrcweir }
631cdf0e10cSrcweir 
632cdf0e10cSrcweir 
633cdf0e10cSrcweir 
634cdf0e10cSrcweir 
RequestFadeIn(const model::SharedPageDescriptor & rpDescriptor,const bool bAnimate)635cdf0e10cSrcweir void ButtonBar::RequestFadeIn (
636cdf0e10cSrcweir     const model::SharedPageDescriptor& rpDescriptor,
637cdf0e10cSrcweir     const bool bAnimate)
638cdf0e10cSrcweir {
639cdf0e10cSrcweir     if ( ! rpDescriptor)
640cdf0e10cSrcweir         return;
641cdf0e10cSrcweir     if (mnLockCount > 0)
642cdf0e10cSrcweir         return;
643cdf0e10cSrcweir 
644cdf0e10cSrcweir     const double nMinAlpha (0);
645cdf0e10cSrcweir     if ( ! bAnimate)
646cdf0e10cSrcweir     {
647cdf0e10cSrcweir         rpDescriptor->GetVisualState().SetButtonAlpha(nMinAlpha);
648cdf0e10cSrcweir         rpDescriptor->GetVisualState().SetButtonBarAlpha(nMinAlpha);
649cdf0e10cSrcweir     }
650cdf0e10cSrcweir     else
651cdf0e10cSrcweir         StartFadeAnimation(rpDescriptor, nMinAlpha, true);
652cdf0e10cSrcweir }
653cdf0e10cSrcweir 
654cdf0e10cSrcweir 
655cdf0e10cSrcweir 
656cdf0e10cSrcweir 
RequestFadeOut(const model::SharedPageDescriptor & rpDescriptor,const bool bAnimate)657cdf0e10cSrcweir void ButtonBar::RequestFadeOut (
658cdf0e10cSrcweir     const model::SharedPageDescriptor& rpDescriptor,
659cdf0e10cSrcweir     const bool bAnimate)
660cdf0e10cSrcweir {
661cdf0e10cSrcweir     if ( ! rpDescriptor)
662cdf0e10cSrcweir         return;
663cdf0e10cSrcweir     if (mnLockCount > 0)
664cdf0e10cSrcweir         return;
665cdf0e10cSrcweir 
666cdf0e10cSrcweir     const double nMaxAlpha (1);
667cdf0e10cSrcweir     if ( ! bAnimate)
668cdf0e10cSrcweir     {
669cdf0e10cSrcweir         rpDescriptor->GetVisualState().SetButtonAlpha(nMaxAlpha);
670cdf0e10cSrcweir         rpDescriptor->GetVisualState().SetButtonBarAlpha(nMaxAlpha);
671cdf0e10cSrcweir     }
672cdf0e10cSrcweir     else
673cdf0e10cSrcweir         StartFadeAnimation(rpDescriptor, nMaxAlpha, false);
674cdf0e10cSrcweir }
675cdf0e10cSrcweir 
676cdf0e10cSrcweir 
677cdf0e10cSrcweir 
678cdf0e10cSrcweir 
IsVisible(const model::SharedPageDescriptor & rpDescriptor)679cdf0e10cSrcweir bool ButtonBar::IsVisible (const model::SharedPageDescriptor& rpDescriptor)
680cdf0e10cSrcweir {
681cdf0e10cSrcweir     const double nMaxAlpha (1);
682cdf0e10cSrcweir     return rpDescriptor && rpDescriptor->GetVisualState().GetButtonBarAlpha() < nMaxAlpha;
683cdf0e10cSrcweir }
684cdf0e10cSrcweir 
685cdf0e10cSrcweir 
686cdf0e10cSrcweir 
687cdf0e10cSrcweir 
HandleDataChangeEvent(void)688cdf0e10cSrcweir void ButtonBar::HandleDataChangeEvent (void)
689cdf0e10cSrcweir {
690cdf0e10cSrcweir     maExcludedButtons.clear();
691cdf0e10cSrcweir     maExcludedButtons.push_back(::boost::shared_ptr<Button>(new UnhideButton(mrSlideSorter)));
692cdf0e10cSrcweir 
693cdf0e10cSrcweir     maRegularButtons.clear();
694cdf0e10cSrcweir     maRegularButtons.push_back(::boost::shared_ptr<Button>(new StartShowButton(mrSlideSorter)));
695cdf0e10cSrcweir     maRegularButtons.push_back(::boost::shared_ptr<Button>(new HideButton(mrSlideSorter)));
696cdf0e10cSrcweir     maRegularButtons.push_back(::boost::shared_ptr<Button>(new DuplicateButton(mrSlideSorter)));
697cdf0e10cSrcweir 
698cdf0e10cSrcweir     mpBackgroundTheme.reset(
699cdf0e10cSrcweir         new BitmapBackgroundTheme(
700cdf0e10cSrcweir             mrSlideSorter.GetTheme(),
701cdf0e10cSrcweir             maRegularButtons));
702cdf0e10cSrcweir 
703cdf0e10cSrcweir     // Force layout on next Paint().
704cdf0e10cSrcweir     maPageObjectSize = Size(0,0);
705cdf0e10cSrcweir }
706cdf0e10cSrcweir 
707cdf0e10cSrcweir 
708cdf0e10cSrcweir 
709cdf0e10cSrcweir 
StartFadeAnimation(const model::SharedPageDescriptor & rpDescriptor,const double nTargetAlpha,const bool bFadeIn)710cdf0e10cSrcweir void ButtonBar::StartFadeAnimation (
711cdf0e10cSrcweir     const model::SharedPageDescriptor& rpDescriptor,
712cdf0e10cSrcweir     const double nTargetAlpha,
713cdf0e10cSrcweir     const bool bFadeIn)
714cdf0e10cSrcweir {
715cdf0e10cSrcweir     model::SharedPageDescriptor pDescriptor (rpDescriptor);
716cdf0e10cSrcweir 
717cdf0e10cSrcweir     const double nCurrentButtonAlpha (pDescriptor->GetVisualState().GetButtonAlpha());
718cdf0e10cSrcweir     const double nCurrentButtonBarAlpha (pDescriptor->GetVisualState().GetButtonBarAlpha());
719cdf0e10cSrcweir 
720cdf0e10cSrcweir     // Stop a running animation.
721cdf0e10cSrcweir     const controller::Animator::AnimationId nId (
722cdf0e10cSrcweir         pDescriptor->GetVisualState().GetButtonAlphaAnimationId());
723cdf0e10cSrcweir     if (nId != controller::Animator::NotAnAnimationId)
724cdf0e10cSrcweir         mrSlideSorter.GetController().GetAnimator()->RemoveAnimation(nId);
725cdf0e10cSrcweir 
726cdf0e10cSrcweir     // Prepare the blending functors that translate [0,1] animation
727cdf0e10cSrcweir     // times into alpha values of buttons and button bar.
728cdf0e10cSrcweir     const ::boost::function<double(double)> aButtonBlendFunctor (
729cdf0e10cSrcweir         ::boost::bind(
730cdf0e10cSrcweir             controller::AnimationFunction::Blend,
731cdf0e10cSrcweir             nCurrentButtonAlpha,
732cdf0e10cSrcweir             nTargetAlpha,
733cdf0e10cSrcweir             ::boost::bind(controller::AnimationFunction::Linear, _1)));
734cdf0e10cSrcweir     const ::boost::function<double(double)> aButtonBarBlendFunctor (
735cdf0e10cSrcweir         ::boost::bind(
736cdf0e10cSrcweir             controller::AnimationFunction::Blend,
737cdf0e10cSrcweir             nCurrentButtonBarAlpha,
738cdf0e10cSrcweir             nTargetAlpha,
739cdf0e10cSrcweir             ::boost::bind(controller::AnimationFunction::Linear, _1)));
740cdf0e10cSrcweir 
741cdf0e10cSrcweir     // Delay the fade in a little bit when the buttons are not visible at
742cdf0e10cSrcweir     // all so that we do not leave a trail of half-visible buttons when the
743cdf0e10cSrcweir     // mouse is moved across the screen.  No delay on fade out or when the
744cdf0e10cSrcweir     // buttons are already showing.  Fade out is faster than fade in.
745117a7820SMichael Stahl     const sal_Int32 nDelay (nCurrentButtonBarAlpha>0 && nCurrentButtonBarAlpha<1
746cdf0e10cSrcweir         ? 0
747cdf0e10cSrcweir         : (mrSlideSorter.GetTheme()->GetIntegerValue(bFadeIn
748cdf0e10cSrcweir             ?  Theme::Integer_ButtonFadeInDelay
749cdf0e10cSrcweir             :  Theme::Integer_ButtonFadeOutDelay)));
750117a7820SMichael Stahl     const sal_Int32 nDuration (mrSlideSorter.GetTheme()->GetIntegerValue(bFadeIn
751cdf0e10cSrcweir             ?  Theme::Integer_ButtonFadeInDuration
752cdf0e10cSrcweir             :  Theme::Integer_ButtonFadeOutDuration));
753cdf0e10cSrcweir     pDescriptor->GetVisualState().SetButtonAlphaAnimationId(
754cdf0e10cSrcweir         mrSlideSorter.GetController().GetAnimator()->AddAnimation(
755cdf0e10cSrcweir             ::boost::bind(
756cdf0e10cSrcweir                 controller::AnimationFunction::ApplyButtonAlphaChange,
757cdf0e10cSrcweir                 pDescriptor,
758cdf0e10cSrcweir                 ::boost::ref(mrSlideSorter.GetView()),
759cdf0e10cSrcweir                 ::boost::bind(aButtonBlendFunctor, _1),
760cdf0e10cSrcweir                 ::boost::bind(aButtonBarBlendFunctor, _1)),
761cdf0e10cSrcweir             nDelay,
762cdf0e10cSrcweir             nDuration,
763cdf0e10cSrcweir             ::boost::bind(
764cdf0e10cSrcweir                 &model::VisualState::SetButtonAlphaAnimationId,
765cdf0e10cSrcweir                 ::boost::ref(pDescriptor->GetVisualState()),
766cdf0e10cSrcweir                 controller::Animator::NotAnAnimationId)
767cdf0e10cSrcweir             ));
768cdf0e10cSrcweir }
769cdf0e10cSrcweir 
770cdf0e10cSrcweir 
771cdf0e10cSrcweir 
772cdf0e10cSrcweir 
AcquireLock(void)773cdf0e10cSrcweir void ButtonBar::AcquireLock (void)
774cdf0e10cSrcweir {
775cdf0e10cSrcweir     if (mnLockCount == 0 && mpDescriptor)
776cdf0e10cSrcweir         RequestFadeOut(mpDescriptor, true);
777cdf0e10cSrcweir 
778cdf0e10cSrcweir     ++mnLockCount;
779cdf0e10cSrcweir }
780cdf0e10cSrcweir 
781cdf0e10cSrcweir 
782cdf0e10cSrcweir 
783cdf0e10cSrcweir 
ReleaseLock(void)784cdf0e10cSrcweir void ButtonBar::ReleaseLock (void)
785cdf0e10cSrcweir {
786cdf0e10cSrcweir     --mnLockCount;
787cdf0e10cSrcweir 
788cdf0e10cSrcweir     if (mnLockCount == 0 && mpDescriptor)
789cdf0e10cSrcweir         RequestFadeIn(mpDescriptor, true);
790cdf0e10cSrcweir }
791cdf0e10cSrcweir 
792cdf0e10cSrcweir 
793cdf0e10cSrcweir 
794cdf0e10cSrcweir 
795cdf0e10cSrcweir //===== BackgroundTheme =====================================================
796cdf0e10cSrcweir 
BackgroundTheme(const::boost::shared_ptr<Theme> & rpTheme,const::std::vector<SharedButton> & rButtons)797cdf0e10cSrcweir ButtonBar::BackgroundTheme::BackgroundTheme (
798cdf0e10cSrcweir     const ::boost::shared_ptr<Theme>& rpTheme,
799cdf0e10cSrcweir     const ::std::vector<SharedButton>& rButtons)
800cdf0e10cSrcweir     : mpTheme(rpTheme)
801cdf0e10cSrcweir {
802cdf0e10cSrcweir     UpdateMinimumIconSizes(rButtons);
803cdf0e10cSrcweir }
804cdf0e10cSrcweir 
805cdf0e10cSrcweir 
806cdf0e10cSrcweir 
807cdf0e10cSrcweir 
SetPreviewBoundingBox(const Rectangle & rPreviewBoundingBox)808cdf0e10cSrcweir void ButtonBar::BackgroundTheme::SetPreviewBoundingBox (const Rectangle& rPreviewBoundingBox)
809cdf0e10cSrcweir {
810cdf0e10cSrcweir     maPreviewBoundingBox = rPreviewBoundingBox;
811cdf0e10cSrcweir     Layout();
812cdf0e10cSrcweir }
813cdf0e10cSrcweir 
814cdf0e10cSrcweir 
815cdf0e10cSrcweir 
816cdf0e10cSrcweir 
UpdateMinimumIconSizes(const::std::vector<SharedButton> & rButtons)817cdf0e10cSrcweir void ButtonBar::BackgroundTheme::UpdateMinimumIconSizes (
818cdf0e10cSrcweir     const ::std::vector<SharedButton>& rButtons)
819cdf0e10cSrcweir {
820cdf0e10cSrcweir     OSL_ASSERT(mpTheme);
821cdf0e10cSrcweir 
822cdf0e10cSrcweir     sal_Int32 nMaximumHeightLarge (0);
823cdf0e10cSrcweir     sal_Int32 nMaximumHeightMedium (0);
824cdf0e10cSrcweir     sal_Int32 nMaximumHeightSmall (0);
825cdf0e10cSrcweir     const sal_Int32 nGap (mpTheme->GetIntegerValue(Theme::Integer_ButtonGap));
826cdf0e10cSrcweir     const sal_Int32 nBorder (mpTheme->GetIntegerValue(Theme::Integer_ButtonBorder));
827cdf0e10cSrcweir     sal_Int32 nTotalWidthLarge ((rButtons.size()-1) * nGap + 2*nBorder);
828cdf0e10cSrcweir     sal_Int32 nTotalWidthMedium ((rButtons.size()-1) * nGap + 2*nBorder);
829cdf0e10cSrcweir     sal_Int32 nTotalWidthSmall ((rButtons.size()-1) * nGap + 2*nBorder);
830cdf0e10cSrcweir     for (sal_uInt32 nIndex=0; nIndex<rButtons.size(); ++nIndex)
831cdf0e10cSrcweir     {
832cdf0e10cSrcweir         // Update large size.
833cdf0e10cSrcweir         Size aSize = rButtons[nIndex]->GetSize(Button::IconSize_Large);
834cdf0e10cSrcweir         if (aSize.Height() > nMaximumHeightLarge)
835cdf0e10cSrcweir             nMaximumHeightLarge = aSize.Height();
836cdf0e10cSrcweir         nTotalWidthLarge += aSize.Width();
837cdf0e10cSrcweir 
838cdf0e10cSrcweir         // Update medium size.
839cdf0e10cSrcweir         aSize = rButtons[nIndex]->GetSize(Button::IconSize_Medium);
840cdf0e10cSrcweir         if (aSize.Height() > nMaximumHeightMedium)
841cdf0e10cSrcweir             nMaximumHeightMedium = aSize.Height();
842cdf0e10cSrcweir         nTotalWidthMedium += aSize.Width();
843cdf0e10cSrcweir 
844cdf0e10cSrcweir         // Update small size.
845cdf0e10cSrcweir         aSize = rButtons[nIndex]->GetSize(Button::IconSize_Small);
846cdf0e10cSrcweir         if (aSize.Height() > nMaximumHeightSmall)
847cdf0e10cSrcweir             nMaximumHeightSmall = aSize.Height();
848cdf0e10cSrcweir         nTotalWidthSmall += aSize.Width();
849cdf0e10cSrcweir     }
850cdf0e10cSrcweir     maMinimumLargeButtonAreaSize = Size(nTotalWidthLarge, nMaximumHeightLarge+2*nBorder);
851cdf0e10cSrcweir     maMinimumMediumButtonAreaSize = Size(nTotalWidthMedium, nMaximumHeightMedium+2*nBorder);
852cdf0e10cSrcweir     maMinimumSmallButtonAreaSize = Size(nTotalWidthSmall, nMaximumHeightSmall+2*nBorder);
853cdf0e10cSrcweir }
854cdf0e10cSrcweir 
855cdf0e10cSrcweir 
856cdf0e10cSrcweir 
857cdf0e10cSrcweir 
GetIconSize(void) const858cdf0e10cSrcweir Button::IconSize ButtonBar::BackgroundTheme::GetIconSize (void) const
859cdf0e10cSrcweir {
860cdf0e10cSrcweir     return meIconSize;
861cdf0e10cSrcweir }
862cdf0e10cSrcweir 
863cdf0e10cSrcweir 
864cdf0e10cSrcweir 
865cdf0e10cSrcweir 
866cdf0e10cSrcweir //===== RectangleBackgroundTheme ============================================
867cdf0e10cSrcweir 
RectangleBackgroundTheme(const::boost::shared_ptr<Theme> & rpTheme,const::std::vector<SharedButton> & rButtons)868cdf0e10cSrcweir RectangleBackgroundTheme::RectangleBackgroundTheme (
869cdf0e10cSrcweir     const ::boost::shared_ptr<Theme>& rpTheme,
870cdf0e10cSrcweir     const ::std::vector<SharedButton>& rButtons)
871cdf0e10cSrcweir     : BackgroundTheme(rpTheme, rButtons),
872cdf0e10cSrcweir       mnBarHeight(0)
873cdf0e10cSrcweir {
874cdf0e10cSrcweir }
875cdf0e10cSrcweir 
876cdf0e10cSrcweir 
877cdf0e10cSrcweir 
878cdf0e10cSrcweir 
CreateBackground(const OutputDevice & rTemplateDevice,const bool bIsButtonDown) const879cdf0e10cSrcweir BitmapEx RectangleBackgroundTheme::CreateBackground (
880cdf0e10cSrcweir     const OutputDevice& rTemplateDevice,
881cdf0e10cSrcweir     const bool bIsButtonDown) const
882cdf0e10cSrcweir {
883cdf0e10cSrcweir     OSL_ASSERT(mpTheme);
884cdf0e10cSrcweir 
885cdf0e10cSrcweir     // Setup background color.
886cdf0e10cSrcweir     Color aTopFillColor (mpTheme->GetGradientColor(
887cdf0e10cSrcweir         Theme::Gradient_ButtonBackground,
888cdf0e10cSrcweir         Theme::Fill1));
889cdf0e10cSrcweir     Color aTopBorderColor (mpTheme->GetGradientColor(
890cdf0e10cSrcweir         Theme::Gradient_ButtonBackground,
891cdf0e10cSrcweir         Theme::Border1));
892cdf0e10cSrcweir     Color aBottomFillColor (mpTheme->GetGradientColor(
893cdf0e10cSrcweir         Theme::Gradient_ButtonBackground,
894cdf0e10cSrcweir         Theme::Fill2));
895cdf0e10cSrcweir     Color aBottomBorderColor (mpTheme->GetGradientColor(
896cdf0e10cSrcweir         Theme::Gradient_ButtonBackground,
897cdf0e10cSrcweir         Theme::Border2));
898cdf0e10cSrcweir     if (bIsButtonDown)
899cdf0e10cSrcweir     {
900cdf0e10cSrcweir         aTopFillColor.DecreaseLuminance(50);
901cdf0e10cSrcweir         aTopBorderColor.DecreaseLuminance(50);
902cdf0e10cSrcweir         aBottomFillColor.DecreaseLuminance(50);
903cdf0e10cSrcweir         aBottomBorderColor.DecreaseLuminance(50);
904cdf0e10cSrcweir     }
905cdf0e10cSrcweir 
906cdf0e10cSrcweir     const int nWidth (maPreviewBoundingBox.GetWidth()+2);
907cdf0e10cSrcweir     const int nHeight (mnBarHeight);
908cdf0e10cSrcweir     const int nCenter (nHeight / 2);
909cdf0e10cSrcweir 
910cdf0e10cSrcweir     VirtualDevice aDevice (rTemplateDevice, 0, 8);
911cdf0e10cSrcweir     aDevice.SetOutputSizePixel(Size(nWidth,nHeight));
912cdf0e10cSrcweir 
913cdf0e10cSrcweir     // Fill upper and lower half.
914cdf0e10cSrcweir     aDevice.SetLineColor();
915cdf0e10cSrcweir     aDevice.SetFillColor(aTopFillColor);
916cdf0e10cSrcweir     aDevice.DrawRect(Rectangle(0,0,nWidth-1,nCenter));
917cdf0e10cSrcweir     aDevice.SetFillColor(aBottomFillColor);
918cdf0e10cSrcweir     aDevice.DrawRect(Rectangle(0,nCenter,nWidth-1,nHeight-1));
919cdf0e10cSrcweir 
920cdf0e10cSrcweir     // Draw border.
921cdf0e10cSrcweir     aDevice.SetFillColor();
922cdf0e10cSrcweir     aDevice.SetLineColor(aTopBorderColor);
923cdf0e10cSrcweir     aDevice.DrawLine(Point(0,nCenter),Point(0,0));
924cdf0e10cSrcweir     aDevice.DrawLine(Point(0,0), Point(nWidth-1,0));
925cdf0e10cSrcweir     aDevice.DrawLine(Point(nWidth-1,0),Point(nWidth-1,nCenter));
926cdf0e10cSrcweir     aDevice.SetLineColor(aBottomBorderColor);
927cdf0e10cSrcweir     aDevice.DrawLine(Point(0,nCenter),Point(0,nHeight-1));
928cdf0e10cSrcweir     aDevice.DrawLine(Point(0,nHeight-1), Point(nWidth-1,nHeight-1));
929cdf0e10cSrcweir     aDevice.DrawLine(Point(nWidth-1,nHeight-1),Point(nWidth-1,nCenter));
930cdf0e10cSrcweir 
931cdf0e10cSrcweir     return aDevice.GetBitmapEx(Point(0,0), Size(nWidth,nHeight));
932cdf0e10cSrcweir }
933cdf0e10cSrcweir 
934cdf0e10cSrcweir 
935cdf0e10cSrcweir 
936cdf0e10cSrcweir 
GetBackgroundLocation(void)937cdf0e10cSrcweir Point RectangleBackgroundTheme::GetBackgroundLocation (void)
938cdf0e10cSrcweir {
939cdf0e10cSrcweir     return Point(
940cdf0e10cSrcweir         maPreviewBoundingBox.Left()-1,
941cdf0e10cSrcweir         maPreviewBoundingBox.Bottom() - mnBarHeight + 2);
942cdf0e10cSrcweir }
943cdf0e10cSrcweir 
944cdf0e10cSrcweir 
945cdf0e10cSrcweir 
946cdf0e10cSrcweir 
GetButtonArea(void)947cdf0e10cSrcweir Rectangle RectangleBackgroundTheme::GetButtonArea (void)
948cdf0e10cSrcweir {
949cdf0e10cSrcweir     return Rectangle(
950cdf0e10cSrcweir         maPreviewBoundingBox.Left(),
951cdf0e10cSrcweir         maPreviewBoundingBox.Bottom() - mnBarHeight + 2,
952cdf0e10cSrcweir         maPreviewBoundingBox.Right(),
953cdf0e10cSrcweir         maPreviewBoundingBox.Bottom());
954cdf0e10cSrcweir }
955cdf0e10cSrcweir 
956cdf0e10cSrcweir 
957cdf0e10cSrcweir 
958cdf0e10cSrcweir 
Layout(void)959cdf0e10cSrcweir void RectangleBackgroundTheme::Layout (void)
960cdf0e10cSrcweir {
961cdf0e10cSrcweir     if (maPreviewBoundingBox.GetWidth() < maMinimumLargeButtonAreaSize.Width())
962cdf0e10cSrcweir         if (maPreviewBoundingBox.GetWidth() < maMinimumMediumButtonAreaSize.Width())
963cdf0e10cSrcweir         {
964cdf0e10cSrcweir             meIconSize = Button::IconSize_Small;
965cdf0e10cSrcweir             mnBarHeight = maMinimumSmallButtonAreaSize.Height();
966cdf0e10cSrcweir         }
967cdf0e10cSrcweir         else
968cdf0e10cSrcweir         {
969cdf0e10cSrcweir             meIconSize = Button::IconSize_Medium;
970cdf0e10cSrcweir             mnBarHeight = maMinimumMediumButtonAreaSize.Height();
971cdf0e10cSrcweir         }
972cdf0e10cSrcweir     else
973cdf0e10cSrcweir     {
974cdf0e10cSrcweir         meIconSize = Button::IconSize_Large;
975cdf0e10cSrcweir         mnBarHeight = maMinimumLargeButtonAreaSize.Height();
976cdf0e10cSrcweir     }
977cdf0e10cSrcweir }
978cdf0e10cSrcweir 
979cdf0e10cSrcweir 
980cdf0e10cSrcweir 
981cdf0e10cSrcweir 
982cdf0e10cSrcweir //===== BitmapBackgroundTheme =================================================
983cdf0e10cSrcweir 
BitmapBackgroundTheme(const::boost::shared_ptr<Theme> & rpTheme,const::std::vector<SharedButton> & rButtons)984cdf0e10cSrcweir BitmapBackgroundTheme::BitmapBackgroundTheme (
985cdf0e10cSrcweir     const ::boost::shared_ptr<Theme>& rpTheme,
986cdf0e10cSrcweir     const ::std::vector<SharedButton>& rButtons)
987cdf0e10cSrcweir     : BackgroundTheme(rpTheme, rButtons),
988cdf0e10cSrcweir       maButtonArea(),
989cdf0e10cSrcweir       maBackgroundLocation()
990cdf0e10cSrcweir {
991cdf0e10cSrcweir }
992cdf0e10cSrcweir 
993cdf0e10cSrcweir 
994cdf0e10cSrcweir 
995cdf0e10cSrcweir 
CreateBackground(const OutputDevice & rTemplateDevice,const bool bIsButtonDown) const996cdf0e10cSrcweir BitmapEx BitmapBackgroundTheme::CreateBackground (
997cdf0e10cSrcweir     const OutputDevice& rTemplateDevice,
998cdf0e10cSrcweir     const bool bIsButtonDown) const
999cdf0e10cSrcweir {
1000cdf0e10cSrcweir     (void)rTemplateDevice;
1001cdf0e10cSrcweir     (void)bIsButtonDown;
1002cdf0e10cSrcweir 
1003cdf0e10cSrcweir     OSL_ASSERT(mpTheme);
1004cdf0e10cSrcweir 
1005cdf0e10cSrcweir     // Get images.
1006cdf0e10cSrcweir     switch (meIconSize)
1007cdf0e10cSrcweir     {
1008cdf0e10cSrcweir         case Button::IconSize_Large:
1009cdf0e10cSrcweir         default:
1010cdf0e10cSrcweir             return mpTheme->GetIcon(Theme::Icon_ButtonBarLarge);
1011cdf0e10cSrcweir 
1012cdf0e10cSrcweir         case Button::IconSize_Medium:
1013cdf0e10cSrcweir             return mpTheme->GetIcon(Theme::Icon_ButtonBarMedium);
1014cdf0e10cSrcweir 
1015cdf0e10cSrcweir         case Button::IconSize_Small:
1016cdf0e10cSrcweir             return mpTheme->GetIcon(Theme::Icon_ButtonBarSmall);
1017cdf0e10cSrcweir     }
1018cdf0e10cSrcweir }
1019cdf0e10cSrcweir 
1020cdf0e10cSrcweir 
1021cdf0e10cSrcweir 
1022cdf0e10cSrcweir 
GetBackgroundLocation(void)1023cdf0e10cSrcweir Point BitmapBackgroundTheme::GetBackgroundLocation (void)
1024cdf0e10cSrcweir {
1025cdf0e10cSrcweir     return maBackgroundLocation;
1026cdf0e10cSrcweir }
1027cdf0e10cSrcweir 
1028cdf0e10cSrcweir 
1029cdf0e10cSrcweir 
1030cdf0e10cSrcweir 
GetButtonArea(void)1031cdf0e10cSrcweir Rectangle BitmapBackgroundTheme::GetButtonArea (void)
1032cdf0e10cSrcweir {
1033cdf0e10cSrcweir     return maButtonArea;
1034cdf0e10cSrcweir }
1035cdf0e10cSrcweir 
1036cdf0e10cSrcweir 
1037cdf0e10cSrcweir 
1038cdf0e10cSrcweir 
Layout(void)1039cdf0e10cSrcweir void BitmapBackgroundTheme::Layout (void)
1040cdf0e10cSrcweir {
1041cdf0e10cSrcweir     Size aImageSize (mpTheme->GetIcon(Theme::Icon_ButtonBarLarge).GetSizePixel());
1042cdf0e10cSrcweir     if (aImageSize.Width() >= maPreviewBoundingBox.GetWidth())
1043cdf0e10cSrcweir     {
1044cdf0e10cSrcweir         aImageSize = mpTheme->GetIcon(Theme::Icon_ButtonBarMedium).GetSizePixel();
1045cdf0e10cSrcweir         if (aImageSize.Width() >= maPreviewBoundingBox.GetWidth())
1046cdf0e10cSrcweir         {
1047cdf0e10cSrcweir             meIconSize = Button::IconSize_Small;
1048cdf0e10cSrcweir             aImageSize = mpTheme->GetIcon(Theme::Icon_ButtonBarSmall).GetSizePixel();
1049cdf0e10cSrcweir         }
1050cdf0e10cSrcweir         else
1051cdf0e10cSrcweir             meIconSize = Button::IconSize_Medium;
1052cdf0e10cSrcweir     }
1053cdf0e10cSrcweir     else
1054cdf0e10cSrcweir     {
1055cdf0e10cSrcweir         meIconSize = Button::IconSize_Large;
1056cdf0e10cSrcweir     }
1057cdf0e10cSrcweir 
1058cdf0e10cSrcweir     maBackgroundLocation = Point(
1059cdf0e10cSrcweir         maPreviewBoundingBox.Left()
1060cdf0e10cSrcweir             + (maPreviewBoundingBox.GetWidth()-aImageSize.Width())/2,
1061cdf0e10cSrcweir         maPreviewBoundingBox.Bottom() - aImageSize.Height());
1062cdf0e10cSrcweir     maButtonArea = Rectangle(maBackgroundLocation, aImageSize);
1063cdf0e10cSrcweir }
1064cdf0e10cSrcweir 
1065cdf0e10cSrcweir 
1066cdf0e10cSrcweir 
1067cdf0e10cSrcweir 
1068cdf0e10cSrcweir //===== Button ================================================================
1069cdf0e10cSrcweir 
Button(SlideSorter & rSlideSorter,const::rtl::OUString & rsHelpText)1070cdf0e10cSrcweir Button::Button (
1071cdf0e10cSrcweir     SlideSorter& rSlideSorter,
1072cdf0e10cSrcweir     const ::rtl::OUString& rsHelpText)
1073cdf0e10cSrcweir     : mrSlideSorter(rSlideSorter),
1074cdf0e10cSrcweir       meState(State_Normal),
1075cdf0e10cSrcweir       maBoundingBox(),
1076cdf0e10cSrcweir       msHelpText(rsHelpText),
1077cdf0e10cSrcweir       mbIsActive(false),
1078cdf0e10cSrcweir       meIconSize(IconSize_Large)
1079cdf0e10cSrcweir {
1080cdf0e10cSrcweir }
1081cdf0e10cSrcweir 
1082cdf0e10cSrcweir 
1083cdf0e10cSrcweir 
1084cdf0e10cSrcweir 
~Button(void)1085cdf0e10cSrcweir Button::~Button (void)
1086cdf0e10cSrcweir {
1087cdf0e10cSrcweir }
1088cdf0e10cSrcweir 
1089cdf0e10cSrcweir 
1090cdf0e10cSrcweir 
1091cdf0e10cSrcweir 
SetState(const State eState)1092cdf0e10cSrcweir bool Button::SetState (const State eState)
1093cdf0e10cSrcweir {
1094cdf0e10cSrcweir     if (meState != eState)
1095cdf0e10cSrcweir     {
1096cdf0e10cSrcweir         meState = eState;
1097cdf0e10cSrcweir         return true;
1098cdf0e10cSrcweir     }
1099cdf0e10cSrcweir     else
1100cdf0e10cSrcweir         return false;
1101cdf0e10cSrcweir }
1102cdf0e10cSrcweir 
1103cdf0e10cSrcweir 
1104cdf0e10cSrcweir 
1105cdf0e10cSrcweir 
GetState(void) const1106cdf0e10cSrcweir Button::State Button::GetState (void) const
1107cdf0e10cSrcweir {
1108cdf0e10cSrcweir     return meState;
1109cdf0e10cSrcweir }
1110cdf0e10cSrcweir 
1111cdf0e10cSrcweir 
1112cdf0e10cSrcweir 
1113cdf0e10cSrcweir 
GetBoundingBox(void) const1114cdf0e10cSrcweir Rectangle Button::GetBoundingBox (void) const
1115cdf0e10cSrcweir {
1116cdf0e10cSrcweir     if (mbIsActive)
1117cdf0e10cSrcweir         return maBoundingBox;
1118cdf0e10cSrcweir     else
1119cdf0e10cSrcweir         return Rectangle();
1120cdf0e10cSrcweir }
1121cdf0e10cSrcweir 
1122cdf0e10cSrcweir 
1123cdf0e10cSrcweir 
1124cdf0e10cSrcweir 
GetHelpText(void) const1125cdf0e10cSrcweir ::rtl::OUString Button::GetHelpText (void) const
1126cdf0e10cSrcweir {
1127cdf0e10cSrcweir     if (mbIsActive)
1128cdf0e10cSrcweir         return msHelpText;
1129cdf0e10cSrcweir     else
1130cdf0e10cSrcweir         return ::rtl::OUString();
1131cdf0e10cSrcweir }
1132cdf0e10cSrcweir 
1133cdf0e10cSrcweir 
1134cdf0e10cSrcweir 
1135cdf0e10cSrcweir 
IsDown(void) const1136cdf0e10cSrcweir bool Button::IsDown (void) const
1137cdf0e10cSrcweir {
1138cdf0e10cSrcweir     return mbIsActive && meState==State_Down;
1139cdf0e10cSrcweir }
1140cdf0e10cSrcweir 
1141cdf0e10cSrcweir 
1142cdf0e10cSrcweir 
1143cdf0e10cSrcweir 
SetActiveState(const bool bIsActive)1144cdf0e10cSrcweir void Button::SetActiveState (const bool bIsActive)
1145cdf0e10cSrcweir {
1146cdf0e10cSrcweir     mbIsActive = bIsActive;
1147cdf0e10cSrcweir }
1148cdf0e10cSrcweir 
1149cdf0e10cSrcweir 
1150cdf0e10cSrcweir 
1151cdf0e10cSrcweir 
IsActive(void) const1152cdf0e10cSrcweir bool Button::IsActive (void) const
1153cdf0e10cSrcweir {
1154cdf0e10cSrcweir     return mbIsActive;
1155cdf0e10cSrcweir }
1156cdf0e10cSrcweir 
1157cdf0e10cSrcweir 
1158cdf0e10cSrcweir 
1159cdf0e10cSrcweir 
SetIconSize(const IconSize eIconSize)1160cdf0e10cSrcweir void Button::SetIconSize (const IconSize eIconSize)
1161cdf0e10cSrcweir {
1162cdf0e10cSrcweir     meIconSize = eIconSize;
1163cdf0e10cSrcweir }
1164cdf0e10cSrcweir 
1165cdf0e10cSrcweir 
1166cdf0e10cSrcweir 
1167cdf0e10cSrcweir 
GetIconSize(void) const1168cdf0e10cSrcweir Button::IconSize Button::GetIconSize (void) const
1169cdf0e10cSrcweir {
1170cdf0e10cSrcweir     return meIconSize;
1171cdf0e10cSrcweir }
1172cdf0e10cSrcweir 
1173cdf0e10cSrcweir 
1174cdf0e10cSrcweir 
1175cdf0e10cSrcweir 
IsEnabled(void) const1176cdf0e10cSrcweir bool Button::IsEnabled (void) const
1177cdf0e10cSrcweir {
1178cdf0e10cSrcweir     return true;
1179cdf0e10cSrcweir }
1180cdf0e10cSrcweir 
1181cdf0e10cSrcweir 
1182cdf0e10cSrcweir 
1183cdf0e10cSrcweir 
1184cdf0e10cSrcweir //===== TextButton ============================================================
1185cdf0e10cSrcweir 
TextButton(SlideSorter & rSlideSorter,const::rtl::OUString & rsText,const::rtl::OUString & rsHelpText)1186cdf0e10cSrcweir TextButton::TextButton (
1187cdf0e10cSrcweir     SlideSorter& rSlideSorter,
1188cdf0e10cSrcweir     const ::rtl::OUString& rsText,
1189cdf0e10cSrcweir     const ::rtl::OUString& rsHelpText)
1190cdf0e10cSrcweir     : Button(rSlideSorter, rsHelpText),
1191cdf0e10cSrcweir       msText(rsText)
1192cdf0e10cSrcweir {
1193cdf0e10cSrcweir }
1194cdf0e10cSrcweir 
1195cdf0e10cSrcweir 
1196cdf0e10cSrcweir 
1197cdf0e10cSrcweir 
Place(const Rectangle aButtonBarBox)1198cdf0e10cSrcweir void TextButton::Place (const Rectangle aButtonBarBox)
1199cdf0e10cSrcweir {
1200cdf0e10cSrcweir     maBoundingBox = aButtonBarBox;
1201cdf0e10cSrcweir     SetActiveState(true);
1202cdf0e10cSrcweir }
1203cdf0e10cSrcweir 
1204cdf0e10cSrcweir 
1205cdf0e10cSrcweir 
1206cdf0e10cSrcweir 
Paint(OutputDevice & rDevice,const Point aOffset,const double nAlpha,const::boost::shared_ptr<Theme> & rpTheme) const1207cdf0e10cSrcweir void TextButton::Paint (
1208cdf0e10cSrcweir     OutputDevice& rDevice,
1209cdf0e10cSrcweir     const Point aOffset,
1210cdf0e10cSrcweir     const double nAlpha,
1211cdf0e10cSrcweir     const ::boost::shared_ptr<Theme>& rpTheme) const
1212cdf0e10cSrcweir {
1213cdf0e10cSrcweir     (void)nAlpha;
1214cdf0e10cSrcweir 
1215cdf0e10cSrcweir     if (mbIsActive)
1216cdf0e10cSrcweir     {
1217cdf0e10cSrcweir         // Paint text over the button background.
1218cdf0e10cSrcweir         if (meState == State_Normal)
1219cdf0e10cSrcweir             rDevice.SetTextColor(rpTheme->GetColor(Theme::Color_ButtonText));
1220cdf0e10cSrcweir         else
1221cdf0e10cSrcweir             rDevice.SetTextColor(rpTheme->GetColor(Theme::Color_ButtonTextHover));
1222cdf0e10cSrcweir         Rectangle aBox (maBoundingBox);
1223cdf0e10cSrcweir         aBox += aOffset;
1224cdf0e10cSrcweir         rDevice.DrawText(aBox, msText, TEXT_DRAW_CENTER | TEXT_DRAW_VCENTER);
1225cdf0e10cSrcweir     }
1226cdf0e10cSrcweir }
1227cdf0e10cSrcweir 
1228cdf0e10cSrcweir 
1229cdf0e10cSrcweir 
1230cdf0e10cSrcweir 
GetSize(void) const1231cdf0e10cSrcweir Size TextButton::GetSize (void) const
1232cdf0e10cSrcweir {
1233cdf0e10cSrcweir     return Size();
1234cdf0e10cSrcweir }
1235cdf0e10cSrcweir 
1236cdf0e10cSrcweir 
1237cdf0e10cSrcweir 
1238cdf0e10cSrcweir 
GetSize(const Button::IconSize) const1239cdf0e10cSrcweir Size TextButton::GetSize (const Button::IconSize) const
1240cdf0e10cSrcweir {
1241cdf0e10cSrcweir     return Size();
1242cdf0e10cSrcweir }
1243cdf0e10cSrcweir 
1244cdf0e10cSrcweir 
1245cdf0e10cSrcweir 
1246cdf0e10cSrcweir 
1247cdf0e10cSrcweir //===== ImageButon ============================================================
1248cdf0e10cSrcweir 
ImageButton(SlideSorter & rSlideSorter,const BitmapEx & rLargeIcon,const BitmapEx & rLargeHoverIcon,const BitmapEx & rMediumIcon,const BitmapEx & rMediumHoverIcon,const BitmapEx & rSmallIcon,const BitmapEx & rSmallHoverIcon,const::rtl::OUString & rsHelpText)1249cdf0e10cSrcweir ImageButton::ImageButton (
1250cdf0e10cSrcweir     SlideSorter& rSlideSorter,
1251cdf0e10cSrcweir     const BitmapEx& rLargeIcon,
1252cdf0e10cSrcweir     const BitmapEx& rLargeHoverIcon,
1253cdf0e10cSrcweir     const BitmapEx& rMediumIcon,
1254cdf0e10cSrcweir     const BitmapEx& rMediumHoverIcon,
1255cdf0e10cSrcweir     const BitmapEx& rSmallIcon,
1256cdf0e10cSrcweir     const BitmapEx& rSmallHoverIcon,
1257cdf0e10cSrcweir     const ::rtl::OUString& rsHelpText)
1258cdf0e10cSrcweir     : Button(rSlideSorter, rsHelpText),
1259cdf0e10cSrcweir       maLargeIcon(rLargeIcon),
1260cdf0e10cSrcweir       maLargeHoverIcon(rLargeHoverIcon.IsEmpty() ? rLargeIcon : rLargeHoverIcon),
1261cdf0e10cSrcweir       maMediumIcon(rMediumIcon),
1262cdf0e10cSrcweir       maMediumHoverIcon(rMediumHoverIcon.IsEmpty() ? rMediumIcon : rMediumHoverIcon),
1263cdf0e10cSrcweir       maSmallIcon(rSmallIcon),
1264cdf0e10cSrcweir       maSmallHoverIcon(rSmallHoverIcon.IsEmpty() ? rSmallIcon : rSmallHoverIcon)
1265cdf0e10cSrcweir {
1266cdf0e10cSrcweir }
1267cdf0e10cSrcweir 
1268cdf0e10cSrcweir 
1269cdf0e10cSrcweir 
1270cdf0e10cSrcweir 
Place(const Rectangle aButtonBarBox)1271cdf0e10cSrcweir void ImageButton::Place (const Rectangle aButtonBarBox)
1272cdf0e10cSrcweir {
1273cdf0e10cSrcweir     const sal_Int32 nWidth (GetSize().Width());
1274cdf0e10cSrcweir     maBoundingBox = Rectangle(
1275cdf0e10cSrcweir         aButtonBarBox.Right() - nWidth,
1276cdf0e10cSrcweir         aButtonBarBox.Top(),
1277cdf0e10cSrcweir         aButtonBarBox.Right(),
1278cdf0e10cSrcweir         aButtonBarBox.Bottom());
1279cdf0e10cSrcweir     SetActiveState(aButtonBarBox.IsInside(maBoundingBox));
1280cdf0e10cSrcweir }
1281cdf0e10cSrcweir 
1282cdf0e10cSrcweir 
1283cdf0e10cSrcweir 
1284cdf0e10cSrcweir 
Paint(OutputDevice & rDevice,const Point aOffset,const double nAlpha,const::boost::shared_ptr<Theme> & rpTheme) const1285cdf0e10cSrcweir void ImageButton::Paint (
1286cdf0e10cSrcweir     OutputDevice& rDevice,
1287cdf0e10cSrcweir     const Point aOffset,
1288cdf0e10cSrcweir     const double nAlpha,
1289cdf0e10cSrcweir     const ::boost::shared_ptr<Theme>& rpTheme) const
1290cdf0e10cSrcweir {
1291cdf0e10cSrcweir     (void)rpTheme;
1292cdf0e10cSrcweir 
1293cdf0e10cSrcweir     if ( ! mbIsActive)
1294cdf0e10cSrcweir         return;
1295cdf0e10cSrcweir 
1296cdf0e10cSrcweir     const sal_uInt16 nSavedAntialiasingMode (rDevice.GetAntialiasing());
1297cdf0e10cSrcweir     rDevice.SetAntialiasing(nSavedAntialiasingMode | ANTIALIASING_ENABLE_B2DDRAW);
1298cdf0e10cSrcweir 
1299cdf0e10cSrcweir     rDevice.SetLineColor();
1300cdf0e10cSrcweir 
1301cdf0e10cSrcweir     // Choose icon.
1302cdf0e10cSrcweir     BitmapEx aIcon;
1303cdf0e10cSrcweir     switch (meIconSize)
1304cdf0e10cSrcweir     {
1305cdf0e10cSrcweir         case IconSize_Large:
1306cdf0e10cSrcweir         default:
1307cdf0e10cSrcweir             if (meState == State_Normal)
1308cdf0e10cSrcweir                 aIcon = maLargeIcon;
1309cdf0e10cSrcweir             else
1310cdf0e10cSrcweir                 aIcon = maLargeHoverIcon;
1311cdf0e10cSrcweir             break;
1312cdf0e10cSrcweir 
1313cdf0e10cSrcweir         case IconSize_Medium:
1314cdf0e10cSrcweir             if (meState == State_Normal)
1315cdf0e10cSrcweir                 aIcon = maMediumIcon;
1316cdf0e10cSrcweir             else
1317cdf0e10cSrcweir                 aIcon = maMediumHoverIcon;
1318cdf0e10cSrcweir             break;
1319cdf0e10cSrcweir 
1320cdf0e10cSrcweir         case IconSize_Small:
1321cdf0e10cSrcweir             if (meState == State_Normal)
1322cdf0e10cSrcweir                 aIcon = maSmallIcon;
1323cdf0e10cSrcweir             else
1324cdf0e10cSrcweir                 aIcon = maSmallHoverIcon;
1325cdf0e10cSrcweir             break;
1326cdf0e10cSrcweir     }
1327cdf0e10cSrcweir 
1328cdf0e10cSrcweir     // Paint icon.
1329cdf0e10cSrcweir     if ( ! aIcon.IsEmpty())
1330cdf0e10cSrcweir     {
1331cdf0e10cSrcweir         AlphaMask aMask (aIcon.GetSizePixel());
1332cdf0e10cSrcweir         AdaptTransparency(aMask, aIcon.GetAlpha(), nAlpha);
1333cdf0e10cSrcweir         rDevice.DrawBitmapEx(
1334cdf0e10cSrcweir             Point(
1335cdf0e10cSrcweir                 maBoundingBox.Left()
1336cdf0e10cSrcweir                     + aOffset.X()
1337cdf0e10cSrcweir                     + (maBoundingBox.GetWidth()-aIcon.GetSizePixel().Width())/2,
1338cdf0e10cSrcweir                 maBoundingBox.Top()
1339cdf0e10cSrcweir                     + aOffset.Y()
1340cdf0e10cSrcweir                     + (maBoundingBox.GetHeight()-aIcon.GetSizePixel().Height())/2),
1341cdf0e10cSrcweir             BitmapEx(aIcon.GetBitmap(), aMask));
1342cdf0e10cSrcweir     }
1343cdf0e10cSrcweir 
1344cdf0e10cSrcweir     rDevice.SetAntialiasing(nSavedAntialiasingMode);
1345cdf0e10cSrcweir }
1346cdf0e10cSrcweir 
1347cdf0e10cSrcweir 
1348cdf0e10cSrcweir 
1349cdf0e10cSrcweir 
GetSize(void) const1350cdf0e10cSrcweir Size ImageButton::GetSize (void) const
1351cdf0e10cSrcweir {
1352cdf0e10cSrcweir     return GetSize(meIconSize);
1353cdf0e10cSrcweir }
1354cdf0e10cSrcweir 
1355cdf0e10cSrcweir 
1356cdf0e10cSrcweir 
1357cdf0e10cSrcweir 
GetSize(const Button::IconSize eIconSize) const1358cdf0e10cSrcweir Size ImageButton::GetSize (const Button::IconSize eIconSize) const
1359cdf0e10cSrcweir {
1360cdf0e10cSrcweir     switch (eIconSize)
1361cdf0e10cSrcweir     {
1362cdf0e10cSrcweir         case IconSize_Large:
1363cdf0e10cSrcweir         default:
1364cdf0e10cSrcweir             return maLargeIcon.GetSizePixel();
1365cdf0e10cSrcweir 
1366cdf0e10cSrcweir         case IconSize_Medium:
1367cdf0e10cSrcweir             return maMediumIcon.GetSizePixel();
1368cdf0e10cSrcweir 
1369cdf0e10cSrcweir         case IconSize_Small:
1370cdf0e10cSrcweir             return maSmallIcon.GetSizePixel();
1371cdf0e10cSrcweir     }
1372cdf0e10cSrcweir }
1373cdf0e10cSrcweir 
1374cdf0e10cSrcweir 
1375cdf0e10cSrcweir 
1376cdf0e10cSrcweir 
1377cdf0e10cSrcweir //===== UnhideButton ==========================================================
1378cdf0e10cSrcweir 
UnhideButton(SlideSorter & rSlideSorter)1379cdf0e10cSrcweir UnhideButton::UnhideButton (SlideSorter& rSlideSorter)
1380cdf0e10cSrcweir     : ImageButton(
1381cdf0e10cSrcweir         rSlideSorter,
1382cdf0e10cSrcweir         rSlideSorter.GetTheme()->GetIcon(Theme::Icon_Command2BLarge),
1383cdf0e10cSrcweir         rSlideSorter.GetTheme()->GetIcon(Theme::Icon_Command2BLargeHover),
1384cdf0e10cSrcweir         rSlideSorter.GetTheme()->GetIcon(Theme::Icon_Command2BMedium),
1385cdf0e10cSrcweir         rSlideSorter.GetTheme()->GetIcon(Theme::Icon_Command2BMediumHover),
1386cdf0e10cSrcweir         rSlideSorter.GetTheme()->GetIcon(Theme::Icon_Command2BSmall),
1387cdf0e10cSrcweir         rSlideSorter.GetTheme()->GetIcon(Theme::Icon_Command2BSmallHover),
1388cdf0e10cSrcweir         rSlideSorter.GetTheme()->GetString(Theme::String_Command2B))
1389cdf0e10cSrcweir {
1390cdf0e10cSrcweir }
1391cdf0e10cSrcweir 
1392cdf0e10cSrcweir 
1393cdf0e10cSrcweir 
1394cdf0e10cSrcweir 
ProcessClick(const model::SharedPageDescriptor & rpDescriptor)1395cdf0e10cSrcweir void UnhideButton::ProcessClick (const model::SharedPageDescriptor& rpDescriptor)
1396cdf0e10cSrcweir {
1397cdf0e10cSrcweir     if ( ! rpDescriptor)
1398cdf0e10cSrcweir         return;
1399cdf0e10cSrcweir     mrSlideSorter.GetController().GetSlotManager()->ChangeSlideExclusionState(
1400cdf0e10cSrcweir         (rpDescriptor->HasState(model::PageDescriptor::ST_Selected)
1401cdf0e10cSrcweir             ? model::SharedPageDescriptor()
1402cdf0e10cSrcweir             : rpDescriptor),
1403cdf0e10cSrcweir         false);
1404cdf0e10cSrcweir }
1405cdf0e10cSrcweir 
1406cdf0e10cSrcweir 
1407cdf0e10cSrcweir 
1408cdf0e10cSrcweir 
1409cdf0e10cSrcweir //===== StartSlideShowButton ==================================================
1410cdf0e10cSrcweir 
StartShowButton(SlideSorter & rSlideSorter)1411cdf0e10cSrcweir StartShowButton::StartShowButton (SlideSorter& rSlideSorter)
1412cdf0e10cSrcweir     : ImageButton(
1413cdf0e10cSrcweir         rSlideSorter,
1414cdf0e10cSrcweir         rSlideSorter.GetTheme()->GetIcon(Theme::Icon_Command1Large),
1415cdf0e10cSrcweir         rSlideSorter.GetTheme()->GetIcon(Theme::Icon_Command1LargeHover),
1416cdf0e10cSrcweir         rSlideSorter.GetTheme()->GetIcon(Theme::Icon_Command1Medium),
1417cdf0e10cSrcweir         rSlideSorter.GetTheme()->GetIcon(Theme::Icon_Command1MediumHover),
1418cdf0e10cSrcweir         rSlideSorter.GetTheme()->GetIcon(Theme::Icon_Command1Small),
1419cdf0e10cSrcweir         rSlideSorter.GetTheme()->GetIcon(Theme::Icon_Command1SmallHover),
1420cdf0e10cSrcweir         rSlideSorter.GetTheme()->GetString(Theme::String_Command1))
1421cdf0e10cSrcweir {
1422cdf0e10cSrcweir }
1423cdf0e10cSrcweir 
1424cdf0e10cSrcweir 
1425cdf0e10cSrcweir 
1426cdf0e10cSrcweir 
IsEnabled(void) const1427cdf0e10cSrcweir bool StartShowButton::IsEnabled (void) const
1428cdf0e10cSrcweir {
1429cdf0e10cSrcweir     ViewShell* pViewShell = mrSlideSorter.GetViewShell();
1430cdf0e10cSrcweir     if (pViewShell == NULL)
1431cdf0e10cSrcweir         return false;
1432cdf0e10cSrcweir     SfxDispatcher* pDispatcher = pViewShell->GetDispatcher();
1433cdf0e10cSrcweir     if (pDispatcher == NULL)
1434cdf0e10cSrcweir         return false;
1435cdf0e10cSrcweir 
1436cdf0e10cSrcweir     const SfxPoolItem* pState = NULL;
1437cdf0e10cSrcweir 	const SfxItemState eState (pDispatcher->QueryState(SID_PRESENTATION, pState));
1438cdf0e10cSrcweir     return (eState & SFX_ITEM_DISABLED) == 0;
1439cdf0e10cSrcweir }
1440cdf0e10cSrcweir 
1441cdf0e10cSrcweir 
1442cdf0e10cSrcweir 
1443cdf0e10cSrcweir 
ProcessClick(const model::SharedPageDescriptor & rpDescriptor)1444cdf0e10cSrcweir void StartShowButton::ProcessClick (const model::SharedPageDescriptor& rpDescriptor)
1445cdf0e10cSrcweir {
1446cdf0e10cSrcweir     // Hide the tool tip early, while the slide show still intializes.
1447cdf0e10cSrcweir     mrSlideSorter.GetView().GetToolTip().SetPage(model::SharedPageDescriptor());
1448cdf0e10cSrcweir 
1449cdf0e10cSrcweir     Reference< XPresentation2 > xPresentation(
1450cdf0e10cSrcweir         mrSlideSorter.GetModel().GetDocument()->getPresentation());
1451cdf0e10cSrcweir     if (xPresentation.is())
1452cdf0e10cSrcweir     {
1453cdf0e10cSrcweir         Sequence<PropertyValue> aProperties (1);
1454cdf0e10cSrcweir         aProperties[0].Name = ::rtl::OUString::createFromAscii("FirstPage");
1455cdf0e10cSrcweir         const ::rtl::OUString sName (rpDescriptor->GetPage()->GetName());
1456cdf0e10cSrcweir         aProperties[0].Value = Any(sName);
145717673424SMichael Stahl 
145817673424SMichael Stahl         // We have to temporarily change the options value
145917673424SMichael Stahl         // StartWithActualPage to make the slide show use the
146017673424SMichael Stahl         // specified first page.
146117673424SMichael Stahl         const DocumentType eType (mrSlideSorter.GetModel().GetDocument()->GetDocumentType());
146260b45af2SMichael Stahl         const sal_Bool bSavedState (SD_MOD()->GetSdOptions(eType)->IsStartWithActualPage());
146360b45af2SMichael Stahl         SD_MOD()->GetSdOptions(eType)->SetStartWithActualPage(sal_False);
146417673424SMichael Stahl 
1465cdf0e10cSrcweir         xPresentation->startWithArguments(aProperties);
146617673424SMichael Stahl 
146717673424SMichael Stahl         // Restore previous StartWithActualPage value.
146817673424SMichael Stahl         SD_MOD()->GetSdOptions(eType)->SetStartWithActualPage(bSavedState);
1469cdf0e10cSrcweir     }
1470cdf0e10cSrcweir }
1471cdf0e10cSrcweir 
1472cdf0e10cSrcweir 
1473cdf0e10cSrcweir 
1474cdf0e10cSrcweir 
1475cdf0e10cSrcweir //===== HideButton ============================================================
1476cdf0e10cSrcweir 
HideButton(SlideSorter & rSlideSorter)1477cdf0e10cSrcweir HideButton::HideButton (SlideSorter& rSlideSorter)
1478cdf0e10cSrcweir     : ImageButton(
1479cdf0e10cSrcweir         rSlideSorter,
1480cdf0e10cSrcweir         rSlideSorter.GetTheme()->GetIcon(Theme::Icon_Command2Large),
1481cdf0e10cSrcweir         rSlideSorter.GetTheme()->GetIcon(Theme::Icon_Command2LargeHover),
1482cdf0e10cSrcweir         rSlideSorter.GetTheme()->GetIcon(Theme::Icon_Command2Medium),
1483cdf0e10cSrcweir         rSlideSorter.GetTheme()->GetIcon(Theme::Icon_Command2MediumHover),
1484cdf0e10cSrcweir         rSlideSorter.GetTheme()->GetIcon(Theme::Icon_Command2Small),
1485cdf0e10cSrcweir         rSlideSorter.GetTheme()->GetIcon(Theme::Icon_Command2SmallHover),
1486cdf0e10cSrcweir         rSlideSorter.GetTheme()->GetString(Theme::String_Command2))
1487cdf0e10cSrcweir {
1488cdf0e10cSrcweir }
1489cdf0e10cSrcweir 
1490cdf0e10cSrcweir 
1491cdf0e10cSrcweir 
1492cdf0e10cSrcweir 
ProcessClick(const model::SharedPageDescriptor & rpDescriptor)1493cdf0e10cSrcweir void HideButton::ProcessClick (const model::SharedPageDescriptor& rpDescriptor)
1494cdf0e10cSrcweir {
1495cdf0e10cSrcweir     if ( ! rpDescriptor)
1496cdf0e10cSrcweir         return;
1497cdf0e10cSrcweir     mrSlideSorter.GetController().GetSlotManager()->ChangeSlideExclusionState(
1498cdf0e10cSrcweir         (rpDescriptor->HasState(model::PageDescriptor::ST_Selected)
1499cdf0e10cSrcweir             ? model::SharedPageDescriptor()
1500cdf0e10cSrcweir             : rpDescriptor),
1501cdf0e10cSrcweir         true);
1502cdf0e10cSrcweir }
1503cdf0e10cSrcweir 
1504cdf0e10cSrcweir 
1505cdf0e10cSrcweir 
1506cdf0e10cSrcweir 
1507cdf0e10cSrcweir //===== DuplicateButton =======================================================
1508cdf0e10cSrcweir 
DuplicateButton(SlideSorter & rSlideSorter)1509cdf0e10cSrcweir DuplicateButton::DuplicateButton (SlideSorter& rSlideSorter)
1510cdf0e10cSrcweir     : ImageButton(
1511cdf0e10cSrcweir         rSlideSorter,
1512cdf0e10cSrcweir         rSlideSorter.GetTheme()->GetIcon(Theme::Icon_Command3Large),
1513cdf0e10cSrcweir         rSlideSorter.GetTheme()->GetIcon(Theme::Icon_Command3LargeHover),
1514cdf0e10cSrcweir         rSlideSorter.GetTheme()->GetIcon(Theme::Icon_Command3Medium),
1515cdf0e10cSrcweir         rSlideSorter.GetTheme()->GetIcon(Theme::Icon_Command3MediumHover),
1516cdf0e10cSrcweir         rSlideSorter.GetTheme()->GetIcon(Theme::Icon_Command3Small),
1517cdf0e10cSrcweir         rSlideSorter.GetTheme()->GetIcon(Theme::Icon_Command3SmallHover),
1518cdf0e10cSrcweir         rSlideSorter.GetTheme()->GetString(Theme::String_Command3))
1519cdf0e10cSrcweir {
1520cdf0e10cSrcweir }
1521cdf0e10cSrcweir 
1522cdf0e10cSrcweir 
1523cdf0e10cSrcweir 
1524cdf0e10cSrcweir 
IsEnabled(void) const1525cdf0e10cSrcweir bool DuplicateButton::IsEnabled (void) const
1526cdf0e10cSrcweir {
1527cdf0e10cSrcweir     ViewShell* pViewShell = mrSlideSorter.GetViewShell();
1528cdf0e10cSrcweir     if (pViewShell == NULL)
1529cdf0e10cSrcweir         return false;
1530cdf0e10cSrcweir     SfxDispatcher* pDispatcher = pViewShell->GetDispatcher();
1531cdf0e10cSrcweir     if (pDispatcher == NULL)
1532cdf0e10cSrcweir         return false;
1533cdf0e10cSrcweir 
1534cdf0e10cSrcweir     const SfxPoolItem* pState = NULL;
1535cdf0e10cSrcweir 	const SfxItemState eState (pDispatcher->QueryState(
1536cdf0e10cSrcweir         SID_DUPLICATE_PAGE,
1537cdf0e10cSrcweir         pState));
1538cdf0e10cSrcweir     return (eState & SFX_ITEM_DISABLED) == 0;
1539cdf0e10cSrcweir }
1540cdf0e10cSrcweir 
1541cdf0e10cSrcweir 
1542cdf0e10cSrcweir 
1543cdf0e10cSrcweir 
ProcessClick(const model::SharedPageDescriptor & rpDescriptor)1544cdf0e10cSrcweir void DuplicateButton::ProcessClick (const model::SharedPageDescriptor& rpDescriptor)
1545cdf0e10cSrcweir {
1546cdf0e10cSrcweir     if ( ! rpDescriptor)
1547cdf0e10cSrcweir         return;
1548cdf0e10cSrcweir 
1549cdf0e10cSrcweir     mrSlideSorter.GetView().SetPageUnderMouse(model::SharedPageDescriptor(),false);
1550cdf0e10cSrcweir 
1551cdf0e10cSrcweir     // When the page under the button is not selected then set the
1552cdf0e10cSrcweir     // selection to just this page.
1553cdf0e10cSrcweir     if ( ! rpDescriptor->HasState(model::PageDescriptor::ST_Selected))
1554cdf0e10cSrcweir     {
1555cdf0e10cSrcweir         mrSlideSorter.GetController().GetPageSelector().DeselectAllPages();
1556cdf0e10cSrcweir         mrSlideSorter.GetController().GetPageSelector().SelectPage(rpDescriptor);
1557cdf0e10cSrcweir     }
1558cdf0e10cSrcweir     // Duplicate the selected pages.  Insert the new pages right
1559cdf0e10cSrcweir     // after the current selection and select them
1560cdf0e10cSrcweir     if (mrSlideSorter.GetViewShell() != NULL
1561cdf0e10cSrcweir         && mrSlideSorter.GetViewShell()->GetDispatcher() != NULL)
1562cdf0e10cSrcweir     {
1563cdf0e10cSrcweir         mrSlideSorter.GetViewShell()->GetDispatcher()->Execute(
1564cdf0e10cSrcweir             SID_DUPLICATE_PAGE,
1565cdf0e10cSrcweir             SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
1566cdf0e10cSrcweir     }
1567cdf0e10cSrcweir }
1568cdf0e10cSrcweir 
1569cdf0e10cSrcweir 
1570cdf0e10cSrcweir 
1571cdf0e10cSrcweir } } } // end of namespace ::sd::slidesorter::view
1572