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