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 ClkDropDownCustomItem
20 *@brief To create Drop Down custom item
26 #include <FGraphics.h>
27 #include <FUiControls.h>
29 #include "ClkDropdownAndRepeatCustomItem.h"
32 using namespace Tizen::App;
33 using namespace Tizen::Base;
34 using namespace Tizen::Graphics;
35 using namespace Tizen::Ui::Controls;
37 static const int IDA_FORMAT_MAIN_STRING = 101;
38 static const int IDA_FORMAT_SUB_STRING = 102;
39 static const int IDA_FORMAT_DROPPER = 103;
41 DropdownAndRepeatCustomItem::DropdownAndRepeatCustomItem(void)
42 : currentState(DROP_DOWN_AND_REPEAT_ITEM_STATE_CLOSED)
52 DropdownAndRepeatCustomItem::~DropdownAndRepeatCustomItem(void)
58 DropdownAndRepeatCustomItem::Construct(int width)
63 Dimension dim(__width, __height);
64 r = CustomItem::Construct(dim, LIST_ANNEX_STYLE_NORMAL);
69 DropdownAndRepeatCustomItem::SetMainText(const String& text)
75 DropdownAndRepeatCustomItem::GetMainText(void) const
81 DropdownAndRepeatCustomItem::SetSubText(const String& text)
87 DropdownAndRepeatCustomItem::GetSubText(void) const
93 DropdownAndRepeatCustomItem::SetRepeatFlags(const String& flag)
99 DropdownAndRepeatCustomItem::GetRepeatFlag(void) const
101 return __repeatFlags;
105 DropdownAndRepeatCustomItem::MakeElements()
107 AppLogDebug("DropDownCustomItem::Make entered");
108 result r = E_FAILURE;
109 EnrichedText* pMainEnText = null;
110 EnrichedText* pSubEnText = null;
111 TextElement* pMainTextElement = null;
112 TextElement* pSubTextElement = null;
113 Font* pMainTextFont = null;
114 Font* pSubTextFont = null;
115 AppResource* pAppResource = null;
116 Bitmap* pDropperBitmapNormal = null;
117 Bitmap* pDropperBitmapPressed = null;
118 Color textColor = Color(0, 0, 0);
119 Color pressedTextColor = Color(249, 249, 249);
122 int subTextFont = 32;
123 int repeatFlagX = 26;
124 int characterGap = 37;
125 int repeatFlagY = 75;
126 int repeatFlagWidth = 32;
127 int repeatFlagHeight = 48;
128 int repeatFlagFont = 32;
129 int mainStringX = 26;
130 int mainStringY = 25;
131 int mainStringWidth = 80;
132 int mainStringHeight = 60;
135 int dropperWidth = 64;
136 int dropperHeight = 64;
137 pMainEnText = new (std::nothrow) EnrichedText();
139 if (pMainEnText == null)
144 pMainEnText->Construct(Dimension(__width - xText, yText));
146 pMainTextElement = new (std::nothrow) TextElement();
148 if (pMainTextElement == null)
153 pMainTextElement->Construct(__mainText);
155 pMainTextFont = new (std::nothrow) Font();
157 if (pMainTextFont == null)
162 pMainTextFont->Construct(FONT_STYLE_PLAIN, yText);
164 pMainTextElement->SetFont(*pMainTextFont);
165 pMainTextElement->SetTextColor(textColor);
166 pMainEnText->Add(*pMainTextElement);
168 pSubEnText = new (std::nothrow) EnrichedText();
170 if (pSubEnText == null)
175 pSubEnText->Construct(Dimension(__width - xText, yText));
177 pSubTextElement = new (std::nothrow) TextElement();
179 if (pSubTextElement == null)
184 __subText.Insert('\n',0);
185 pSubTextElement->Construct(__subText);
187 pSubTextFont = new (std::nothrow) Font();
189 if (pSubTextFont == null)
194 pSubTextFont->Construct(FONT_STYLE_PLAIN, subTextFont);
196 pSubTextElement->SetFont(*pSubTextFont);
197 pSubTextElement->SetTextColor(Color(128, 128, 128));
198 pMainEnText->Add(*pSubTextElement);
200 for (int i = 0; i < 7 ; i++)
202 AppLogDebug("inside for loop");
206 GetRepeatFlag().GetCharAt(i, ch);
207 AppLogDebug("the flag is %ls",GetRepeatFlag().GetPointer());
211 textColor = Color::GetColor(COLOR_ID_BLUE);
212 AppLogDebug("color is blue");
216 textColor = Color(124,124,124);
244 AppLogDebug("the string is %ls", flag.GetPointer());
245 r = AddElement(Rectangle(repeatFlagX + i*characterGap, repeatFlagY, repeatFlagWidth, repeatFlagHeight), i, flag, repeatFlagFont, textColor, textColor, textColor, true);
246 AppLogDebug("the last result %s", GetErrorMessage(r));
248 r = AddElement(Rectangle(mainStringX, mainStringY, __width - mainStringWidth, mainStringHeight), IDA_FORMAT_MAIN_STRING, __mainText);
250 pAppResource = UiApp::GetInstance()->GetAppResource();
252 if (pAppResource != null)
255 if (GetCurState() == DROP_DOWN_AND_REPEAT_ITEM_STATE_CLOSED)
257 pDropperBitmapNormal = pAppResource->GetBitmapN(IDB_LIST_EXPAND_CLOSED, BITMAP_PIXEL_FORMAT_ARGB8888);
258 pDropperBitmapPressed = pAppResource->GetBitmapN(IDB_LIST_EXPAND_CLOSED_PRESS, BITMAP_PIXEL_FORMAT_ARGB8888);
262 pDropperBitmapNormal = pAppResource->GetBitmapN(IDB_LIST_EXPAND_OPENED, BITMAP_PIXEL_FORMAT_ARGB8888);
263 pDropperBitmapPressed = pAppResource->GetBitmapN(IDB_LIST_EXPAND_OPENED_PRESS, BITMAP_PIXEL_FORMAT_ARGB8888);
266 AddElement(Rectangle(__width - dropperX, (__height - dropperY) / 2, dropperWidth, dropperHeight), IDA_FORMAT_DROPPER, *pDropperBitmapNormal, pDropperBitmapPressed, pDropperBitmapNormal);
267 delete pDropperBitmapNormal;
268 delete pDropperBitmapPressed;
271 SetElementSelectionEnabled(IDA_FORMAT_MAIN_STRING, true);
272 SetElementSelectionEnabled(IDA_FORMAT_SUB_STRING, true);
273 SetElementSelectionEnabled(IDA_FORMAT_DROPPER, true);
275 if (pMainTextFont != null)
277 delete pMainTextFont;
278 pMainTextFont = null;
281 if (pSubTextFont != null)
287 if (pSubEnText != null)
289 pSubEnText->RemoveAllTextElements(true);
294 if (pMainEnText != null)
296 pMainEnText->RemoveAllTextElements(true);
304 DropDownAndRepeatItemState
305 DropdownAndRepeatCustomItem::GetCurState(void) const
311 DropdownAndRepeatCustomItem::SetCurState(const DropDownAndRepeatItemState state)
313 currentState = state;