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: DropDownCustomItem
19 *@brief: To create Drop Down custom item
24 #include <FUiControls.h>
25 #include "GlDropDownCustomItem.h"
28 using namespace Tizen::App;
29 using namespace Tizen::Base;
30 using namespace Tizen::Graphics;
31 using namespace Tizen::Ui::Controls;
33 const int DropDownCustomItem::IDA_FORMAT_BITMAP = 101;
34 const int DropDownCustomItem::IDA_FORMAT_MAIN_STRING = 102;
35 const int DropDownCustomItem::IDA_FORMAT_SUB_STRING = 103;
36 const int DropDownCustomItem::IDA_FORMAT_DROPPER = 104;
38 DropDownCustomItem::DropDownCustomItem(void)
39 : __currentState(DROP_DOWN__ITEM_STATE_CLOSED)
45 DropDownCustomItem::~DropDownCustomItem(void)
50 DropDownCustomItem::Construct(int width)
55 Dimension dim(__width, __height);
56 r = CustomItem::Construct(dim, LIST_ANNEX_STYLE_NORMAL);
61 DropDownCustomItem::SetMainText(const Tizen::Base::String& text)
67 DropDownCustomItem::GetMainText(void)
73 DropDownCustomItem::SetSubText(const Tizen::Base::String& text)
79 DropDownCustomItem::GetSubText(void)
85 DropDownCustomItem::Make()
87 AppLogDebug("DropDownCustomItem::Make entered");
89 EnrichedText* pMainEnText = null;
90 EnrichedText* pSubEnText = null;
91 TextElement* pMainTextElement = null;
92 TextElement* pSubTextElement = null;
95 Tizen::Graphics::Bitmap* pDropperBitmapNormal = null;
96 Tizen::Graphics::Bitmap* pDropperBitmapPressed = null;
98 pMainEnText = new(std::nothrow) EnrichedText();
99 r = pMainEnText->Construct(Dimension(__width - 80, 54));
106 pMainTextElement = new(std::nothrow) TextElement();
107 pMainTextElement->Construct(__mainText);
109 mainTextFont.Construct(FONT_STYLE_BOLD, 44);
111 Color pressedTextColor = CUSTOM_COLOR_LISTVIEW_TEXT;
112 pMainTextElement->SetFont(mainTextFont);
113 pMainTextElement->SetTextColor(CUSTOM_COLOR_TRANSPARENT);
114 pMainEnText->Add(*pMainTextElement);
116 pSubEnText = new(std::nothrow) EnrichedText();
117 r = pSubEnText->Construct(Dimension(__width - 80, 42));
121 pMainEnText->RemoveAll(true);
127 pSubTextElement = new(std::nothrow) TextElement();
128 pSubTextElement->Construct(__subText);
130 subTextFont.Construct(FONT_STYLE_PLAIN, 32);
132 pSubTextElement->SetFont(subTextFont);
133 pSubTextElement->SetTextColor(CUSTOM_COLOR_GREY);
134 pSubEnText->Add(*pSubTextElement);
136 r = AddElement(Rectangle(26, 22, __width - 126, 54), IDA_FORMAT_MAIN_STRING, *pMainEnText);
137 r = AddElement(Rectangle(26, 76, __width - 126, 42), IDA_FORMAT_SUB_STRING, *pSubEnText);
140 pMainEnText->RemoveAll(true);
141 pSubEnText->RemoveAll(true);
146 AppResource* pAppResource = UiApp::GetInstance()->GetAppResource();
149 if (GetCurState() == DROP_DOWN__ITEM_STATE_CLOSED)
151 pDropperBitmapNormal = pAppResource->GetBitmapN(IDB_LIST_EXPAND_CLOSED, BITMAP_PIXEL_FORMAT_ARGB8888);
152 pDropperBitmapPressed = pAppResource->GetBitmapN(IDB_LIST_EXPAND_CLOSED_PRESS, BITMAP_PIXEL_FORMAT_ARGB8888);
156 pDropperBitmapNormal = pAppResource->GetBitmapN(IDB_LIST_EXPAND_OPENED, BITMAP_PIXEL_FORMAT_ARGB8888);
157 pDropperBitmapPressed = pAppResource->GetBitmapN(IDB_LIST_EXPAND_OPENED_PRESS, BITMAP_PIXEL_FORMAT_ARGB8888);
160 AddElement(Rectangle(__width - 95, (__height - 74) / 2, 74, 74), IDA_FORMAT_DROPPER, *pDropperBitmapNormal, pDropperBitmapPressed, pDropperBitmapNormal);
161 delete pDropperBitmapNormal;
162 delete pDropperBitmapPressed;
165 SetElementSelectionEnabled(IDA_FORMAT_MAIN_STRING, true);
166 SetElementSelectionEnabled(IDA_FORMAT_SUB_STRING, true);
167 SetElementSelectionEnabled(IDA_FORMAT_DROPPER, true);
169 pSubEnText->RemoveAllTextElements(true);
170 pMainEnText->RemoveAllTextElements(true);
179 DropDownCustomItem::GetCurState(void)
181 return __currentState;
185 DropDownCustomItem::SetCurState(DropDownItemState state)
187 __currentState = state;