2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
8 // http://floralicense.org/license/
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.
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.
23 #ifndef _MF_FORMATED_TEXT_H_
24 #define _MF_FORMATED_TEXT_H_
28 #include <FGraphics.h>
34 #include "MfFontManager.h"
38 : public Tizen::Ui::Controls::ICustomElement
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);
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
56 FormatedText(const FormatedText& p);
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
67 * Overloaded Assignment operator of the FormattedText class
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
73 FormatedText& operator =(const FormatedText& p);
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
81 void AddSimpleText(Tizen::Base::String& text, FontId fontid, Tizen::Graphics::Color& color, Tizen::Graphics::TextHorizontalAlignment halign, Tizen::Graphics::TextVerticalAlignment valign);
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
89 void AddText(Tizen::Base::String& text, FontId fontid, Tizen::Graphics::Color& color);
92 * Get total height(px) of all strings
97 * Get width(px) of first string
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
107 void SetAlignment(Tizen::Graphics::TextHorizontalAlignment halign, Tizen::Graphics::TextVerticalAlignment valign);
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
115 void SetLineSpace(int gap);
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
123 void SetTextWrap(Tizen::Graphics::TextWrap textWrap);
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
131 bool OnDraw(Tizen::Graphics::Canvas& canvas, const Tizen::Graphics::Rectangle& rect, Tizen::Ui::Controls::ListItemDrawingStatus status);
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
139 void CreateEnrichedText(Tizen::Graphics::EnrichedText& eText, Tizen::Graphics::Rectangle* rect = NULL, bool textonButton = false);
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
146 void FreeTextElements(void);
155 FontId __font[ID_MAX_TEXT_ITEMS];
157 Tizen::Base::String __strText[ID_MAX_TEXT_ITEMS];
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];
164 Tizen::Graphics::TextHorizontalAlignment __halign;
165 Tizen::Graphics::TextVerticalAlignment __valign;
166 Tizen::Graphics::TextWrap __textWrap;
169 #endif //_MF__FORMATED_TEXT_H__