2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
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
9 // http://floralicense.org/license/
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.
18 * @file FUi_LayoutAbsoluteLayout.cpp
19 * @brief This is the implementation file for AbsoluteLayout class.
21 * This file contains the implementation of AbsoluteLayout class.
25 #include "FUi_LayoutAbsoluteLayout.h"
26 #include "FUi_LayoutLayoutItemProxy.h"
27 #include "FUi_LayoutProxyList.h"
28 #include "FUi_LayoutLayoutItemInfo.h"
30 namespace Tizen { namespace Ui { namespace _Layout
33 AbsoluteLayout::AbsoluteLayout(void)
34 : __defaultMatchParent(false)
36 AbsoluteProxyList* pAbsoluteProxyList = new (std::nothrow) AbsoluteProxyList();
37 SysTryReturnVoidResult(NID_UI, pAbsoluteProxyList, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage");
38 SetItemList(pAbsoluteProxyList);
41 AbsoluteLayout::~AbsoluteLayout(void)
46 AbsoluteLayout::CreateAbsoluteLayoutN(bool defaultMatchParent)
48 AbsoluteLayout* pLayout = new (std::nothrow) AbsoluteLayout();
49 SysTryReturn(NID_UI, pLayout != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Absolute layout core allocation failure.");
50 if (GetLastResult() != E_SUCCESS)
56 pLayout->__defaultMatchParent = defaultMatchParent;
62 AbsoluteLayout::AddItem(LayoutItem& addItem)
66 r = Layout::AddItem(addItem);
72 if (__defaultMatchParent)
74 r = Layout::SetItemWidthMatchMode(addItem, MATCH_PARENT);
80 r = Layout::SetItemHeightMatchMode(addItem, MATCH_PARENT);
91 AbsoluteLayout::OnLayout(int width, int height, bool layoutUpdating)
93 ProxyList* pProxyList = GetProxyList();
94 SysAssertf(pProxyList != null, "ProxyList is invalid");
96 if (pProxyList == null)
98 return E_INVALID_STATE;
101 LayoutItemProxy* pContainerProxy = GetContainerProxy();
102 if (pContainerProxy == null)
104 return E_INVALID_STATE;
107 LayoutRect intendedRect = {0, 0, width, height};
108 pContainerProxy->ConvertWindowToClientBounds(intendedRect, intendedRect);
110 LayoutRect layoutRect = GetLayoutRect();
111 layoutRect.w = intendedRect.w;
112 layoutRect.h = intendedRect.h;
113 SetLayoutRect(layoutRect);
115 ProxyListNode* pNode = pProxyList->GetFirstNode();
116 while (pNode != null)
118 LayoutItemProxy* pItemProxy = pNode->GetItemProxy();
119 if (pItemProxy == null)
121 return E_INVALID_STATE;
123 LayoutRect itemRect = pItemProxy->GetItemBaseRect();
124 if (pItemProxy->Measure(itemRect.w, itemRect.h) != E_SUCCESS)
126 return E_INVALID_STATE;
128 pItemProxy->GetMeasuredSize(itemRect.w, itemRect.h);
129 LayoutRect layoutRect = GetLayoutRect();
130 itemRect.x += layoutRect.x;
131 itemRect.y += layoutRect.y;
132 if (pItemProxy->SetItemWindowRect(itemRect) != E_SUCCESS)
134 return E_INVALID_STATE;
137 pNode = pProxyList->GetNextNode(*pNode);
143 }}} // Tizen::Ui::_Layout