New Popup implementation
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / popup / confirmation-popup-impl.h
1 #ifndef __DALI_TOOLKIT_INTERNAL_CONFIRMATION_POPUP_H__
2 #define __DALI_TOOLKIT_INTERNAL_CONFIRMATION_POPUP_H__
3
4 /*
5  * Copyright (c) 2015 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/animation/animation.h>
23 #include <dali/public-api/common/dali-vector.h>
24 #include <dali/devel-api/signals/signal-delegate.h>
25
26 // INTERNAL INCLUDES
27 #include "popup-impl.h"
28 #include <dali-toolkit/devel-api/controls/popup/confirmation-popup.h>
29
30 namespace Dali
31 {
32
33 namespace Toolkit
34 {
35
36 namespace Internal
37 {
38
39 namespace
40 {
41
42 #define MAXIMUM_NUMBER_OF_CONTROLS 2
43
44 }
45
46 /**
47  * ConfirmationPopup implementation class.
48  *
49  * \sa Dali::Toolkit::ConfirmationPopup
50  */
51 class ConfirmationPopup : public Dali::Toolkit::Internal::Popup
52 {
53 public:
54
55   /**
56    * Create a new ConfirmationPopup.
57    * @return A smart-pointer to the newly allocated ConfirmationPopup.
58    */
59   static Dali::Toolkit::ConfirmationPopup New();
60
61 protected:
62
63   /**
64    * Construct a new ConfirmationPopup.
65    */
66   ConfirmationPopup();
67
68   /**
69    * A reference counted object may only be deleted by calling Unreference()
70    */
71   virtual ~ConfirmationPopup();
72
73 public:
74
75   /**
76    * Called when a property of an object of this type is set.
77    * @param[in] object The object whose property is set.
78    * @param[in] propertyIndex The property index.
79    * @param[in] value The new property value.
80    */
81   static void SetProperty( BaseObject* object, Property::Index propertyIndex, const Property::Value& value );
82
83   /**
84    * Called to retrieve a property of an object of this type.
85    * @param[in] object The object whose property is to be retrieved.
86    * @param[in] propertyIndex The property index.
87    * @return The current value of the property.
88    */
89   static Property::Value GetProperty( BaseObject* object, Property::Index propertyIndex );
90
91   /**
92    * Connects a callback function with the object's signals.
93    * @param[in] object The object providing the signal.
94    * @param[in] tracker Used to disconnect the signal.
95    * @param[in] signalName The signal to connect to.
96    * @param[in] functor A newly allocated FunctorDelegate.
97    * @return True if the signal was connected.
98    * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
99    */
100   static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
101
102 private:
103
104   /**
105    * This type houses a list of dynamically created signals.
106    */
107   typedef std::vector< std::pair< std::string, SignalDelegate* > > SignalContainerType;
108
109 private:
110
111   /**
112    * Sets the name of the signal to connect to within the specified actor.
113    *
114    * @param[in] controlNumber The index of the control.
115    * @param[in] signalName The name of the signal to connect to.
116    */
117   void SetControlSignalName( const unsigned int controlNumber, const std::string& signalName );
118
119   /**
120    * Gets the name of the signal to connect to within the specified actor.
121    *
122    * @param[in] controlNumber The index of the control.
123    * @return The name of the signal to connect to.
124    */
125   std::string GetControlSignalName( unsigned int controlNumber ) const;
126
127   /**
128    * @copydoc Control::GetControlSignal()
129    */
130   SignalDelegate* GetControlSignal( const std::string& signalName );
131
132 private:
133
134   // Undefined
135   ConfirmationPopup( const ConfirmationPopup& );
136
137   // Undefined
138   ConfirmationPopup& operator=( const ConfirmationPopup& );
139
140 private:
141
142   // Properties:
143
144   std::string mControlSignalNames[ MAXIMUM_NUMBER_OF_CONTROLS ]; ///< Stores the names of the signals to connect to per control.
145
146   // Internal variables:
147
148   SignalContainerType mControlSignals;                           ///< Stores the dynamically created signals.
149
150 };
151
152 } // namespace Internal
153
154
155 // Helpers for public-api forwarding methods
156
157 inline Toolkit::Internal::ConfirmationPopup& GetDerivedImplementation( Toolkit::ConfirmationPopup& popup )
158 {
159   DALI_ASSERT_ALWAYS( popup );
160
161   Dali::RefObject& handle = popup.GetImplementation();
162
163   return static_cast<Toolkit::Internal::ConfirmationPopup&>( handle );
164 }
165
166 inline const Toolkit::Internal::ConfirmationPopup& GetDerivedImplementation( const Toolkit::ConfirmationPopup& popup )
167 {
168   DALI_ASSERT_ALWAYS( popup );
169
170   const Dali::RefObject& handle = popup.GetImplementation();
171
172   return static_cast<const Toolkit::Internal::ConfirmationPopup&>( handle );
173 }
174
175
176 } // namespace Toolkit
177
178 } // namespace Dali
179
180 #endif // __DALI_TOOLKIT_INTERNAL_CONFIRMATION_POPUP_H__