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_renderer.h
18 * @author Lukasz Wrzosek (l.wrzosek@samsung.com)
20 * @brief This is declaration file of PopupRenderer
23 #ifndef WRT_SRC_POPUP_POPUP_RENDERER_H_
24 #define WRT_SRC_POPUP_POPUP_RENDERER_H_
30 #include <dpl/noncopyable.h>
31 #include <dpl/log/log.h>
32 #include <dpl/assert.h>
33 #include <dpl/foreach.h>
39 class PopupRenderer : public std::enable_shared_from_this<PopupRenderer>
46 IPopupPtr CreatePopup();
47 virtual void setExternalCanvas(void* externalCanvas);
51 typedef std::shared_ptr<Popup> PopupPtr;
53 class Popup : public IPopup
56 typedef std::map<int, std::string> ButtonMap;
57 virtual void SetTitle(const std::string &title)
60 Assert(m_title.empty());
64 virtual void Append(PopupObject::IPopupObject *object)
66 m_popupObjectList.push_back(object);
69 virtual void Show(IPopup::PopupCallbackType callback,
74 m_callback = callback;
75 m_renderer->Render(std::static_pointer_cast<Popup>(shared_from_this()));
78 const std::string& GetTitle() const
83 PopupObject::PopupObjects& GetPopupObjects()
85 return m_popupObjectList;
90 FOREACH(it, m_popupObjectList) {
96 friend class PopupRenderer;
97 friend class std::shared_ptr<Popup>;
98 friend class PopupObjectTheme;
100 Popup(std::shared_ptr<PopupRenderer> renderer) : m_renderer(renderer)
103 void ForwardAnswer(const AnswerCallbackData & answer) const
105 m_callback(answer, m_data);
110 IPopup::PopupCallbackType m_callback;
111 PopupObject::PopupObjects m_popupObjectList;
112 std::shared_ptr<PopupRenderer> m_renderer;
116 void Render (PopupPtr popup);
122 typedef std::shared_ptr<PopupRenderer> PopupRendererPtr;
127 #endif //WRT_SRC_POPUP_POPUP_RENDERER_H_