[dali_1.0.11] Merge branch 'tizen'
[platform/core/uifw/dali-toolkit.git] / base / dali-toolkit / internal / controls / buttons / radio-button-impl.h
1 #ifndef __DALI_TOOLKIT_INTERNAL_RADIO_BUTTON_H__
2 #define __DALI_TOOLKIT_INTERNAL_RADIO_BUTTON_H__
3
4 /*
5  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // INTERNAL INCLUDES
22 #include <dali/dali.h>
23
24 #include <dali-toolkit/public-api/controls/text-view/text-view.h>
25
26 #include <dali-toolkit/public-api/controls/buttons/radio-button.h>
27
28 #include <dali/public-api/common/dali-vector.h>
29
30 #include "button-impl.h"
31
32 namespace Dali
33 {
34 namespace Toolkit
35 {
36 namespace Internal
37 {
38
39 /**
40  * RadioButton implementation class.
41  *
42  * \sa Dali::Toolkit::RadioButton
43  */
44 class RadioButton: public Button
45 {
46  public:
47
48   /**
49    * Create a new RadioButton.
50    *
51    * @return A smart-pointer to the newly allocated PushButton.
52    */
53   static Dali::Toolkit::RadioButton New();
54
55   /**
56    * Construct a new PushButton.
57    */
58   RadioButton();
59
60   /**
61    * Construct a new PushButton with label.
62    */
63   RadioButton(const std::string& label);
64
65   /**
66    * Construct a new PushButton with label.
67    */
68   RadioButton(Actor label);
69
70   /**
71    * A reference counted object may only be deleted by calling Unreference()
72    */
73   virtual ~RadioButton();
74
75   /**
76    * @copydoc Dali::Toolkit::RadioButton::SetLabel(const std::string& label)
77    */
78   void SetLabel(const std::string& label);
79
80   /**
81    * @copydoc Dali::Toolkit::RadioButton::SetLabel(Actor label)
82    */
83   void SetLabel(Actor label);
84
85   /**
86    * @copydoc Dali::Toolkit::RadioButton::GetLabel()
87    */
88   Actor GetLabel() const;
89
90   /**
91    * @copydoc Dali::Toolkit::RadioButton::SetActive(bool active)
92    */
93   void SetActive(bool active);
94
95   /**
96    * @copydoc Dali::Toolkit::RadioButton::IsActive()
97    */
98   bool IsActive()const;
99
100   /**
101    * @copydoc Dali::Toolkit::RadioButton::ToggleState()
102    */
103   void ToggleState();
104
105   /**
106    * @copydoc Dali::Toolkit::Control::OnRelaidOut(Vector2 size, ActorSizeContainer& container)
107    */
108   virtual void OnRelaidOut( Vector2 size, ActorSizeContainer& container );
109
110  public:
111   // Properties
112
113   /**
114    * @copydoc Button::SetProperty
115    */
116   static void SetProperty(BaseObject* object, Property::Index propertyIndex, const Property::Value& value);
117
118   /**
119    * @copydoc Button::GetProperty
120    */
121   static Property::Value GetProperty(BaseObject* object, Property::Index propertyIndex);
122
123  protected: // From Control
124
125   /**
126    * Sets the relative position of image and label.
127    */
128   virtual void OnInitialize();
129
130  protected: // From Button
131   /**
132    * Change button state when the button is pressed.
133    */
134   virtual void OnButtonUp();
135
136  private:
137
138   // Undefined
139   RadioButton(const RadioButton& origin);
140
141   // Undefined
142   RadioButton& operator=(const RadioButton& origin);
143
144   Image mInactiveImage;     ///< Stores the inactive image
145   Image mActiveImage;       ///< Stores the active image
146   ImageActor mRadioIcon;   ///< Stores the current image
147   Actor mLabel;             ///< Stores the button label
148   bool mActive;             ///< Stores the active state
149 } ;
150
151 } // namespace Internal
152
153 // Helpers for public-api forwarding methods
154
155 inline Toolkit::Internal::RadioButton& GetImplementation(Toolkit::RadioButton& button)
156 {
157   DALI_ASSERT_ALWAYS(button);
158
159   Dali::RefObject& handle = button.GetImplementation();
160
161   return static_cast<Toolkit::Internal::RadioButton&> (handle);
162 }
163
164 inline const Toolkit::Internal::RadioButton& GetImplementation(const Toolkit::RadioButton& button)
165 {
166   DALI_ASSERT_ALWAYS(button);
167
168   const Dali::RefObject& handle = button.GetImplementation();
169
170   return static_cast<const Toolkit::Internal::RadioButton&> (handle);
171 }
172
173 } // namespace Toolkit
174 } // namespace Dali
175
176 #endif // __DALI_TOOLKIT_INTERNAL_RADIO_BUTTON_H__