Tizen 2.1 base
[framework/osp/uifw.git] / src / ui / FUi_UiBuilderControlMaker.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 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 /**
19 * @file         FUi_UiBuilderControlMaker.cpp
20 * @brief                This is the implementation file for _UiBuilderControlMaker class.
21 */
22
23 #include <app.h>
24 #include <runtime_info.h>
25 #include <FAppApplication.h>
26 #include <FUiContainer.h>
27 #include <FBaseSysLog.h>
28 #include <FBaseInteger.h>
29 #include <FBase_StringConverter.h>
30 #include <FGrp_NonScale.h>
31 #include <FGrp_BitmapImpl.h>
32 #include "FUi_UiBuilderControlMaker.h"
33 #include "FUi_UiBuilder.h"
34
35 using namespace Tizen::Base;
36 using namespace Tizen::Ui;
37 using namespace Tizen::Ui::Controls;
38 using namespace Tizen::App;
39 using namespace Tizen::Graphics;
40
41 namespace Tizen { namespace Ui
42 {
43 _UiBuilderControlMaker::_UiBuilderControlMaker(_UiBuilder* pUibuilder)
44         : __pUiBuilder(null)
45 {
46         __pUiBuilder = pUibuilder;
47 }
48 _UiBuilderControlMaker::_UiBuilderControlMaker(void)
49         : __pUiBuilder(null)
50 {
51 }
52 _UiBuilderControlMaker::~_UiBuilderControlMaker(void)
53 {
54 }
55
56 result
57 _UiBuilderControlMaker::MakeControl(_UiBuilderControl* pUiBuilderControl)
58 {
59         Tizen::Ui::Control* pControl = null;
60
61         if (pUiBuilderControl != null)
62         {
63                 pControl = Make(pUiBuilderControl);
64                 if ((pUiBuilderControl->GetType()).Equals(L"Header", false) || (pUiBuilderControl->GetType()).Equals(L"Footer", false))
65                 {
66                         return E_SUCCESS;
67                 }
68                 if (pControl != null)
69                 {
70                         pControl->SetName(pUiBuilderControl->GetId());
71                         SetLayoutOrientation(pUiBuilderControl, pControl);
72                         if (!(pUiBuilderControl->GetType().Equals(L"Form", false) || pUiBuilderControl->GetType().Equals(L"Popup", false)))
73                         {
74                                 if (pUiBuilderControl->GetType().Equals(L"Panel", false) || pUiBuilderControl->GetType().Equals(L"ScrollPanel", false))
75                                 {
76                                         if (pUiBuilderControl->GetParentWin().IsEmpty())
77                                         {
78                                                 return E_SUCCESS;
79                                         }
80
81                                 }
82                                 AddControl(pUiBuilderControl, pControl);
83                                 SetLayoutProperty(pUiBuilderControl, pControl);
84
85                         }
86                         return E_SUCCESS;
87                 }
88         }
89
90                 return E_OPERATION_FAILED;
91 }
92
93 void
94 _UiBuilderControlMaker::ConvertStringToColor(const Tizen::Base::String& colorString, Color& color)
95 {
96         int index = 0;
97         int len = 0;
98         int gap = 0;
99         const wchar_t* colorStringPointer = colorString.GetPointer();
100         char ch;
101         unsigned long temp = 0;
102
103         len = colorString.GetLength();
104
105         if (len < 1)
106         {
107                 return;
108         }
109         color = 0;
110
111         for (index = 0; index < len + 1; index++)
112         {
113                 ch = colorStringPointer[index];
114                 if ((ch >= '0') && (ch <= '9'))
115                 {
116                         temp = temp << 4;
117                         gap = ch - '0';
118                         temp |= gap;
119
120                 }
121                 else if ((ch >= 'A') && (ch <= 'F'))
122                 {
123                         temp = temp << 4;
124                         gap = ch - 'A' + 10;
125                         temp |= gap;
126
127                 }
128                 else if ((ch >= 'a') && (ch <= 'f'))
129                 {
130                         temp = temp << 4;
131                         gap = ch - 'a' + 10;
132                         temp |= gap;
133                 }
134         }
135         color.SetRGB32(temp, false);
136 }
137
138 void
139 _UiBuilderControlMaker::ConvertStringToColor32(const Tizen::Base::String& colorString, int opacity, Color& color)
140 {
141         int index = 0;
142         int len = 0;
143         int gap = 0;
144         int alpha = 0;
145         const wchar_t* colorStringPointer = colorString.GetPointer();
146         char ch;
147         unsigned long temp = 0;
148
149         len = colorString.GetLength();
150
151         if (len < 1)
152         {
153                 SysLog(NID_UI, "String is empty");
154                 return;
155         }
156
157         color = 0;
158
159         for (index = 0; index < len + 1; index++)
160         {
161                 ch = colorStringPointer[index];
162                 if ((ch >= '0') && (ch <= '9'))
163                 {
164                         temp = temp << 4;
165                         gap = ch - '0';
166                         temp |= gap;
167
168                 }
169                 else if ((ch >= 'A') && (ch <= 'F'))
170                 {
171                         temp = temp << 4;
172                         gap = ch - 'A' + 10;
173                         temp |= gap;
174
175                 }
176                 else if ((ch >= 'a') && (ch <= 'f'))
177                 {
178                         temp = temp << 4;
179                         gap = ch - 'a' + 10;
180                         temp |= gap;
181                 }
182         }
183
184         color.SetRGB32(temp, true);
185         alpha = ConvertOpacity100to255(opacity);
186         color.SetAlpha(alpha);
187 }
188
189 int
190 _UiBuilderControlMaker::ConvertOpacity100to255(int opacity)
191 {
192         return 255 * opacity / 100;
193 }
194
195 bool
196 _UiBuilderControlMaker::ConvertHAlignToHorizontalAlignment(const Tizen::Base::String& align, HorizontalAlignment& alignment)
197 {
198         if (align.Equals(L"ALIGN_LEFT", false))
199         {
200                 alignment = ALIGNMENT_LEFT;
201         }
202         else if (align.Equals(L"ALIGN_CENTER", false))
203         {
204                 alignment = ALIGNMENT_CENTER;
205         }
206         else if (align.Equals(L"ALIGN_RIGHT", false))
207         {
208                 alignment = ALIGNMENT_RIGHT;
209         }
210         else
211         {
212                 return false;
213         }
214
215         return true;
216 }
217
218 bool
219 _UiBuilderControlMaker::ConvertVAlignToVerticalAlignment(const Tizen::Base::String& align, VerticalAlignment& alignment)
220 {
221         if (align.Equals(L"ALIGN_TOP", false))
222         {
223                 alignment = ALIGNMENT_TOP;
224         }
225         else if (align.Equals(L"ALIGN_MIDDLE", false))
226         {
227                 alignment = ALIGNMENT_MIDDLE;
228         }
229         else if (align.Equals(L"ALIGN_BOTTOM", false))
230         {
231                 alignment = ALIGNMENT_BOTTOM;
232         }
233         else
234         {
235                 return false;
236         }
237
238         return true;
239 }
240
241 bool
242 _UiBuilderControlMaker::ConvertSlideShowAnimation(const Tizen::Base::String& animationType, GalleryAnimation& animation)
243 {
244         if (animationType.Equals(L"GALLERY_ANIMATION_PAGE", false))
245         {
246                 animation = GALLERY_ANIMATION_PAGE;
247         }
248         else if (animationType.Equals(L"GALLERY_ANIMATION_DISSOLVE", false))
249         {
250                 animation = GALLERY_ANIMATION_DISSOLVE;
251         }
252         else if (animationType.Equals(L"GALLERY_ANIMATION_ZOOM", false))
253         {
254                 animation = GALLERY_ANIMATION_ZOOM;
255         }
256         else
257         {
258                 return false;
259         }
260
261         return true;
262 }
263
264 Tizen::Graphics::Bitmap*
265 _UiBuilderControlMaker::LoadBitmapN(const Tizen::Base::String& imagePath)
266 {
267         UiApp* pUiApp = UiApp::GetInstance();
268         if (pUiApp != null)
269         {
270                 AppResource* pAppResource = UiApp::GetInstance()->GetAppResource();
271                 if (pAppResource != null)
272                 {
273                         Tizen::Graphics::Bitmap* pBitmap = pAppResource->GetBitmapN(imagePath);
274                                 return pBitmap;
275                 }
276         }
277
278         return null;
279 }
280 void
281 _UiBuilderControlMaker::GetProperty(_UiBuilderControl* pControl, _UiBuilderControlLayout** pControlProperty) const
282 {
283         // Form's orientation mode is AUTOMATIC
284         if (__pUiBuilder->GetUiBuilderRotateState() == UIBUIDER_SCREEN_NONE)
285         {
286                 // Get device orientation
287
288                 bool autoRotateLock = false;
289                 int ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_AUTO_ROTATION_ENABLED, &autoRotateLock);
290
291                 if (ret == RUNTIME_INFO_ERROR_NONE)
292                 {
293                         SysLog(NID_UI, "The flag of auto-rotate lock is %d.", autoRotateLock);
294                 }
295                 else
296                 {
297                         autoRotateLock = false;
298                         SysLog(NID_UI, "It's failed to get the flag of auto-rotate.");
299                 }
300
301                 app_device_orientation_e deviceOrientation = app_get_device_orientation();
302                 bool isHorizontal = (deviceOrientation == APP_DEVICE_ORIENTATION_90) || (deviceOrientation == APP_DEVICE_ORIENTATION_270);
303
304                 if (isHorizontal && autoRotateLock == true)
305                 {
306                         __pUiBuilder->SetUiBuilderRotateState(UIBUIDER_SCREEN_HORIZONTAL);
307                 }
308                 else
309                 {
310                         __pUiBuilder->SetUiBuilderRotateState(UIBUIDER_SCREEN_VERTICAL);
311                 }
312         }
313
314         if (__pUiBuilder->GetUiBuilderRotateState() == UIBUIDER_SCREEN_HORIZONTAL)
315         {
316                 *pControlProperty = pControl->GetAttribute(UIBUILDER_ATTRIBUTE_LANDSCAPE);
317         }
318         else
319         {
320                 *pControlProperty = pControl->GetAttribute(UIBUILDER_ATTRIBUTE_PORTRAIT);
321         }
322
323         return;
324 }
325
326 bool
327 _UiBuilderControlMaker::GetLayoutType(_UiBuilderControlLayout* pControlProperty, _UiBuilderLayoutType& returnType) const
328 {
329         if (pControlProperty == null)
330         {
331                 return false;
332         }
333
334         Tizen::Base::String layoutType(L"");
335
336         if (pControlProperty->GetLayoutElement( L"type", layoutType))
337         {
338
339                 if (layoutType.Equals(L"NONE", false))
340                 {
341                         returnType = UIBUILDER_LAYOUT_NONE;
342                 }
343                 else if (layoutType.Equals(L"LAYOUT_GRID", false))
344                 {
345                         returnType = UIBUILDER_LAYOUT_GRID;
346                 }
347                 else if (layoutType.Equals(L"LAYOUT_HORIZONTAL_BOX", false))
348                 {
349                         returnType = UIBUILDER_LAYOUT_HORIZONTAL_BOX;
350                 }
351                 else if (layoutType.Equals(L"LAYOUT_VERTICAL_BOX", false))
352                 {
353                         returnType = UIBUILDER_LAYOUT_VERTICAL_BOX;
354                 }
355                 else if (layoutType.Equals(L"LAYOUT_RELATIVE", false))
356                 {
357                         returnType = UIBUILDER_LAYOUT_RELATIVE;
358                 }
359                 else
360                 {
361                         returnType = UIBUILDER_LAYOUT_NONE;
362                         return false;
363                 }
364         }
365         else
366         {
367                 returnType = UIBUILDER_LAYOUT_NONE;
368         }
369
370         return true;
371 }
372
373 bool
374 _UiBuilderControlMaker::GetParentLayoutType(_UiBuilderControlLayout* pControlProperty, _UiBuilderLayoutType& returnType) const
375 {
376         if (pControlProperty == null)
377         {
378                 return false;
379         }
380         Tizen::Base::String parentLayoutType(L"");
381
382         if (pControlProperty->GetLayoutElement(L"parentType", parentLayoutType))
383         {
384                 if (parentLayoutType.Equals(L"NONE", false))
385                 {
386                         returnType = UIBUILDER_LAYOUT_NONE;
387                 }
388                 else if (parentLayoutType.Equals(L"LAYOUT_GRID", false))
389                 {
390                         returnType = UIBUILDER_LAYOUT_GRID;
391                 }
392                 else if (parentLayoutType.Equals(L"LAYOUT_HORIZONTAL_BOX", false))
393                 {
394                         returnType = UIBUILDER_LAYOUT_HORIZONTAL_BOX;
395                 }
396                 else if (parentLayoutType.Equals(L"LAYOUT_VERTICAL_BOX", false))
397                 {
398                         returnType = UIBUILDER_LAYOUT_VERTICAL_BOX;
399                 }
400                 else if (parentLayoutType.Equals(L"LAYOUT_RELATIVE", false))
401                 {
402                         returnType = UIBUILDER_LAYOUT_RELATIVE;
403                 }
404                 else
405                 {
406                         returnType = UIBUILDER_LAYOUT_NONE;
407                         return false;
408                 }
409         }
410         else
411         {
412                 returnType = UIBUILDER_LAYOUT_NONE;
413         }
414         return true;
415 }
416
417 result
418 _UiBuilderControlMaker::GetGridLayoutN(_UiBuilderControlLayout* pControlProperty, Layout*& pLayout) const
419 {
420         if (pControlProperty == null)
421         {
422                 return E_SYSTEM;
423         }
424
425         result r = E_SUCCESS;
426         Tizen::Base::String gridLayoutValue(L"");
427         GridLayout* pGridLayout = null;
428         int maxColumn = 0;
429         int maxRow = 0;
430
431         pGridLayout = new (std::nothrow) GridLayout;
432         if (!pGridLayout)
433         {
434                 SysLog(NID_UI, "Unable to create layout");
435                 r = E_SYSTEM;
436                 goto CATCH;
437         }
438         if (pControlProperty->GetLayoutElement(L"maxColumn", gridLayoutValue))
439         {
440                 Integer::Parse(gridLayoutValue, maxColumn);
441         }
442
443         if (pControlProperty->GetLayoutElement(L"maxRow", gridLayoutValue))
444         {
445                 Integer::Parse(gridLayoutValue, maxRow);
446         }
447
448         r = pGridLayout->Construct(maxRow, maxColumn);
449         if (E_SUCCESS != r)
450         {
451                 SysLog(NID_UI, "[%s] Propagated.", GetErrorMessage(r));
452                 delete pGridLayout;
453                 pGridLayout = null;
454         }
455
456 CATCH:
457         pLayout = pGridLayout;
458
459         return r;
460 }
461
462 result
463 _UiBuilderControlMaker::GetHorizontalBoxLayoutN(_UiBuilderControlLayout* pControlProperty, Layout*& pLayout) const
464 {
465         if (pControlProperty == null)
466         {
467                 return E_SYSTEM;
468         }
469         result r = E_SUCCESS;
470
471         Tizen::Base::String horizontalBoxLayoutValue(L"");
472
473         HorizontalBoxLayout* pHboxLayout = null;
474         HorizontalDirection direction;
475
476         pHboxLayout = new (std::nothrow) HorizontalBoxLayout;
477         if (!pHboxLayout)
478         {
479                 SysLog(NID_UI, "[E_SYSTEM] Unable to create layout");
480                 r = E_SYSTEM;
481                 goto CATCH;
482         }
483
484         if (pControlProperty->GetLayoutElement(L"horizontalDirection", horizontalBoxLayoutValue))
485         {
486                 if (horizontalBoxLayoutValue.Equals(L"HORIZONTAL_DIRECTION_LEFTWARD", false))
487                 {
488                         direction = HORIZONTAL_DIRECTION_LEFTWARD;
489                 }
490                 else
491                 {
492                         direction = HORIZONTAL_DIRECTION_RIGHTWARD;
493                 }
494         }
495         else
496         {
497                 direction = HORIZONTAL_DIRECTION_RIGHTWARD;
498         }
499
500         r = pHboxLayout->Construct(direction);
501         if (E_SUCCESS != r)
502         {
503                 SysLog(NID_UI, "[%s] Propagated.", GetErrorMessage(r));
504                 delete pHboxLayout;
505                 pHboxLayout = null;
506         }
507
508 CATCH:
509         pLayout = pHboxLayout;
510
511         return r;
512 }
513
514 result
515 _UiBuilderControlMaker::GetVerticalBoxLayoutN(_UiBuilderControlLayout* pControlProperty, Layout*& pLayout) const
516 {
517         if (pControlProperty == null)
518         {
519                 return E_SYSTEM;
520         }
521         result r = E_SUCCESS;
522
523 Tizen::Base::String verticalBoxLayoutValue(L"");
524
525         VerticalBoxLayout* pVboxLayout = null;
526         VerticalDirection direction;
527
528         pVboxLayout = new (std::nothrow) VerticalBoxLayout;
529         if (!pVboxLayout)
530         {
531                 SysLog(NID_UI, "[E_SYSTEM] Unable to create layout");
532                 r = E_SYSTEM;
533                 goto CATCH;
534         }
535
536         if (pControlProperty->GetLayoutElement(L"verticalDirection", verticalBoxLayoutValue))
537         {
538                 if (verticalBoxLayoutValue.Equals(L"VERTICAL_DIRECTION_UPWARD", false))
539                 {
540                         direction = VERTICAL_DIRECTION_UPWARD;
541                 }
542                 else
543                 {
544                         direction = VERTICAL_DIRECTION_DOWNWARD;
545                 }
546         }
547         else
548         {
549                 direction = VERTICAL_DIRECTION_DOWNWARD;
550         }
551
552         r = pVboxLayout->Construct(direction);
553         if (E_SUCCESS != r)
554         {
555                 SysLog(NID_UI, "[%s] Propagated.", GetErrorMessage(r));
556                 delete pVboxLayout;
557                 pVboxLayout = null;
558         }
559
560 CATCH:
561         pLayout = pVboxLayout;
562
563         return r;
564 }
565
566 result
567 _UiBuilderControlMaker::GetRelativeLayoutN(_UiBuilderControlLayout* pControlProperty, Layout*& pLayout) const
568 {
569         if (pControlProperty == null)
570         {
571                 return E_SYSTEM;
572         }
573         result r = E_SUCCESS;
574
575         RelativeLayout* pRelLayout = null;
576
577         pRelLayout = new (std::nothrow) RelativeLayout;
578         if (!pRelLayout)
579         {
580                 SysLog(NID_UI, "Unable to create layout");
581                 r = E_SYSTEM;
582                 goto CATCH;
583         }
584
585         if (E_SUCCESS != pRelLayout->Construct())
586         {
587                 SysLog(NID_UI, "[%s] Propagated.", GetErrorMessage(r));
588                 delete pRelLayout;
589                 pRelLayout = null;
590         }
591 CATCH:
592         pLayout = pRelLayout;
593
594         return r;
595 }
596
597 result
598 _UiBuilderControlMaker::GetLayoutN(_UiBuilderControl* pUiBuilderControl, Layout*& pPortraitLayout, Layout*& pLandscapeLayout) const
599 {
600         result r = E_SUCCESS;
601
602         _UiBuilderControlLayout* pControlProperty = null;
603
604         Layout* pLayout = null;
605         Layout* pLayoutPortrait = null;
606         Layout* pLayoutLandscape = null;
607
608         for (int i = 0; i < UIBUILDER_ATTRIBUTE_NUM; i++)
609         {
610                 _UiBuilderLayoutType layoutType = UIBUILDER_LAYOUT_NONE;
611                 pControlProperty = pUiBuilderControl->GetAttribute(i);
612                 if (pControlProperty == null)
613                 {
614                         SysLog(NID_UI, "Unable to set layout property");
615                         return E_SYSTEM;
616                 }
617                 if (GetLayoutType(pControlProperty, layoutType) == false)
618                 {
619                         return E_SYSTEM;
620                 }
621
622                 switch (layoutType)
623                 {
624                 case UIBUILDER_LAYOUT_GRID:
625                         r = GetGridLayoutN(pControlProperty, pLayout);
626                         break;
627
628                 case UIBUILDER_LAYOUT_HORIZONTAL_BOX:
629                         r = GetHorizontalBoxLayoutN(pControlProperty, pLayout);
630                         break;
631
632                 case UIBUILDER_LAYOUT_VERTICAL_BOX:
633                         r = GetVerticalBoxLayoutN(pControlProperty, pLayout);
634                         break;
635
636                 case UIBUILDER_LAYOUT_RELATIVE:
637                         r = GetRelativeLayoutN(pControlProperty, pLayout);
638                         break;
639
640                 default:
641                         SysLog(NID_UI, "Unknown Layout type = %d", layoutType);
642                         break;
643                 }
644                 if (r != E_SUCCESS)
645                 {
646                         SysLog(NID_UI, "[%s] Propagated.", GetErrorMessage(r));
647                         return r;
648                 }
649                 if (UIBUILDER_ATTRIBUTE_PORTRAIT == i)
650                 {
651                         pLayoutPortrait = pLayout;
652                 }
653                 else if (UIBUILDER_ATTRIBUTE_LANDSCAPE == i)
654                 {
655                         pLayoutLandscape = pLayout;
656                 }
657         }
658         if ((pLayoutPortrait == null) && (pLayoutLandscape != null))
659         {
660                 pLayoutPortrait = pLayoutLandscape;
661         }
662         else if ((pLayoutPortrait != null) && (pLayoutLandscape == null))
663         {
664                 pLayoutLandscape = pLayoutPortrait;
665         }
666
667         pPortraitLayout = pLayoutPortrait;
668         pLandscapeLayout = pLayoutLandscape;
669
670         return r;
671 }
672
673 result
674 _UiBuilderControlMaker::SetGridLayoutContainerProperty(GridLayout* pLayout, _UiBuilderControlLayout* pControlProperty) const
675 {
676         result r = E_SUCCESS;
677
678         if ((null == pLayout) || (null == pControlProperty))
679         {
680                 return E_SYSTEM;
681         }
682
683         GridLayout& layout = *pLayout;
684         UiBuilderGridLayoutContainer layoutParam;
685         Tizen::Base::String gridLayoutContainerPropertyValue(L"");
686
687         layoutParam.maxColumn = 0;
688         layoutParam.maxRow = 0;
689         if (pControlProperty->GetLayoutElement(L"maxColumn", gridLayoutContainerPropertyValue))
690         {
691                 Integer::Parse(gridLayoutContainerPropertyValue, layoutParam.maxColumn);
692         }
693
694         if (pControlProperty->GetLayoutElement(L"maxRow", gridLayoutContainerPropertyValue))
695         {
696                 Integer::Parse(gridLayoutContainerPropertyValue, layoutParam.maxRow);
697         }
698
699         String headerColumn = "column";
700         String headerRow = "row";
701         String tempString;
702
703         for (int i = 1; i <= layoutParam.maxColumn; i++)
704         {
705                 tempString = headerColumn;
706                 tempString.Append(i);
707                 tempString.Append("Collapsed");
708
709                 if (pControlProperty->GetLayoutElement(tempString, gridLayoutContainerPropertyValue))
710                 {
711                         if (gridLayoutContainerPropertyValue.Equals(L"true", false))
712                         {
713                                 layoutParam.columnCollapsed = true;
714                         }
715                         else
716                         {
717                                 layoutParam.columnCollapsed = false;
718                         }
719                         r = layout.SetColumnCollapsed(i - 1, layoutParam.columnCollapsed);
720                         if (IsFailed(r))
721                         {
722                                 goto CATCH;
723                         }
724                 }
725
726                 tempString = headerColumn;
727                 tempString.Append(i);
728                 tempString.Append("Shrinkable");
729
730                 if (pControlProperty->GetLayoutElement(tempString, gridLayoutContainerPropertyValue))
731                 {
732                         if (gridLayoutContainerPropertyValue.Equals(L"true", false))
733                         {
734                                 layoutParam.columnShrinkable = true;
735                         }
736                         else
737                         {
738                                 layoutParam.columnShrinkable = false;
739                         }
740                         r = layout.SetColumnShrinkable(i - 1, layoutParam.columnShrinkable);
741                         if (IsFailed(r))
742                         {
743                                 goto CATCH;
744                         }
745                 }
746
747                 tempString = headerColumn;
748                 tempString.Append(i);
749                 tempString.Append("Stretchable");
750
751                 if (pControlProperty->GetLayoutElement(tempString, gridLayoutContainerPropertyValue))
752                 {
753                         if (gridLayoutContainerPropertyValue.Equals(L"true", false))
754                         {
755                                 layoutParam.columnStretchable = true;
756                         }
757                         else
758                         {
759                                 layoutParam.columnStretchable = false;
760                         }
761                         r = layout.SetColumnStretchable(i - 1, layoutParam.columnStretchable);
762                         if (IsFailed(r))
763                         {
764                                 goto CATCH;
765                         }
766                 }
767
768                 tempString = headerColumn;
769                 tempString.Append(i);
770                 tempString.Append("Spacing");
771
772                 if (pControlProperty->GetLayoutElement(tempString, gridLayoutContainerPropertyValue))
773                 {
774                         Integer::Parse(gridLayoutContainerPropertyValue, layoutParam.columnSpacing);
775                         r = layout.SetColumnSpacing(i - 1, layoutParam.columnSpacing);
776                         if (IsFailed(r))
777                         {
778                                 goto CATCH;
779                         }
780                 }
781
782         }
783         for (int i = 1; i <= layoutParam.maxRow; i++)
784         {
785
786                 tempString = headerRow;
787                 tempString.Append(i);
788                 tempString.Append("Collapsed");
789
790                 if (pControlProperty->GetLayoutElement(tempString, gridLayoutContainerPropertyValue))
791                 {
792                         if (gridLayoutContainerPropertyValue.Equals(L"true", false))
793                         {
794                                 layoutParam.rowCollapsed = true;
795                         }
796                         else
797                         {
798                                 layoutParam.rowCollapsed = false;
799                         }
800                         r = layout.SetRowCollapsed(i - 1, layoutParam.rowCollapsed);
801                         if (IsFailed(r))
802                         {
803                                 goto CATCH;
804                         }
805                 }
806
807                 tempString = headerRow;
808                 tempString.Append(i);
809                 tempString.Append("Shrinkable");
810
811                 if (pControlProperty->GetLayoutElement(tempString, gridLayoutContainerPropertyValue))
812                 {
813                         if (gridLayoutContainerPropertyValue.Equals(L"true", false))
814                         {
815                                 layoutParam.rowShrinkable = true;
816                         }
817                         else
818                         {
819                                 layoutParam.rowShrinkable = false;
820                         }
821                         r = layout.SetRowShrinkable(i - 1, layoutParam.rowShrinkable);
822                         if (IsFailed(r))
823                         {
824                                 goto CATCH;
825                         }
826                 }
827
828                 tempString = headerRow;
829                 tempString.Append(i);
830                 tempString.Append("Stretchable");
831
832                 if (pControlProperty->GetLayoutElement(tempString, gridLayoutContainerPropertyValue))
833                 {
834                         if (gridLayoutContainerPropertyValue.Equals(L"true", false))
835                         {
836                                 layoutParam.rowStretchable = true;
837                         }
838                         else
839                         {
840                                 layoutParam.rowStretchable = false;
841                         }
842                         r = layout.SetRowStretchable(i - 1, layoutParam.rowStretchable);
843                         if (IsFailed(r))
844                         {
845                                 goto CATCH;
846                         }
847                 }
848
849                 tempString = headerRow;
850                 tempString.Append(i);
851                 tempString.Append("Spacing");
852
853                 if (pControlProperty->GetLayoutElement(tempString, gridLayoutContainerPropertyValue))
854                 {
855                         Integer::Parse(gridLayoutContainerPropertyValue, layoutParam.rowSpacing);
856                         r = layout.SetRowSpacing(i - 1, layoutParam.rowSpacing);
857                         if (IsFailed(r))
858                         {
859                                 goto CATCH;
860                         }
861                 }
862
863         }
864 CATCH:
865
866         return r;
867 }
868
869 void
870 _UiBuilderControlMaker::SetGridLayoutControlProperty(GridLayout* pLayout, _UiBuilderControlLayout* pControlProperty, Control* pControl)
871 {
872         if ((null == pLayout) || (null == pControlProperty) || (null == pControlProperty) || (null == pControl))
873         {
874                 return ;
875         }
876
877         GridLayout& layout = *pLayout;
878         Control& control = *pControl;
879         UiBuilderGridLayoutControl layoutParam;
880         Tizen::Base::String gridLayoutValue(L"");
881         bool alignmentSet = false;
882
883         if (pControlProperty->GetLayoutElement(L"horizontalAlignment", gridLayoutValue))
884         {
885                 alignmentSet = true;
886                 if (gridLayoutValue.Equals(L"LAYOUT_HORIZONTAL_ALIGN_CENTER", false))
887                 {
888                         layoutParam.horizontalAlignment = LAYOUT_HORIZONTAL_ALIGN_CENTER;
889                 }
890                 else if (gridLayoutValue.Equals(L"LAYOUT_HORIZONTAL_ALIGN_RIGHT", false))
891                 {
892                         layoutParam.horizontalAlignment = LAYOUT_HORIZONTAL_ALIGN_RIGHT;
893                 }
894                 else
895                 {
896                         layoutParam.horizontalAlignment = LAYOUT_HORIZONTAL_ALIGN_LEFT;
897                 }
898         }
899         else
900         {
901                 layoutParam.horizontalAlignment = LAYOUT_HORIZONTAL_ALIGN_LEFT;
902         }
903
904         if (pControlProperty->GetLayoutElement(L"verticalAlignment", gridLayoutValue))
905         {
906                 alignmentSet = true;
907                 if (gridLayoutValue.Equals(L"LAYOUT_VERTICAL_ALIGN_MIDDLE", false))
908                 {
909                         layoutParam.verticalAlignment = LAYOUT_VERTICAL_ALIGN_MIDDLE;
910                 }
911                 else if (gridLayoutValue.Equals(L"LAYOUT_VERTICAL_ALIGN_BOTTOM", false))
912                 {
913                         layoutParam.verticalAlignment = LAYOUT_VERTICAL_ALIGN_BOTTOM;
914                 }
915                 else
916                 {
917                         layoutParam.verticalAlignment = LAYOUT_VERTICAL_ALIGN_TOP;
918                 }
919         }
920         else
921         {
922                 layoutParam.verticalAlignment = LAYOUT_VERTICAL_ALIGN_TOP;
923         }
924         if (alignmentSet)
925         {
926                 layout.SetAlignment(control, layoutParam.horizontalAlignment, layoutParam.verticalAlignment);
927         }
928
929         _ICoordinateSystemTransformer* pTransform = GetTransformer();
930         bool marginSet = false;
931         layoutParam.marginLeft = 0;
932         layoutParam.marginRight = 0;
933         layoutParam.marginTop = 0;
934         layoutParam.marginBottom = 0;
935         if (pControlProperty->GetLayoutElement(L"marginLeft", gridLayoutValue))
936         {
937                 marginSet = true;
938                 Integer::Parse(gridLayoutValue, layoutParam.marginLeft);
939                 if (pTransform)
940                 {
941
942                         layoutParam.marginLeft = pTransform->Transform(layoutParam.marginLeft);
943                 }
944         }
945         if (pControlProperty->GetLayoutElement(L"marginRight", gridLayoutValue))
946         {
947                 marginSet = true;
948                 Integer::Parse(gridLayoutValue, layoutParam.marginRight);
949                 if (pTransform)
950                 {
951
952                         layoutParam.marginRight = pTransform->Transform(layoutParam.marginRight);
953                 }
954         }
955         if (pControlProperty->GetLayoutElement(L"marginTop", gridLayoutValue))
956         {
957                 marginSet = true;
958                 Integer::Parse(gridLayoutValue, layoutParam.marginTop);
959                 if (pTransform)
960                 {
961
962                         layoutParam.marginTop = pTransform->Transform(layoutParam.marginTop);
963                 }
964         }
965         if (pControlProperty->GetLayoutElement(L"marginBottom", gridLayoutValue))
966         {
967                 marginSet = true;
968                 Integer::Parse(gridLayoutValue, layoutParam.marginBottom);
969                 if (pTransform)
970                 {
971
972                         layoutParam.marginBottom = pTransform->Transform(layoutParam.marginBottom);
973                 }
974         }
975         if (marginSet)
976         {
977                 layout.SetMargin(control, layoutParam.marginLeft, layoutParam.marginRight, layoutParam.marginTop, layoutParam.marginBottom);
978         }
979
980         bool positionSet = false;
981         layoutParam.positionRow = 0;
982         layoutParam.positionColumn = 0;
983         layoutParam.positionRowSpan = 0;
984         layoutParam.positionColumnSpan = 0;
985         if (pControlProperty->GetLayoutElement(L"positionRow", gridLayoutValue))
986         {
987                 positionSet = true;
988                 Integer::Parse(gridLayoutValue, layoutParam.positionRow);
989         }
990         if (pControlProperty->GetLayoutElement(L"positionColumn", gridLayoutValue))
991         {
992                 positionSet = true;
993                 Integer::Parse(gridLayoutValue, layoutParam.positionColumn);
994         }
995         if (pControlProperty->GetLayoutElement(L"positionRowSpan", gridLayoutValue))
996         {
997                 positionSet = true;
998                 Integer::Parse(gridLayoutValue, layoutParam.positionRowSpan);
999         }
1000         if (pControlProperty->GetLayoutElement(L"positionColumnSpan", gridLayoutValue))
1001         {
1002                 positionSet = true;
1003                 Integer::Parse(gridLayoutValue, layoutParam.positionColumnSpan);
1004         }
1005         if (positionSet)
1006         {
1007                 layout.SetPosition(control, layoutParam.positionRow, layoutParam.positionColumn, layoutParam.positionRowSpan, layoutParam.positionColumnSpan);
1008         }
1009 }
1010
1011 void
1012 _UiBuilderControlMaker::SetHorizontalBoxLayoutProperty(HorizontalBoxLayout* pLayout, _UiBuilderControlLayout* pControlProperty, Control* pControl)
1013 {
1014         if ((null == pLayout) || (null == pControlProperty) || (null == pControlProperty) || (null == pControl))
1015         {
1016                 return ;
1017         }
1018
1019         HorizontalBoxLayout& layout = *pLayout;
1020         Control& control = *pControl;
1021         UiBuilderHorizontalBoxLayoutControl layoutParam;
1022         Tizen::Base::String horizontalBoxLayoutValue(L"");
1023         _ICoordinateSystemTransformer* pTransform = GetTransformer();
1024
1025         if (pControlProperty->GetLayoutElement(L"height", horizontalBoxLayoutValue))
1026         {
1027                 Integer::Parse(horizontalBoxLayoutValue, layoutParam.height);
1028                 if (pTransform)
1029                 {
1030
1031                         layoutParam.height = pTransform->Transform(layoutParam.height);
1032                 }
1033                 layout.SetHeight(control, layoutParam.height);
1034         }
1035         else
1036         {
1037                 layoutParam.height = 0;
1038         }
1039
1040         if (pControlProperty->GetLayoutElement(L"verticalFitPolicy", horizontalBoxLayoutValue))
1041         {
1042                 if (horizontalBoxLayoutValue.Equals(L"FIT_POLICY_CONTENT", false))
1043                 {
1044                         layoutParam.verticalFitPolicy = FIT_POLICY_CONTENT;
1045                 }
1046                 else if (horizontalBoxLayoutValue.Equals(L"FIT_POLICY_PARENT", false))
1047                 {
1048                         layoutParam.verticalFitPolicy = FIT_POLICY_PARENT;
1049                 }
1050                 else
1051                 {
1052                         layoutParam.verticalFitPolicy = FIT_POLICY_FIXED;
1053                 }
1054                         layout.SetVerticalFitPolicy(control, layoutParam.verticalFitPolicy);
1055         }
1056         else
1057         {
1058                 layoutParam.verticalFitPolicy = FIT_POLICY_CONTENT;
1059         }
1060
1061         if (pControlProperty->GetLayoutElement(L"verticalAlignment", horizontalBoxLayoutValue))
1062         {
1063                 if (horizontalBoxLayoutValue.Equals(L"LAYOUT_VERTICAL_ALIGN_MIDDLE", false))
1064                 {
1065                         layoutParam.verticalAlignment = LAYOUT_VERTICAL_ALIGN_MIDDLE;
1066                 }
1067                 else if (horizontalBoxLayoutValue.Equals(L"LAYOUT_VERTICAL_ALIGN_BOTTOM", false))
1068                 {
1069                         layoutParam.verticalAlignment = LAYOUT_VERTICAL_ALIGN_BOTTOM;
1070                 }
1071                 else
1072                 {
1073                         layoutParam.verticalAlignment = LAYOUT_VERTICAL_ALIGN_TOP;
1074                 }
1075
1076                         layout.SetVerticalAlignment(control, layoutParam.verticalAlignment);
1077                 }
1078         else
1079         {
1080                 layoutParam.verticalAlignment = LAYOUT_VERTICAL_ALIGN_TOP;
1081         }
1082
1083         bool marginSet = false;
1084         layoutParam.verticalTopMargin = 0;
1085         layoutParam.verticalBottomMargin = 0;
1086         if (pControlProperty->GetLayoutElement(L"verticalTopMargin", horizontalBoxLayoutValue))
1087         {
1088                 marginSet = true;
1089                 Integer::Parse(horizontalBoxLayoutValue, layoutParam.verticalTopMargin);
1090                 if (pTransform)
1091                 {
1092
1093                         layoutParam.verticalTopMargin = pTransform->Transform(layoutParam.verticalTopMargin);
1094                 }
1095         }
1096         if (pControlProperty->GetLayoutElement(L"verticalBottomMargin", horizontalBoxLayoutValue))
1097         {
1098                 marginSet = true;
1099                 Integer::Parse(horizontalBoxLayoutValue, layoutParam.verticalBottomMargin);
1100                 if (pTransform)
1101                 {
1102
1103                         layoutParam.verticalBottomMargin = pTransform->Transform(layoutParam.verticalBottomMargin);
1104                 }
1105         }
1106         if (marginSet)
1107         {
1108                 layout.SetVerticalMargin(control, layoutParam.verticalTopMargin, layoutParam.verticalBottomMargin);
1109         }
1110
1111         if (pControlProperty->GetLayoutElement(L"spacing", horizontalBoxLayoutValue))
1112         {
1113                 Integer::Parse(horizontalBoxLayoutValue, layoutParam.spacing);
1114                 if (pTransform)
1115                 {
1116
1117                         layoutParam.spacing = pTransform->Transform(layoutParam.spacing);
1118                 }
1119                 layout.SetSpacing(control, layoutParam.spacing);
1120         }
1121         else
1122         {
1123                 layoutParam.spacing = 0;
1124         }
1125
1126         if (pControlProperty->GetLayoutElement(L"weight", horizontalBoxLayoutValue))
1127         {
1128                 Float::Parse(horizontalBoxLayoutValue, layoutParam.weight);
1129                 layout.SetWeight(control, layoutParam.weight);
1130         }
1131         else
1132         {
1133                 layoutParam.weight = 0;
1134         }
1135
1136         if (pControlProperty->GetLayoutElement(L"width", horizontalBoxLayoutValue))
1137         {
1138                 Integer::Parse(horizontalBoxLayoutValue, layoutParam.width);
1139                 if (pTransform)
1140                 {
1141
1142                         layoutParam.width = pTransform->Transform(layoutParam.width);
1143                 }
1144                 layout.SetWidth(control, layoutParam.width);
1145         }
1146         else
1147         {
1148                 layoutParam.width = 0;
1149         }
1150
1151         if (pControlProperty->GetLayoutElement(L"horizontalFitPolicy", horizontalBoxLayoutValue))
1152         {
1153                 if (horizontalBoxLayoutValue.Equals(L"FIT_POLICY_CONTENT", false))
1154                 {
1155                         layoutParam.horizontalFitPolicy = FIT_POLICY_CONTENT;
1156                 }
1157                 else if (horizontalBoxLayoutValue.Equals(L"FIT_POLICY_PARENT", false))
1158                 {
1159                         layoutParam.horizontalFitPolicy = FIT_POLICY_PARENT;
1160                 }
1161                 else
1162                 {
1163                         layoutParam.horizontalFitPolicy = FIT_POLICY_FIXED;
1164                 }
1165                         layout.SetHorizontalFitPolicy(control, layoutParam.horizontalFitPolicy);
1166         }
1167         else
1168         {
1169                 layoutParam.horizontalFitPolicy = FIT_POLICY_CONTENT;
1170         }
1171 }
1172
1173 void
1174 _UiBuilderControlMaker::SetVerticalBoxLayoutProperty(VerticalBoxLayout* pLayout, _UiBuilderControlLayout* pControlProperty, Control* pControl)
1175 {
1176         if ((null == pLayout) || (null == pControlProperty) || (null == pControlProperty) || (null == pControl))
1177         {
1178                 return ;
1179         }
1180
1181         VerticalBoxLayout& layout = *pLayout;
1182         Control& control = *pControl;
1183         UiBuilderVerticalBoxLayoutControl layoutParam;
1184         Tizen::Base::String verticalBoxLayoutValue(L"");
1185         _ICoordinateSystemTransformer* pTransform = GetTransformer();
1186
1187         if (pControlProperty->GetLayoutElement(L"height", verticalBoxLayoutValue))
1188         {
1189                 Integer::Parse(verticalBoxLayoutValue, layoutParam.height);
1190                 if (pTransform)
1191                 {
1192
1193                         layoutParam.height = pTransform->Transform(layoutParam.height);
1194                 }
1195                 layout.SetHeight(control, layoutParam.height);
1196         }
1197         else
1198         {
1199                 layoutParam.height = 0;
1200         }
1201
1202         if (pControlProperty->GetLayoutElement(L"verticalFitPolicy", verticalBoxLayoutValue))
1203         {
1204                 if (verticalBoxLayoutValue.Equals(L"FIT_POLICY_CONTENT", false))
1205                 {
1206                         layoutParam.verticalFitPolicy = FIT_POLICY_CONTENT;
1207                 }
1208                 else if (verticalBoxLayoutValue.Equals(L"FIT_POLICY_PARENT", false))
1209                 {
1210                         layoutParam.verticalFitPolicy = FIT_POLICY_PARENT;
1211                 }
1212                 else
1213                 {
1214                         layoutParam.verticalFitPolicy = FIT_POLICY_FIXED;
1215                 }
1216                         layout.SetVerticalFitPolicy(control, layoutParam.verticalFitPolicy);
1217         }
1218         else
1219         {
1220                 layoutParam.verticalFitPolicy = FIT_POLICY_CONTENT;
1221         }
1222
1223         if (pControlProperty->GetLayoutElement(L"horizontalAlignment", verticalBoxLayoutValue))
1224         {
1225                 if (verticalBoxLayoutValue.Equals(L"LAYOUT_HORIZONTAL_ALIGN_CENTER", false))
1226                 {
1227                         layoutParam.horizontalAlignment = LAYOUT_HORIZONTAL_ALIGN_CENTER;
1228                 }
1229                 else if (verticalBoxLayoutValue.Equals(L"LAYOUT_HORIZONTAL_ALIGN_RIGHT", false))
1230                 {
1231                         layoutParam.horizontalAlignment = LAYOUT_HORIZONTAL_ALIGN_RIGHT;
1232                 }
1233                 else
1234                 {
1235                         layoutParam.horizontalAlignment = LAYOUT_HORIZONTAL_ALIGN_LEFT;
1236                 }
1237
1238                        layout.SetHorizontalAlignment(control, layoutParam.horizontalAlignment);
1239         }
1240         else
1241         {
1242                 layoutParam.horizontalAlignment = LAYOUT_HORIZONTAL_ALIGN_LEFT;
1243         }
1244
1245         bool marginSet = false;
1246         layoutParam.horizontalLeftMargin = 0;
1247         layoutParam.horizontalRightMargin = 0;
1248         if (pControlProperty->GetLayoutElement(L"horizontalLeftMargin", verticalBoxLayoutValue))
1249         {
1250                 marginSet = true;
1251                 Integer::Parse(verticalBoxLayoutValue, layoutParam.horizontalLeftMargin);
1252                 if (pTransform)
1253                 {
1254                         layoutParam.horizontalLeftMargin = pTransform->Transform(layoutParam.horizontalLeftMargin);
1255                 }
1256         }
1257         if (pControlProperty->GetLayoutElement(L"horizontalRightMargin", verticalBoxLayoutValue))
1258         {
1259                 marginSet = true;
1260                 Integer::Parse(verticalBoxLayoutValue, layoutParam.horizontalRightMargin);
1261                 if (pTransform)
1262                 {
1263                         layoutParam.horizontalRightMargin = pTransform->Transform(layoutParam.horizontalRightMargin);
1264                 }
1265         }
1266         if (marginSet)
1267         {
1268                  layout.SetHorizontalMargin(control, layoutParam.horizontalLeftMargin, layoutParam.horizontalRightMargin);
1269         }
1270
1271         if (pControlProperty->GetLayoutElement(L"spacing", verticalBoxLayoutValue))
1272         {
1273                 Integer::Parse(verticalBoxLayoutValue, layoutParam.spacing);
1274                 if (pTransform)
1275                 {
1276                         layoutParam.spacing = pTransform->Transform(layoutParam.spacing);
1277
1278                 }
1279                 layout.SetSpacing(control, layoutParam.spacing);
1280         }
1281         else
1282         {
1283                 layoutParam.spacing = 0;
1284         }
1285
1286         if (pControlProperty->GetLayoutElement(L"weight", verticalBoxLayoutValue))
1287         {
1288                 Float::Parse(verticalBoxLayoutValue, layoutParam.weight);
1289                 layout.SetWeight(control, layoutParam.weight);
1290         }
1291         else
1292         {
1293                 layoutParam.weight = 0;
1294         }
1295
1296         if (pControlProperty->GetLayoutElement(L"width", verticalBoxLayoutValue))
1297         {
1298                 Integer::Parse(verticalBoxLayoutValue, layoutParam.width);
1299                 if (pTransform)
1300                 {
1301                         layoutParam.width = pTransform->Transform(layoutParam.width);
1302
1303                 }
1304                 layout.SetWidth(control, layoutParam.width);
1305         }
1306         else
1307         {
1308                 layoutParam.width = 0;
1309         }
1310
1311         if (pControlProperty->GetLayoutElement(L"horizontalFitPolicy", verticalBoxLayoutValue))
1312         {
1313                 if (verticalBoxLayoutValue.Equals(L"FIT_POLICY_CONTENT", false))
1314                 {
1315                         layoutParam.horizontalFitPolicy = FIT_POLICY_CONTENT;
1316                 }
1317                 else if (verticalBoxLayoutValue.Equals(L"FIT_POLICY_PARENT", false))
1318                 {
1319                         layoutParam.horizontalFitPolicy = FIT_POLICY_PARENT;
1320                 }
1321                 else
1322                 {
1323                         layoutParam.horizontalFitPolicy = FIT_POLICY_FIXED;
1324                 }
1325
1326                 layout.SetHorizontalFitPolicy(control, layoutParam.horizontalFitPolicy);
1327         }
1328         else
1329         {
1330                 layoutParam.horizontalFitPolicy = FIT_POLICY_FIXED;
1331         }
1332 }
1333
1334 void
1335 _UiBuilderControlMaker::SetRelativeLayoutProperty(RelativeLayout* pLayout, _UiBuilderControlLayout* pControlProperty, Control* pControl)
1336 {
1337         if ((null == pLayout) || (null == pControlProperty) || (null == pControlProperty) || (null == pControl))
1338         {
1339                 return;
1340         }
1341
1342         RelativeLayout& layout = *pLayout;
1343         Control& control = *pControl;
1344         UiBuilderRelativeLayout layoutParam;
1345         Tizen::Base::String relativeLayoutValue(L"");
1346         Tizen::Graphics::Rectangle rect =  pControlProperty->GetRect();
1347
1348         if (pControlProperty->GetLayoutElement(L"bottomRelation", relativeLayoutValue))
1349         {
1350                 if (GetContainer()->GetName().Equals(relativeLayoutValue))
1351                 {
1352                         layoutParam.pBottomRelation = GetContainer();
1353                 }
1354                 else
1355                 {
1356                         layoutParam.pBottomRelation = GetContainer()->GetControl(relativeLayoutValue, true);
1357                 }
1358         }
1359         else
1360         {
1361                 layoutParam.pBottomRelation = null;
1362         }
1363
1364         if (layoutParam.pBottomRelation)
1365         {
1366                 if (pControlProperty->GetLayoutElement(L"bottomRelationType", relativeLayoutValue))
1367                 {
1368                         if (relativeLayoutValue.Equals(L"RECT_EDGE_RELATION_BOTTOM_TO_BOTTOM", false))
1369                         {
1370                                 layoutParam.bottomRelationType = RECT_EDGE_RELATION_BOTTOM_TO_BOTTOM;
1371                         }
1372                         else
1373                         {
1374                                 layoutParam.bottomRelationType = RECT_EDGE_RELATION_BOTTOM_TO_TOP;
1375                         }
1376                         layout.SetRelation(control, *(layoutParam.pBottomRelation), layoutParam.bottomRelationType);
1377                 }
1378                 else
1379                 {
1380                         layoutParam.bottomRelationType = RECT_EDGE_RELATION_BOTTOM_TO_BOTTOM;
1381                 }
1382         }
1383
1384         if (pControlProperty->GetLayoutElement(L"leftRelation", relativeLayoutValue))
1385         {
1386                 if (GetContainer()->GetName().Equals(relativeLayoutValue))
1387                 {
1388                         layoutParam.pLeftRelation = GetContainer();
1389                 }
1390                 else
1391                 {
1392                         layoutParam.pLeftRelation = GetContainer()->GetControl(relativeLayoutValue, true);
1393                 }
1394         }
1395         else
1396         {
1397                 layoutParam.pLeftRelation = null;
1398         }
1399
1400         if (layoutParam.pLeftRelation)
1401         {
1402                 if (pControlProperty->GetLayoutElement(L"leftRelationType", relativeLayoutValue))
1403                 {
1404                         if (relativeLayoutValue.Equals(L"RECT_EDGE_RELATION_LEFT_TO_LEFT", false))
1405                         {
1406                                 layoutParam.leftRelationType = RECT_EDGE_RELATION_LEFT_TO_LEFT;
1407                         }
1408                         else
1409                         {
1410                                 layoutParam.leftRelationType = RECT_EDGE_RELATION_LEFT_TO_RIGHT;
1411                         }
1412                         layout.SetRelation(control, *(layoutParam.pLeftRelation), layoutParam.leftRelationType);
1413                 }
1414                 else
1415                 {
1416                         layoutParam.leftRelationType = RECT_EDGE_RELATION_LEFT_TO_LEFT;
1417                 }
1418         }
1419
1420         if (pControlProperty->GetLayoutElement(L"rightRelation", relativeLayoutValue))
1421         {
1422                 if (GetContainer()->GetName().Equals(relativeLayoutValue))
1423                 {
1424                         layoutParam.pRightRelation = GetContainer();
1425                 }
1426                 else
1427                 {
1428                         layoutParam.pRightRelation = GetContainer()->GetControl(relativeLayoutValue, true);
1429                 }
1430         }
1431         else
1432         {
1433                 layoutParam.pRightRelation = null;
1434         }
1435
1436         if (layoutParam.pRightRelation)
1437         {
1438                 if (pControlProperty->GetLayoutElement(L"rightRelationType", relativeLayoutValue))
1439                 {
1440                         if (relativeLayoutValue.Equals(L"RECT_EDGE_RELATION_RIGHT_TO_RIGHT", false))
1441                         {
1442                                 layoutParam.rightRelationType = RECT_EDGE_RELATION_RIGHT_TO_RIGHT;
1443                         }
1444                         else
1445                         {
1446                                 layoutParam.rightRelationType = RECT_EDGE_RELATION_RIGHT_TO_LEFT;
1447                         }
1448                         layout.SetRelation(control, *(layoutParam.pRightRelation), layoutParam.rightRelationType);
1449                 }
1450                 else
1451                 {
1452                         layoutParam.rightRelationType = RECT_EDGE_RELATION_RIGHT_TO_RIGHT;
1453                 }
1454         }
1455
1456         if (pControlProperty->GetLayoutElement(L"topRelation", relativeLayoutValue))
1457         {
1458                 if (GetContainer()->GetName().Equals(relativeLayoutValue))
1459                 {
1460                         layoutParam.pTopRelation = GetContainer();
1461                 }
1462                 else
1463                 {
1464                         layoutParam.pTopRelation = GetContainer()->GetControl(relativeLayoutValue, true);
1465                 }
1466         }
1467         else
1468         {
1469                 layoutParam.pTopRelation = null;
1470         }
1471
1472         if (layoutParam.pTopRelation)
1473         {
1474                 if (pControlProperty->GetLayoutElement(L"topRelationType", relativeLayoutValue))
1475                 {
1476                         if (relativeLayoutValue.Equals(L"RECT_EDGE_RELATION_TOP_TO_TOP", false))
1477                         {
1478                                 layoutParam.topRelationType = RECT_EDGE_RELATION_TOP_TO_TOP;
1479                         }
1480                         else
1481                         {
1482                                 layoutParam.topRelationType = RECT_EDGE_RELATION_TOP_TO_BOTTOM;
1483                         }
1484                         layout.SetRelation(control, *(layoutParam.pTopRelation), layoutParam.topRelationType);
1485                 }
1486                 else
1487                 {
1488                         layoutParam.topRelationType = RECT_EDGE_RELATION_TOP_TO_TOP;
1489                 }
1490         }
1491
1492         if (pControlProperty->GetLayoutElement(L"centerHorizontal", relativeLayoutValue))
1493         {
1494                 if (relativeLayoutValue.Equals(L"true", false))
1495                 {
1496                         layoutParam.centerHorizontal = true;
1497                         layout.SetCenterAligned(control, CENTER_ALIGN_HORIZONTAL);
1498                 }
1499                 else
1500                 {
1501                         layoutParam.centerHorizontal = false;
1502                 }
1503         }
1504         else
1505         {
1506                 layoutParam.centerHorizontal = false;
1507         }
1508
1509         if (pControlProperty->GetLayoutElement(L"centerVertical", relativeLayoutValue))
1510         {
1511                 if (relativeLayoutValue.Equals(L"true", false))
1512                 {
1513                         layoutParam.centerVertical = true;
1514                         layout.SetCenterAligned(control, CENTER_ALIGN_VERTICAL);
1515                 }
1516                 else
1517                 {
1518                         layoutParam.centerVertical = false;
1519                 }
1520         }
1521         else
1522         {
1523                 layoutParam.centerVertical = false;
1524         }
1525
1526
1527         if (pControlProperty->GetLayoutElement(L"height", relativeLayoutValue))
1528         {
1529                 layoutParam.height = rect.height;
1530                 layout.SetHeight(control, layoutParam.height);
1531         }
1532         else
1533         {
1534                 layoutParam.height = 0;
1535         }
1536
1537         if (pControlProperty->GetLayoutElement(L"verticalFitPolicy", relativeLayoutValue))
1538         {
1539                 if (relativeLayoutValue.Equals(L"FIT_POLICY_CONTENT", false))
1540                 {
1541                         layoutParam.verticalFitPolicy = FIT_POLICY_CONTENT;
1542                 }
1543                 else if (relativeLayoutValue.Equals(L"FIT_POLICY_PARENT", false))
1544                 {
1545                         layoutParam.verticalFitPolicy = FIT_POLICY_PARENT;
1546                 }
1547                 else
1548                 {
1549                         layoutParam.verticalFitPolicy = FIT_POLICY_FIXED;
1550                 }
1551                 layout.SetVerticalFitPolicy(control, layoutParam.verticalFitPolicy);
1552         }
1553         else
1554         {
1555                 layoutParam.verticalFitPolicy = FIT_POLICY_CONTENT;
1556         }
1557
1558         if (pControlProperty->GetLayoutElement(L"width", relativeLayoutValue))
1559         {
1560                 layoutParam.width = rect.width;
1561                 layout.SetWidth(control, layoutParam.width);
1562         }
1563         else
1564         {
1565                 layoutParam.width = 0;
1566         }
1567
1568         if (pControlProperty->GetLayoutElement(L"horizontalFitPolicy", relativeLayoutValue))
1569         {
1570                 if (relativeLayoutValue.Equals(L"FIT_POLICY_CONTENT", false))
1571                 {
1572                         layoutParam.horizontalFitPolicy = FIT_POLICY_CONTENT;
1573                 }
1574                 else if (relativeLayoutValue.Equals(L"FIT_POLICY_PARENT", false))
1575                 {
1576                         layoutParam.horizontalFitPolicy = FIT_POLICY_PARENT;
1577                 }
1578                 else
1579                 {
1580                         layoutParam.horizontalFitPolicy = FIT_POLICY_FIXED;
1581                 }
1582                 layout.SetHorizontalFitPolicy(control, layoutParam.horizontalFitPolicy);
1583         }
1584         else
1585         {
1586                 layoutParam.horizontalFitPolicy = FIT_POLICY_CONTENT;
1587         }
1588
1589         bool marginSet = false;
1590         layoutParam.marginLeft = 0;
1591         layoutParam.marginRight = 0;
1592         layoutParam.marginTop = 0;
1593         layoutParam.marginBottom = 0;
1594
1595         Tizen::Graphics::_ICoordinateSystemTransformer* pTransform = GetTransformer();
1596
1597         if (pControlProperty->GetLayoutElement(L"marginLeft", relativeLayoutValue))
1598         {
1599                 marginSet = true;
1600                 Integer::Parse(relativeLayoutValue, layoutParam.marginLeft);
1601                 if (pTransform)
1602                 {
1603
1604                         layoutParam.marginLeft = pTransform->Transform(layoutParam.marginLeft);
1605                 }
1606         }
1607         if (pControlProperty->GetLayoutElement(L"marginRight", relativeLayoutValue))
1608         {
1609                 marginSet = true;
1610                 Integer::Parse(relativeLayoutValue, layoutParam.marginRight);
1611                 if (pTransform)
1612                 {
1613
1614                         layoutParam.marginRight = pTransform->Transform(layoutParam.marginRight);
1615                 }
1616         }
1617         if (pControlProperty->GetLayoutElement(L"marginTop", relativeLayoutValue))
1618         {
1619                 marginSet = true;
1620                 Integer::Parse(relativeLayoutValue, layoutParam.marginTop);
1621                 if (pTransform)
1622                 {
1623
1624                         layoutParam.marginTop = pTransform->Transform(layoutParam.marginTop);
1625                 }
1626         }
1627         if (pControlProperty->GetLayoutElement(L"marginBottom", relativeLayoutValue))
1628         {
1629                 marginSet = true;
1630                 Integer::Parse(relativeLayoutValue, layoutParam.marginBottom);
1631                 if (pTransform)
1632                 {
1633
1634                         layoutParam.marginBottom = pTransform->Transform(layoutParam.marginBottom);
1635                 }
1636         }
1637         if (marginSet)
1638         {
1639                 layout.SetMargin(control, layoutParam.marginLeft, layoutParam.marginRight, layoutParam.marginTop, layoutParam.marginBottom);
1640         }
1641 }
1642
1643 void
1644 _UiBuilderControlMaker::SetLayoutProperty(_UiBuilderControl* pUiBuilderControl, Control* pControl)
1645 {
1646         int i = 0;
1647         _UiBuilderControlLayout* pControlProperty = null;
1648
1649         Container* pContainer = null;
1650         if (GetContainer()->GetName().Equals(Tizen::Base::String(pUiBuilderControl->GetParentWin())))
1651         {
1652                 pContainer = static_cast<Tizen::Ui::Container*>(GetContainer());
1653         }
1654         else
1655         {
1656                 pContainer = dynamic_cast<Tizen::Ui::Container*>(static_cast<Tizen::Ui::Container*>(GetContainer())->GetControl(pUiBuilderControl->GetParentWin(), true));
1657         }
1658
1659         SysTryReturnVoidResult(NID_UI, pContainer != null, GetLastResult(),  "Failed to get Container");
1660
1661         for (i = 0; i < UIBUILDER_ATTRIBUTE_NUM; i++)
1662         {
1663                 _UiBuilderLayoutType layoutType = UIBUILDER_LAYOUT_NONE;
1664                 pControlProperty = pUiBuilderControl->GetAttribute(i);
1665                 GetParentLayoutType(pControlProperty, layoutType);
1666                 switch (layoutType)
1667                 {
1668                 case UIBUILDER_LAYOUT_NONE:
1669                         break;
1670
1671                 case UIBUILDER_LAYOUT_GRID:
1672                 {
1673                         GridLayout* pLayout = null;
1674                         if (UIBUILDER_ATTRIBUTE_PORTRAIT == i)
1675                         {
1676                                 pLayout = dynamic_cast<GridLayout*>(pContainer->GetPortraitLayoutN());
1677                         }
1678                         else if (UIBUILDER_ATTRIBUTE_LANDSCAPE == i)
1679                         {
1680                                 pLayout = dynamic_cast<GridLayout*>(pContainer->GetLandscapeLayoutN());
1681                         }
1682
1683                         if (pLayout)
1684                         {
1685                                 SetGridLayoutControlProperty(pLayout, pControlProperty, pControl);
1686                                 delete pLayout;
1687                         }
1688                         break;
1689                 }
1690
1691                 case UIBUILDER_LAYOUT_HORIZONTAL_BOX:
1692                 {
1693                         HorizontalBoxLayout* pLayout = null;
1694                         if (UIBUILDER_ATTRIBUTE_PORTRAIT == i)
1695                         {
1696                                 pLayout = dynamic_cast<HorizontalBoxLayout*>(pContainer->GetPortraitLayoutN());
1697                         }
1698                         else if (UIBUILDER_ATTRIBUTE_LANDSCAPE == i)
1699                         {
1700                                 pLayout = dynamic_cast<HorizontalBoxLayout*>(pContainer->GetLandscapeLayoutN());
1701                         }
1702                         if (pLayout)
1703                         {
1704                                 SetHorizontalBoxLayoutProperty(pLayout, pControlProperty, pControl);
1705                                 delete pLayout;
1706                         }
1707                         break;
1708                 }
1709
1710                 case UIBUILDER_LAYOUT_VERTICAL_BOX:
1711                 {
1712                         VerticalBoxLayout* pLayout = null;
1713                         if (UIBUILDER_ATTRIBUTE_PORTRAIT == i)
1714                         {
1715                                 pLayout = dynamic_cast<VerticalBoxLayout*>(pContainer->GetPortraitLayoutN());
1716                         }
1717                         else if (UIBUILDER_ATTRIBUTE_LANDSCAPE == i)
1718                         {
1719                                 pLayout = dynamic_cast<VerticalBoxLayout*>(pContainer->GetLandscapeLayoutN());
1720                         }
1721                         if (pLayout)
1722                         {
1723                                 SetVerticalBoxLayoutProperty(pLayout, pControlProperty, pControl);
1724                                 delete pLayout;
1725                         }
1726                         break;
1727                 }
1728
1729                 case UIBUILDER_LAYOUT_RELATIVE:
1730                 {
1731                         RelativeLayout* pLayout = null;
1732                         if (UIBUILDER_ATTRIBUTE_PORTRAIT == i)
1733                         {
1734                                 pLayout = dynamic_cast<RelativeLayout*>(pContainer->GetPortraitLayoutN());
1735                         }
1736                         else if (UIBUILDER_ATTRIBUTE_LANDSCAPE == i)
1737                         {
1738                                 pLayout = dynamic_cast<RelativeLayout*>(pContainer->GetLandscapeLayoutN());
1739                         }
1740                         if (pLayout)
1741                         {
1742                                 SetRelativeLayoutProperty(pLayout, pControlProperty, pControl);
1743                                 delete pLayout;
1744                         }
1745                         break;
1746                 }
1747
1748                 default:
1749                         SysLog(NID_UI, "Unknown Layout type = %d", layoutType);
1750                         break;
1751                 }
1752
1753         }
1754 }
1755
1756 void
1757 _UiBuilderControlMaker::AddControl(_UiBuilderControl* pUiBuilderControl, Tizen::Ui::Control* pControl)
1758 {
1759         Tizen::Base::String panePosition;
1760         Tizen::Ui::Container* pContainer = GetContainer();
1761         Tizen::Ui::Control* pFindControl = null;
1762
1763
1764         //Find Container
1765         if (pContainer->GetName().Equals(pUiBuilderControl->GetParentWin()))
1766         {
1767                 pFindControl = pContainer;
1768         }
1769         else
1770         {
1771                 pFindControl = pContainer->GetControl(Tizen::Base::String(pUiBuilderControl->GetParentWin()), true);
1772         }
1773
1774
1775         //Add SplitPanel child
1776         if (pUiBuilderControl->GetElement(L"controlPosition", panePosition))
1777         {
1778
1779                 Tizen::Ui::Controls::SplitPanel *pSplitPanel = dynamic_cast<SplitPanel*>(pFindControl);
1780                 if (pSplitPanel)
1781                 {
1782                         if(panePosition.Equals(L"first", false))
1783                         {
1784                                 pSplitPanel->SetPane(pControl, SPLIT_PANEL_PANE_ORDER_FIRST);
1785                         }
1786                         else
1787                         {
1788                                 pSplitPanel->SetPane(pControl, SPLIT_PANEL_PANE_ORDER_SECOND);
1789                         }
1790                 }
1791         }
1792
1793         //Add Container chid
1794         Tizen::Ui::Container* pParent = dynamic_cast<Tizen::Ui::Container*>(pFindControl);
1795
1796         if (pParent != null)
1797         {
1798                 pParent->AddControl(*pControl);
1799         }
1800 }
1801
1802 Tizen::Ui::Container*
1803 _UiBuilderControlMaker::GetContainer(void) const
1804 {
1805         return __pUiBuilder->GetContainer();
1806 }
1807
1808 void
1809 _UiBuilderControlMaker::SetLayoutOrientation(_UiBuilderControl* pUiBuilderCOntrol, Tizen::Ui::Control* pControl)
1810 {
1811         __pUiBuilder->SetLayoutOrientation(pUiBuilderCOntrol, pControl);
1812 }
1813
1814 void
1815 _UiBuilderControlMaker::SetUiBuilderRotateState(_UiBuilderScreenRotate rotate)
1816 {
1817         return __pUiBuilder->SetUiBuilderRotateState(rotate);
1818 }
1819
1820 _UiBuilderScreenRotate
1821 _UiBuilderControlMaker::GetUiBuilderRotateState(void)
1822 {
1823         return __pUiBuilder->GetUiBuilderRotateState();
1824 }
1825
1826 Tizen::Graphics::_ICoordinateSystemTransformer*
1827 _UiBuilderControlMaker::GetTransformer(void) const
1828 {
1829         return __pUiBuilder->GetTransformer();
1830 }
1831
1832 } }  // Tizen::Ui