Tizen 2.1 base
[framework/osp/uifw.git] / src / graphics / inc / FGrp_FontImpl.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_FontImpl.h
20  * @brief       This is the header file for the _FontImpl class.
21  *
22  * This header file contains the declarations of the %_FontImpl class.
23  *
24  */
25
26 #ifndef _FGRP_INTERNAL_FONT_IMPL_H_
27 #define _FGRP_INTERNAL_FONT_IMPL_H_
28
29
30 #include <FBaseObject.h>
31 #include <FBaseString.h>
32
33 namespace Tizen { namespace Base
34 {
35 class String;
36 class ByteBuffer;
37 }} // Tizen::Base
38
39 namespace Tizen { namespace Base { namespace Collection
40 {
41 class IList;
42 }}} // Tizen::Base::Collection
43
44 namespace Tizen { namespace Graphics
45 {
46 class Dimension;
47 class Font;
48
49 class _Font;
50
51 class _OSP_EXPORT_ _FontImpl
52         : public Tizen::Base::Object
53 {
54 public:
55         _FontImpl(void);
56         virtual ~_FontImpl(void);
57
58         result Construct(int style, int size);
59         result Construct(const Tizen::Base::String& fontName, int style, int size, bool isPathEnabled = true);
60         result Construct(const Tizen::Base::ByteBuffer& fontData, int style, int size);
61
62         bool IsConstructed(void) const;
63
64         int GetMaxHeight(void) const;
65         int GetMaxWidth(void) const;
66         int GetAscender(void) const;
67         int GetDescender(void) const;
68         result GetLeftBear(wchar_t character, int& leftBear) const;
69         result GetRightBear(wchar_t character, int& rightBear) const;
70         result GetTextExtent(const Tizen::Base::String& text, int length, Dimension& dim) const;
71         bool IsBold(void) const;
72         bool IsItalic(void) const;
73         bool IsPlain(void) const;
74         bool IsStrikeOut(void) const;
75         bool IsUnderlined(void) const;
76         int GetSize(void) const;
77         void SetStrikeOut(bool strikeOut);
78         void SetUnderline(bool underline);
79         void SetCharSpace(int space);
80         int GetCharSpace(void) const;
81         Tizen::Base::String GetFaceName(void) const;
82         static Tizen::Base::Collection::IList* GetSystemFontListN(void);
83         static Tizen::Base::String GetFaceName(const Tizen::Base::String& filePath);
84
85         _FontImpl* CloneN(void);
86         static Font* CloneN(const Font& font);
87
88         /*
89          * Gets the count and dimension of characters which can be get in the given width. @n
90          *
91          * @return      An error code
92          * @param[in] width         The width for calculating how many characters can be get in there
93          *                                                              The width must be greater than or equal to @c 0
94          * @param[in] text              The string
95          * @param[in] startIndex        The start index
96          * @param[in] length            The length of @c text
97          * @param[in] outline           The outline effect of @c text
98          * @param[out] count            The count of characters
99          * @param[out] dim              The width and height of the font of the @c text which get in given width
100          * @exception   E_SUCCESS                       The method is successful.
101          * @exception   E_INVALID_ARG           The value of @c width is greater than or equal to @c 0.
102          * @exception   E_OPERATION_FAILED      This instance is in an invalid state.
103          * @exception   E_SYSTEM                                The system error occurs.
104          */
105         result GetTextExtent(int width, const Tizen::Base::String& text, int startIndex, int length, bool outline, int& count, Dimension& dim) const;
106
107         /*
108          * Gets the count and dimension of characters which can be get in the given width. @n
109          *
110          * @return      An error code
111          * @param[in] width         The width for calculating how many characters can be get in there
112          *                                              The width must be greater than or equal to @c 0
113          * @param[in] text                      The string
114          * @param[in] startIndex        The start index
115          * @param[in] length            The length of @c text
116          * @param[in] outline           The outline effect of @c text
117          * @param[in] delimiter         The delimiter
118          * @param[out] count            The count of characters
119          * @param[out] dim              The width and height of the font of the @c text which get in given width
120          * @exception   E_SUCCESS                       The method is successful.
121          * @exception   E_INVALID_ARG           The value of @c width is greater than or equal to @c 0.
122          * @exception   E_OPERATION_FAILED              This instance is in an invalid state.
123          * @exception   E_SYSTEM                        The system error occurs.
124          */
125         result GetTextExtent(int width, const Tizen::Base::String& text, int startIndex, int length, bool outline, const Tizen::Base::String& delimiter, int& count, Dimension& dim) const;
126
127         /*
128          * Sets the font size.
129          *
130          * @return      An error code
131          * @param[in]   size            The font size in pixels @n
132          *                                      The size must be greater than @c 0.
133          * @exception   E_SUCCESS                       The method is successful.
134          * @exception   E_INVALID_ARG           A specified input parameter is invalid.
135          * @exception   E_OPERATION_FAILED              This instance is in an invalid state.
136          * @exception   E_SYSTEM                        The system error occurs.
137          */
138         result SetSize(int size);
139
140         /*
141          * Sets the font style.
142          *
143          * @return      An error code
144          * @param[in]   style   The font style @n
145          *                                      For more information, see Tizen::Graphics::FontStyle.
146          * @exception   E_SUCCESS                       The method is successful.
147          * @exception   E_INVALID_ARG           A specified input parameter is invalid.
148          * @exception   E_OPERATION_FAILED              This instance is in an invalid state.
149          * @exception   E_SYSTEM                        The system error occurs.
150          */
151         result SetStyle(int style);
152
153         /*
154          * Gets the font style.
155          *
156          * @return      the style of font
157          */
158         int GetStyle(void) const;
159
160         /*
161          * Gets the leading of the current instance of Font.
162          *
163          * @return      the leading of the current instance of Font, @n
164          *                      else @c -1 if the method fails
165          */
166         int GetLeading(void) const;
167
168         static _FontImpl* GetInstance(Font& font);
169         static const _FontImpl* GetInstance(const Font& font);
170
171         static bool UpdateDefaultFont(const Tizen::Base::String& key);
172
173 protected:
174         struct _FontCoordHolder* _pCoordHolder;
175         Tizen::Graphics::_Font* _pNativeFont;
176
177 private:
178         _FontImpl(const _FontImpl& obj);
179         _FontImpl& operator =(const _FontImpl& rhs);
180
181         friend class _Font;
182
183 }; // _FontImpl
184
185 }} // Tizen::Graphics
186
187 #endif // _FGRP_INTERNAL_FONT_IMPL_H_