Tizen 2.1 base
[apps/osp/MyFiles.git] / inc / MfFormatedText.h
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Flora License, Version 1.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //     http://floralicense.org/license/
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 /**
18  * @file: MfFormatedText.h
19  * @brief: This file contains declaration of FormatedText class, which is derived from ICustomElement and contains
20  * customized format of text for the application.
21  */
22
23 #ifndef _MF_FORMATED_TEXT_H_
24 #define _MF_FORMATED_TEXT_H_
25
26 #include <FApp.h>
27 #include <FBase.h>
28 #include <FGraphics.h>
29 #include <FIo.h>
30 #include <FMedia.h>
31 #include <FText.h>
32 #include <FUi.h>
33
34 #include "MfFontManager.h"
35 #include "MfTypes.h"
36
37 class FormatedText
38         : public Tizen::Ui::Controls::ICustomElement
39 {
40 public:
41         //! Constructor of the class.
42         /*!@fn FormatedText(int width, bool selectState = false)
43          * @brief A public member taking the width of the text and a boolean value indicating the
44          * selected state of the text which initializes the member variables of the class.
45          * @param Takes no parameters
46          * @return No value returned */
47         FormatedText(int width, bool selectState = false);
48
49         /*
50          * Copy constructor of the FormattedText class
51          * @fn FormatedText(const FormatedText& p)
52          * @brief: Copy constructor of the FormattedText class
53          * @param [const FormatedText&] Reference to an instance of the FormattedText Class.
54          * @return No value returned
55          */
56         FormatedText(const FormatedText& p);
57
58         //! Destructor of the class.
59         /*!@fn ~FormatedText(void)
60          * @brief A public virtual member taking no arguments, frees the memory allocated to the member variables.
61          * @param Takes no parameters
62          * @return No value returned
63          * */
64         ~FormatedText(void);
65
66         /*
67          * Overloaded Assignment operator of the FormattedText class
68          * @fn operator =
69          * @brief: Overloaded Assignment operator of the FormattedText class
70          * @param [const FormatedText&] Reference to an instance of the FormattedText Class.
71          * @return reference to a FormatedText object
72          */
73         FormatedText& operator =(const FormatedText& p);
74
75         //!  A public function which takes in parameters to add text to the text element.
76         /*!@fn AddSimpleText(Tizen::Base::String& text, FontId fontid, Tizen::Graphics::Color& color, Tizen::Graphics::TextHorizontalAlignment halign, Tizen::Graphics::TextVerticalAlignment valign)
77          * @brief A public member taking arguments which are used to configure the text element within the enriched text.
78          * @param [String&, FontId, Color, TextHorizontalAlignment, TextVerticalAlignment] Properties of the text element.
79          * @return No value returned
80          * */
81         void AddSimpleText(Tizen::Base::String& text, FontId fontid, Tizen::Graphics::Color& color, Tizen::Graphics::TextHorizontalAlignment halign, Tizen::Graphics::TextVerticalAlignment valign);
82
83         //!  A public function which takes in parameters to format the text.
84         /*!@fn AddText(Tizen::Base::String& text, FontId fontid, Tizen::Graphics::Color& color)
85          * @brief A public member taking arguments which takes in the values for the properties of the text element.
86          * @param [String&, FontId, Color] Properties of the text element.
87          * @return No value returned
88          * */
89         void AddText(Tizen::Base::String& text, FontId fontid, Tizen::Graphics::Color& color);
90
91         /*
92          * Get total height(px) of all strings
93          */
94         int GetHeight(void);
95
96         /*
97          * Get width(px) of first string
98          */
99         int GetWidth(void);
100
101         //!  A public function which takes in parameters to align the text.
102         /*!@fn SetAlignment(Tizen::Graphics::TextHorizontalAlignment halign, Tizen::Graphics::TextVerticalAlignment valign)
103          * @brief A public member taking arguments which takes in the values for the properties of alignment of the text element.
104          * @param [Tizen::Graphics::TextHorizontalAlignment halign, Tizen::Graphics::TextVerticalAlignment valign] Horizontal and Vertical Alignment of the text.
105          * @return No value returned
106          * */
107         void SetAlignment(Tizen::Graphics::TextHorizontalAlignment halign, Tizen::Graphics::TextVerticalAlignment valign);
108
109         //!  A public function which takes in parameters to set the linespace of the text.
110         /*!@fn SetLineSpace(int gap)
111          * @brief A public member taking arguments which takes in the integer value for the line space.
112          * @param [int] gap, the integer value of the line space of the text.
113          * @return No value returned
114          * */
115         void SetLineSpace(int gap);
116
117         //!  A public function which takes in parameters to set the text wrapping style.
118         /*!@fn SetTextWrap(Tizen::Graphics::TextWrap textWrap)
119          * @brief A public member taking arguments which takes the text wrapping style of the text.
120          * @param [int] gap, the integer value of the line space of the text.
121          * @return No value returned
122          * */
123         void SetTextWrap(Tizen::Graphics::TextWrap textWrap);
124
125         //! A public virtual function which overrides the drawing of the enriched text on the canvas.
126         /*!@fn  OnDraw(Tizen::Graphics::Canvas& canvas, const Tizen::Graphics::Rectangle& rect, Tizen::Ui::Controls::ListItemDrawingStatus status)
127          * @brief A public virtual member taking arguments which draws the text onto the canvas.
128          * @param[Canvas, Rectangle, ListItemDrawingStatus] The canvas with the bounds of the text to be drawn.
129          * @return No value returned
130          * */
131         bool OnDraw(Tizen::Graphics::Canvas& canvas, const Tizen::Graphics::Rectangle& rect, Tizen::Ui::Controls::ListItemDrawingStatus status);
132
133 private:
134         /*!@fn  CreateEnrichedText(Tizen::Graphics::EnrichedText& eText, Tizen::Graphics::Rectangle* rect = NULL, bool textonButton = false)
135          * @brief A private member which creates a new instance of the enriched text.
136          * @param[EnrichedText, Rectangle, textonButton] The reference of the enriched text, the bounds of the text and a boolean value.
137          * @return No value returned
138          * */
139         void CreateEnrichedText(Tizen::Graphics::EnrichedText& eText, Tizen::Graphics::Rectangle* rect = NULL, bool textonButton = false);
140
141         /*!@fn  FreeTextElements(void)
142          * @brief A private member which deletes all the elements of the enriched text.
143          * @param No parameters taken.
144          * @return No value returned
145          * */
146         void FreeTextElements(void);
147
148         int __nCurIdx;
149         int __nLineSpace;
150         int __nWidth;
151
152         bool __bSelectState;
153         bool __bUpdated;
154
155         FontId __font[ID_MAX_TEXT_ITEMS];
156
157         Tizen::Base::String __strText[ID_MAX_TEXT_ITEMS];
158
159         Tizen::Graphics::Bitmap* __pButtonBgNormal;
160         Tizen::Graphics::Bitmap* __pButtonBgSelect;
161         Tizen::Graphics::Color __textColor[ID_MAX_TEXT_ITEMS];
162         Tizen::Graphics::TextElement* __pTElement[ID_MAX_TEXT_ITEMS];
163
164         Tizen::Graphics::TextHorizontalAlignment __halign;
165         Tizen::Graphics::TextVerticalAlignment __valign;
166         Tizen::Graphics::TextWrap __textWrap;
167 };
168
169 #endif //_MF__FORMATED_TEXT_H__