Tizen 2.1 base
[framework/osp/uifw.git] / src / ui / layout / FUi_LayoutLayoutList.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  * @file                FUi_LayoutLayoutList.cpp
19  * @brief       This is the implementation file for LayoutList class.
20  *
21  * This file contains the implementation of LayoutList class.
22  */
23
24 #include <new>
25 #include "FUi_LayoutLayoutList.h"
26
27 namespace Tizen { namespace Ui { namespace _Layout
28 {
29
30 LayoutList::LayoutList(void)
31 {
32 }
33
34 LayoutList::~LayoutList(void)
35 {
36         RemoveAllNode();
37 }
38
39 LayoutListNode*
40 LayoutList::GetFirstNode(void) const
41 {
42         return dynamic_cast <LayoutListNode*>(LinkedList::GetFirstNode());
43 }
44
45 LayoutListNode*
46 LayoutList::GetLastNode(void) const
47 {
48         return dynamic_cast <LayoutListNode*>(LinkedList::GetLastNode());
49 }
50
51 LayoutListNode*
52 LayoutList::GetNextNode(const LayoutListNode& node) const
53 {
54         return dynamic_cast <LayoutListNode*>(LinkedList::GetNextNode(node));
55 }
56
57 LayoutListNode*
58 LayoutList::GetPrevNode(const LayoutListNode& node) const
59 {
60         return dynamic_cast <LayoutListNode*>(LinkedList::GetPrevNode(node));
61 }
62
63 LayoutListNode*
64 LayoutList::AddNode(Layout& addLayout)
65 {
66         LayoutListNode* pAddNode = new (std::nothrow) LayoutListNode();
67
68         if (pAddNode == null)
69         {
70                 return null;
71         }
72
73         pAddNode->Create(addLayout);
74
75         if (InsertIntoLeft(*_pEndNode, *pAddNode) != E_SUCCESS)
76         {
77                 delete pAddNode;
78                 return null;
79         }
80
81         return pAddNode;
82 }
83
84 bool
85 LayoutList::CheckNodeExists(const Layout& layout) const
86 {
87         LayoutListNode* pCurNode = GetFirstNode();
88         Layout* pCurLayout = null;
89
90         while (pCurNode)
91         {
92                 pCurLayout = pCurNode->GetLayout();
93                 if (pCurLayout == &layout)
94                 {
95                         return true;
96                 }
97                 pCurNode = GetNextNode(*pCurNode);
98         }
99         return false;
100 }
101
102 result
103 LayoutList::RemoveNode(LinkedListNode& node)
104 {
105         return LinkedList::RemoveNode(node);
106 }
107
108
109 void
110 LayoutList::RemoveAllNode(void)
111 {
112         LinkedListNode* pCurNode = GetFirstNode();
113         LinkedListNode* pNextNode = pCurNode;
114
115         while (pCurNode != null)
116         {
117                 pNextNode = LinkedList::GetNextNode(*pCurNode);
118                 if (RemoveNode(*pCurNode) != E_SUCCESS)
119                 {
120                         SysAssert(false);
121                 }
122                 pCurNode = pNextNode;
123         }
124 }
125
126 }}} // Tizen::Ui::_Layout