Merge "fixed bug (TapGesture improvement)" into tizen_2.1
[platform/framework/native/uifw.git] / src / graphics / inc / FGrp_TextTextSimple.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0/
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an ”AS IS” BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /*
19  * @file        FGrp_TextTextSimple.h
20  * @brief       This is the header file for the TextSimple class.
21  *
22  * This header file contains the declarations of the TextSimple class.
23  */
24
25 #ifndef _FGRP_INTERNAL_TEXT_SIMPLE_H_
26 #define _FGRP_INTERNAL_TEXT_SIMPLE_H_
27
28 // Includes
29 #include "FGrp_TextCommon.h"
30 #include "FGrp_TextTextElement.h"
31
32 namespace Tizen { namespace Graphics
33 {
34 class _CanvasImpl;
35
36 namespace _Text
37 {
38
39 enum WordType
40 {
41         WORD_ENTER = 0,
42         WORD_SPACE,
43         WORD_WORD,
44         WORD_ERROR
45 };
46
47 class _OSP_EXPORT_ TextSimple
48         : public TextElement
49 {
50 public:
51         TextSimple(const wchar_t* pText, int length, TextElementSourceType sourceType = TEXT_ELEMENT_SOURCE_TYPE_INTERNAL, Font* pFont = null,
52                 const Color& foregroundColor = Color::GetColor(COLOR_ID_BLACK), const Color& backgroundColor = Color::GetColor(COLOR_ID_WHITE),
53                 const Color& outlineColor = 0);
54
55         virtual ~TextSimple(void);
56
57 public:
58         virtual result Draw(_CanvasImpl& canvasImpl, Rectangle& displayRect, int startTextIndex, int textLength,
59                                                 const TextObjectAlignment alignment, const TextObjectActionType action);
60
61         virtual result Draw(_CanvasImpl& canvasImpl, FloatRectangle& displayRect, int startTextIndex, int textLength,
62                                                 const TextObjectAlignment alignment, const TextObjectActionType action);
63
64         virtual int ForwardAnalyze(int startTextIndex, int textLength, int maxWidth, TextObjectWrapType wrap,
65                                                         int& actualLength, int& width, int& height);
66
67         virtual int ForwardAnalyze(int startTextIndex, int textLength, float maxWidth, TextObjectWrapType wrap,
68                                                         int& actualLength, float& width, float& height);
69
70         virtual TextElement* CloneN(TextComponentInfoValueType type, unsigned int value);
71
72         virtual TextElement* CopyN(int startTextIndex, int textLength);
73
74         virtual result GetRegion(int textIndex, int textLength, int& width, int& height) const;
75
76         virtual result GetRegion(int textIndex, int textLength, float& width, float& height) const;
77
78         virtual int GetHeight(void) const;
79
80         virtual float GetHeightF(void) const;
81
82         virtual unsigned int GetValue(TextComponentInfoValueType type) const;
83
84         virtual result SetValue(TextComponentInfoValueType type, unsigned int value);
85
86         virtual result ChangeTextOffset(wchar_t* pText, int gap);
87
88         virtual result SetTextOffset(int offset);
89
90         virtual int GetBaseline(void) const;
91
92         virtual float GetBaselineF(void) const;
93
94         int GetTextOffset(void) const;
95
96         result SetFont(const Font* pFont);
97
98         virtual const Font* GetFont(void) const;
99
100         virtual void SetForegroundColor(const Color& color);
101
102         virtual Color GetForegroundColor(void) const;
103
104         virtual void SetBackgroundColor(const Color& color);
105
106         virtual Color GetBackgroundColor(void) const;
107
108         void SetOutlineColor(const Color& color);
109
110         Color GetOutlineColor(void) const;
111
112         virtual void SetBackGroundDrawingModeEnabled(bool enable);
113
114         virtual bool IsBackGroundDrawingModeEnable(void) const;
115
116         const wchar_t* GetTextSource(void) const;
117
118         const wchar_t* GetText(void) const;
119
120         bool IsSame(wchar_t* pText, Font* pFont, const Color& foregroundColor,
121                                                 const Color& backgroundColor, const Color& outlineColor, const bool isBitmapDisplayMode) const;
122
123         void SetUserWrap(TextObjectWrapType userWrap);
124
125         int GetWordLength(int textIndex, int& wordLength) const;
126
127         result SetBitmap(const Bitmap& bitmap);
128
129         result SetBitmap(BitmapDisplayProperty bitmapDisplayProperty);
130
131         const Bitmap* GetBitmap(void) const;
132
133         bool IsBitmapDisplayMode(void) const;
134
135 private:
136         static int ConvertEnterToSpace(wchar_t* pDstText, const wchar_t* pSrcText, int textLength);
137
138         bool IsKorean(const wchar_t* ch) const;
139
140         bool IsChinese(const wchar_t* ch) const;
141
142         bool IsJapanese(const wchar_t* ch) const;
143
144         int GetSentenceLength(const wchar_t* pText, int textLength, int& actualLength) const;
145
146         int GetWordWrapLength(const wchar_t* pText, int textLength, int& actualLength) const;
147
148         int GetWordWrapLengthEx(const wchar_t* pText, int textLength, int& actualLength) const;
149
150         int GetGlyphedLength(const wchar_t* pText, int textLength, int& actualLength) const;
151
152 protected:
153         virtual Font* GetCurrentFont(void) const;
154
155         virtual Color GetCurrentForegroundColor(void) const;
156
157         virtual Color GetCurrentBackgroundColor(void) const;
158
159         virtual Color GetCurrentOutlineColor(void) const;
160
161 protected:
162         const wchar_t* _pText;
163         Font* _pFont;
164         TextObjectWrapType _userWrap;
165         Color _foregroundColor;
166         Color _backgroundColor;
167         Color _outlineColor;
168         bool _outline;
169         int _offset;
170         bool _isBackgroundDrawingModeEnabled;
171
172 private:
173         BitmapDisplayProperty __bitmapProperty;
174
175 private:
176         TextSimple(const TextSimple& other); // NOT IMPLMENTED
177
178         TextSimple& operator =(const TextSimple& rhs); // NOT IMPLMENTED
179
180 }; // TextSimple
181
182 }}} // Tizen::Graphics::_Text
183
184 #endif // _FGRP_INTERNAL_TEXT_SIMPLE_H_