2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 * @file popup_manager.h
18 * @author Lukasz Wrzosek (l.wrzosek@samsung.com)
20 * @brief This is popup_manager declaration file
23 #ifndef WRT_SRC_POPUP_POPUP_MANAGER_H_
24 #define WRT_SRC_POPUP_POPUP_MANAGER_H_
26 #include <dpl/assert.h>
27 #include <dpl/shared_ptr.h>
28 #include <dpl/noncopyable.h>
29 #include <dpl/singleton.h>
30 #include <dpl/optional.h>
31 #include <dpl/popup/popup.h>
32 #include <dpl/popup/popup_renderer.h>
37 class PopupManager : DPL::Noncopyable
39 template <class ArgType>
40 struct TemplatedPopupCallback
42 typedef void (*Type)(const AnswerCallbackData& answer, ArgType* data);
46 PopupManager() : m_initialized(false) {}
49 Assert(!m_initialized);
51 void Initialize (PopupRendererPtr creator);
53 void SetPopupRenderer (PopupRendererPtr creator);
54 IPopupPtr CreatePopup();
56 template <class ArgType>
57 void RunAsyncWithArgType(IPopupPtr popup,
58 typename TemplatedPopupCallback<ArgType>::Type callback,
62 WrapCbAndArg<ArgType>* wrapped =
63 new WrapCbAndArg<ArgType>(callback, argument);
64 popup->Show(&CallbackArgTypeTranslator<ArgType>, wrapped);
67 void Show(IPopupPtr popup,
68 IPopup::PopupCallbackType callback,
71 popup->Show(callback, userdata);
74 void setExternalCanvas(void* externalCanvas)
76 Assert(m_initialized && "Manger should be initialized");
77 m_popupRenderer->setExternalCanvas(externalCanvas);
81 template <class ArgType>
84 WrapCbAndArg(typename TemplatedPopupCallback<ArgType>::Type cb,
91 typename TemplatedPopupCallback<ArgType>::Type callback;
95 template <class ArgType>
96 static void CallbackArgTypeTranslator(const AnswerCallbackData & answer,
99 WrapCbAndArg<ArgType>* wrapped =
100 static_cast< WrapCbAndArg<ArgType>* >(data);
101 wrapped->callback(answer, wrapped->argument);
106 PopupRendererPtr m_popupRenderer;
109 typedef DPL::Singleton<Popup::PopupManager> PopupManagerSingleton;
114 #endif //WRT_SRC_POPUP_POPUP_MANAGER_H_