Special characters added to the script.
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / public-api / text / text-controller.h
1 #ifndef __DALI_TOOLKIT_TEXT_CONTROLLER_H__
2 #define __DALI_TOOLKIT_TEXT_CONTROLLER_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/public-api/common/intrusive-ptr.h>
23 #include <dali/public-api/object/ref-object.h>
24 #include <dali-toolkit/public-api/text/text-view.h>
25
26 // EXTERNAL INCLUDES
27 #include <string>
28
29 namespace Dali
30 {
31
32 namespace Toolkit
33 {
34
35 namespace Text
36 {
37
38 class Controller;
39 class LayoutEngine;
40
41 typedef IntrusivePtr<Controller> ControllerPtr;
42
43 /**
44  * @brief A Text Controller is used by UI Controls which display text.
45  *
46  * It manipulates the Logical & Visual text models on behalf of the UI Controls.
47  * It provides a view of the text that can be used by rendering back-ends.
48  */
49 class Controller : public RefObject
50 {
51 public:
52
53   /**
54    * @brief Create a new instance of a Controller.
55    *
56    * @return A pointer to a new Controller.
57    */
58   static ControllerPtr New();
59
60   /**
61    * @brief Replaces any text previously set.
62    *
63    * @note This will be converted into UTF-32 when stored in the text model.
64    * @param[in] text A string of UTF-8 characters.
65    */
66   void SetText( const std::string& text );
67
68   /**
69    * @brief Triggers a relayout which updates View (if necessary).
70    *
71    * @note UI Controls are expected to minimize calls to this method e.g. call once after size negotiation.
72    * @param[in] size A the size of a bounding box to layout text within.
73    * @return True if the View was updated.
74    */
75   bool Relayout( const Vector2& size );
76
77   /**
78    * @brief Return the layout engine.
79    *
80    * @return A reference to the layout engine.
81    */
82   LayoutEngine& GetLayoutEngine();
83
84   /**
85    * @brief Return a view of the text.
86    *
87    * @return A reference to the view.
88    */
89   View& GetView();
90
91 protected:
92
93   /**
94    * @brief A reference counted object may only be deleted by calling Unreference().
95    */
96   virtual ~Controller();
97
98 private:
99
100   /**
101    * @brief Private constructor.
102    */
103   Controller();
104
105   /**
106    * @brief Populates the visual model.
107    */
108   void UpdateVisualModel();
109
110   // Undefined
111   Controller( const Controller& handle );
112
113   // Undefined
114   Controller& operator=( const Controller& handle );
115
116 private:
117
118   struct Impl;
119   Impl* mImpl;
120 };
121 } // namespace Text
122
123 } // namespace Toolkit
124
125 } // namespace Dali
126
127 #endif // __DALI_TOOLKIT_TEXT_CONTROLLER_H__