1cb23545dc71694c17265137bf4d61eff14315b6
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / public-api / controls / scrollable / scroll-component-impl.h
1 #ifndef __DALI_TOOLKIT_SCROLL_COMPONENT_IMPL_H__
2 #define __DALI_TOOLKIT_SCROLL_COMPONENT_IMPL_H__
3
4 //
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
6 //
7 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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 // INTERNAL INCLUDES
21 #include <dali-toolkit/public-api/controls/scrollable/scroll-component.h>
22
23 #include <dali-toolkit/public-api/controls/control-impl.h>
24 #include <dali-toolkit/public-api/controls/scrollable/scrollable.h>
25 #include <dali-toolkit/public-api/controls/scrollable/scroll-connector.h>
26
27 namespace Dali
28 {
29
30 namespace Toolkit
31 {
32
33 class ScrollComponentImpl;
34 typedef IntrusivePtr<ScrollComponentImpl> ScrollComponentPtr;
35
36 /**
37  * Base class for scroll component implementations.
38  * Scroll-components such as scroll bars, indicators etc. are connected to scrollable containers via ScrollConnector.
39  */
40 class ScrollComponentImpl : public ControlImpl
41 {
42 public:
43
44   /**
45    * @brief Sets the scroll connector.
46    *
47    * @param[in] connector The scroll-connector used to connect with a scrollable container.
48    */
49   void SetScrollConnector( Toolkit::ScrollConnector connector );
50
51   /**
52    * @brief Retrieve the scroll connector.
53    *
54    * @return The scroll-connector used to connect with a scrollable container.
55    */
56   Toolkit::ScrollConnector GetScrollConnector() const;
57
58 protected:
59
60   /**
61    * Construct a new ScrollComponentImpl.
62    */
63   ScrollComponentImpl();
64
65   /**
66    * A reference counted object may only be deleted by calling Unreference()
67    */
68   virtual ~ScrollComponentImpl();
69
70   /**
71    * @brief Called when a scroll component is connected to a scrollable UI control.
72    *
73    * @param[in] oldConnector The previous connector, or an empty handle.
74    */
75   virtual void OnScrollConnectorSet( Toolkit::ScrollConnector oldConnector );
76
77 private:
78
79   // Undefined
80   ScrollComponentImpl(const ScrollComponentImpl&);
81
82   // Undefined
83   ScrollComponentImpl& operator=(const ScrollComponentImpl& rhs);
84
85 protected:
86
87   Toolkit::ScrollConnector mScrollConnector;
88 };
89
90 // Helpers for public-api forwarding methods
91
92 inline Toolkit::ScrollComponentImpl& GetImpl(Toolkit::ScrollComponent& scrollComponent)
93 {
94   DALI_ASSERT_ALWAYS(scrollComponent);
95
96   Dali::RefObject& handle = scrollComponent.GetImplementation();
97
98   return static_cast<Toolkit::ScrollComponentImpl&>(handle);
99 }
100
101 inline const Toolkit::ScrollComponentImpl& GetImpl(const Toolkit::ScrollComponent& scrollComponent)
102 {
103   DALI_ASSERT_ALWAYS(scrollComponent);
104
105   const Dali::RefObject& handle = scrollComponent.GetImplementation();
106
107   return static_cast<const Toolkit::ScrollComponentImpl&>(handle);
108 }
109
110 } // namespace Toolkit
111
112 } // namespace Dali
113
114 #endif // __DALI_TOOLKIT_SCROLL_COMPONENT_IMPL_H__