1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: document.hxx,v $
10 * $Revision: 1.115.36.9 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SC_DPCONTROL_HXX
32 #define SC_DPCONTROL_HXX
34 #include "rtl/ustring.hxx"
35 #include "tools/gen.hxx"
36 #include "vcl/floatwin.hxx"
37 #include "vcl/button.hxx"
38 #include "vcl/scrbar.hxx"
39 #include "vcl/timer.hxx"
41 #include <boost/shared_ptr.hpp>
52 * This class takes care of physically drawing field button controls inside
58 ScDPFieldButton(OutputDevice
* pOutDev
, const StyleSettings
* pStyle
);
61 void setText(const ::rtl::OUString
& rText
);
62 void setBoundingBox(const Point
& rPos
, const Size
& rSize
);
63 void setDrawPopupButton(bool b
);
64 void setHasHiddenMember(bool b
);
67 void getPopupBoundingBox(Point
& rPos
, Size
& rSize
) const;
68 bool isPopupButton() const;
71 void drawPopupButton();
76 ::rtl::OUString maText
;
77 OutputDevice
* mpOutDev
;
78 const StyleSettings
* mpStyle
;
80 bool mbHasHiddenMember
;
83 // ============================================================================
85 class ScMenuFloatingWindow
: public FloatingWindow
89 * Action to perform when an event takes place. Create a sub-class of
90 * this to implement the desired action.
95 virtual void execute() = 0;
98 explicit ScMenuFloatingWindow(Window
* pParent
);
99 virtual ~ScMenuFloatingWindow();
101 virtual void MouseMove(const MouseEvent
& rMEvt
);
102 virtual void MouseButtonDown(const MouseEvent
& rMEvt
);
103 virtual void MouseButtonUp(const MouseEvent
& rMEvt
);
104 virtual void KeyInput(const KeyEvent
& rKEvt
);
105 virtual void Paint(const Rectangle
& rRect
);
107 void addMenuItem(const ::rtl::OUString
& rText
, bool bEnabled
, Action
* pAction
);
108 ScMenuFloatingWindow
* addSubMenuItem(const ::rtl::OUString
& rText
, bool bEnabled
);
111 void drawMenuItem(size_t nPos
);
112 void drawAllMenuItems();
113 const Font
& getLabelFont() const;
115 void executeMenu(size_t nPos
);
116 void setSelectedMenuItem(size_t nPos
, bool bSubMenuTimer
= true);
117 size_t getSelectedMenuItem() const;
118 void queueLaunchSubMenu(size_t nPos
, ScMenuFloatingWindow
* pMenu
);
119 void queueCloseSubMenu();
120 void launchSubMenu(bool bSetMenuPos
);
125 void handleMenuTimeout(SubMenuItem
* pTimer
);
127 enum NotificationType
{ SUBMENU_FOCUSED
};
128 void notify(NotificationType eType
);
130 void resetMenu(bool bSetMenuPos
);
131 void resizeToFitMenuItems();
132 void selectMenuItem(size_t nPos
, bool bSelected
, bool bSubMenuTimer
);
133 void highlightMenuItem(size_t nPos
, bool bSelected
);
135 void getMenuItemPosSize(Point
& rPos
, Size
& rSize
, size_t nPos
) const;
136 size_t getEnclosingMenuItem(const Point
& rPos
) const;
138 DECL_LINK( EndPopupHdl
, void* );
143 ::rtl::OUString maText
;
146 ::boost::shared_ptr
<Action
> mpAction
;
147 ::boost::shared_ptr
<ScMenuFloatingWindow
> mpSubMenuWin
;
152 ::std::vector
<MenuItem
> maMenuItems
;
157 ScMenuFloatingWindow
* mpSubMenu
;
160 DECL_LINK( TimeoutHdl
, void* );
162 SubMenuItem(ScMenuFloatingWindow
* pParent
);
166 ScMenuFloatingWindow
* mpParent
;
168 SubMenuItem maOpenTimer
;
169 SubMenuItem maCloseTimer
;
173 size_t mnSelectedMenu
;
174 size_t mnClickedMenu
;
176 ScMenuFloatingWindow
* mpParentMenu
;
177 ScMenuFloatingWindow
* mpActiveSubMenu
;
182 // ============================================================================
185 * This class implements a popup window for field button, for quick access
186 * of hide-item list, and possibly more stuff related to field options.
188 class ScDPFieldPopupWindow
: public ScMenuFloatingWindow
192 * Extended data that the client code may need to store. Create a
193 * sub-class of this and store data there.
195 struct ExtendedData
{};
197 explicit ScDPFieldPopupWindow(Window
* pParent
);
198 virtual ~ScDPFieldPopupWindow();
200 virtual void MouseMove(const MouseEvent
& rMEvt
);
201 virtual void Paint(const Rectangle
& rRect
);
203 void setMemberSize(size_t n
);
204 void addMember(const ::rtl::OUString
& rName
, bool bVisible
);
207 void getResult(::std::hash_map
< ::rtl::OUString
, bool, ::rtl::OUStringHash
>& rResult
);
208 void close(bool bOK
);
211 * Set auxiliary data that the client code might need. Note that this
212 * popup window class manages its life time; no explicit deletion of the
213 * instance is needed in the client code.
215 void setExtendedData(ExtendedData
* p
);
218 * Get the store auxiliary data, or NULL if no such data is stored.
220 ExtendedData
* getExtendedData();
222 void setOKAction(Action
* p
);
227 ::rtl::OUString maName
;
233 class CancelButton
: public ::CancelButton
236 CancelButton(ScDPFieldPopupWindow
* pParent
);
238 virtual void Click();
241 ScDPFieldPopupWindow
* mpParent
;
244 ::std::vector
<Member
>& getMembers();
247 WHOLE
, // entire window
248 LISTBOX_AREA
, // box enclosing the check box items.
249 FIRST_LISTITEM
, // first list item at the top
251 BTN_CANCEL
, // Cancel button
252 SCROLL_BAR_V
, // vertical scroll bar along the right edge of the list box.
254 void getSectionPosSize(Point
& rPos
, Size
& rSize
, SectionType eType
) const;
256 void resetDisplayedItems();
258 DECL_LINK( CheckBoxHdl
, CheckBox
* );
259 DECL_LINK( OKButtonHdl
, OKButton
* );
260 DECL_LINK( ScrollHdl
, ScrollBar
* );
275 ScrollBar maScrollBar
;
278 CancelButton maBtnCancel
;
280 ::std::vector
<CheckBox
*> mpCheckPtr
;
282 ::std::vector
<Member
> maMembers
;
283 ::std::auto_ptr
<ExtendedData
> mpExtendedData
;
284 ::std::auto_ptr
<Action
> mpOKAction
;