NABI_SE issues resolved
[apps/osp/MyFiles.git] / src / MfContentListItem.cpp
1 //\r
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.\r
3 //\r
4 // Licensed under the Flora License, Version 1.1 (the License);\r
5 // you may not use this file except in compliance with the License.\r
6 // You may obtain a copy of the License at\r
7 //\r
8 //     http://floralicense.org/license/\r
9 //\r
10 // Unless required by applicable law or agreed to in writing, software\r
11 // distributed under the License is distributed on an AS IS BASIS,\r
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
13 // See the License for the specific language governing permissions and\r
14 // limitations under the License.\r
15 //\r
16 \r
17 /**\r
18  * @file: MfContentListViewItem.cpp\r
19  * @brief: This file contains implementation of ContentListItem class, which is used to\r
20  * customize and personalize the Listview elements.\r
21  */\r
22 \r
23 #include "MfContentListItem.h"\r
24 #include "MfMyFilesApp.h"\r
25 \r
26 using namespace Tizen::App;\r
27 using namespace Tizen::Base;\r
28 using namespace Tizen::Base::Collection;\r
29 using namespace Tizen::Base::Utility;\r
30 using namespace Tizen::Graphics;\r
31 using namespace Tizen::Media;\r
32 using namespace Tizen::System;\r
33 using namespace Tizen::Ui;\r
34 using namespace Tizen::Ui::Controls;\r
35 \r
36 ContentListItem::ContentListItem(int nWidth, int nHeight, bool isSearchedtextPresent)\r
37 {\r
38         AppLogDebug("Entry");\r
39         COLOR_TITLE = Color::GetColor(COLOR_ID_BLACK);\r
40         COLOR_DATE = Color(124, 124, 124);\r
41         __contentTitle = L"";\r
42         __creationDate = L"";\r
43         __descriptionText = L"";\r
44         __filepath = L"";\r
45         __searchedText = L"";\r
46 \r
47         __itemWidth = nWidth;\r
48         __itemHeight = nHeight;\r
49         __pBg = null;\r
50         __pThumbnailBitmap = null;\r
51         __pFtTitle = null;\r
52 \r
53         __titleRect.SetBounds(0, 0, 0, 0);\r
54         __thumbnailRect.SetBounds(0, 0, 0, 0);\r
55 \r
56         __detailedListDateRect.SetBounds(0, 0, 0, 0);\r
57         __detailedListDescriptionRect.SetBounds(0, 0, 0, 0);\r
58         __detailedListThumbnailRect.SetBounds(0, 0, 0, 0);\r
59 \r
60         __detailedListTitleRect.SetBounds(0, 0, 0, 0);\r
61 \r
62         __pRenameBitmap = null;\r
63         __pPlayBitmap = null;\r
64         __pPauseBitmap = null;\r
65 \r
66         __editRenameRect.SetBounds(0, 0, 0, 0);\r
67         __editDateRect.SetBounds(0, 0, 0, 0);\r
68         __editPlayRect.SetBounds(0, 0, 0, 0);\r
69         __editPauseRect.SetBounds(0, 0, 0, 0);\r
70 \r
71         __isSearchedTextPresent = isSearchedtextPresent;\r
72         __searchedText = L"";\r
73 \r
74         __pFtDescriptionText = null;\r
75         __pFtCreationDate = null;\r
76         AppLogDebug("Exit %s", GetErrorMessage(GetLastResult()));\r
77 \r
78 }\r
79 \r
80 ContentListItem::~ContentListItem(void)\r
81 {\r
82         AppLogDebug("Entry");\r
83 \r
84         if (__pFtTitle != null)\r
85         {\r
86                 delete __pFtTitle;\r
87         }\r
88         if (__pFtDescriptionText != null)\r
89         {\r
90                 delete __pFtDescriptionText;\r
91         }\r
92         if (__pFtCreationDate != null)\r
93         {\r
94                 delete __pFtCreationDate;\r
95         }\r
96         if (__pBg != null)\r
97         {\r
98                 delete __pBg;\r
99         }\r
100 #if 0\r
101         if (__pThumbnailBitmap != null)\r
102         {\r
103                 delete __pThumbnailBitmap;\r
104         }\r
105 #endif\r
106 \r
107         /*if (__pPlayBitmap != null)\r
108         {\r
109             delete __pPlayBitmap;\r
110         }\r
111 \r
112         if (__pPauseBitmap != null)\r
113         {\r
114             delete __pPauseBitmap;\r
115         }*/\r
116 \r
117         RemoveAllElements();            //Code to remove CustomItem elements.\r
118 \r
119         AppLogDebug("ContentListItem::~ContentListItem()");\r
120 }\r
121 \r
122 ContentListItem&\r
123 ContentListItem::operator =(const ContentListItem& contentListItem)\r
124 {\r
125         return *this;\r
126 }\r
127 \r
128 ContentListItem::ContentListItem(const ContentListItem& contentListItem)\r
129 {\r
130         //Do Nothing\r
131 }\r
132 \r
133 void\r
134 ContentListItem::Refresh(void)\r
135 {\r
136         AppLogDebug("Entry");\r
137         int thumbnailX = X_LISTVIEW;\r
138         int normalGap = X_LISTVIEW;\r
139         int thumbnailWidth = W_LISTVIEW_ITEM_BITMAP;\r
140         int nMultiTextWidth = __itemWidth - thumbnailX - thumbnailWidth - 2 * normalGap;\r
141 \r
142         if (__pThumbnailBitmap != null)\r
143         {\r
144                 AddElement(__thumbnailRect, CONTENT_LIST_ITEM_TYPE_THUMBNAIL, *__pThumbnailBitmap, __pThumbnailBitmap, __pThumbnailBitmap);\r
145         }\r
146 \r
147         // Title\r
148         __pFtTitle = new (std::nothrow) FormatedText(nMultiTextWidth);\r
149         if (__pFtTitle == null)\r
150                 return;\r
151 \r
152         __pFtTitle->SetTextWrap(TEXT_WRAP_NONE);\r
153         __pFtTitle->AddText(__contentTitle, FONT_MAIN, COLOR_TITLE);\r
154 \r
155         AddElement(__titleRect, CONTENT_LIST_ITEM_TYPE_TITLE, *__pFtTitle);\r
156         AppLogDebug("Exit %s", GetErrorMessage(GetLastResult()));\r
157 }\r
158 \r
159 void\r
160 ContentListItem::GetItemSize(int& itemHeight, int& titleHeight)\r
161 {\r
162         AppLogDebug("Entry");\r
163         int y = X_LISTVIEW;\r
164         titleHeight = 0;\r
165         titleHeight = GetTitleHeight(__contentTitle);\r
166 \r
167         //Calculate Y position of Description\r
168         y += H_LISTVIEW_ITEM_BITMAP;\r
169         y += 2 * X_LISTVIEW; //Gap of 20 between title and content\r
170 \r
171         itemHeight = H_ITEM_LISTVIEW;\r
172         AppLogDebug("Exit %s", GetErrorMessage(GetLastResult()));\r
173 }\r
174 void\r
175 ContentListItem::MakePlainTitleItem(void)\r
176 {\r
177         //__itemHeight = 0;\r
178         int titleHeight = 0;\r
179         int w_Title = __itemWidth - ((W_LISTVIEW_ITEM_BITMAP * 4) + (4 * X_LISTVIEW));\r
180 \r
181         GetItemSize(__itemHeight, titleHeight);\r
182 \r
183         Construct(Dimension(__itemWidth, __itemHeight), LIST_ANNEX_STYLE_MARK);\r
184         SetElementTextVerticalAlignment(CONTENT_LIST_ITEM_TYPE_TITLE, ALIGNMENT_MIDDLE);\r
185 \r
186         __titleRect.SetBounds(X_LISTVIEW, (__itemHeight - titleHeight) / 2, w_Title, 60);\r
187 \r
188         Refresh();\r
189 \r
190 }\r
191 void\r
192 ContentListItem::Make(int indent)\r
193 {\r
194         AppLogDebug("Entry");\r
195         __itemHeight = 0;\r
196         int titleHeight = 0;\r
197 \r
198         GetItemSize(__itemHeight, titleHeight);\r
199 \r
200         Construct(Dimension(__itemWidth, __itemHeight), LIST_ANNEX_STYLE_NORMAL);\r
201         SetElementTextVerticalAlignment(CONTENT_LIST_ITEM_TYPE_TITLE, ALIGNMENT_MIDDLE);\r
202 \r
203         CreateFormatRectangle(__itemHeight, titleHeight, indent);\r
204         Refresh();\r
205         AppLogDebug("Exit %s", GetErrorMessage(GetLastResult()));\r
206 }\r
207 \r
208 void\r
209 ContentListItem::MakeFileManageFormListItem(void)\r
210 {\r
211         AppLogDebug("Entry");\r
212         int titleHeight = 0;\r
213         GetItemSize(__itemHeight, titleHeight);\r
214 \r
215         Construct(Dimension(__itemWidth, __itemHeight), LIST_ANNEX_STYLE_MARK);\r
216 \r
217         //SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_PRESSED, Color::GetColor(COLOR_ID_WHITE));\r
218         SetElementTextVerticalAlignment(CONTENT_LIST_ITEM_TYPE_THUMBNAIL, ALIGNMENT_MIDDLE);\r
219         SetElementTextVerticalAlignment(CONTENT_LIST_ITEM_TYPE_DATE, ALIGNMENT_BOTTOM);\r
220         SetElementTextVerticalAlignment(CONTENT_LIST_ITEM_TYPE_RENAME, ALIGNMENT_MIDDLE);\r
221 \r
222         CreateFormatRectangleForFileManageForm(__itemHeight, titleHeight);\r
223         RefreshFileManageFormListItem();\r
224 \r
225         AppLogDebug("Exit %s", GetErrorMessage(GetLastResult()));\r
226 }\r
227 \r
228 void\r
229 ContentListItem::CreateFormatRectangle(int itemHeight, int textHeight, int indent)\r
230 {\r
231         AppLogDebug("Entry");\r
232         int thumbnailX = X_LISTVIEW * indent;\r
233         int thumbnailY = X_LISTVIEW;\r
234 \r
235         int normalGap = X_LISTVIEW;\r
236         int thumbnailWidth = W_LISTVIEW_ITEM_BITMAP;\r
237         int thumbnailHeight = H_LISTVIEW_ITEM_BITMAP;\r
238 \r
239         int width = __itemWidth;\r
240         int w_Title = width - (W_LISTVIEW_ITEM_BITMAP + 3 * X_LISTVIEW);\r
241 \r
242         __thumbnailRect.SetBounds(thumbnailX, thumbnailY, thumbnailWidth, thumbnailHeight); //right side width:20\r
243 \r
244         if (!__creationDate.IsEmpty())\r
245         {\r
246                 SetElementTextVerticalAlignment(CONTENT_LIST_ITEM_TYPE_TITLE, ALIGNMENT_MIDDLE);\r
247                 __titleRect.SetBounds(thumbnailX + thumbnailWidth + normalGap, thumbnailY, w_Title, H_LISTVIEW_ITEM_TITLE);\r
248         }\r
249         else\r
250         {\r
251                 SetElementTextVerticalAlignment(CONTENT_LIST_ITEM_TYPE_TITLE, ALIGNMENT_MIDDLE);\r
252                 __titleRect.SetBounds(thumbnailX + thumbnailWidth + normalGap, (itemHeight - textHeight) / 2, w_Title, H_LISTVIEW_ITEM_TITLE);\r
253         }\r
254 }\r
255 \r
256 void\r
257 ContentListItem::CreateFormatRectangleForFileManageForm(int itemHeight, int textHeight)\r
258 {\r
259         AppLogDebug("Entry");\r
260         int thumbnailX = X_LISTVIEW;\r
261         int thumbnailY = X_LISTVIEW;\r
262 \r
263         int normalGap = X_LISTVIEW;\r
264         int thumbnailWidth = W_LISTVIEW_ITEM_BITMAP;\r
265         int thumbnailHeight = H_LISTVIEW_ITEM_BITMAP;\r
266 \r
267         int width = __itemWidth;\r
268         int w_Rename = W_RENAME_ICON;\r
269         int h_Rename = W_RENAME_ICON;\r
270 \r
271         int w_Title = width - (W_LISTVIEW_ITEM_BITMAP + (4 * X_LISTVIEW) + (2 * W_RENAME_ICON));\r
272         int x_Rename = width - (w_Rename + W_RENAME_ICON + (2 * X_LISTVIEW));\r
273 \r
274 \r
275         __thumbnailRect.SetBounds(thumbnailX, thumbnailY, thumbnailWidth, thumbnailHeight); //right side width:20\r
276 \r
277         if (!__creationDate.IsEmpty())\r
278         {\r
279                 SetElementTextVerticalAlignment(CONTENT_LIST_ITEM_TYPE_TITLE, ALIGNMENT_MIDDLE);\r
280                 __titleRect.SetBounds(thumbnailX + thumbnailWidth + normalGap, Y_LISTVIEW, w_Title, H_LISTVIEW_ITEM_TITLE);\r
281         }\r
282         else\r
283         {\r
284                 SetElementTextVerticalAlignment(CONTENT_LIST_ITEM_TYPE_TITLE, ALIGNMENT_MIDDLE);\r
285                 __titleRect.SetBounds(thumbnailX + thumbnailWidth + normalGap, (itemHeight - textHeight) / 2, w_Title, H_LISTVIEW_ITEM_TITLE);\r
286         }\r
287         __editRenameRect.SetBounds(x_Rename, (itemHeight - W_RENAME_ICON) / 2, w_Rename, h_Rename);\r
288         __editDateRect.SetBounds(thumbnailX + thumbnailWidth + normalGap, H_LISTVIEW_ITEM_TITLE + Y_LISTVIEW, w_Title, H_LISTVIEW_ITEM_DESCRIPTION);\r
289 }\r
290 void\r
291 ContentListItem::SetThumbnail(const Bitmap* picture)\r
292 {\r
293         AppLogDebug("Entry");\r
294         if (__pThumbnailBitmap)\r
295         {\r
296                 delete __pThumbnailBitmap;\r
297                 __pThumbnailBitmap = null;\r
298         }\r
299         __pThumbnailBitmap = (Bitmap*) picture;\r
300         AppLogDebug("Exit ");\r
301 }\r
302 \r
303 void\r
304 ContentListItem::SetTitle(const String& title, const String& searchedText)\r
305 {\r
306         AppLogDebug("Entry");\r
307         __contentTitle = title;\r
308         if (__isSearchedTextPresent == true)\r
309         {\r
310                 __searchedText = searchedText;\r
311         }\r
312         AppLogDebug("Exit %s", GetErrorMessage(GetLastResult()));\r
313 }\r
314 \r
315 void\r
316 ContentListItem::SetDescription(const String& descriptionText)\r
317 {\r
318         AppLogDebug("Entry");\r
319         __descriptionText = descriptionText;\r
320         AppLogDebug("Exit %s", GetErrorMessage(GetLastResult()));\r
321 }\r
322 \r
323 void\r
324 ContentListItem::SetDate(const String& date)\r
325 {\r
326         AppLogDebug("Entry");\r
327         __creationDate = date;\r
328         AppLogDebug("Exit %s", GetErrorMessage(GetLastResult()));\r
329 }\r
330 \r
331 int\r
332 ContentListItem::GetTitleHeight(String& title)\r
333 {\r
334         AppLogDebug("Entry");\r
335         int thumbnailX = X_LISTVIEW;\r
336         int normalGap = X_LISTVIEW;\r
337         int thumbnailWidth = W_LISTVIEW_ITEM_BITMAP;\r
338         int nMultiTextWidth = __itemWidth - thumbnailX - thumbnailWidth - 2 * normalGap;\r
339 \r
340         if (title.GetLength() <= 0)\r
341                 return 0;\r
342         FormatedText ft(nMultiTextWidth);\r
343 \r
344         ft.AddText(title, FONT_MAIN, COLOR_TITLE);\r
345         //ft.SetLineSpace(1);\r
346 \r
347         AppLogDebug("Exit %s", GetErrorMessage(GetLastResult()));\r
348         return ft.GetHeight();\r
349 }\r
350 \r
351 void\r
352 ContentListItem::SetBackground(const Bitmap* pBg)\r
353 {\r
354         AppLogDebug("Entry");\r
355         __pBg = (Bitmap*) pBg;\r
356         AppLogDebug("Exit %s", GetErrorMessage(GetLastResult()));\r
357 }\r
358 \r
359 void\r
360 ContentListItem::MakeDetailedListItem(void)\r
361 {\r
362         AppLogDebug("Entry");\r
363         int titleHeight = 0;\r
364 \r
365         Construct(Dimension(__itemWidth, __itemHeight), LIST_ANNEX_STYLE_NORMAL);\r
366         SetElementTextVerticalAlignment(DETAILED_LIST_ELEMENTS_TITLE, ALIGNMENT_MIDDLE);\r
367         SetElementTextVerticalAlignment(DETAILED_LIST_ELEMENTS_DESCRIPTION, ALIGNMENT_MIDDLE);\r
368         SetElementTextVerticalAlignment(DETAILED_LIST_ELEMENTS_CREATION_DATE, ALIGNMENT_MIDDLE);\r
369         SetElementTextVerticalAlignment(DETAILED_LIST_ELEMENTS_RENAME, ALIGNMENT_MIDDLE);\r
370 \r
371         CreateFormatRectangleForDetailedList(__itemHeight, titleHeight);\r
372         RefreshDetailedListItem();\r
373 \r
374         AppLogDebug("Exit %s", GetErrorMessage(GetLastResult()));\r
375 }\r
376 \r
377 void\r
378 ContentListItem::MakeFileManageFormDetailedListItem(void)\r
379 {\r
380         AppLogDebug("ENTRY::ContentListItem::MakeFileManageFormDetailedListItem()");\r
381         int titleHeight = 0;\r
382 \r
383         Construct(Dimension(__itemWidth, __itemHeight), LIST_ANNEX_STYLE_MARK);\r
384         SetElementTextVerticalAlignment(DETAILED_LIST_ELEMENTS_TITLE, ALIGNMENT_MIDDLE);\r
385         SetElementTextVerticalAlignment(DETAILED_LIST_ELEMENTS_DESCRIPTION, ALIGNMENT_MIDDLE);\r
386         SetElementTextVerticalAlignment(DETAILED_LIST_ELEMENTS_CREATION_DATE, ALIGNMENT_MIDDLE);\r
387         SetElementTextVerticalAlignment(DETAILED_LIST_ELEMENTS_RENAME, ALIGNMENT_MIDDLE);\r
388 \r
389         CreateFormatRectangleForDetailedList(__itemHeight, titleHeight);\r
390         RefreshDetailedListItem();\r
391         AppLogDebug("EXIT::ContentListItem::MakeFileManageFormDetailedListItem()");\r
392 }\r
393 \r
394 void\r
395 ContentListItem::RefreshDetailedListItem(void)\r
396 {\r
397         AppLogDebug("Entry");\r
398         int nMultiTextWidth = (__itemWidth - (4 * X_LISTVIEW - W_LISTVIEW_ITEM_BITMAP)) / 2;\r
399 \r
400         //Bitmap\r
401         if (__pThumbnailBitmap != null)\r
402         {\r
403                 AddElement(__thumbnailRect, DETAILED_LIST_ELEMENTS_THUMBNAIL, *__pThumbnailBitmap, __pThumbnailBitmap, __pThumbnailBitmap);\r
404         }\r
405 \r
406         // Title\r
407         __pFtTitle = new (std::nothrow) FormatedText(nMultiTextWidth);\r
408         if (__pFtTitle == null)\r
409                 return;\r
410 \r
411         __pFtTitle->AddText(__contentTitle, FONT_MAIN, COLOR_TITLE);\r
412         AddElement(__titleRect, DETAILED_LIST_ELEMENTS_TITLE, *__pFtTitle);\r
413 \r
414         // Description Text\r
415         __pFtDescriptionText = new (std::nothrow) FormatedText(nMultiTextWidth);\r
416         if (__pFtDescriptionText == null)\r
417                 return;\r
418 \r
419         __pFtDescriptionText->SetAlignment(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_MIDDLE);\r
420 \r
421         if (!__descriptionText.IsEmpty())\r
422         {\r
423                 __pFtDescriptionText->SetTextWrap(TEXT_WRAP_NONE);\r
424                 __pFtDescriptionText->AddText(__descriptionText, FONT_SUB, COLOR_DATE);\r
425                 AddElement(__detailedListDescriptionRect, DETAILED_LIST_ELEMENTS_DESCRIPTION, *__pFtDescriptionText);\r
426         }\r
427 \r
428         //CreationDate\r
429         __pFtCreationDate = new (std::nothrow) FormatedText(nMultiTextWidth);\r
430         if (__pFtCreationDate == null)\r
431                 return;\r
432 \r
433         if (!__creationDate.IsEmpty())\r
434         {\r
435                 __pFtCreationDate->SetTextWrap(TEXT_WRAP_NONE);\r
436                 __pFtCreationDate->SetAlignment(TEXT_ALIGNMENT_RIGHT, TEXT_ALIGNMENT_MIDDLE);\r
437                 __pFtCreationDate->AddText(__creationDate, FONT_SUB, COLOR_DATE);\r
438                 AddElement(__detailedListDateRect, DETAILED_LIST_ELEMENTS_CREATION_DATE, *__pFtCreationDate);\r
439         }\r
440 \r
441         if (__pRenameBitmap != null)\r
442         {\r
443                 AddElement(__editRenameRect, DETAILED_LIST_ELEMENTS_RENAME, *__pRenameBitmap, __pRenameBitmap, __pRenameBitmap);\r
444         }\r
445 \r
446 }\r
447 \r
448 void\r
449 ContentListItem::CreateFormatRectangleForDetailedList(int itemHeight, int textHeight)\r
450 {\r
451         AppLogDebug("Entry");\r
452         int width = __itemWidth;\r
453 \r
454         itemHeight = itemHeight - (2 * X_LISTVIEW);\r
455         //Bitmap\r
456         int thumbnailX = X_LISTVIEW;\r
457         int thumbnailY = (H_DETAIL_LISTVIEW - H_LISTVIEW_ITEM_BITMAP) / 2;\r
458 \r
459         //int normalGap = DETAILEDLIST_COMMON_OFFSET;\r
460         int thumbnailWidth = W_LISTVIEW_ITEM_BITMAP;\r
461         int thumbnailHeight = H_LISTVIEW_ITEM_BITMAP;\r
462 \r
463         int bitmapElementWidth = thumbnailWidth + 2 * X_LISTVIEW;\r
464         //Title\r
465         int x_Title = bitmapElementWidth;\r
466         int y_Title = Y_LISTVIEW;\r
467         int w_Title = width - (thumbnailWidth + 3 * X_LISTVIEW); //width - (W_LISTVIEW_ITEM_BITMAP + 3 * LISTVIEW_COMMON_OFFSET);;\r
468         int h_Title = H_LISTVIEW_ITEM_TITLE;\r
469 \r
470         //Description\r
471         int x_Description = x_Title; //width - (W_DETAILED_LIST_DESCRIPTION_TEXT + X_LISTVIEW);\r
472         int y_Description = h_Title + X_LISTVIEW; //X_DETAILEDLIST_COMMON_OFFSET;\r
473         int w_Description = width / 2;\r
474         int h_Description = H_LISTVIEW_ITEM_DESCRIPTION;\r
475 \r
476         //Date\r
477         int x_CreationDate = width / 2 - X_LISTVIEW; //(3 * X_DETAILEDLIST_COMMON_OFFSET) + thumbnailWidth + w_Description;//x_Title;\r
478         int y_CreationDate = h_Title + X_LISTVIEW;\r
479         int w_CreationDate = (width / 2) + 2;\r
480         int h_CreationDate = H_LISTVIEW_ITEM_DESCRIPTION;\r
481 \r
482         //Rename\r
483         int x_Rename = width - (W_RENAME_ICON + (2 * X_LISTVIEW));\r
484         int y_Rename = (itemHeight - W_RENAME_ICON) / 2;\r
485         int w_Rename = W_RENAME_ICON;\r
486         int h_Rename = W_RENAME_ICON;\r
487 \r
488         __thumbnailRect.SetBounds(thumbnailX, thumbnailY, thumbnailWidth, thumbnailHeight); //right side width:20\r
489 \r
490         if (__pRenameBitmap != null)\r
491         {\r
492                 __titleRect.SetBounds(x_Title, y_Title, w_Title - W_RENAME_ICON - X_LISTVIEW, h_Title);\r
493         }\r
494         else\r
495         {\r
496                 __titleRect.SetBounds(x_Title, y_Title, w_Title, h_Title);\r
497         }\r
498         __detailedListDescriptionRect.SetBounds(x_Description, y_Description, w_Description, h_Description);\r
499         __detailedListDateRect.SetBounds(x_CreationDate, y_CreationDate, w_CreationDate, h_CreationDate);\r
500         __editRenameRect.SetBounds(x_Rename, y_Rename, w_Rename, h_Rename);\r
501 }\r
502 \r
503 \r
504 void\r
505 ContentListItem::SetRenameBitmap(const Bitmap* picture, const Bitmap* pressedPicture)\r
506 {\r
507         AppLogDebug("Entry");\r
508         __pRenameBitmap = (Bitmap*) picture;\r
509         __pRenamePressed = (Bitmap*) pressedPicture;\r
510         AppLogDebug("Exit %s", GetErrorMessage(GetLastResult()));\r
511 \r
512 }\r
513 \r
514 void\r
515 ContentListItem::RefreshFileManageFormListItem(void)\r
516 {\r
517         int thumbnailX = X_LISTVIEW;\r
518         int normalGap = X_LISTVIEW;\r
519         int thumbnailWidth = W_LISTVIEW_ITEM_BITMAP;\r
520         int nMultiTextWidth = __itemWidth - thumbnailX - thumbnailWidth - 2 * normalGap;\r
521         //Bitmap\r
522         if (__pThumbnailBitmap != null)\r
523         {\r
524                 AddElement(__thumbnailRect, CONTENT_LIST_ITEM_TYPE_THUMBNAIL, *__pThumbnailBitmap, __pThumbnailBitmap, __pThumbnailBitmap);\r
525         }\r
526 \r
527         // Title\r
528         __pFtTitle = new (std::nothrow) FormatedText(nMultiTextWidth);\r
529         if (__pFtTitle == null)\r
530                 return;\r
531 \r
532         __pFtTitle->AddText(__contentTitle, FONT_MAIN, COLOR_TITLE);\r
533         AddElement(__titleRect, CONTENT_LIST_ITEM_TYPE_TITLE, *__pFtTitle);\r
534 \r
535         //CreationDate\r
536         __pFtCreationDate = new (std::nothrow) FormatedText(nMultiTextWidth);\r
537         if (__pFtCreationDate == null)\r
538                 return;\r
539 \r
540         __pFtCreationDate->SetTextWrap(TEXT_WRAP_NONE);\r
541         __pFtCreationDate->AddText(__creationDate, FONT_SUB, COLOR_DATE);\r
542         AddElement(__editDateRect, CONTENT_LIST_ITEM_TYPE_DATE, *__pFtCreationDate);\r
543 \r
544         //Rename Bitmap\r
545         if (__pRenameBitmap != null)\r
546         {\r
547                 AddElement(__editRenameRect, CONTENT_LIST_ITEM_TYPE_RENAME, *__pRenameBitmap, __pRenamePressed, __pRenameBitmap);\r
548         }\r
549 \r
550 }\r
551 \r
552 void\r
553 ContentListItem::SetTitleColor(const Color& colorTitle)\r
554 {\r
555         COLOR_TITLE = colorTitle;\r
556 }\r
557 \r
558 void\r
559 ContentListItem::SetDescColor(const Color& colorDesc)\r
560 {\r
561         COLOR_TITLE = colorDesc;\r
562 }\r
563 \r
564 void\r
565 ContentListItem::SetTimeColor(const Color& colorTime)\r
566 {\r
567         COLOR_DATE = colorTime;\r
568 }\r
569 \r
570 /*\r
571  * SearchAllFoldersItem\r
572  */\r
573 \r
574 SearchAllFolders::SearchAllFolders(String text)\r
575 {\r
576         __text = text;  //FbkGetString(L"IDS_SHOWMORE");\r
577 \r
578 }\r
579 \r
580 SearchAllFolders::~SearchAllFolders(void)\r
581 {\r
582         //Empty Implementation\r
583 }\r
584 \r
585 SearchAllFolders&\r
586 SearchAllFolders::operator =(const SearchAllFolders& searchAllFolders)\r
587 {\r
588         return *this;\r
589 }\r
590 \r
591 SearchAllFolders::SearchAllFolders(const SearchAllFolders& searchAllFolders)\r
592 {\r
593         //Do Nothing\r
594 }\r
595 \r
596 bool\r
597 SearchAllFolders::OnDraw(Tizen::Graphics::Canvas& canvas, const Tizen::Graphics::Rectangle& rect, Tizen::Ui::Controls::ListItemDrawingStatus status)\r
598 {\r
599         Canvas* pCanvas = const_cast< Canvas* >(&canvas);\r
600 \r
601         Dimension rectSearchAllFolders(10, 10);\r
602         pCanvas->DrawRoundRectangle(rect, rectSearchAllFolders);\r
603         if (status == LIST_ITEM_DRAWING_STATUS_NORMAL)\r
604         {\r
605                 pCanvas->FillRoundRectangle(Color(129, 141, 149), rect, rectSearchAllFolders);\r
606         }\r
607         else\r
608         {\r
609                 pCanvas->FillRoundRectangle(Color(58, 119, 153), rect, rectSearchAllFolders);\r
610         }\r
611 \r
612 \r
613         // draw text\r
614         Dimension dim(rect.width, rect.height);\r
615 \r
616         EnrichedText enrichedText;\r
617         enrichedText.Construct(dim);\r
618 \r
619         enrichedText.SetHorizontalAlignment(TEXT_ALIGNMENT_CENTER);\r
620         enrichedText.SetVerticalAlignment(TEXT_ALIGNMENT_MIDDLE);\r
621         enrichedText.SetTextWrapStyle(TEXT_WRAP_WORD_WRAP);\r
622         enrichedText.SetTextAbbreviationEnabled(false);\r
623         //et.SetLineSpace(0);\r
624 \r
625         TextElement textElement;\r
626         textElement.Construct(__text);\r
627         textElement.SetFont(*FontManager::GetFont(FONT_MAIN));\r
628 \r
629         textElement.SetTextColor(Color(0, 0, 0));\r
630 \r
631         enrichedText.Add(textElement);\r
632         enrichedText.Refresh();\r
633 \r
634         pCanvas->DrawText(Point(0, 0), enrichedText);\r
635 \r
636         return true;\r
637 \r
638 }\r
639 \r
640 SearchAllFoldersItem::SearchAllFoldersItem(int width, int height, String text = "")\r
641 {\r
642 \r
643         __height = height;\r
644         __width = width;\r
645         __text = text;\r
646         __pElement = null;\r
647 \r
648         Construct(Dimension(width, height), LIST_ANNEX_STYLE_NORMAL);\r
649         SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_PRESSED, Color::GetColor(COLOR_ID_WHITE));\r
650         CreateFormatRectangle();\r
651 \r
652         __pElement = new (std::nothrow) SearchAllFolders(text);\r
653         if (__pElement)\r
654         {\r
655                 AddElement(searchAllFoldersRect, H_SEARCH_ALL_FOLDERS, *__pElement);\r
656         }\r
657 }\r
658 \r
659 SearchAllFoldersItem::~SearchAllFoldersItem(void)\r
660 {\r
661         if (__pElement)\r
662                 delete __pElement;\r
663 }\r
664 \r
665 void\r
666 SearchAllFoldersItem::CreateFormatRectangle(void)\r
667 {\r
668 \r
669         int height = H_SEARCH_ALL_FOLDERS;\r
670 \r
671         searchAllFoldersRect.SetBounds(X_SEARCH_ALL_FOLDERS, (__height - height) / 2, __width - (2 * X_SEARCH_ALL_FOLDERS), height);\r
672 \r
673 }\r
674 \r
675 void\r
676 ContentListItem::SetAudioBitmap(const Bitmap* pBitmapplay, const Bitmap* pBitmapPause)\r
677 {\r
678         AppLogDebug("Entry");\r
679 \r
680         if (pBitmapplay != null)\r
681         {\r
682                 __pPlayBitmap = (Bitmap*) pBitmapplay;\r
683         }\r
684 \r
685         if (pBitmapPause != null)\r
686         {\r
687                 __pPauseBitmap = (Bitmap*) pBitmapPause;\r
688         }\r
689         AppLogDebug("Exit %s", GetErrorMessage(GetLastResult()));\r
690 \r
691 }\r
692 \r
693 void\r
694 ContentListItem::MakeAppControlFormListItem(void)\r
695 {\r
696         AppLogDebug("Entry");\r
697         int titleHeight = 0;\r
698         GetItemSize(__itemHeight, titleHeight);\r
699 \r
700         if (__currentListStyle == ANNEX_STYLE_NORMAL)\r
701         {\r
702                 Construct(Dimension(__itemWidth, __itemHeight), LIST_ANNEX_STYLE_NORMAL);\r
703         }\r
704         else if (__currentListStyle == ANNEX_STYLE_RADIO)\r
705         {\r
706                 Construct(Dimension(__itemWidth, __itemHeight), LIST_ANNEX_STYLE_RADIO);\r
707         }\r
708         else if (__currentListStyle == ANNEX_STYLE_MARK)\r
709         {\r
710                 Construct(Dimension(__itemWidth, __itemHeight), LIST_ANNEX_STYLE_MARK);\r
711         }\r
712 \r
713         SetElementTextVerticalAlignment(CONTENT_LIST_ITEM_TYPE_TITLE, ALIGNMENT_MIDDLE);\r
714 \r
715         CreateFormatRectangleForAppControl(__itemHeight, titleHeight);\r
716         RefreshAppControlListItem();\r
717         AppLogDebug("Exit %s", GetErrorMessage(GetLastResult()));\r
718 }\r
719 \r
720 void\r
721 ContentListItem::SetListAnnexStyle(AnnexStyle currentStyle)\r
722 {\r
723         __currentListStyle = currentStyle;\r
724 }\r
725 \r
726 void\r
727 ContentListItem::RefreshAppControlListItem(void)\r
728 {\r
729         AppLogDebug("Entry");\r
730         int thumbnailX = X_LISTVIEW;\r
731         int normalGap = X_LISTVIEW;\r
732         int thumbnailWidth = W_LISTVIEW_ITEM_BITMAP;\r
733         int nMultiTextWidth = __itemWidth - thumbnailX - thumbnailWidth - 2 * normalGap;\r
734 \r
735         if (__pThumbnailBitmap != null)\r
736         {\r
737                 AddElement(__thumbnailRect, CONTENT_LIST_ITEM_TYPE_THUMBNAIL, *__pThumbnailBitmap, __pThumbnailBitmap, __pThumbnailBitmap);\r
738         }\r
739 \r
740         // Title\r
741         __pFtTitle = new (std::nothrow) FormatedText(nMultiTextWidth);\r
742         if (__pFtTitle == null)\r
743                 return;\r
744 \r
745         __pFtTitle->SetTextWrap(TEXT_WRAP_NONE);\r
746         __pFtTitle->AddText(__contentTitle, FONT_MAIN, COLOR_TITLE);\r
747 \r
748         AddElement(__titleRect, CONTENT_LIST_ITEM_TYPE_TITLE, *__pFtTitle);\r
749 \r
750         if (__pPlayBitmap != null)\r
751         {\r
752                 AddElement(__editPlayRect, CONTENT_LIST_ITEM_TYPE_PLAY, *__pPlayBitmap, __pPlayBitmap, __pPlayBitmap);\r
753         }\r
754         else if (__pPauseBitmap != null)\r
755         {\r
756                 AddElement(__editPauseRect, CONTENT_LIST_ITEM_TYPE_PAUSE, *__pPauseBitmap, __pPauseBitmap, __pPauseBitmap);\r
757         }\r
758 \r
759         AppLogDebug("Exit %s", GetErrorMessage(GetLastResult()));\r
760 }\r
761 \r
762 void\r
763 ContentListItem::CreateFormatRectangleForAppControl(int itemHeight, int textHeight)\r
764 {\r
765         AppLogDebug("Entry");\r
766         int thumbnailX = X_LISTVIEW;\r
767         int thumbnailY = X_LISTVIEW;\r
768 \r
769         int normalGap = X_LISTVIEW;\r
770         int thumbnailWidth = W_LISTVIEW_ITEM_BITMAP;\r
771         int thumbnailHeight = H_LISTVIEW_ITEM_BITMAP;\r
772 \r
773         int width = __itemWidth;\r
774         int w_AudioPlay = W_RENAME_ICON;\r
775         int h_AudioPlay = W_RENAME_ICON;\r
776 \r
777         int w_Title = width - (W_LISTVIEW_ITEM_BITMAP + (4 * X_LISTVIEW) + (2 * w_AudioPlay));\r
778         int x_Play = width - (w_AudioPlay + w_AudioPlay + (2 * X_LISTVIEW));\r
779         AppControlView currentViewStyle;\r
780 \r
781         __thumbnailRect.SetBounds(thumbnailX, thumbnailY, thumbnailWidth, thumbnailHeight); //right side width:20\r
782 \r
783 \r
784         currentViewStyle = ((MyFilesApp*) Application::GetInstance())->GetCurrentView();\r
785         //currentViewStyle = APPCONTROL_VIEW_EXPORT;\r
786 \r
787         SetElementTextVerticalAlignment(CONTENT_LIST_ITEM_TYPE_TITLE, ALIGNMENT_MIDDLE);\r
788 \r
789         if (currentViewStyle == APPCONTROL_VIEW_IMPORT)\r
790         {\r
791                 w_Title = width - (W_LISTVIEW_ITEM_BITMAP + 3 * X_LISTVIEW) - w_AudioPlay;\r
792         }\r
793         else if (currentViewStyle == APPCONTROL_VIEW_EXPORT)\r
794         {\r
795                 w_Title = width - (W_LISTVIEW_ITEM_BITMAP + 3 * X_LISTVIEW);\r
796         }\r
797 \r
798         __titleRect.SetBounds(thumbnailX + thumbnailWidth + normalGap, (itemHeight - textHeight) / 2, w_Title + w_AudioPlay, H_LISTVIEW_ITEM_TITLE);\r
799 \r
800         if (__pPlayBitmap != null)\r
801         {\r
802                 __editPlayRect.SetBounds(x_Play, (itemHeight - w_AudioPlay) / 2, w_AudioPlay, h_AudioPlay);\r
803                 __titleRect.SetBounds(thumbnailX + thumbnailWidth + normalGap, (itemHeight - textHeight) / 2, w_Title, H_LISTVIEW_ITEM_TITLE);\r
804 \r
805         }\r
806         else if (__pPauseBitmap != null)\r
807         {\r
808                 __editPauseRect.SetBounds(x_Play, (itemHeight - w_AudioPlay) / 2, w_AudioPlay, h_AudioPlay);\r
809                 __titleRect.SetBounds(thumbnailX + thumbnailWidth + normalGap, (itemHeight - textHeight) / 2, w_Title, H_LISTVIEW_ITEM_TITLE);\r
810         }\r
811 }\r
812 void\r
813 ContentListItem::MakeSearchFormListItem(void)\r
814 {\r
815         AppLogDebug("Entry");\r
816         int titleHeight = 0;\r
817         int thumbnailX = X_LISTVIEW;\r
818         int thumbnailY = X_LISTVIEW;\r
819         int normalGap = X_LISTVIEW;\r
820         int thumbnailWidth = W_LISTVIEW_ITEM_BITMAP;\r
821         int thumbnailHeight = H_LISTVIEW_ITEM_BITMAP;\r
822         int detailIconWidth = W_LISTVIEW_ITEM_BITMAP;\r
823         int width = __itemWidth;\r
824         int w_Title = 0;\r
825 \r
826         GetItemSize(__itemHeight, titleHeight);\r
827 \r
828         if (__currentListStyle == ANNEX_STYLE_DETAILED)\r
829         {\r
830                 w_Title = width - (W_LISTVIEW_ITEM_BITMAP + 4 * X_LISTVIEW) - detailIconWidth;\r
831                 Construct(Dimension(__itemWidth, __itemHeight), LIST_ANNEX_STYLE_DETAILED);\r
832         }\r
833         else\r
834         {\r
835                 w_Title = width - (W_LISTVIEW_ITEM_BITMAP + 3 * X_LISTVIEW);\r
836                 Construct(Dimension(__itemWidth, __itemHeight), LIST_ANNEX_STYLE_NORMAL);\r
837         }\r
838 \r
839         SetElementTextVerticalAlignment(CONTENT_LIST_ITEM_TYPE_THUMBNAIL, ALIGNMENT_MIDDLE);\r
840         SetElementTextVerticalAlignment(CONTENT_LIST_ITEM_TYPE_FILEPATH, ALIGNMENT_BOTTOM);\r
841 \r
842         __thumbnailRect.SetBounds(thumbnailX, thumbnailY, thumbnailWidth, thumbnailHeight); //right side width:20\r
843         __titleRect.SetBounds((2 * thumbnailX) + thumbnailWidth, Y_LISTVIEW, w_Title, H_LISTVIEW_ITEM_TITLE);\r
844         __editDateRect.SetBounds(thumbnailX + thumbnailWidth + normalGap, H_LISTVIEW_ITEM_TITLE + Y_LISTVIEW, w_Title, H_LISTVIEW_ITEM_DESCRIPTION);\r
845 \r
846         RefreshSearchFormListItem();\r
847         AppLogDebug("Exit %s", GetErrorMessage(GetLastResult()));\r
848 }\r
849 void\r
850 ContentListItem::RefreshSearchFormListItem(void)\r
851 {\r
852         int thumbnailX = X_LISTVIEW;\r
853         int normalGap = X_LISTVIEW;\r
854         int thumbnailWidth = W_LISTVIEW_ITEM_BITMAP;\r
855         int nMultiTextWidth = __itemWidth - thumbnailX - thumbnailWidth - 2 * normalGap;\r
856         if (__pThumbnailBitmap != null)\r
857         {\r
858                 AddElement(__thumbnailRect, CONTENT_LIST_ITEM_TYPE_THUMBNAIL, *__pThumbnailBitmap, __pThumbnailBitmap, __pThumbnailBitmap);\r
859         }\r
860         __pFtTitle = new (std::nothrow) FormatedText(nMultiTextWidth);\r
861         if (__pFtTitle == null)\r
862                 return;\r
863         if (__searchedText.GetLength() > 0)\r
864         {\r
865                 String tempTitleString = __contentTitle;\r
866                 tempTitleString.ToLowerCase();\r
867                 bool found = false;\r
868                 __searchedText.ToLowerCase();\r
869                 String temp1 = L"", temp2 = L"", temp3 = L"";\r
870 \r
871                 if (tempTitleString.StartsWith(__searchedText, 0))\r
872                 {\r
873                         found = true;\r
874                         __contentTitle.SubString(0, __searchedText.GetLength(), temp1);\r
875                         __contentTitle.SubString(__searchedText.GetLength(), __contentTitle.GetLength() - __searchedText.GetLength(), temp2);\r
876 \r
877                         Color titleColor = Color(42, 137, 194);\r
878                         __pFtTitle->AddText(temp1, FONT_MAIN, titleColor);\r
879                         __pFtTitle->AddText(temp2, FONT_MAIN, COLOR_TITLE);\r
880                 }\r
881                 else\r
882                 {\r
883                         int index = -1;\r
884                         tempTitleString.IndexOf(__searchedText, 0, index);\r
885                         if (index > -1)\r
886                         {\r
887                                 __contentTitle.SubString(0, index, temp1);\r
888                                 __contentTitle.SubString(index, __searchedText.GetLength(), temp2);\r
889                                 __contentTitle.SubString(index + __searchedText.GetLength(), tempTitleString.GetLength() - __searchedText.GetLength() - index, temp3);\r
890                         }\r
891                         else\r
892                         {\r
893                                 __contentTitle.SubString(0, tempTitleString.GetLength(), temp1);\r
894                         }\r
895                         __pFtTitle->SetTextWrap(TEXT_WRAP_NONE);\r
896                         Color titleColor = Color(42, 137, 194);\r
897                         if (temp1.GetLength() > 0)\r
898                                 __pFtTitle->AddText(temp1, FONT_MAIN, COLOR_TITLE);\r
899                         if (temp2.GetLength() > 0)\r
900                                 __pFtTitle->AddText(temp2, FONT_MAIN, titleColor);\r
901                         if (temp3.GetLength() > 0)\r
902                                 __pFtTitle->AddText(temp3, FONT_MAIN, COLOR_TITLE);\r
903                 }\r
904         }\r
905         else\r
906         {\r
907         __pFtTitle->AddText(__contentTitle, FONT_MAIN, COLOR_TITLE);\r
908         }\r
909         AddElement(__titleRect, CONTENT_LIST_ITEM_TYPE_TITLE, *__pFtTitle);\r
910 \r
911         __pFtFilepath = new (std::nothrow) FormatedText(nMultiTextWidth);\r
912         if (__pFtFilepath == null)\r
913                 return;\r
914         __pFtFilepath->SetTextWrap(TEXT_WRAP_NONE);\r
915         __pFtFilepath->AddText(__filepath, FONT_SUB, COLOR_DATE);\r
916         AddElement(__editDateRect, CONTENT_LIST_ITEM_TYPE_FILEPATH, *__pFtFilepath);\r
917 }\r
918 void\r
919 ContentListItem::SetFilepath(const Tizen::Base::String& filePath)\r
920 {\r
921         __filepath = filePath;\r
922 }\r