Tizen 2.0 Release
[apps/osp/Internet.git] / src / IntRadioCustomItem.cpp
1 //
2
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 //     http://floralicense.org/license/
10 //
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.
16 //
17
18 //!Internet RadioCustomItem class
19 /*@file:        RadioCustomItem.cpp
20  *@brief:       The RadioCustomItem
21  */
22 #include <FApp.h>
23 #include <FUiControls.h>
24
25 #include "IntRadioCustomItem.h"
26
27 using namespace Tizen::App;
28 using namespace Tizen::Base;
29 using namespace Tizen::Graphics;
30 using namespace Tizen::Ui::Controls;
31
32 static const wchar_t* IDB_BUTTON_RADIO_PRESS2 = L"00_button_radio_selected.png";
33 static const wchar_t* IDB_BUTTON_RADIO_PRESS1 = L"00_button_radio.png";
34
35 const int RadioCustomItem::IDA_FORMAT_STRING = 500;
36 const int RadioCustomItem::IDA_FORMAT_RADIO_BUTTON = 501;
37
38 RadioCustomItem::RadioCustomItem(void)
39 {
40         __width = 0;
41         __height = 0;
42         __text = L"";
43         __isSelected = false;
44 }
45
46 RadioCustomItem::~RadioCustomItem(void)
47 {
48
49 }
50
51 result
52 RadioCustomItem::Construct(int width, int height)
53 {
54         result r = E_FAILURE;
55
56         __width = width;
57         __height = height;
58         const Dimension dim(width, height);
59         r = CustomItem::Construct(dim, LIST_ANNEX_STYLE_NORMAL);
60
61         return r;
62 }
63
64 void
65 RadioCustomItem::SetText(Tizen::Base::String& text)
66 {
67         __text = text;
68 }
69
70 String
71 RadioCustomItem::GetText(void)
72 {
73         return __text;
74 }
75
76 result
77 RadioCustomItem::Make(void)
78 {
79         result r = E_FAILURE;
80         Color textColor = CUSTOM_COLOR_LISTVIEW_TEXT2;
81         Color pressedTextColor = CUSTOM_COLOR_LISTVIEW_TEXT;
82         Bitmap* pBitmap = null;
83
84         if (__isSelected == true)
85         {
86                 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_RADIO_PRESS2);
87         }
88         else
89         {
90                 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_RADIO_PRESS1);
91         }
92
93         if ( pBitmap != NULL)
94         {
95                 AddElement(Rectangle(26, (__height-pBitmap->GetHeight())/2, pBitmap->GetWidth(), pBitmap->GetHeight()), IDA_FORMAT_RADIO_BUTTON, *pBitmap, null);
96                 AppLogDebug("RadioCustomItem::the text is %ls",__text.GetPointer());
97
98                 r = AddElement(Rectangle(26 + pBitmap->GetWidth() + 10, 5, __width - 26 - 10 - pBitmap->GetWidth(), __height), IDA_FORMAT_STRING, __text, 40, textColor, textColor, textColor, true);
99                 delete pBitmap;
100         }
101         TryCatch(!IsFailed(r),,"RadioCustomItem::the value is %s",GetErrorMessage(r));
102
103         r = SetElementSelectionEnabled(IDA_FORMAT_STRING, true);
104         TryCatch(!IsFailed(r),,"RadioCustomItem::the value is %s",GetErrorMessage(r));
105
106         CATCH:
107         return r;
108 }
109
110 void
111 RadioCustomItem::SetSelected(bool selectedValue)
112 {
113         __isSelected = selectedValue;
114 }
115
116 bool
117 RadioCustomItem::GetSelected(void)
118 {
119         return __isSelected;
120 }