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