[dali_1.0.45] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / text-controls / text-selection-toolbar-impl.h
1 #ifndef __DALI_TOOLKIT_INTERNAL_TEXT_SELECTION_TOOLBAR_H__
2 #define __DALI_TOOLKIT_INTERNAL_TEXT_SELECTION_TOOLBAR_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 // INTERNAL INCLUDES
22 #include <dali-toolkit/public-api/controls/control-impl.h>
23 #include <dali-toolkit/public-api/controls/table-view/table-view.h>
24 #include <dali-toolkit/devel-api/controls/text-controls/text-selection-toolbar.h>
25
26 // EXTERNAL INCLUDES
27 #include <dali/public-api/actors/layer.h>
28
29 namespace Dali
30 {
31
32 namespace Toolkit
33 {
34
35 namespace Internal
36 {
37
38 namespace
39 {
40
41 } // namespace
42
43 class TextSelectionToolbar : public Control
44 {
45 public:
46
47   /**
48    * @copydoc Dali::Toollkit::TextSelectionToolbar::New()
49    */
50   static Toolkit::TextSelectionToolbar New();
51
52   // Properties
53
54   /**
55    * @brief Called when a property of an object of this type is set.
56    * @param[in] object The object whose property is set.
57    * @param[in] index The property index.
58    * @param[in] value The new property value.
59    */
60   static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value );
61
62   /**
63    * @brief Called to retrieve a property of an object of this type.
64    *
65    * @param[in] object The object whose property is to be retrieved.
66    * @param[in] index The property index.
67    * @return The current value of the property.
68    */
69   static Property::Value GetProperty( BaseObject* object, Property::Index index );
70
71   /**
72    *  @copydoc TextSelectionToolbar::AddOption
73    */
74   void AddOption( Actor& option );
75
76   /**
77    *  @copydoc TextSelectionToolbar::AddDivider
78    */
79   void AddDivider( Actor& divider );
80
81   /**
82    * @copydoc ResizeDividers
83    */
84   void ResizeDividers( Size& size );
85
86 private: // From Control
87
88   /**
89    * @copydoc Control::OnInitialize()
90    */
91  virtual void OnInitialize();
92
93   /**
94    * @brief Set max size of Popup
95    * @param[in] maxSize Size (Vector2)
96    */
97   void SetPopupMaxSize( const Size& maxSize );
98
99   /**
100    * @brief Get Max size of Popup
101    * @return Vector2 the max size of the Popup
102    */
103   const Dali::Vector2& GetPopupMaxSize() const;
104
105   /**
106    * @brief Set up the parts that make the Toolbar
107    */
108   void SetUp();
109
110 private: // Implementation
111
112   /**
113    * Construct a new TextField.
114    */
115   TextSelectionToolbar();
116
117   /**
118    * A reference counted object may only be deleted by calling Unreference()
119    */
120   virtual ~TextSelectionToolbar();
121
122 private:
123
124   // Undefined copy constructor and assignment operators
125   TextSelectionToolbar(const TextSelectionToolbar&);
126   TextSelectionToolbar& operator=(const TextSelectionToolbar& rhs);
127
128 private: // Data
129
130   Dali::Toolkit::TableView mTableOfButtons;           // Actor which holds all the buttons, sensitivity can be set on buttons via this actor
131   Layer mStencilLayer;                                // Layer to enable clipping when buttons exceed popup
132
133   Size mMaxSize;                                      // Max size of the Toolbar
134   unsigned int mIndexInTable;                         // Index in table to add option
135   Dali::Vector< unsigned int > mDividerIndexes;       // Vector of indexes in the Toolbar that contain dividers.
136
137 };
138
139 } // namespace Internal
140
141 // Helpers for public-api forwarding methods
142
143 inline Toolkit::Internal::TextSelectionToolbar& GetImpl( Toolkit::TextSelectionToolbar& textSelectionToolbar )
144 {
145   DALI_ASSERT_ALWAYS( textSelectionToolbar );
146
147   Dali::RefObject& handle = textSelectionToolbar.GetImplementation();
148
149   return static_cast<Toolkit::Internal::TextSelectionToolbar&>(handle);
150 }
151
152 inline const Toolkit::Internal::TextSelectionToolbar& GetImpl( const Toolkit::TextSelectionToolbar& textSelectionToolbar )
153 {
154   DALI_ASSERT_ALWAYS( textSelectionToolbar );
155
156   const Dali::RefObject& handle = textSelectionToolbar.GetImplementation();
157
158   return static_cast<const Toolkit::Internal::TextSelectionToolbar&>(handle);
159 }
160
161 } // namespace Toolkit
162
163 } // namespace Dali
164
165 #endif // __DALI_TOOLKIT_INTERNAL_TEXT_SELECTION_TOOLBAR_H__