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