N_SE-47263 : reset touch cancel when indicator touch released/N_SE-51832 : fix checki...
[platform/framework/native/uifw.git] / inc / FUiHorizontalBoxLayout.h
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                FUiHorizontalBoxLayout.h
20  * @brief               This is the header file for the %HorizontalBoxLayout class.
21  *
22  * This header file contains the declarations of the %HorizontalBoxLayout class.
23  */
24
25 #ifndef _FUI_HORIZONTAL_BOX_LAYOUT_H_
26 #define _FUI_HORIZONTAL_BOX_LAYOUT_H_
27
28 #include <FUiLayout.h>
29
30 namespace Tizen { namespace Ui
31 {
32 class Control;
33
34 /**
35  * @class       HorizontalBoxLayout
36  * @brief       The horizontal box layout positions the children of a container horizontally.
37  *
38  * @since       2.0
39  *
40  * The %HorizontalBoxLayout class defines the horizontal box layout for a Container. The layout positions the children of the %Container horizontally.
41  * @n
42  * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/ui/single_dimensional_layout.htm">Vertical and Horizontal Box Layouts</a>.
43  *
44  * @code
45 // Sample code for HorizontalBoxLayoutSample.h
46 #include <FUi.h>
47
48 class HorizontalBoxLayoutSample
49         : public Tizen::Ui::Controls::Form
50 {
51 public:
52         bool Initialize(void);
53         virtual result OnInitializing(void);
54 };
55  *      @endcode
56  *
57  *      @code
58 // Sample code for HorizontalBoxLayoutSample.cpp
59 #include <FGraphics.h>
60
61 #include "HorizontalBoxLayoutSample.h"
62
63 using namespace Tizen::Ui::Controls;
64 using namespace Tizen::Ui;
65 using namespace Tizen::Graphics;
66
67 bool
68 HorizontalBoxLayoutSample::Initialize(void)
69 {
70         //Creates an instance of VerticalBoxLayout
71         VerticalBoxLayout formLayout;
72         formLayout.Construct(VERTICAL_DIRECTION_DOWNWARD);
73
74         // Applies the vertical box layout to the form
75         Construct(formLayout, FORM_STYLE_NORMAL);
76         return true;
77 }
78
79 result
80 HorizontalBoxLayoutSample::OnInitializing(void)
81 {
82         result r = E_SUCCESS;
83
84         // Creates an instance of HorizontalBoxLayout for the top panel
85         HorizontalBoxLayout topPanelLayout;
86         topPanelLayout.Construct(HORIZONTAL_DIRECTION_RIGHTWARD);
87
88         // Creates an instance of Panel and applies it to the horizontal box layout
89         Panel* pTopPanel = new Panel();
90         pTopPanel->Construct(topPanelLayout, Rectangle(0, 0, GetClientAreaBounds().width, 450));
91         {
92                 // Creates instances of Label and an instance of Button
93                 Label* pLabel1 = new Label();
94                 pLabel1->Construct(Rectangle(0,0,GetClientAreaBounds().width/4,100), L"TOP");
95                 pLabel1->SetTextConfig(20, LABEL_TEXT_STYLE_NORMAL);
96                 pLabel1->SetBackgroundColor(Color(0x00, 0x10, 0x80, 0xFF));
97                 pTopPanel->AddControl(pLabel1);
98
99                 Label* pLabel2 = new Label();
100                 pLabel2->Construct(Rectangle(0,0,GetClientAreaBounds().width/4,100), L"MIDDLE");
101                 pLabel2->SetTextConfig(20, LABEL_TEXT_STYLE_NORMAL);
102                 pLabel2->SetBackgroundColor(Color(0x00, 0x20, 0xA0, 0xFF));
103                 pTopPanel->AddControl(pLabel2);
104
105                 Label* pLabel3 = new Label();
106                 pLabel3->Construct(Rectangle(0,0,GetClientAreaBounds().width/4,100), L"BOTTOM");
107                 pLabel3->SetTextConfig(20, LABEL_TEXT_STYLE_NORMAL);
108                 pLabel3->SetBackgroundColor(Color(0x00, 0x30, 0xC0, 0xFF));
109                 pTopPanel->AddControl(pLabel3);
110
111                 Button* pButton = new Button();
112                 pButton->Construct(Rectangle(0,0,GetClientAreaBounds().width/4 - 10,100), L"FIT\nTO\nPARENT");
113                 pButton->SetTextSize(20);
114                 pTopPanel->AddControl(pButton);
115
116                 // Sets relations each label and button
117                 topPanelLayout.SetVerticalAlignment(*pLabel1, LAYOUT_VERTICAL_ALIGN_TOP);
118                 topPanelLayout.SetVerticalAlignment(*pLabel2, LAYOUT_VERTICAL_ALIGN_MIDDLE);
119                 topPanelLayout.SetVerticalAlignment(*pLabel3, LAYOUT_VERTICAL_ALIGN_BOTTOM);
120                 topPanelLayout.SetSpacing(*pButton, 10);
121                 topPanelLayout.SetVerticalFitPolicy(*pButton, FIT_POLICY_PARENT);
122         }
123         // Adds the top panel to the form
124         AddControl(pTopPanel);
125
126         // Creates an instance of HorizontalBoxLayout for bottom panel
127         HorizontalBoxLayout bottomPanelLayout;
128         bottomPanelLayout.Construct(HORIZONTAL_DIRECTION_RIGHTWARD);
129
130         // Creates an instance of Panel and applies it to the horizontal box layout
131         Panel* pBottomPanel = new Panel();
132         pBottomPanel->Construct(bottomPanelLayout, Rectangle(0, 0, 400, 500));
133         {
134                 // Creates instances of Label
135                 Label* pLabel1 = new Label();
136                 pLabel1->Construct(Rectangle(0,0,30,100), L"W\n1.0f");
137                 pLabel1->SetBackgroundColor(Color(0x00, 0x10, 0x80, 0xFF));
138                 pBottomPanel->AddControl(pLabel1);
139
140                 Label* pLabel2 = new Label();
141                 pLabel2->Construct(Rectangle(0,0,30,100), L"W\n2.0f");
142                 pLabel2->SetBackgroundColor(Color(0x00, 0x20, 0xA0, 0xFF));
143                 pBottomPanel->AddControl(pLabel2);
144
145                 Label* pLabel3 = new Label();
146                 pLabel3->Construct(Rectangle(0,0,30,100), L"W\n3.0f");
147                 pLabel3->SetBackgroundColor(Color(0x00, 0x30, 0xC0, 0xFF));
148                 pBottomPanel->AddControl(pLabel3);
149
150                 // Sets relations each label
151                 bottomPanelLayout.SetVerticalFitPolicy(*pLabel1, FIT_POLICY_PARENT);
152                 bottomPanelLayout.SetVerticalFitPolicy(*pLabel2, FIT_POLICY_PARENT);
153                 bottomPanelLayout.SetVerticalFitPolicy(*pLabel3, FIT_POLICY_PARENT);
154                 bottomPanelLayout.SetWeight(*pLabel1, 1.0f);
155                 bottomPanelLayout.SetWeight(*pLabel2, 2.0f);
156                 bottomPanelLayout.SetWeight(*pLabel3, 3.0f);
157         }
158
159         // Adds the bottom panel to the form
160         AddControl(pBottomPanel);
161
162         //Gets the layout of the form
163         VerticalBoxLayout* pFormLayout = dynamic_cast<VerticalBoxLayout*>(this->GetLayoutN());
164
165         // Sets relations between panels
166         pFormLayout->SetHorizontalFitPolicy(*pTopPanel, FIT_POLICY_PARENT);
167         pFormLayout->SetSpacing(*pBottomPanel, 30);
168         pFormLayout->SetHorizontalFitPolicy(*pBottomPanel, FIT_POLICY_PARENT);
169
170         return r;
171 }
172  * @endcode
173  *
174  */
175
176 class _OSP_EXPORT_ HorizontalBoxLayout
177         : public Layout
178 {
179 public:
180         /**
181          * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor.
182          *
183          * @since       2.0
184          *
185          * @remarks     After creating an instance of this class, the Construct() method must be called explicitly to initialize this instance.
186          */
187         HorizontalBoxLayout(void);
188
189         /**
190          * This destructor overrides Tizen::Base::Object::~Object().
191          *
192          * @since               2.0
193          */
194         virtual ~HorizontalBoxLayout(void);
195
196         /**
197          * Initializes this instance of %HorizontalBoxLayout with the specified parameter.
198          *
199          * @since               2.0
200          *
201          * @return              An error code
202          * @param[in]   direction               The direction in which the children are attached
203          * @exception   E_SUCCESS               The method is successful.
204          * @exception   E_INVALID_ARG   The specified input parameter is invalid.
205          * @exception   E_SYSTEM                A system error has occurred.
206          */
207         result Construct(HorizontalDirection direction);
208
209         /**
210          * Gets the direction of %HorizontalBoxLayout.
211          *
212          * @since               2.0
213          *
214          * @return              An error code
215          * @param[out]  direction               The direction in which the children are attached
216          * @exception   E_SUCCESS               The method is successful.
217          */
218         result GetDirection(HorizontalDirection& direction) const;
219
220         /**
221          * Gets the type of the layout.
222          *
223          * @since       2.0
224          *
225          * @return      The layout type
226          */
227         virtual LayoutType GetLayoutType(void) const;
228
229         /**
230          * Sets the vertical alignment of the specified control.
231          *
232          * @since               2.0
233          *
234          * @return              An error code
235          * @param[in]   childControl    The control for which the alignment is set
236          * @param[in]   alignment               The vertical alignment
237          * @exception   E_SUCCESS               The method is successful.
238          * @exception   E_INVALID_ARG   The specified @c childControl parameter is not a child of the container that owns the layout.
239          * @exception   E_SYSTEM                A system error has occurred.
240          * @remarks             By default, the horizontal alignment is VERTICAL_ALIGN_TOP.
241          */
242         result SetVerticalAlignment(Control& childControl, LayoutVerticalAlignment alignment);
243
244         /**
245          * Sets the space between the specified control and its predecessor.
246          *
247          * @since               2.0
248          *
249          * @return              An error code
250          * @param[in]   childControl    The control for which the space is set
251          * @param[in]   space                   The space
252          * @exception   E_SUCCESS               The method is successful.
253          * @exception   E_INVALID_ARG   The specified @c childControl parameter is not a child of the container that owns the layout.
254          * @exception   E_SYSTEM                A system error has occurred.
255          * @remarks             By default, the spacing is set to @c 0.
256          */
257         result SetSpacing(Control& childControl, int space);
258
259         /**
260          * Sets the space between the specified control and its predecessor.
261          *
262          * @since               2.1
263          *
264          * @return              An error code
265          * @param[in]   childControl    The control for which the space is set
266          * @param[in]   space                   The space
267          * @exception   E_SUCCESS               The method is successful.
268          * @exception   E_INVALID_ARG   The specified @c childControl parameter is not a child of the container that owns the layout.
269          * @exception   E_SYSTEM                A system error has occurred.
270          * @remarks             By default, the spacing is set to @c 0.
271          */
272         result SetSpacing(Control& childControl, float space);
273
274         /**
275          * Sets the vertical margins of the specified control.
276          *
277          * @since               2.0
278          *
279          * @return              An error code
280          * @param[in]   childControl    The control for which the margins are set
281          * @param[in]   top                             The top margin
282          * @param[in]   bottom                  The bottom margin
283          * @exception   E_SUCCESS               The method is successful.
284          * @exception   E_INVALID_ARG   The specified @c childControl parameter is not a child of the container that owns the layout.
285          * @exception   E_SYSTEM                A system error has occurred.
286          * @remarks             By default, the margins are set to @c 0.
287          */
288         result SetVerticalMargin(Control& childControl, int top, int bottom);
289
290         /**
291          * Sets the vertical margins of the specified control.
292          *
293          * @since               2.1
294          *
295          * @return              An error code
296          * @param[in]   childControl    The control for which the margins are set
297          * @param[in]   top                             The top margin
298          * @param[in]   bottom                  The bottom margin
299          * @exception   E_SUCCESS               The method is successful.
300          * @exception   E_INVALID_ARG   The specified @c childControl parameter is not a child of the container that owns the layout.
301          * @exception   E_SYSTEM                A system error has occurred.
302          * @remarks             By default, the margins are set to @c 0.
303          */
304         result SetVerticalMargin(Control& childControl, float top, float bottom);
305
306         /**
307          * Sets the width of the specified control with the fixed length.
308          *
309          * @since               2.0
310          *
311          * @return              An error code
312          * @param[in]   childControl    The control for which the width is set
313          * @param[in]   width               The value of the width
314          * @exception   E_SUCCESS               The method is successful.
315          * @exception   E_INVALID_ARG   The specified @c childControl parameter is not a child of the container that owns the layout.
316          * @exception   E_SYSTEM                A system error has occurred.
317          */
318         result SetWidth(Control& childControl, int width);
319
320         /*
321          * Sets the width of the specified control with the fixed length.
322          *
323          * @since               2.1
324          *
325          * @return              An error code
326          * @param[in]   childControl    The control for which the width is set
327          * @param[in]   width               The value of the width
328          * @exception   E_SUCCESS               The method is successful.
329          * @exception   E_INVALID_ARG   The specified @c childControl parameter is not a child of the container that owns the layout.
330          * @exception   E_SYSTEM                A system error has occurred.
331          */
332         result SetWidth(Control& childControl, float width);
333
334         /**
335          * Sets the width of the specified control with the fitting policy.
336          *
337          * @since               2.0
338          *
339          * @return              An error code
340          * @param[in]   childControl    The control for which the width is set
341          * @param[in]   policy                  The fitting policy for the width
342          * @exception   E_SUCCESS               The method is successful.
343          * @exception   E_INVALID_ARG   The specified @c childControl parameter is not a child of the container that owns the layout.
344          * @exception   E_SYSTEM                A system error has occurred.
345          * @remarks             Setting FIT_POLICY_PARENT as @c policy does not cause the width of control to change.
346          */
347         result SetHorizontalFitPolicy(Control& childControl, FitPolicy policy);
348
349         /**
350          * Sets the height of the specified control with a fixed length.
351          *
352          * @since               2.0
353          *
354          * @return              An error code
355          * @param[in]   childControl    The control for which the height is set
356          * @param[in]   height                  The value of the height
357          * @exception   E_SUCCESS               The method is successful.
358          * @exception   E_INVALID_ARG   The specified @c childControl parameter is not a child of the container that owns the layout.
359          * @exception   E_SYSTEM                A system error has occurred.
360          */
361         result SetHeight(Control& childControl, int height);
362
363         /**
364          * Sets the height of the specified control with a fixed length.
365          *
366          * @since               2.1
367          *
368          * @return              An error code
369          * @param[in]   childControl    The control for which the height is set
370          * @param[in]   height                  The value of the height
371          * @exception   E_SUCCESS               The method is successful.
372          * @exception   E_INVALID_ARG   The specified @c childControl parameter is not a child of the container that owns the layout.
373          * @exception   E_SYSTEM                A system error has occurred.
374          */
375         result SetHeight(Control& childControl, float height);
376
377         /**
378          * Sets the height of the specified control with the fitting policy.
379          *
380          * @since               2.0
381          *
382          * @return              An error code
383          * @param[in]   childControl    The control for which the height is set
384          * @param[in]   policy                  The fitting policy for the height
385          * @exception   E_SUCCESS               The method is successful.
386          * @exception   E_INVALID_ARG   The specified @c childControl parameter is not a child of the container that owns the layout.
387          * @exception   E_SYSTEM                A system error has occurred.
388          */
389         result SetVerticalFitPolicy(Control& childControl, FitPolicy policy);
390
391         /**
392          * Sets the weight of the specified control.
393          *
394          * @since               2.0
395          *
396          * @return              An error code
397          * @param[in]   childControl    The control for which the weight is set
398          * @param[in]   weight                  The weight that indicates how much extra space the control occupies in proportion to it, in the %HorizontalBoxLayout
399          * @exception   E_SUCCESS               The method is successful.
400          * @exception   E_INVALID_ARG   The specified @c childControl parameter is not a child of the container that owns the layout.
401          * @exception   E_SYSTEM                A system error has occurred.
402          * @remarks             By default, the weight is set to @c 0.0f.
403          */
404         result SetWeight(Control& childControl, float weight);
405
406 private:
407         //
408         // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
409         //
410         HorizontalBoxLayout(const HorizontalBoxLayout& rhs);
411
412         //
413         // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
414         //
415         HorizontalBoxLayout& operator =(const HorizontalBoxLayout& rhs);
416 }; // HorizontalBoxLayout
417
418 }} // Tizen::Ui
419
420 #endif // _FUI_HORIZONTAL_BOX_LAYOUT_H_