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_
27 #include <dpl/assert.h>
28 #include <dpl/noncopyable.h>
29 #include <dpl/singleton.h>
30 #include <dpl/log/log.h>
32 #include "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) {}
50 LogError("Destroyed without Deinitialize");
53 void Initialize (PopupRendererPtr creator);
55 void SetPopupRenderer (PopupRendererPtr creator);
56 IPopupPtr CreatePopup();
58 template <class ArgType>
59 void RunAsyncWithArgType(
61 typename TemplatedPopupCallback<ArgType>::Type
66 WrapCbAndArg<ArgType>* wrapped =
67 new WrapCbAndArg<ArgType>(callback, argument);
68 popup->Show(&CallbackArgTypeTranslator<ArgType>, wrapped);
71 void Show(IPopupPtr popup,
72 IPopup::PopupCallbackType callback,
75 popup->Show(callback, userdata);
78 void setExternalCanvas(void* externalCanvas)
80 AssertMsg(m_initialized, "Manger should be initialized");
81 m_popupRenderer->setExternalCanvas(externalCanvas);
85 template <class ArgType>
88 WrapCbAndArg(typename TemplatedPopupCallback<ArgType>::Type cb,
94 typename TemplatedPopupCallback<ArgType>::Type callback;
98 template <class ArgType>
99 static void CallbackArgTypeTranslator(const AnswerCallbackData & answer,
102 WrapCbAndArg<ArgType>* wrapped =
103 static_cast< WrapCbAndArg<ArgType>* >(data);
104 wrapped->callback(answer, wrapped->argument);
109 PopupRendererPtr m_popupRenderer;
112 typedef DPL::Singleton<PopupManager> PopupManagerSingleton;
117 #endif //WRT_SRC_POPUP_POPUP_MANAGER_H_