Changed indicator bg color.
[platform/framework/native/uifw.git] / src / ui / controls / FUiCtrl_IconListItemDrawingProperty.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0/
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 /**
19  * @file                FUiCtrl_IconListItemDrawingProperty.cpp
20  * @brief               This is the implementation file for the _IconListItemDrawingProperty class.
21  */
22
23 //Includes
24 #include <FBaseSysLog.h>
25 #include <FGrp_BitmapImpl.h>
26
27 #include "FUi_CoordinateSystemUtils.h"
28 #include "FUi_Math.h"
29 #include "FUi_ResourceManager.h"
30 #include "FUiCtrl_IconListItemDrawingProperty.h"
31
32 using namespace Tizen::Base;
33 using namespace Tizen::Graphics;
34 using namespace Tizen::Ui;
35
36 namespace Tizen { namespace Ui { namespace Controls
37 {
38
39 _IconListItemDrawingProperty::_IconListItemDrawingProperty(void)
40         : __textSize(0.0f)
41         , __pFont(null)
42         , __normalTextColor(0)
43         , __pressedTextColor(0)
44         , __highlightedTextColor(0)
45         , __size(0.0f, 0.0f)
46         , __bitmapBounds(0.0f, 0.0f, 0.0f, 0.0f)
47         , __pDropShadowBitmap(null)
48         , __pFocusBitmap(null)
49         , __pDropShadowBitmapWithReplacementColor(null)
50         , __dropShadowBorderWidth(0.0f)
51         , __dropShadowMargin(0.0f)
52         , __pCheckBitmap(null)
53         , __pCheckedBackgroundBitmap(null)
54         , __pUnCheckedBackgroundBitmap(null)
55         , __pDisabledCheckBitmap(null)
56         , __checkMargin(0.0f)
57         , __overlayMargin(0.0f)
58         , __pressedBackgroundColor(0)
59         , __normalBorderColor(0)
60         , __focusBorderColor(0)
61         , __inTextBackgroundColor(0)
62         , __textYPos(0.0f)
63         , __2LineTextYPos(0.0f)
64         , __checkBoxPosition(ICON_LIST_VIEW_CHECK_BOX_POSITION_TOP_RIGHT)
65         , __borderStyle(ICON_LIST_VIEW_ITEM_BORDER_STYLE_NONE)
66         , __textHorizontalAlignment(ALIGNMENT_CENTER)
67         , __textVerticalAlignment(ICON_LIST_VIEW_ITEM_TEXT_VERTICAL_ALIGNMENT_INSIDE_BOTTOM)
68         , __refCount(1)
69         , __changed(true)
70         , __asAspectRatio(true)
71         , __checkedStyle(false)
72         , __verticalExtent(0.0f)
73         , __insideOneLineTextHeight(0.0f)
74         , __insideTwoLineTextHeight(0.0f)
75         , __selectBackgroundMargin(0.0f)
76         , __itemTextHorizontalMargin(0.0f)
77         , __itemTextVerticalMargin(0.0f)
78         , __accessibilityEnabled(false)
79         , __customColorSet(false)
80 {
81         // Do nothing
82 }
83
84 _IconListItemDrawingProperty::~_IconListItemDrawingProperty(void)
85 {
86         delete __pDropShadowBitmap;
87         __pDropShadowBitmap = null;
88
89         delete __pFocusBitmap;
90         __pFocusBitmap = null;
91
92         delete __pDropShadowBitmapWithReplacementColor;
93         __pDropShadowBitmapWithReplacementColor = null;
94
95         delete __pCheckBitmap;
96         __pCheckBitmap = null;
97
98         delete __pCheckedBackgroundBitmap;
99         __pCheckedBackgroundBitmap = null;
100
101         delete __pUnCheckedBackgroundBitmap;
102         __pUnCheckedBackgroundBitmap = null;
103
104         delete __pDisabledCheckBitmap;
105         __pDisabledCheckBitmap = null;
106 }
107
108 _IconListItemDrawingProperty*
109 _IconListItemDrawingProperty::CreateInstanceN(void)
110 {
111         _IconListItemDrawingProperty* pProperty = new (std::nothrow) _IconListItemDrawingProperty;
112         SysTryReturn(NID_UI_CTRL, (pProperty != null), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
113
114         result r = pProperty->Initialize();
115         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
116
117         return pProperty;
118
119 CATCH:
120         delete pProperty;
121
122         return null;
123 }
124
125 result
126 _IconListItemDrawingProperty::Initialize(void)
127 {
128         result r = E_SUCCESS;
129
130         // Load Drop Shadow Bitmap
131         GET_FIXED_VALUE_CONFIG(ICONLIST::DROP_SHADOW_BORDER, _CONTROL_ORIENTATION_PORTRAIT, __dropShadowBorderWidth);
132         GET_FIXED_VALUE_CONFIG(ICONLIST::DROP_SHADOW_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __dropShadowMargin);
133
134         float width = 0.0f;
135         float height = 0.0f;
136         GET_FIXED_VALUE_CONFIG(ICONLIST::DROP_SHADOW_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, width);
137         GET_FIXED_VALUE_CONFIG(ICONLIST::DROP_SHADOW_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, height);
138
139         if (!_FloatCompareLE(width, 0.0f) && !_FloatCompareLE(height, 0.0f))
140         {
141                 r = GET_BITMAP_CONFIG_N(ICONLIST::ITEM_BORDER_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pDropShadowBitmap);
142                 if (r != E_SUCCESS)
143                 {
144                         delete __pDropShadowBitmap;
145                         __pDropShadowBitmap = null;
146
147                         SysLogException(NID_UI_CTRL, r, "[%s] Propagating.", GetErrorMessage(r));
148                         return r;
149                 }
150
151                 r = GET_BITMAP_CONFIG_N(ICONLIST::ITEM_BORDER_HIGHLIGHTED, BITMAP_PIXEL_FORMAT_ARGB8888, __pFocusBitmap);
152                 if (r != E_SUCCESS)
153                 {
154                         delete __pFocusBitmap;
155                         __pFocusBitmap = null;
156
157                         SysLogException(NID_UI_CTRL, r, "[%s] Propagating.", GetErrorMessage(r));
158                         return r;
159                 }
160         }
161
162         // Load Check Bitmap
163         GET_FIXED_VALUE_CONFIG(ICONLIST::CHECKBOX_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __checkMargin);
164
165         FloatDimension dimension(0.0f, 0.0f);
166         GET_DIMENSION_CONFIG(ICONLIST::CHECKBOX_SIZE, _CONTROL_ORIENTATION_PORTRAIT, dimension);
167         width = dimension.width;
168         height = dimension.height;
169
170         if (!_FloatCompareLE(width, 0.0f) && !_FloatCompareLE(height, 0.0f))
171         {
172                 r = GET_BITMAP_CONFIG_N(ICONLIST::CHECK_SELECTED, BITMAP_PIXEL_FORMAT_ARGB8888, __pCheckBitmap);
173                 if (r != E_SUCCESS)
174                 {
175                         delete __pCheckBitmap;
176                         __pCheckBitmap = null;
177
178                         SysLogException(NID_UI_CTRL, r, "[%s] Propagating.", GetErrorMessage(r));
179                         return r;
180                 }
181
182                 r = GET_BITMAP_CONFIG_N(ICONLIST::CHECK_BG_SELECTED, BITMAP_PIXEL_FORMAT_ARGB8888, __pCheckedBackgroundBitmap);
183                 if (r != E_SUCCESS)
184                 {
185                         delete __pCheckedBackgroundBitmap;
186                         __pCheckedBackgroundBitmap = null;
187
188                         SysLogException(NID_UI_CTRL, r, "[%s] Propagating.", GetErrorMessage(r));
189                         return r;
190                 }
191
192                 r = GET_BITMAP_CONFIG_N(ICONLIST::CHECK_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pUnCheckedBackgroundBitmap);
193                 if (r != E_SUCCESS)
194                 {
195                         delete __pUnCheckedBackgroundBitmap;
196                         __pUnCheckedBackgroundBitmap = null;
197
198                         SysLogException(NID_UI_CTRL, r, "[%s] Propagating.", GetErrorMessage(r));
199                         return r;
200                 }
201         }
202
203         // Load overlay bitmap margin
204         GET_FIXED_VALUE_CONFIG(ICONLIST::OVERLAY_ICON_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __overlayMargin);
205
206         // Load item press state background color
207         GET_COLOR_CONFIG(ICONLIST::ITEM_BG_PRESSED, __pressedBackgroundColor);
208         __pressedBackgroundColor.SetAlpha(0x80);
209
210         // Load border color
211         GET_COLOR_CONFIG(ICONLIST::ITEM_BORDER_NORMAL, __normalBorderColor);
212         GET_COLOR_CONFIG(ICONLIST::ITEM_BORDER_HIGHLIGHTED, __focusBorderColor);
213
214         // Load Drop Shadow Bitmap with Replacement Color
215         if (__pDropShadowBitmap != null)
216         {
217                 __pDropShadowBitmapWithReplacementColor = _BitmapImpl::GetColorReplacedBitmapN(*__pDropShadowBitmap,
218                                 Color::GetColor(COLOR_ID_MAGENTA), __normalBorderColor);
219                 SysTryReturn(NID_UI_CTRL, (__pDropShadowBitmapWithReplacementColor != null), r, r, "[%s] Propagating.", GetErrorMessage(r));
220         }
221
222         // Load Item Text Size & color
223         GET_SHAPE_CONFIG(ICONLIST::FONT_SIZE, _CONTROL_ORIENTATION_PORTRAIT, __textSize);
224         GET_COLOR_CONFIG(ICONLIST::INNER_TEXT_BG_NORMAL, __inTextBackgroundColor);
225         __inTextBackgroundColor.SetAlpha(0x80);
226
227         // Load Item text height
228         GET_SHAPE_CONFIG(ICONLIST::VERTICAL_EXTENT, _CONTROL_ORIENTATION_PORTRAIT, __verticalExtent);
229         GET_SHAPE_CONFIG(ICONLIST::INSIDE_ONE_LINE_TEXT_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, __insideOneLineTextHeight);
230         GET_SHAPE_CONFIG(ICONLIST::INSIDE_TWO_LINE_TEXT_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, __insideTwoLineTextHeight);
231
232         // Load item margin
233         GET_FIXED_VALUE_CONFIG(ICONLIST::SELECT_BG_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __selectBackgroundMargin);
234         GET_FIXED_VALUE_CONFIG(ICONLIST::TEXT_HORIZONTAL_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __itemTextHorizontalMargin);
235         GET_FIXED_VALUE_CONFIG(ICONLIST::TEXT_VERTICAL_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __itemTextVerticalMargin);
236
237         return r;
238 }
239
240 const Color
241 _IconListItemDrawingProperty::GetBackgroundColor(IconListViewItemDrawingStatus status) const
242 {
243         SysTryReturn(NID_UI_CTRL,
244                         (status >= ICON_LIST_VIEW_ITEM_DRAWING_STATUS_NORMAL && status <= ICON_LIST_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED),
245                         Color(0), E_INVALID_ARG, "[E_INVALID_ARG] Invalid value of drawing status is used.");
246
247         ClearLastResult();
248         if (status == ICON_LIST_VIEW_ITEM_DRAWING_STATUS_PRESSED)
249         {
250                 return __pressedBackgroundColor;
251         }
252         return Color(0, 0, 0, 0);
253 }
254
255 result
256 _IconListItemDrawingProperty::SetTextSize(float size)
257 {
258         float minSize = 0.0f;
259         GET_FIXED_VALUE_CONFIG(ICONLIST::MINIMUM_FONT_SIZE, _CONTROL_ORIENTATION_PORTRAIT, minSize);
260         SysTryReturn(NID_UI_CTRL, _FloatCompareGE(size, minSize), E_INVALID_ARG, E_INVALID_ARG,
261                         "[E_INVALID_ARG] Invalid argument is used. Font size should be greater than or equal to the minimum size.");
262
263         if (!_FloatCompare(__textSize, size))
264         {
265                 __textSize = size;
266         }
267
268         return E_SUCCESS;
269 }
270
271 float
272 _IconListItemDrawingProperty::GetTextSize(void) const
273 {
274         ClearLastResult();
275         return __textSize;
276 }
277
278 result
279 _IconListItemDrawingProperty::SetFont(Font* pFont)
280 {
281         SysTryReturn(NID_UI_CTRL, pFont != null, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used.");
282
283         if (pFont == __pFont)
284         {
285                 return E_SUCCESS;
286         }
287
288         __pFont = pFont;
289
290         float oldVerticalExtent = __verticalExtent;
291         float textSize = 0.0f;
292         GET_SHAPE_CONFIG(ICONLIST::FONT_SIZE, _CONTROL_ORIENTATION_PORTRAIT, textSize);
293
294         if (!_FloatCompare(__textSize, textSize))
295         {
296                 int leading = _FontImpl::GetInstance(*__pFont)->GetLeading();
297                 __insideOneLineTextHeight = leading + __itemTextVerticalMargin * 2.0f;
298                 __insideTwoLineTextHeight = (leading * 2.0f) + __itemTextVerticalMargin * 2.0f;
299                 __verticalExtent = __insideTwoLineTextHeight;
300         }
301         else
302         {
303                 GET_SHAPE_CONFIG(ICONLIST::VERTICAL_EXTENT, _CONTROL_ORIENTATION_PORTRAIT, __verticalExtent);
304                 GET_SHAPE_CONFIG(ICONLIST::INSIDE_ONE_LINE_TEXT_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, __insideOneLineTextHeight);
305                 GET_SHAPE_CONFIG(ICONLIST::INSIDE_TWO_LINE_TEXT_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, __insideTwoLineTextHeight);
306         }
307
308         if (__textVerticalAlignment >= ICON_LIST_VIEW_ITEM_TEXT_VERTICAL_ALIGNMENT_OUTSIDE_TOP)
309         {
310                 __size.height -= oldVerticalExtent;
311                 __size.height = __size.height + __insideTwoLineTextHeight;
312         }
313
314         __changed = true;
315
316         // Adjust layout of Item.
317         return SetItemLayout();
318 }
319
320 Font*
321 _IconListItemDrawingProperty::GetFont(void) const
322 {
323         return __pFont;
324 }
325
326 result
327 _IconListItemDrawingProperty::SetTextColor(IconListViewItemDrawingStatus status, const Color color)
328 {
329         SysTryReturn(NID_UI_CTRL,
330                         (status >= ICON_LIST_VIEW_ITEM_DRAWING_STATUS_NORMAL && status <= ICON_LIST_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED),
331                         E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Invalid value of drawing status.");
332
333         if (status == ICON_LIST_VIEW_ITEM_DRAWING_STATUS_NORMAL)
334         {
335                 __normalTextColor = color;
336         }
337         else if (status == ICON_LIST_VIEW_ITEM_DRAWING_STATUS_PRESSED)
338         {
339                 __pressedTextColor = color;
340         }
341         else
342         {
343                 __highlightedTextColor = color;
344         }
345
346         __changed = true;
347         __customColorSet = true;
348         return E_SUCCESS;
349 }
350
351 const Color
352 _IconListItemDrawingProperty::GetTextColor(IconListViewItemDrawingStatus status) const
353 {
354         SysTryReturn(NID_UI_CTRL,
355                         (status >= ICON_LIST_VIEW_ITEM_DRAWING_STATUS_NORMAL && status <= ICON_LIST_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED),
356                         Color(0), E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Invalid value of drawing status.");
357
358         ClearLastResult();
359
360         if (status == ICON_LIST_VIEW_ITEM_DRAWING_STATUS_NORMAL)
361         {
362                 return __normalTextColor;
363         }
364         else if (status == ICON_LIST_VIEW_ITEM_DRAWING_STATUS_PRESSED)
365         {
366                 return __pressedTextColor;
367         }
368         else
369         {
370                 return __highlightedTextColor;
371         }
372 }
373
374 const Color
375 _IconListItemDrawingProperty::GetTextBackgroundColor(void) const
376 {
377         if (__textVerticalAlignment >= ICON_LIST_VIEW_ITEM_TEXT_VERTICAL_ALIGNMENT_OUTSIDE_TOP)
378         {
379                 return Color(0, 0, 0, 0);
380         }
381         return __inTextBackgroundColor;
382 }
383
384 const Color
385 _IconListItemDrawingProperty::GetBorderColor(bool isFocused) const
386 {
387         return isFocused ? __focusBorderColor : __normalBorderColor;
388 }
389
390 result
391 _IconListItemDrawingProperty::SetItemLayout(void)
392 {
393         SysTryReturn(NID_UI_CTRL,
394                         (__textVerticalAlignment >= ICON_LIST_VIEW_ITEM_TEXT_VERTICAL_ALIGNMENT_INSIDE_TOP && __textVerticalAlignment <=
395                         ICON_LIST_VIEW_ITEM_TEXT_VERTICAL_ALIGNMENT_OUTSIDE_BOTTOM), E_SYSTEM, E_SYSTEM,
396                         "[E_SYSTEM] A system error has been occurred. The current state of vertical text alignment is not valid.");
397
398         switch (__textVerticalAlignment)
399         {
400         case ICON_LIST_VIEW_ITEM_TEXT_VERTICAL_ALIGNMENT_INSIDE_TOP:
401                 __textYPos = 1.0f;
402                 __2LineTextYPos = __textYPos;
403                 break;
404
405         case ICON_LIST_VIEW_ITEM_TEXT_VERTICAL_ALIGNMENT_INSIDE_MIDDLE:
406                 __textYPos = (__size.height - __insideOneLineTextHeight) / 2.0f ;
407                 __2LineTextYPos = (__size.height - __insideTwoLineTextHeight) / 2.0f;
408                 break;
409
410         case ICON_LIST_VIEW_ITEM_TEXT_VERTICAL_ALIGNMENT_INSIDE_BOTTOM:
411                 __textYPos = __size.height - __insideOneLineTextHeight - 2.0f;
412                 __2LineTextYPos = __size.height - __insideTwoLineTextHeight - 2.0f;
413                 break;
414
415         case ICON_LIST_VIEW_ITEM_TEXT_VERTICAL_ALIGNMENT_OUTSIDE_TOP:
416                 __textYPos = __insideOneLineTextHeight - __itemTextVerticalMargin;
417                 __2LineTextYPos = 1.0f;
418                 break;
419
420         case ICON_LIST_VIEW_ITEM_TEXT_VERTICAL_ALIGNMENT_OUTSIDE_BOTTOM:
421                 __textYPos = __size.height - __verticalExtent;
422                 __2LineTextYPos = __textYPos;
423                 break;
424         }
425
426         if (!__customColorSet)
427         {
428                 if (__textVerticalAlignment >= ICON_LIST_VIEW_ITEM_TEXT_VERTICAL_ALIGNMENT_INSIDE_TOP && __textVerticalAlignment <= ICON_LIST_VIEW_ITEM_TEXT_VERTICAL_ALIGNMENT_INSIDE_BOTTOM)
429                 {
430                         GET_COLOR_CONFIG(ICONLIST::INNER_TEXT_NORMAL, __normalTextColor);
431                         GET_COLOR_CONFIG(ICONLIST::INNER_TEXT_PRESSED, __pressedTextColor);
432                         GET_COLOR_CONFIG(ICONLIST::INNER_TEXT_HIGHLIGHTED, __highlightedTextColor);
433                 }
434                 else if (__textVerticalAlignment >= ICON_LIST_VIEW_ITEM_TEXT_VERTICAL_ALIGNMENT_OUTSIDE_TOP && __textVerticalAlignment <= ICON_LIST_VIEW_ITEM_TEXT_VERTICAL_ALIGNMENT_OUTSIDE_BOTTOM)
435                 {
436                         GET_COLOR_CONFIG(ICONLIST::TEXT_NORMAL, __normalTextColor);
437                         GET_COLOR_CONFIG(ICONLIST::TEXT_PRESSED, __pressedTextColor);
438                         GET_COLOR_CONFIG(ICONLIST::TEXT_HIGHLIGHTED, __highlightedTextColor);
439                 }
440         }
441
442         __changed = true;
443
444         return E_SUCCESS;
445 }
446
447 result
448 _IconListItemDrawingProperty::SetItemBitmapBounds(const FloatRectangle bounds)
449 {
450         SysTryReturn(NID_UI_CTRL, _FloatCompareGE(bounds.x, 0.0f) && _FloatCompareGE(bounds.y, 0.0f), E_INVALID_ARG, E_INVALID_ARG,
451                         "[E_INVALID_ARG] Invalid argument is used. X and Y must be a non-negative value.");
452         SysTryReturn(NID_UI_CTRL, _FloatCompareGE(bounds.width, 0.0f) && _FloatCompareGE(bounds.height, 0.0f), E_INVALID_ARG,
453                         E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. Width and height should be larger than 0.0f.");
454
455         __bitmapBounds = bounds;
456         __size.width = bounds.width;
457         __size.height = bounds.height;
458
459         if (__textVerticalAlignment >= ICON_LIST_VIEW_ITEM_TEXT_VERTICAL_ALIGNMENT_OUTSIDE_TOP)
460         {
461                 __size.height += __insideTwoLineTextHeight;
462         }
463
464         return SetItemLayout();
465 }
466
467 FloatRectangle
468 _IconListItemDrawingProperty::GetItemBitmapBounds(void) const
469 {
470         ClearLastResult();
471
472         FloatRectangle bounds(__bitmapBounds);
473         if (__textVerticalAlignment == ICON_LIST_VIEW_ITEM_TEXT_VERTICAL_ALIGNMENT_OUTSIDE_TOP)
474         {
475                 bounds.y += __verticalExtent;
476         }
477
478         return bounds;
479 }
480
481 FloatDimension
482 _IconListItemDrawingProperty::GetItemBitmapSize(void) const
483 {
484         ClearLastResult();
485         return FloatDimension(__bitmapBounds.width, __bitmapBounds.height);
486 }
487
488 result
489 _IconListItemDrawingProperty::SetItemSize(const FloatDimension size)
490 {
491         SysTryReturn(NID_UI_CTRL, !_FloatCompareLE(size.width, 0.0f) && !_FloatCompareLE(size.height, 0.0f), E_INVALID_ARG,
492                         E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. Width and height should be larger than 0.");
493
494         __size = size;
495         return E_SUCCESS;
496 }
497
498 FloatDimension
499 _IconListItemDrawingProperty::GetItemSize(void) const
500 {
501         ClearLastResult();
502         return __size;
503 }
504
505 float
506 _IconListItemDrawingProperty::GetTextXPosition(void) const
507 {
508         return __itemTextHorizontalMargin;
509 }
510
511 float
512 _IconListItemDrawingProperty::GetTextYPosition(void) const
513 {
514         return __textYPos;
515 }
516
517 float
518 _IconListItemDrawingProperty::GetTwoLineTextYPosition(void) const
519 {
520         return __2LineTextYPos;
521 }
522
523 float
524 _IconListItemDrawingProperty::GetTextAreaWidth(void) const
525 {
526         return __bitmapBounds.width - __itemTextHorizontalMargin * 2.0f;
527 }
528
529 float
530 _IconListItemDrawingProperty::GetTextVerticalMargin(void) const
531 {
532         return __itemTextVerticalMargin;
533 }
534
535 result
536 _IconListItemDrawingProperty::SetCheckBoxPosition(IconListViewCheckBoxPosition position)
537 {
538         SysTryReturn(NID_UI_CTRL,
539                         (position >= ICON_LIST_VIEW_CHECK_BOX_POSITION_TOP_LEFT && position <= ICON_LIST_VIEW_CHECK_BOX_POSITION_BOTTOM_RIGHT),
540                         E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Invalid position of CheckBox is used.");
541
542         if (__checkBoxPosition == position)
543         {
544                 return E_SUCCESS;
545         }
546
547         __checkBoxPosition = position;
548         __changed = true;
549
550         return E_SUCCESS;
551 }
552
553 IconListViewCheckBoxPosition
554 _IconListItemDrawingProperty::GetCheckBoxPosition(void) const
555 {
556         return __checkBoxPosition;
557 }
558
559 result
560 _IconListItemDrawingProperty::SetBorderStyle(IconListViewItemBorderStyle style)
561 {
562         SysTryReturn(NID_UI_CTRL, (style >= ICON_LIST_VIEW_ITEM_BORDER_STYLE_NONE && style <= ICON_LIST_VIEW_ITEM_BORDER_STYLE_SHADOW),
563                         E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Invalid item border style is used.");
564
565         if (__borderStyle == style)
566         {
567                 return E_SUCCESS;
568         }
569
570         __borderStyle = style;
571         __changed = true;
572
573         return E_SUCCESS;
574 }
575
576 IconListViewItemBorderStyle
577 _IconListItemDrawingProperty::GetBorderStyle(void) const
578 {
579         ClearLastResult();
580         return __borderStyle;
581 }
582
583 result
584 _IconListItemDrawingProperty::SetTextHorizontalAlignment(HorizontalAlignment alignment)
585 {
586         SysTryReturn(NID_UI_CTRL, (alignment >= ALIGNMENT_LEFT && alignment <= ALIGNMENT_RIGHT), E_SYSTEM, E_SYSTEM,
587                         "[E_SYSTEM] A system error has been occurred. Invalid horizontal text alignment is used.");
588
589         if (__textHorizontalAlignment == alignment)
590         {
591                 return E_SUCCESS;
592         }
593
594         __textHorizontalAlignment = alignment;
595         __changed = true;
596
597         return E_SUCCESS;
598 }
599
600 HorizontalAlignment
601 _IconListItemDrawingProperty::GetTextHorizontalAlignment(void) const
602 {
603         return __textHorizontalAlignment;
604 }
605
606 result
607 _IconListItemDrawingProperty::SetTextVerticalAlignment(IconListViewItemTextVerticalAlignment alignment)
608 {
609         SysTryReturn(NID_UI_CTRL, (alignment >= ICON_LIST_VIEW_ITEM_TEXT_VERTICAL_ALIGNMENT_INSIDE_TOP && alignment <=
610                         ICON_LIST_VIEW_ITEM_TEXT_VERTICAL_ALIGNMENT_OUTSIDE_BOTTOM), E_SYSTEM, E_SYSTEM,
611                         "[E_SYSTEM] A system error has been occurred. Invalid vertical text alignment is used.");
612
613         if (__textVerticalAlignment == alignment)
614         {
615                 return E_SUCCESS;
616         }
617
618         if (alignment >= ICON_LIST_VIEW_ITEM_TEXT_VERTICAL_ALIGNMENT_OUTSIDE_TOP &&
619                         __textVerticalAlignment < ICON_LIST_VIEW_ITEM_TEXT_VERTICAL_ALIGNMENT_OUTSIDE_TOP)
620         {
621                 __size.height = __size.height + __verticalExtent;
622         }
623         else if (alignment < ICON_LIST_VIEW_ITEM_TEXT_VERTICAL_ALIGNMENT_OUTSIDE_TOP &&
624                         __textVerticalAlignment >= ICON_LIST_VIEW_ITEM_TEXT_VERTICAL_ALIGNMENT_OUTSIDE_TOP)
625         {
626                 __size.height -= __verticalExtent;
627         }
628
629         __textVerticalAlignment = alignment;
630         __changed = true;
631
632         // Adjust layout of Item.
633         return SetItemLayout();
634 }
635
636 IconListViewItemTextVerticalAlignment
637 _IconListItemDrawingProperty::GetTextVerticalAlignment(void) const
638 {
639         return __textVerticalAlignment;
640 }
641
642 const Bitmap*
643 _IconListItemDrawingProperty::GetDropShadowBitmap(void) const
644 {
645         return __pDropShadowBitmapWithReplacementColor;
646 }
647
648 const Bitmap*
649 _IconListItemDrawingProperty::GetFocusBitmap(void) const
650 {
651         return __pFocusBitmap;
652 }
653
654 float
655 _IconListItemDrawingProperty::GetDropShadowBorderWidth(void) const
656 {
657         return __dropShadowBorderWidth;
658 }
659
660 float
661 _IconListItemDrawingProperty::GetDropShadowMargin(void) const
662 {
663         return __dropShadowMargin;
664 }
665
666 FloatRectangle
667 _IconListItemDrawingProperty::GetDropShadowBitmapBounds(void) const
668 {
669         FloatRectangle bounds(__bitmapBounds);
670         if (__textVerticalAlignment == ICON_LIST_VIEW_ITEM_TEXT_VERTICAL_ALIGNMENT_OUTSIDE_TOP)
671         {
672                 bounds.y += __verticalExtent;
673         }
674
675         return bounds;
676 }
677
678 const Bitmap*
679 _IconListItemDrawingProperty::GetCheckBitmap(void) const
680 {
681         return __pCheckBitmap;
682 }
683
684 const Bitmap*
685 _IconListItemDrawingProperty::GetCheckedBackgroundBitmap(void) const
686 {
687         return __pCheckedBackgroundBitmap;
688 }
689
690 const Bitmap*
691 _IconListItemDrawingProperty::GetUnCheckedBackgroundBitmap(void) const
692 {
693         return __pUnCheckedBackgroundBitmap;
694 }
695
696 const Bitmap*
697 _IconListItemDrawingProperty::GetDisabledCheckBitmap(void) const
698 {
699         return __pDisabledCheckBitmap;
700 }
701
702 void
703 _IconListItemDrawingProperty::SetItemCheckedStyle(bool checkStyle)
704 {
705         __checkedStyle = checkStyle;
706 }
707
708 bool
709 _IconListItemDrawingProperty::IsItemCheckedStyle(void) const
710 {
711         return __checkedStyle;
712 }
713
714 float
715 _IconListItemDrawingProperty::GetCheckMargin(void) const
716 {
717         return __checkMargin;
718 }
719
720 float
721 _IconListItemDrawingProperty::GetOverlayMargin(void) const
722 {
723         return __overlayMargin;
724 }
725
726 float
727 _IconListItemDrawingProperty::GetSelectBackgroundMargin(void) const
728 {
729         return __selectBackgroundMargin;
730 }
731
732 void
733 _IconListItemDrawingProperty::SetDrawingFlag(void)
734 {
735         __changed = false;
736 }
737
738 bool
739 _IconListItemDrawingProperty::IsChanged(void) const
740 {
741         return __changed;
742 }
743
744 int
745 _IconListItemDrawingProperty::AddRef(void)
746 {
747         return ++__refCount;
748 }
749
750 int
751 _IconListItemDrawingProperty::Release(void)
752 {
753         --__refCount;
754         if (__refCount <= 0)
755         {
756                 delete this;
757                 return 0;
758         }
759
760         return __refCount;
761 }
762
763 void
764 _IconListItemDrawingProperty::SetItemBitmapAsAspectRatio(bool isAspect)
765 {
766         __asAspectRatio = isAspect;
767 }
768
769 bool
770 _IconListItemDrawingProperty::IsItemBitmapAsAspectRatio(void) const
771 {
772         return __asAspectRatio;
773 }
774
775 void
776 _IconListItemDrawingProperty::SetAccessibilityEnabled(bool enabled)
777 {
778         if (__accessibilityEnabled != enabled)
779         {
780                 __accessibilityEnabled = enabled;
781                 __changed = true;
782         }
783 }
784
785 bool
786 _IconListItemDrawingProperty::IsAccessibilityEnabled(void)
787 {
788         return __accessibilityEnabled;
789 }
790
791 }}} // Tizen::Ui::Controls