Initialize Tizen 2.3
[framework/web/wrt-plugins-common.git] / src_wearable / wrt-popup / wrt / popup-bin / renderer / popup_object.h
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 /*
17  * @file        popup_object.h
18  * @author      Justyna Mejzner (j.mejzner@samsung.com)
19  * @version     1.0
20  * @brief       This is declaration file of PopupObject
21  */
22
23 #ifndef WRT_SRC_POPUP_POPUPOBJECT_H_
24 #define WRT_SRC_POPUP_POPUPOBJECT_H_
25
26 #include <dpl/foreach.h>
27
28 #include <list>
29 #include <string>
30
31 namespace Wrt {
32 namespace Popup {
33 namespace Renderer {
34 namespace PopupObject {
35 class IPopupObject;
36 class PopupObjectBase;
37 class Button;
38 class Label;
39 class Check;
40
41 typedef std::list<IPopupObject*> PopupObjects;
42
43 enum PopupType
44 {
45     BUTTON,
46     LABEL,
47     CHECK
48 };
49
50 class IPopupObject
51 {
52   public:
53     virtual Button* asButton() = 0;
54     virtual Label* asLabel() = 0;
55     virtual Check* asCheck() = 0;
56     virtual PopupType getType() const = 0;
57     virtual ~IPopupObject()
58     {}
59 };
60
61 class PopupObjectBase : public IPopupObject
62 {
63   public:
64     virtual Button* asButton()
65     {
66         Assert("wrong type");
67         return NULL;
68     }
69     virtual Label* asLabel()
70     {
71         Assert("wrong type");
72         return NULL;
73     }
74     virtual Check* asCheck()
75     {
76         Assert("wrong type");
77         return NULL;
78     }
79
80     PopupType getType() const
81     {
82         return m_type;
83     }
84
85   protected:
86     PopupObjectBase(PopupType type) : m_type(type)
87     {}
88
89     PopupType m_type;
90 };
91
92 class Button : public PopupObjectBase
93 {
94   public:
95     Button(const std::string& label,
96            int labelId) :
97         PopupObjectBase(BUTTON),
98         m_label(label),
99         m_labelId(labelId)
100     {}
101
102     Button* asButton()
103     {
104         return this;
105     }
106
107     const std::string& getLabel() const
108     {
109         return m_label;
110     }
111
112     int getLabelId() const
113     {
114         return m_labelId;
115     }
116
117   private:
118     std::string m_label;
119     int m_labelId;
120 };
121
122 class Label : public PopupObjectBase
123 {
124   public:
125     Label(const std::string &label) :
126         PopupObjectBase(LABEL),
127         m_label(label)
128     {}
129
130     Label* asLabel()
131     {
132         return this;
133     }
134
135     const std::string& getLabel() const
136     {
137         return m_label;
138     }
139
140   private:
141     std::string m_label;
142 };
143
144 class Check : public PopupObjectBase
145 {
146   public:
147     Check(const std::string &label) :
148         PopupObjectBase(CHECK),
149         m_checkLabel(label)
150     {}
151
152     Check* asCheck()
153     {
154         return this;
155     }
156
157     const std::string& getCheckLabel() const
158     {
159         return m_checkLabel;
160     }
161
162   private:
163     std::string m_checkLabel;
164 };
165 } /*PopupObject*/
166 }
167 } //namespace Popup
168 } //namespace Wrt
169
170 #endif //WRT_SRC_POPUP_POPUPOBJECT_H_