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: IntDropDownCustomItem
20 *@brief: To create Drop Down custom item
25 #include <FUiControls.h>
27 #include "IntCommonLib.h"
28 #include "IntDropDownCustomItem.h"
31 using namespace Tizen::App;
32 using namespace Tizen::Base;
33 using namespace Tizen::Graphics;
34 using namespace Tizen::Ui::Controls;
36 static const wchar_t* IDB_LIST_EXPAND_CLOSED = L"00_button_expand_closed.png";
37 static const wchar_t* IDB_LIST_EXPAND_CLOSED_PRESS = L"00_button_expand_closed_press.png";
38 static const wchar_t* IDB_LIST_EXPAND_OPENED = L"00_button_expand_opened.png";
39 static const wchar_t* IDB_LIST_EXPAND_OPENED_PRESS = L"00_button_expand_opened_press.png";
41 const int DropDownCustomItem::IDA_FORMAT_BITMAP = 101;
42 const int DropDownCustomItem::IDA_FORMAT_MAIN_STRING = 102;
43 const int DropDownCustomItem::IDA_FORMAT_SUB_STRING = 103;
44 const int DropDownCustomItem::IDA_FORMAT_DROPPER = 104;
47 DropDownCustomItem::DropDownCustomItem(void)
53 __currentState = DROP_DOWN__ITEM_STATE_CLOSED;
56 DropDownCustomItem::~DropDownCustomItem(void)
62 DropDownCustomItem::Construct(int width)
66 __fontSize = CommonUtil::GetFontSize();
67 __height = 140 + (__fontSize - 44);
68 Dimension dim(__width, __height);
69 r = CustomItem::Construct(dim, LIST_ANNEX_STYLE_NORMAL);
74 DropDownCustomItem::SetMainText(const Tizen::Base::String& text)
80 DropDownCustomItem::GetMainText(void)
86 DropDownCustomItem::SetSubText(const Tizen::Base::String& text)
92 DropDownCustomItem::GetSubText(void)
98 DropDownCustomItem::Make()
100 AppLogDebug("DropDownCustomItem::Make entered");
101 result r = E_FAILURE;
102 EnrichedText* pMainEnText = null;
103 EnrichedText* pSubEnText = null;
104 TextElement* pMainTextElement = null;
105 TextElement* pSubTextElement = null;
108 Tizen::Graphics::Bitmap* pDropperBitmapNormal = null;
109 Tizen::Graphics::Bitmap* pDropperBitmapPressed = null;
111 pMainEnText = new(std::nothrow) EnrichedText();
112 r = pMainEnText->Construct(Dimension(__width - 80, 54 + (__fontSize - 44)));
119 pMainTextElement = new(std::nothrow) TextElement();
120 pMainTextElement->Construct(__mainText);
122 mainTextFont.Construct(FONT_STYLE_BOLD, __fontSize);
124 Color pressedTextColor = CUSTOM_COLOR_LISTVIEW_TEXT;
125 pMainTextElement->SetFont(mainTextFont);
126 pMainTextElement->SetTextColor(CUSTOM_COLOR_TRANSPARENT);
127 pMainEnText->Add(*pMainTextElement);
129 pSubEnText = new(std::nothrow) EnrichedText();
130 r = pSubEnText->Construct(Dimension(__width - 80, 42));
133 pMainEnText->RemoveAll(true);
139 pSubTextElement = new(std::nothrow) TextElement();
140 r = pSubTextElement->Construct(__subText);
143 pMainEnText->RemoveAll(true);
146 delete pSubTextElement;
151 subTextFont.Construct(FONT_STYLE_PLAIN, 32);
153 pSubTextElement->SetFont(subTextFont);
154 pSubTextElement->SetTextColor(CUSTOM_COLOR_GREY);
155 pSubEnText->Add(*pSubTextElement);
157 r = AddElement(Rectangle(26, 22, __width - 126, 72 + (__fontSize - 44)), IDA_FORMAT_MAIN_STRING, *pMainEnText);
158 r = AddElement(Rectangle(26, 76 + (__fontSize - 44), __width - 126, 42), IDA_FORMAT_SUB_STRING, *pSubEnText);
161 pMainEnText->RemoveAll(true);
162 pSubEnText->RemoveAll(true);
167 AppResource* pAppResource = UiApp::GetInstance()->GetAppResource();
170 if (GetCurState() == DROP_DOWN__ITEM_STATE_CLOSED)
172 pDropperBitmapNormal = pAppResource->GetBitmapN(IDB_LIST_EXPAND_CLOSED, BITMAP_PIXEL_FORMAT_ARGB8888);
173 pDropperBitmapPressed = pAppResource->GetBitmapN(IDB_LIST_EXPAND_CLOSED_PRESS, BITMAP_PIXEL_FORMAT_ARGB8888);
177 pDropperBitmapNormal = pAppResource->GetBitmapN(IDB_LIST_EXPAND_OPENED, BITMAP_PIXEL_FORMAT_ARGB8888);
178 pDropperBitmapPressed = pAppResource->GetBitmapN(IDB_LIST_EXPAND_OPENED_PRESS, BITMAP_PIXEL_FORMAT_ARGB8888);
181 AddElement(Rectangle(__width - pDropperBitmapNormal->GetWidth() - 12, (__height - pDropperBitmapNormal->GetHeight()) / 2 + (__fontSize - 44)/2, pDropperBitmapNormal->GetWidth(), pDropperBitmapNormal->GetHeight()), IDA_FORMAT_DROPPER, *pDropperBitmapNormal, pDropperBitmapNormal, pDropperBitmapNormal);
182 delete pDropperBitmapNormal;
183 delete pDropperBitmapPressed;
186 // SetElementSelectionEnabled(IDA_FORMAT_MAIN_STRING, true);
187 // SetElementSelectionEnabled(IDA_FORMAT_SUB_STRING, true);
188 // SetElementSelectionEnabled(IDA_FORMAT_DROPPER, true);
190 pSubEnText->RemoveAllTextElements(true);
191 pMainEnText->RemoveAllTextElements(true);
200 DropDownCustomItem::GetCurState(void)
202 return __currentState;
206 DropDownCustomItem::SetCurState(DropDownItemState state)
208 __currentState = state;