990acf0443a96ead88eddd8b3e946f56f80229b7
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / buttons / push-button-impl.h
1 #ifndef __DALI_TOOLKIT_INTERNAL_PUSH_BUTTON_H__
2 #define __DALI_TOOLKIT_INTERNAL_PUSH_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/common/vector-wrapper.h>
23
24 // INTERNAL INCLUDES
25 #include <dali-toolkit/public-api/controls/buttons/push-button.h>
26 #include "button-impl.h"
27
28 namespace Dali
29 {
30
31 namespace Toolkit
32 {
33
34 namespace Internal
35 {
36
37 /**
38  * PushButton implementation class.
39  *
40  * \sa Dali::Toolkit::PushButton
41  */
42 class PushButton : public Button
43 {
44 public:
45
46   /**
47    * Create a new PushButton.
48    * @return A smart-pointer to the newly allocated PushButton.
49    */
50   static Dali::Toolkit::PushButton New();
51
52 protected:
53
54   /**
55    * Construct a new PushButton.
56    */
57   PushButton();
58
59   /**
60    * A reference counted object may only be deleted by calling Unreference()
61    */
62   virtual ~PushButton();
63
64 public:
65
66   // Properties
67
68   /**
69    * Enum for the alignment modes of the icon.
70    */
71   enum IconAlignment
72   {
73     LEFT,
74     RIGHT,
75     TOP,
76     BOTTOM,
77     DEFAULT = RIGHT
78   };
79
80   /**
81    * Called when a property of an object of this type is set.
82    * @param[in] object The object whose property is set.
83    * @param[in] index The property index.
84    * @param[in] value The new property value.
85    */
86   static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value );
87
88   /**
89    * Called to retrieve a property of an object of this type.
90    * @param[in] object The object whose property is to be retrieved.
91    * @param[in] index The property index.
92    * @return The current value of the property.
93    */
94   static Property::Value GetProperty( BaseObject* object, Property::Index propertyIndex );
95
96 private: // From Button
97
98   /**
99    * @copydoc Toolkit::Internal::Button::OnInitialize
100    */
101   virtual void OnInitialize();
102
103   /**
104    * @copydoc Toolkit::Internal::Button::PrepareForTranstionIn( Actor actor )
105    */
106   virtual void PrepareForTranstionIn( Actor actor );
107
108   /**
109    * @copydoc Toolkit::Internal::Button::PrepareForTranstionOut( Actor actor )
110    */
111   virtual void PrepareForTranstionOut( Actor actor );
112
113   /**
114    * @copydoc Toolkit::Internal::Button::OnTransitionIn( Toolkit::Visual::Base& visual )
115    */
116   virtual void OnTransitionIn( Actor actor );
117
118   /**
119    * @copydoc Toolkit::Internal::Button::OnTransitionOut( Toolkit::Visual::Base& visual )
120    */
121   virtual void OnTransitionOut( Actor actor );
122
123
124 private:
125
126   /**
127    * @brief Sets the alignment mode to use to align the icon to the label.
128    *
129    * @param[in] iconAlignment The alignment mode to use
130    */
131   void SetIconAlignment( const PushButton::IconAlignment iconAlignment );
132
133   /**
134    * @brief Gets the alignment mode used to align the icon to the label.
135    *
136    * @return The alignment mode in use
137    */
138   const PushButton::IconAlignment GetIconAlignment() const;
139
140 private:
141
142   // Undefined
143   PushButton( const PushButton& );
144
145   // Undefined
146   PushButton& operator=( const PushButton& );
147
148 private:
149
150   IconAlignment  mIconAlignment;                 ///< The alignment of the icon against the label.
151 };
152
153 } // namespace Internal
154
155 // Helpers for public-api forwarding methods
156
157 inline Toolkit::Internal::PushButton& GetImplementation( Toolkit::PushButton& button )
158 {
159   DALI_ASSERT_ALWAYS( button );
160
161   Dali::RefObject& handle = button.GetImplementation();
162
163   return static_cast<Toolkit::Internal::PushButton&>( handle );
164 }
165
166 inline const Toolkit::Internal::PushButton& GetImplementation( const Toolkit::PushButton& button )
167 {
168   DALI_ASSERT_ALWAYS( button );
169
170   const Dali::RefObject& handle = button.GetImplementation();
171
172   return static_cast<const Toolkit::Internal::PushButton&>( handle );
173 }
174
175 } // namespace Toolkit
176
177 } // namespace Dali
178
179 #endif // __DALI_TOOLKIT_INTERNAL_PUSH_BUTTON_H__