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