3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.1 (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
9 // http://floralicense.org/license/
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.
19 * @file ClkDefaultCustomItem
20 * @brief This header file contains the declarations of the DefaultCustomItem
24 #include <FUiControls.h>
25 #include "ClkDefaultCustomItem.h"
27 using namespace Tizen::Base;
28 using namespace Tizen::Graphics;
29 using namespace Tizen::Ui::Controls;
31 static const int IDA_FORMAT_STRING = 101;
32 static const int IDA_FORMAT_SUB_STRING = 102;
33 static const int IDA_FORMAT_RIGHT_SUB_STRING = 103;
35 DefaultCustomItem::DefaultCustomItem(void)
44 DefaultCustomItem::~DefaultCustomItem(void)
50 DefaultCustomItem::Construct(int width, int fontsize)
54 __height = 128 + fontsize - 44;
55 const Dimension dim(width, __height);
56 r = CustomItem::Construct(dim, LIST_ANNEX_STYLE_NORMAL);
62 DefaultCustomItem::SetText(String& text)
68 DefaultCustomItem::GetText(void)
74 DefaultCustomItem::SetSubText(String& text)
77 __subText.Append(text);
81 DefaultCustomItem::GetSubText(void)
87 DefaultCustomItem::SetRightSubText(String& text)
89 __rightSubText.Clear();
90 __rightSubText.Append(text);
94 DefaultCustomItem::GetRightSubText(void)
96 return __rightSubText;
101 DefaultCustomItem::Make(int fontSize)
103 result r = E_SUCCESS;
105 EnrichedText* pMainEnText = null;
106 EnrichedText* pSubEnText = null;
107 TextElement* pMainTextElement = null;
108 TextElement* pSubTextElement = null;
109 Font* pMainTextFont = null;
110 Font* pSubTextFont = null;
111 int mainTextFont = 32;
112 int subTextFont = fontSize;
117 int width_Element = __width - 60;
118 int width_text = width_Element;
119 int width_rightSubText = 0;
120 int stringHeight = 60;
121 int subStringHeight = 62 + fontSize - 44;
122 int subStringFont = 44;
123 Color textColor = Color(128, 128, 128);
124 Color pressedTextColor = Color(255, 255, 255);
126 pMainEnText = new (std::nothrow) EnrichedText();
128 if (pMainEnText == null)
133 pMainEnText->Construct(Dimension(__width - textX, textY));
135 pMainTextElement = new (std::nothrow) TextElement();
136 pMainTextElement->Construct(__text);
138 pMainTextFont = new (std::nothrow) Font();
140 if (pMainTextFont == null)
145 pMainTextFont->Construct(FONT_STYLE_BOLD, mainTextFont);
147 pMainTextElement->SetFont(*pMainTextFont);
148 pMainTextElement->SetTextColor(textColor);
149 pMainEnText->Add(*pMainTextElement);
152 if (__rightSubText != L"")
154 width_rightSubText = 200;
155 width_text = width_Element - width_rightSubText - 16;
158 r = AddElement(Rectangle(xMargin, yMargin, width_text, stringHeight), IDA_FORMAT_STRING, *pMainEnText);
159 //r = AddElement(Rectangle(xMargin, yMargin, width_text, stringHeight), IDA_FORMAT_STRING, __text, textSize, textColor, pressedTextColor, pressedTextColor, true);
160 //TryCatch( !IsFailed(r),L"DefaultCustomItem::Make %s",GetErrorMessage(r));
162 if (__subText != L"")
164 pSubEnText = new (std::nothrow) EnrichedText();
166 if (pSubEnText == null)
171 pSubEnText->Construct(Dimension(__width - textX, textY));
173 pSubTextElement = new (std::nothrow) TextElement();
174 pSubTextElement->Construct(__subText);
176 pSubTextFont = new (std::nothrow) Font();
178 if (pSubTextFont == null)
183 pSubTextFont->Construct(FONT_STYLE_PLAIN, subTextFont);
185 pSubTextElement->SetFont(*pSubTextFont);
186 pSubTextElement->SetTextColor(Color(0, 0, 0));
187 pSubEnText->Add(*pSubTextElement);
189 r = AddElement(Rectangle(xMargin, yMargin + stringHeight -20, width_Element, subStringHeight), IDA_FORMAT_SUB_STRING, *pSubEnText);
192 if (__rightSubText != L"")
194 r = AddElement(Rectangle(xMargin + width_text + 16, yMargin, width_rightSubText, subStringHeight), IDA_FORMAT_RIGHT_SUB_STRING, __rightSubText, subStringFont, Color(128,128,128), pressedTextColor, pressedTextColor, true);
197 // SetElementSelectionEnabled(IDA_FORMAT_STRING, true);
198 // SetElementSelectionEnabled(IDA_FORMAT_SUB_STRING, true);
200 if (pMainTextFont != null)
202 delete pMainTextFont;
203 pMainTextFont = null;
206 if (pSubTextFont != null)
212 if (pSubEnText != null)
214 pSubEnText->RemoveAllTextElements(true);
219 if (pMainEnText != null)
221 pMainEnText->RemoveAllTextElements(true);