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 .
20 #ifndef SD_TOOLS_EVENT_MULTIPLEXER_HXX
21 #define SD_TOOLS_EVENT_MULTIPLEXER_HXX
23 #include <svl/lstner.hxx>
34 namespace sd
{ namespace tools
{
36 class EventMultiplexerEvent
39 typedef sal_uInt32 EventId
;
40 /** The EventMultiplexer itself is being disposed. Called for a live
41 EventMultiplexer. Removing a listener as response is not necessary,
44 static const EventId EID_DISPOSING
= 0x00000001;
46 /** The selection in the center pane has changed.
48 static const EventId EID_EDIT_VIEW_SELECTION
= 0x00000002;
50 /** The selection in the slide sorter has changed, regardless of whether
51 the slide sorter is displayed in the left pane or the center pane.
53 static const EventId EID_SLIDE_SORTER_SELECTION
= 0x00000004;
55 /** The current page has changed.
57 static const EventId EID_CURRENT_PAGE
= 0x00000008;
59 /** The current MainViewShell (the ViewShell displayed in the center
60 pane) has been removed.
62 static const EventId EID_MAIN_VIEW_REMOVED
= 0x00000010;
64 /** A new ViewShell has been made the MainViewShell.
66 static const EventId EID_MAIN_VIEW_ADDED
= 0x00000020;
68 /** A ViewShell has been removed from one of the panes. Note that for
69 the ViewShell in the center pane bth this event type and
70 EID_MAIN_VIEW_REMOVED is broadcasted.
72 static const EventId EID_VIEW_REMOVED
= 0x00000040;
74 /** A new ViewShell is being displayed in one of the panes. Note that
75 for the ViewShell in the center pane both this event type and
76 EID_MAIN_VIEW_ADDED is broadcasted.
78 static const EventId EID_VIEW_ADDED
= 0x00000080;
80 /** The PaneManager is being destroyed.
82 static const EventId EID_PANE_MANAGER_DYING
= 0x00000100;
84 /** Edit mode was (or is being) switched to normal mode. Find
85 EID_EDIT_MODE_MASTER below.
87 static const EventId EID_EDIT_MODE_NORMAL
= 0x00000200;
89 /** One or more pages have been inserted into or deleted from the model.
91 static const EventId EID_PAGE_ORDER
= 0x00000400;
93 /** Text editing in one of the shapes in the MainViewShell has started.
95 static const EventId EID_BEGIN_TEXT_EDIT
= 0x00000800;
97 /** Text editing in one of the shapes in the MainViewShell has ended.
99 static const EventId EID_END_TEXT_EDIT
= 0x00001000;
101 /** A UNO controller has been attached to the UNO frame.
103 static const EventId EID_CONTROLLER_ATTACHED
= 0x00002000;
105 /** A UNO controller has been detached to the UNO frame.
107 static const EventId EID_CONTROLLER_DETACHED
= 0x00004000;
109 /** The state of a shape has changed. The page is available in the user data.
111 static const EventId EID_SHAPE_CHANGED
= 0x00008000;
113 /** A shape has been inserted to a page. The page is available in the
116 static const EventId EID_SHAPE_INSERTED
= 0x00010000;
118 /** A shape has been removed from a page. The page is available in the
121 static const EventId EID_SHAPE_REMOVED
= 0x00020000;
123 /** A configuration update has been completed.
125 static const EventId EID_CONFIGURATION_UPDATED
= 0x00040000;
127 /** Edit mode was (or is being) switched to master mode.
129 static const EventId EID_EDIT_MODE_MASTER
= 0x00080000;
131 const ViewShellBase
& mrBase
;
133 const void* mpUserData
;
135 EventMultiplexerEvent (
136 const ViewShellBase
& rBase
,
138 const void* pUserData
);
142 /** This convenience class makes it easy to listen to various events that
143 originally are broadcasted via different channels.
145 There is usually one EventMultiplexer instance per ViewShellBase().
146 Call the laters GetEventMultiplexer() method to get access to that
149 When a listener is registered it can specify the events it
150 wants to be informed of. This can be done with code like the following:
152 mrViewShellBase.GetEventMultiplexer().AddEventListener (
153 LINK(this,MasterPagesSelector,EventMultiplexerListener),
154 tools::EventMultiplexerEvent::EID_MAIN_VIEW_ADDED
155 | tools::EventMultiplexerEvent::EID_MAIN_VIEW_REMOVED);
157 class EventMultiplexer
160 /** Create new EventMultiplexer for the given ViewShellBase object.
162 EventMultiplexer (ViewShellBase
& rBase
);
163 ~EventMultiplexer (void);
165 /** Some constants that make it easier to remove a listener for all
168 static const EventMultiplexerEvent::EventId EID_FULL_SET
= 0xffffffff;
169 static const EventMultiplexerEvent::EventId EID_EMPTY_SET
= 0x00000000;
171 /** Add an event listener that will be informed about the specified
174 The callback to call as soon as one of the event specified by
175 aEventTypeSet is received by the EventMultiplexer.
177 A, possibly empty, set of event types that the listener wants to
180 void AddEventListener (
182 EventMultiplexerEvent::EventId aEventTypeSet
);
184 /** Remove an event listener for the specified event types.
186 The listener will not be called anymore for any of the event
187 types in this set. Use EID_FULL_SET, the default value, to
188 remove the listener for all event types it has been registered
191 void RemoveEventListener (
193 EventMultiplexerEvent::EventId aEventTypeSet
= EID_FULL_SET
);
195 /** This method is used for out-of-line events. An event of the
196 specified type will be sent to all listeners that are registered for
199 The type of the event.
201 Some data sent to the listeners along with the event.
204 EventMultiplexerEvent::EventId eEventId
,
205 void* pUserData
= 0);
208 class Implementation
;
209 ::std::auto_ptr
<Implementation
> mpImpl
;
212 } } // end of namespace ::sd::tools
216 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */