2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 #ifndef _SVX_SIDEBAR_POPUP_HXX_
19 #define _SVX_SIDEBAR_POPUP_HXX_
21 #include "svx/svxdllapi.h"
22 #include <rtl/ustring.hxx>
23 #include <tools/link.hxx>
25 #include <boost/function.hpp>
26 #include <boost/scoped_ptr.hpp>
31 namespace svx
{ namespace sidebar
{
36 /** A wrapper around a PopupContainer and a PopupControl object.
37 Usually used as drop down for a toolbox. Use Show() to start
38 drop down mode and Hide() to end it.
40 class SVX_DLLPUBLIC Popup
43 /** Create a Popup wrapper object.
45 Parent window of the PopupContainer, which in turn is the
46 parent of the PopupControl.
47 @param rControlCreator
48 A functor that is called to create the PopupControl object
49 (usually an instance of a class derived from
54 const ::boost::function
<PopupControl
*(PopupContainer
*)>& rControlCreator
,
55 const ::rtl::OUString
& rsAccessibleName
);
56 virtual ~Popup (void);
60 The tool box is used to determine the position at which
61 the popup is displayed.
63 void Show (ToolBox
& rToolBox
);
66 This method is called automatically when eg. the user clicks
67 outside the popup or when the ESC-key is pressed. The
68 application can call Hide() when the popup should be closed
69 for other, non-standard reasons.
73 /** If you want to be informed when the popup closes then add a
74 callback that is called after that.
76 void SetPopupModeEndHandler (const ::boost::function
<void(void)>& rCallback
);
79 ::boost::scoped_ptr
<PopupControl
> mpControl
;
81 /** Make sure that both PopupContainer and PopupControl objects
82 exist. Calls the maControlCreator functor if necessary.
84 void ProvideContainerAndControl (void);
86 /** A derived specialisation class can override this method to do
89 virtual void CreateContainerAndControl (void);
93 ::boost::function
<PopupControl
*(PopupContainer
*)> maControlCreator
;
94 ::boost::function
<void(void)> maPopupModeEndCallback
;
95 const ::rtl::OUString msAccessibleName
;
96 ::boost::scoped_ptr
<PopupContainer
> mpContainer
;
98 DECL_LINK(PopupModeEndHandler
, void*);
101 } } // end of namespace svx::sidebar