3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.0 (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 "IntDropDownCustomItem.h"
30 using namespace Tizen::App;
31 using namespace Tizen::Base;
32 using namespace Tizen::Graphics;
33 using namespace Tizen::Ui::Controls;
35 static const wchar_t* IDB_LIST_EXPAND_CLOSED = L"00_circle_button_Expand_closed.png";
36 static const wchar_t* IDB_LIST_EXPAND_CLOSED_PRESS = L"00_list_expand_closed_press.png";
37 static const wchar_t* IDB_LIST_EXPAND_OPENED = L"00_circle_button_Expand_open.png";
38 static const wchar_t* IDB_LIST_EXPAND_OPENED_PRESS = L"00_list_expand_opened_press.png";
40 const int DropDownCustomItem::IDA_FORMAT_BITMAP = 101;
41 const int DropDownCustomItem::IDA_FORMAT_MAIN_STRING = 102;
42 const int DropDownCustomItem::IDA_FORMAT_SUB_STRING = 103;
43 const int DropDownCustomItem::IDA_FORMAT_DROPPER = 104;
46 DropDownCustomItem::DropDownCustomItem(void)
52 __currentState = DROP_DOWN__ITEM_STATE_CLOSED;
55 DropDownCustomItem::~DropDownCustomItem(void)
61 DropDownCustomItem::Construct(int width)
66 Dimension dim(__width, __height);
67 r = CustomItem::Construct(dim, LIST_ANNEX_STYLE_NORMAL);
72 DropDownCustomItem::SetMainText(const Tizen::Base::String& text)
78 DropDownCustomItem::GetMainText(void)
84 DropDownCustomItem::SetSubText(const Tizen::Base::String& text)
90 DropDownCustomItem::GetSubText(void)
96 DropDownCustomItem::Make()
98 AppLogDebug("DropDownCustomItem::Make entered");
100 EnrichedText* pMainEnText = null;
101 EnrichedText* pSubEnText = null;
102 TextElement* pMainTextElement = null;
103 TextElement* pSubTextElement = null;
106 Tizen::Graphics::Bitmap* pDropperBitmapNormal = null;
107 Tizen::Graphics::Bitmap* pDropperBitmapPressed = null;
109 pMainEnText = new(std::nothrow) EnrichedText();
110 r = pMainEnText->Construct(Dimension(__width - 80, 54));
117 pMainTextElement = new(std::nothrow) TextElement();
118 pMainTextElement->Construct(__mainText);
120 mainTextFont.Construct(FONT_STYLE_BOLD, 44);
122 Color pressedTextColor = CUSTOM_COLOR_LISTVIEW_TEXT;
123 pMainTextElement->SetFont(mainTextFont);
124 pMainTextElement->SetTextColor(CUSTOM_COLOR_TRANSPARENT);
125 pMainEnText->Add(*pMainTextElement);
127 pSubEnText = new(std::nothrow) EnrichedText();
128 r = pSubEnText->Construct(Dimension(__width - 80, 42));
131 pMainEnText->RemoveAll(true);
137 pSubTextElement = new(std::nothrow) TextElement();
138 pSubTextElement->Construct(__subText);
141 subTextFont.Construct(FONT_STYLE_PLAIN, 32);
143 pSubTextElement->SetFont(subTextFont);
144 pSubTextElement->SetTextColor(CUSTOM_COLOR_GREY);
145 pSubEnText->Add(*pSubTextElement);
147 r = AddElement(Rectangle(26, 22, __width - 126, 54), IDA_FORMAT_MAIN_STRING, *pMainEnText);
148 r = AddElement(Rectangle(26, 76, __width - 126, 42), IDA_FORMAT_SUB_STRING, *pSubEnText);
151 pMainEnText->RemoveAll(true);
152 pSubEnText->RemoveAll(true);
157 AppResource* pAppResource = UiApp::GetInstance()->GetAppResource();
160 if (GetCurState() == DROP_DOWN__ITEM_STATE_CLOSED)
162 pDropperBitmapNormal = pAppResource->GetBitmapN(IDB_LIST_EXPAND_CLOSED, BITMAP_PIXEL_FORMAT_ARGB8888);
163 pDropperBitmapPressed = pAppResource->GetBitmapN(IDB_LIST_EXPAND_CLOSED_PRESS, BITMAP_PIXEL_FORMAT_ARGB8888);
167 pDropperBitmapNormal = pAppResource->GetBitmapN(IDB_LIST_EXPAND_OPENED, BITMAP_PIXEL_FORMAT_ARGB8888);
168 pDropperBitmapPressed = pAppResource->GetBitmapN(IDB_LIST_EXPAND_OPENED_PRESS, BITMAP_PIXEL_FORMAT_ARGB8888);
171 AddElement(Rectangle(__width - pDropperBitmapNormal->GetWidth() - 12, (__height - 74) / 2, 74, 74), IDA_FORMAT_DROPPER, *pDropperBitmapNormal, pDropperBitmapNormal, pDropperBitmapNormal);
172 delete pDropperBitmapNormal;
173 delete pDropperBitmapPressed;
176 // SetElementSelectionEnabled(IDA_FORMAT_MAIN_STRING, true);
177 // SetElementSelectionEnabled(IDA_FORMAT_SUB_STRING, true);
178 // SetElementSelectionEnabled(IDA_FORMAT_DROPPER, true);
180 pSubEnText->RemoveAllTextElements(true);
181 pMainEnText->RemoveAllTextElements(true);
190 DropDownCustomItem::GetCurState(void)
192 return __currentState;
196 DropDownCustomItem::SetCurState(DropDownItemState state)
198 __currentState = state;