Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef SD_SLIDESORTER_VIEW_BUTTON_BAR_HXX
30 : : #define SD_SLIDESORTER_VIEW_BUTTON_BAR_HXX
31 : :
32 : : #include "model/SlsSharedPageDescriptor.hxx"
33 : : #include <tools/gen.hxx>
34 : : #include <rtl/ustring.hxx>
35 : : #include <vcl/bitmapex.hxx>
36 : : #include <vcl/bmpacc.hxx>
37 : : #include <boost/scoped_ptr.hpp>
38 : :
39 : : namespace sd { namespace slidesorter {
40 : : class SlideSorter;
41 : : } }
42 : :
43 : :
44 : : namespace sd { namespace slidesorter { namespace view {
45 : :
46 : : class Theme;
47 : :
48 : : class Button;
49 : : typedef ::boost::shared_ptr<Button> SharedButton;
50 : :
51 : : /** This is a container of buttons and a coordinating controller.
52 : : The last means that it receives mouse events and forwards them to
53 : : the right button.
54 : : */
55 : : class ButtonBar
56 : : {
57 : : public:
58 : : ButtonBar (SlideSorter& rSlideSorter);
59 : : ~ButtonBar (void);
60 : :
61 : : void ProcessButtonDownEvent (
62 : : const model::SharedPageDescriptor& rpDescriptor,
63 : : const Point aMouseModelLocation);
64 : : void ProcessButtonUpEvent (
65 : : const model::SharedPageDescriptor& rpDescriptor,
66 : : const Point aMouseModelLocation);
67 : : void ProcessMouseMotionEvent (
68 : : const model::SharedPageDescriptor& rpDescriptor,
69 : : const Point aMouseModelLocation,
70 : : const bool bIsMouseButtonDown);
71 : :
72 : : void ResetPage (void);
73 : :
74 : : bool IsMouseOverBar (void) const;
75 : :
76 : : /** Paint the specified page object. When this is not the same as the
77 : : one under the mouse (mpDescriptor) then the buttons are all
78 : : painted in their normal state.
79 : : */
80 : : void Paint (
81 : : OutputDevice& rDevice,
82 : : const model::SharedPageDescriptor& rpPageDescriptor);
83 : :
84 : : bool IsMouseOverButton (void) const;
85 : :
86 : : /** Return the help text for the button under the mouse.
87 : : @return
88 : : When the mouse is not over a button then an empty string
89 : : is returned.
90 : : */
91 : : ::rtl::OUString GetButtonHelpText (void) const;
92 : :
93 : : /** Request the button bar to be shown.
94 : : @param bAnimate
95 : : This flag controls whether to just show the button bar (<FALSE/>)
96 : : or to fade it in smoothly (<TRUE/>.)
97 : : */
98 : : void RequestFadeIn (
99 : : const model::SharedPageDescriptor& rpDescriptor,
100 : : const bool bAnimate);
101 : :
102 : : /** Request the button bar to be hidden.
103 : : @param bAnimate
104 : : This flag controls whether to just hide the button bar (<FALSE/>)
105 : : or to fade it out smoothly (<TRUE/>.)
106 : : */
107 : : void RequestFadeOut (
108 : : const model::SharedPageDescriptor& rpDescriptor,
109 : : const bool bAnimate);
110 : :
111 : : /** Return whether the button bar is visible for the givn descriptor (or
112 : : being faded in.)
113 : : */
114 : : bool IsVisible (const model::SharedPageDescriptor& rpDescriptor);
115 : :
116 : : void HandleDataChangeEvent (void);
117 : :
118 : : class BackgroundTheme;
119 : :
120 : : /** While at least one Lock object exists the button bar will not be
121 : : displayed. Used, e.g. during a mouse multiselection to avoid
122 : : confusing and unhelpfull visual signals.
123 : : */
124 : : class Lock
125 : : {
126 : : public:
127 : : Lock (SlideSorter& rSlideSorter);
128 : : ~Lock (void);
129 : : private:
130 : : ButtonBar& mrButtonBar;
131 : : };
132 : :
133 : : private:
134 : : SlideSorter& mrSlideSorter;
135 : : Size maPageObjectSize;
136 : : Rectangle maButtonBoundingBox;
137 : : Point maBackgroundLocation;
138 : : model::SharedPageDescriptor mpDescriptor;
139 : : bool mbIsExcluded;
140 : : boost::shared_ptr<Button> mpButtonUnderMouse;
141 : : // The button on which the mouse button was pressed.
142 : : boost::shared_ptr<Button> mpDownButton;
143 : : ::std::vector<SharedButton> maRegularButtons;
144 : : ::std::vector<SharedButton> maExcludedButtons;
145 : : BitmapEx maNormalBackground;
146 : : bool mbIsMouseOverBar;
147 : : ::boost::scoped_ptr<BackgroundTheme> mpBackgroundTheme;
148 : : int mnLockCount;
149 : :
150 : : /** Remember the specified page. If it differs from mpDescriptor then
151 : : the buttons are placed anew.
152 : : @return
153 : : The returned flag indicates whether the mpDescriptor member
154 : : is set to a new value.
155 : : */
156 : : bool SetPage (const model::SharedPageDescriptor& rpDescriptor);
157 : : SharedButton GetButtonAt (const Point aModelLocation);
158 : : bool SetButtonUnderMouse (const SharedButton& rButton = SharedButton());
159 : : void PaintButtonBackground (
160 : : OutputDevice& rDevice,
161 : : const model::SharedPageDescriptor& rpPageDescriptor,
162 : : const Point aOffset);
163 : : void LayoutButtons (const Size aPageModelSize);
164 : : bool LayoutButtons (void);
165 : : BitmapEx CreateBackground (
166 : : const OutputDevice& rTemplateDevice,
167 : : const bool bIsButtonDown) const;
168 : : bool IsMouseOverBar (const Point aModelLocation) const;
169 : : void StartFadeAnimation (
170 : : const model::SharedPageDescriptor& rpDescriptor,
171 : : const double nTargetAlpha,
172 : : const bool bFadeIn);
173 : :
174 : : void AcquireLock (void);
175 : : void ReleaseLock (void);
176 : : };
177 : :
178 : :
179 : :
180 : :
181 : : class Button
182 : : {
183 : : public:
184 : : Button (
185 : : SlideSorter& rSlideSorter,
186 : : const BitmapEx& rLargeIcon,
187 : : const BitmapEx& rLargeHoverIcon,
188 : : const BitmapEx& rMediumIcon,
189 : : const BitmapEx& rMediumHoverIcon,
190 : : const BitmapEx& rSmallIcon,
191 : : const BitmapEx& rSmallHoverIcon,
192 : : const ::rtl::OUString& rsHelpText);
193 : : virtual ~Button (void);
194 : :
195 : : enum State { State_Normal, State_Hover, State_Down };
196 : : enum IconSize { IconSize_Large, IconSize_Medium, IconSize_Small };
197 : :
198 : : /** Set a new state.
199 : : @return
200 : : When the new state is different from the old state
201 : : then <TRUE/> is returned.
202 : : */
203 : : bool SetState (const State eState);
204 : :
205 : : virtual void Place (const Rectangle aButtonBarBox);
206 : : virtual void Paint (
207 : : OutputDevice& rDevice,
208 : : const Point aOffset,
209 : : const double nAlpha,
210 : : const ::boost::shared_ptr<Theme>& rpTheme) const;
211 : : virtual void ProcessClick (const model::SharedPageDescriptor& rpDescriptor) = 0;
212 : :
213 : : /** Return the bounding box of the layouted button.
214 : : */
215 : : Rectangle GetBoundingBox (void) const;
216 : : /** Return the minimum size required to completely paint the
217 : : button.
218 : : */
219 : : virtual Size GetSize (void) const;
220 : : virtual Size GetSize (const IconSize eIconSize) const;
221 : : ::rtl::OUString GetHelpText (void) const;
222 : : void SetActiveState (const bool bIsActive);
223 : : bool IsActive (void) const;
224 : : void SetIconSize (const IconSize eIconSize);
225 : : /** By default a button is always enabled. Override to change this.
226 : : */
227 : : virtual bool IsEnabled (void) const;
228 : :
229 : : protected:
230 : : SlideSorter& mrSlideSorter;
231 : : State meState;
232 : : Rectangle maBoundingBox;
233 : : const ::rtl::OUString msHelpText;
234 : : // Buttons that lie (partly) outside the button bar are deactivated.
235 : : bool mbIsActive;
236 : : IconSize meIconSize;
237 : :
238 : : const BitmapEx maLargeIcon;
239 : : const BitmapEx maLargeHoverIcon;
240 : : const BitmapEx maMediumIcon;
241 : : const BitmapEx maMediumHoverIcon;
242 : : const BitmapEx maSmallIcon;
243 : : const BitmapEx maSmallHoverIcon;
244 : : };
245 : :
246 : :
247 : :
248 [ - + ]: 260 : class UnhideButton : public Button
249 : : {
250 : : public:
251 : : UnhideButton (SlideSorter& rSlideSorter);
252 : :
253 : : protected:
254 : : virtual void ProcessClick (const model::SharedPageDescriptor& rpDescriptor);
255 : : };
256 : :
257 : :
258 [ - + ]: 260 : class StartShowButton : public Button
259 : : {
260 : : public:
261 : : StartShowButton (SlideSorter& rSlideSorter);
262 : : virtual bool IsEnabled (void) const;
263 : :
264 : : protected:
265 : : virtual void ProcessClick (const model::SharedPageDescriptor& rpDescriptor);
266 : : };
267 : :
268 : :
269 [ - + ]: 260 : class HideButton : public Button
270 : : {
271 : : public:
272 : : HideButton (SlideSorter& rSlideSorter);
273 : :
274 : : protected:
275 : : virtual void ProcessClick (const model::SharedPageDescriptor& rpDescriptor);
276 : : };
277 : :
278 : :
279 [ - + ]: 260 : class DuplicateButton : public Button
280 : : {
281 : : public:
282 : : DuplicateButton (SlideSorter& rSlideSorter);
283 : : virtual bool IsEnabled (void) const;
284 : :
285 : : protected:
286 : : virtual void ProcessClick (const model::SharedPageDescriptor& rpDescriptor);
287 : : };
288 : :
289 : :
290 : : } } } // end of namespace ::sd::slidesorter::view
291 : :
292 : : #endif
293 : :
294 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|