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