1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef INCLUDED_SVX_SIDEBAR_POPUP_HXX
20 #define INCLUDED_SVX_SIDEBAR_POPUP_HXX
22 #include <svx/svxdllapi.h>
23 #include <rtl/ustring.hxx>
24 #include <tools/link.hxx>
26 #include <boost/function.hpp>
27 #include <boost/scoped_ptr.hpp>
32 namespace svx
{ namespace sidebar
{
37 /** A wrapper around a PopupContainer and a PopupControl object.
38 Usually used as drop down for a toolbox. Use Show() to start
39 drop down mode and Hide() to end it.
41 class SVX_DLLPUBLIC Popup
44 /** Create a Popup wrapper object.
46 Parent window of the PopupContainer, which in turn is the
47 parent of the PopupControl.
48 @param rControlCreator
49 A functor that is called to create the PopupControl object
50 (usually an instance of a class derived from
55 const ::boost::function
<PopupControl
*(PopupContainer
*)>& rControlCreator
,
56 const ::rtl::OUString
& rsAccessibleName
);
57 virtual ~Popup (void);
61 The tool box is used to determine the position at which
62 the popup is displayed.
64 void Show (ToolBox
& rToolBox
);
67 This method is called automatically when eg. the user clicks
68 outside the popup or when the ESC-key is pressed. The
69 application can call Hide() when the popup should be closed
70 for other, non-standard reasons.
74 /** If you want to be informed when the popup closes then add a
75 callback that is called after that.
77 void SetPopupModeEndHandler (const ::boost::function
<void(void)>& rCallback
);
80 ::boost::scoped_ptr
<PopupControl
> mpControl
;
82 /** Make sure that both PopupContainer and PopupControl objects
83 exist. Calls the maControlCreator functor if necessary.
85 void ProvideContainerAndControl (void);
87 /** A derived specialisation class can override this method to do
90 virtual void CreateContainerAndControl (void);
94 ::boost::function
<PopupControl
*(PopupContainer
*)> maControlCreator
;
95 ::boost::function
<void(void)> maPopupModeEndCallback
;
96 const ::rtl::OUString msAccessibleName
;
97 ::boost::scoped_ptr
<PopupContainer
> mpContainer
;
99 DECL_LINK(PopupModeEndHandler
, void*);
102 } } // end of namespace svx::sidebar
106 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */