Tizen 2.1 base
[framework/osp/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 Flora License, Version 1.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://floralicense.org/license/
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 int ForwardAnalyze(int startTextIndex, int textLength, int maxWidth, TextObjectWrapType wrap,
62                                                         int& actualLength, int& width, int& height);
63
64         virtual TextElement* CloneN(TextComponentInfoValueType type, unsigned int value);
65
66         virtual TextElement* CopyN(int startTextIndex, int textLength);
67
68         virtual result GetRegion(int textIndex, int textLength, int& width, int& height) const;
69
70         virtual result GetBlockRegion(int textIndex, int textLength, int& width, int& height) const;
71
72         virtual int GetHeight(void) const;
73
74         virtual unsigned int GetValue(TextComponentInfoValueType type) const;
75
76         virtual result SetValue(TextComponentInfoValueType type, unsigned int value);
77
78         virtual result ChangeTextOffset(wchar_t* pText, int gap);
79
80         virtual result SetTextOffset(int offset);
81
82         virtual int GetBaseline(void) const;
83
84         int GetTextOffset(void) const;
85
86         result SetFont(const Font* pFont);
87
88         const Font* GetFont(void) const;
89
90         virtual void SetForegroundColor(const Color& color);
91
92         virtual Color GetForegroundColor(void) const;
93
94         virtual void SetBackgroundColor(const Color& color);
95
96         virtual Color GetBackgroundColor(void) const;
97
98         void SetOutlineColor(const Color& color);
99
100         Color GetOutlineColor(void) const;
101
102         virtual void SetBackGroundDrawingModeEnabled(bool enable);
103
104         virtual bool IsBackGroundDrawingModeEnable(void) const;
105
106         const wchar_t* GetTextSource(void) const;
107
108         const wchar_t* GetText(void) const;
109
110         bool IsSame(wchar_t* pText, Font* pFont, const Color& foregroundColor,
111                                                 const Color& backgroundColor, const Color& outlineColor);
112
113         void SetUserWrap(TextObjectWrapType userWrap);
114
115         int GetWordLength(int textIndex, int& wordLength) const;
116
117         result SetBitmap(const Bitmap& bitmap);
118
119         const Bitmap* GetBitmap(void) const;
120
121 private:
122         static int ConvertEnterToSpace(wchar_t* pDstText, const wchar_t* pSrcText, int textLength);
123
124         bool IsKorean(const wchar_t* ch) const;
125
126         bool IsChinese(const wchar_t* ch) const;
127
128         int GetSentenceLength(const wchar_t* pText, int textLength, int& actualLength) const;
129
130         int GetWordWrapLength(const wchar_t* pText, int textLength, int& actualLength) const;
131
132         int GetWordWrapLengthEx(const wchar_t* pText, int textLength, int& actualLength) const;
133
134 protected:
135         virtual Font* GetCurrentFont(void) const;
136
137         virtual Color GetCurrentForegroundColor(void) const;
138
139         virtual Color GetCurrentBackgroundColor(void) const;
140
141         virtual Color GetCurrentOutlineColor(void) const;
142
143 protected:
144         const wchar_t* _pText;
145         Font* _pFont;
146         TextObjectWrapType _userWrap;
147         Color _foregroundColor;
148         Color _backgroundColor;
149         Color _outlineColor;
150         bool _outline;
151         int _offset;
152         bool _isBackgroundDrawingModeEnabled;
153
154 private:
155         const Bitmap* __pBitmap;
156
157 private:
158         TextSimple(const TextSimple& other); // NOT IMPLMENTED
159
160         TextSimple& operator =(const TextSimple& rhs); // NOT IMPLMENTED
161
162 }; // TextSimple
163
164 }}} // Tizen::Graphics::_Text
165
166 #endif // _FGRP_INTERNAL_TEXT_SIMPLE_H_