Merge remote-tracking branch 'origin/tizen' into new_text
[platform/core/uifw/dali-toolkit.git] / 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 // EXTERNAL INCLUDES
22 #include <dali/public-api/actors/image-actor.h>
23 #include <dali/public-api/common/dali-vector.h>
24
25 // INTERNAL INCLUDES
26 #include <dali-toolkit/public-api/controls/buttons/radio-button.h>
27 #include "button-impl.h"
28
29 namespace Dali
30 {
31 namespace Toolkit
32 {
33 namespace Internal
34 {
35
36 /**
37  * RadioButton implementation class.
38  *
39  * \sa Dali::Toolkit::RadioButton
40  */
41 class RadioButton: public Button
42 {
43  public:
44
45   /**
46    * Create a new RadioButton.
47    *
48    * @return A smart-pointer to the newly allocated PushButton.
49    */
50   static Dali::Toolkit::RadioButton New();
51
52   /**
53    * Construct a new PushButton.
54    */
55   RadioButton();
56
57   /**
58    * Construct a new PushButton with label.
59    */
60   RadioButton(const std::string& label);
61
62   /**
63    * Construct a new PushButton with label.
64    */
65   RadioButton(Actor label);
66
67   /**
68    * A reference counted object may only be deleted by calling Unreference()
69    */
70   virtual ~RadioButton();
71
72   /**
73    * @copydoc Dali::Toolkit::RadioButton::SetLabel(const std::string& label)
74    */
75   void SetLabel(const std::string& label);
76
77   /**
78    * @copydoc Dali::Toolkit::RadioButton::SetLabel(Actor label)
79    */
80   void SetLabel(Actor label);
81
82   /**
83    * @copydoc Dali::Toolkit::RadioButton::GetLabel()
84    */
85   Actor GetLabel() const;
86
87   /**
88    * @copydoc Dali::Toolkit::RadioButton::SetSelected(bool selected)
89    */
90   void SetSelected(bool selected);
91
92   /**
93    * @copydoc Dali::Toolkit::RadioButton::IsSelected()
94    */
95   bool IsSelected()const;
96
97   /**
98    * @copydoc Dali::Toolkit::RadioButton::ToggleState()
99    */
100   void ToggleState();
101
102   /**
103    * @copydoc Dali::Toolkit::Control::OnRelayout()
104    */
105   virtual void OnRelayout( const Vector2& size, ActorSizeContainer& container );
106
107  public:
108   // Properties
109
110   /**
111    * @copydoc Button::SetProperty
112    */
113   static void SetProperty(BaseObject* object, Property::Index propertyIndex, const Property::Value& value);
114
115   /**
116    * @copydoc Button::GetProperty
117    */
118   static Property::Value GetProperty(BaseObject* object, Property::Index propertyIndex);
119
120  protected: // From Control
121
122   /**
123    * Sets the relative position of image and label.
124    */
125   virtual void OnInitialize();
126
127  protected: // From Button
128   /**
129    * Change button state when the button is pressed.
130    */
131   virtual void OnButtonUp();
132
133  private:
134
135   // Undefined
136   RadioButton(const RadioButton& origin);
137
138   // Undefined
139   RadioButton& operator=(const RadioButton& origin);
140
141   Image mUnselectedImage;  ///< Stores the unselected image
142   Image mSelectedImage;    ///< Stores the selected image
143   ImageActor mRadioIcon;   ///< Stores the current image
144   Actor mLabel;            ///< Stores the button label
145   bool mSelected;          ///< Stores the selected state
146 } ;
147
148 } // namespace Internal
149
150 // Helpers for public-api forwarding methods
151
152 inline Toolkit::Internal::RadioButton& GetImplementation(Toolkit::RadioButton& button)
153 {
154   DALI_ASSERT_ALWAYS(button);
155
156   Dali::RefObject& handle = button.GetImplementation();
157
158   return static_cast<Toolkit::Internal::RadioButton&> (handle);
159 }
160
161 inline const Toolkit::Internal::RadioButton& GetImplementation(const Toolkit::RadioButton& button)
162 {
163   DALI_ASSERT_ALWAYS(button);
164
165   const Dali::RefObject& handle = button.GetImplementation();
166
167   return static_cast<const Toolkit::Internal::RadioButton&> (handle);
168 }
169
170 } // namespace Toolkit
171 } // namespace Dali
172
173 #endif // __DALI_TOOLKIT_INTERNAL_RADIO_BUTTON_H__