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.
19 * @file FUiCtrlScrollPanel.h
20 * @brief This is the header file for the %ScrollPanel class.
22 * This header file contains the declarations of the %ScrollPanel class.
25 #ifndef _FUI_CTRL_SCROLL_PANEL_H_
26 #define _FUI_CTRL_SCROLL_PANEL_H_
28 #include <FBaseString.h>
29 #include <FBaseTypes.h>
30 #include <FUiCtrlForm.h>
31 #include <FUiCtrlInputTypes.h>
32 #include <FUiCtrlPanel.h>
33 #include <FUiCtrlIScrollEventListener.h>
34 #include <FUiCtrlScrollPanelTypes.h>
35 #include <FUiCtrlTableViewTypes.h>
37 namespace Tizen { namespace Ui { namespace Controls
41 * @brief This class implements a scrollable container class.
45 * The %ScrollPanel class is a Panel with automatic scroll bars.
47 * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/ui/implementing_panels.htm">Panels</a>.
49 * The following example demonstrates how to use the %ScrollPanel class.
52 // Sample code for ScrollPanelSample.h
55 class ScrollPanelSample
56 : public Tizen::Ui::Controls::Form
59 ScrollPanelSample(void)
60 : __pScrollPanel(null){}
62 bool Initialize(void);
63 virtual result OnInitializing(void);
66 Tizen::Ui::Controls::ScrollPanel* __pScrollPanel;
71 // Sample code for ScrollPanelSample.cpp
72 #include <FGraphics.h>
74 #include "ScrollPanelSample.h"
76 using namespace Tizen::Graphics;
77 using namespace Tizen::Ui::Controls;
80 ScrollPanelSample::Initialize(void)
82 Construct(FORM_STYLE_NORMAL);
87 ScrollPanelSample::OnInitializing(void)
91 // Creates an instance of ScrollPanel
92 __pScrollPanel = new ScrollPanel();
93 __pScrollPanel->Construct(Rectangle(100, 250, 400, 300));
94 __pScrollPanel->SetBackgroundColor(Color::GetColor(COLOR_ID_YELLOW));
96 // Creates an instance of Button and an instance of EditField
97 Button* pButton = new Button();
98 pButton->Construct(Rectangle(0, 80, 200, 150), L"Button");
100 EditField* pEdit = new EditField();
101 pEdit->Construct(Rectangle(0, 250, 200, 150));
102 pEdit->SetText(L"Edit");
104 // Adds the button and the edit field to the ScrollPanel
105 __pScrollPanel->AddControl(*pButton);
106 __pScrollPanel->AddControl(*pEdit);
108 // Adds the ScrollPanel to the form
109 AddControl(*__pScrollPanel);
116 class _OSP_EXPORT_ ScrollPanel
123 * 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.
132 * This destructor overrides Tizen::Base::Object::~Object().
137 virtual ~ScrollPanel(void);
141 * Initializes this instance of %ScrollPanel with the specified rectangular region.
145 * @return An error code
146 * @param[in] rect The location and size of the %ScrollPanel control
147 * @exception E_SUCCESS The method is successful.
148 * @exception E_INVALID_ARG The given width or height is less than 0.
149 * @exception E_SYSTEM A system error has occurred.
150 * @remarks By default, the scroll direction is vertical and the scroll area is resized automatically.
151 * @see Tizen::Ui::Container
153 result Construct(const Tizen::Graphics::Rectangle& rect);
157 * Initializes this instance of %ScrollPanel and child controls with the specified resource ID @n
159 * This method first attempts to find the resource file in the folder that corresponds to the current screen resolution. @n
160 * If it fails to find the resource file, it searches in other folders in the following order when CoordinateSystem is Logical in the application manifest file @n
161 * the density folder that corresponds to the current screen size category "res/screen-size-normal/" folder.
165 * @return An error code
166 * @param[in] resourceId The resource ID describing the %ScrollPanel control
167 * @exception E_SUCCESS The method is successful.
168 * @exception E_FILE_NOT_FOUND The specified file cannot be found.
169 * @exception E_INVALID_FORMAT The specified XML format is invalid.
170 * @exception E_OPERATION_FAILED The operation has failed.
172 result Construct(const Tizen::Base::String& resourceId);
175 * Initializes this instance of %ScrollPanel with the specified rectangular region.
179 * @return An error code
180 * @param[in] rect The location and size of the %ScrollPanel control
181 * @param[in] scrollDirection The scroll direction of %ScrollPanel
182 * @param[in] autoResizingEnable Whether to resize the client area automatically
183 * @exception E_SUCCESS The method is successful.
184 * @exception E_INVALID_ARG The given width or height is less than 0.
185 * @see Tizen::Ui::Container
187 result Construct(const Tizen::Graphics::Rectangle& rect, ScrollPanelScrollDirection scrollDirection, bool autoResizingEnable);
191 * Initializes this instance of %ScrollPanel with the specified layout and rectangular region.
195 * @return An error code
196 * @param[in] layout The layout for both the portrait and landscape mode
197 * @param[in] rect The location and size of the %ScrollPanel control
198 * @exception E_SUCCESS The method is successful.
199 * @exception E_INVALID_ARG @c layout is already bound to another container, or the given width or the height is less than 0.
200 * @exception E_SYSTEM A system error has occurred.
201 * @remarks By default, the scroll direction is vertical and the scroll area is resized automatically.
202 * @see Tizen::Ui::Container
204 result Construct(const Tizen::Ui::Layout& layout, const Tizen::Graphics::Rectangle& rect);
208 * Initializes this instance of %ScrollPanel with the specified layout and rectangular region.
212 * @return An error code
213 * @param[in] layout The layout for both the portrait and landscape mode
214 * @param[in] rect The location and size of the %ScrollPanel control
215 * @param[in] scrollDirection The scroll direction of %ScrollPanel
216 * @param[in] autoResizingEnable Whether to resize the client area automatically
217 * @exception E_SUCCESS The method is successful.
218 * @exception E_INVALID_ARG @c layout is already bound to another container, or the given width or height is less than 0.
219 * @see Tizen::Ui::Container
221 result Construct(const Tizen::Ui::Layout& layout, const Tizen::Graphics::Rectangle& rect, ScrollPanelScrollDirection scrollDirection, bool autoResizingEnable);
225 * Initializes this instance of %ScrollPanel with the specified layouts and rectangular region.
229 * @return An error code
230 * @param[in] portraitLayout The layout for the portrait mode
231 * @param[in] landscapeLayout The layout for the landscape mode
232 * @param[in] rect The location and size of the %ScrollPanel control
233 * @exception E_SUCCESS The method is successful.
234 * @exception E_INVALID_ARG @c portraitLayout or @c landscapeLayout is already bound to another container, or the given width or height is less than 0.
235 * @exception E_SYSTEM A system error has occurred.
236 * @remarks By default, the scroll direction is vertical and the scroll area is resized automatically.
237 * @see Tizen::Ui::Container
239 result Construct(const Tizen::Ui::Layout& portraitLayout, const Tizen::Ui::Layout& landscapeLayout, const Tizen::Graphics::Rectangle& rect);
243 * Initializes this instance of %ScrollPanel with the specified layouts and rectangular region.
247 * @return An error code
248 * @param[in] portraitLayout The layout for the portrait mode
249 * @param[in] landscapeLayout The layout for the landscape mode
250 * @param[in] rect The location and size of the %ScrollPanel control
251 * @param[in] scrollDirection The scroll direction of %ScrollPanel
252 * @param[in] autoResizingEnable Whether to resize the client area automatically
253 * @exception E_SUCCESS The method is successful.
254 * @exception E_INVALID_ARG @c portraitLayout or @c landscapeLayout is already bound to another container, or the given width or height is less than 0.
255 * @see Tizen::Ui::Container
257 result Construct(const Tizen::Ui::Layout& portraitLayout, const Tizen::Ui::Layout& landscapeLayout, const Tizen::Graphics::Rectangle& rect, ScrollPanelScrollDirection scrollDirection, bool autoResizingEnable);
261 * Adds a listener instance that listens to the state changes of a scroll event. @n
262 * The added listener can listen to the events on the given event dispatcher's context when they are fired.
266 * @param[in] listener The listener to add
267 * @exception E_SUCCESS The method is successful.
268 * @exception E_OUT_OF_MEMORY The memory is insufficient.
269 * @see IScrollEventListener::OnScrollEndReached()
270 * @see RemoveScrollEventListener()
272 void AddScrollEventListener(IScrollEventListener& listener);
276 * Removes a listener instance that listens to the state changes of a scroll event. @n
277 * The removed listener cannot listen to the events when they are fired.
281 * @param[in] listener The listener to remove
282 * @see IScrollEventListener::OnScrollEndReached()
283 * @see AddScrollEventListener()
285 void RemoveScrollEventListener(IScrollEventListener& listener);
289 * Gets the scroll position.
293 * @return The scroll position
295 int GetScrollPosition(void) const;
300 * Sets the scroll position.
302 * @brief <i> [Deprecated] </i>
303 * @deprecated This method is deprecated. Instead of using this method, use the SetScrollPosition(int, bool), which supports animated scroll.
306 * @param[in] position The scroll position
309 void SetScrollPosition(int position);
312 * Sets the scroll position.
316 * @param[in] position The scroll position in pixel
317 * @param[in] withAnimation @c true to scroll the %ScrollPanel smoothly. @n
321 void SetScrollPosition(int position, bool withAnimation);
324 * Scrolls to the bottom of %ScrollPanel.
328 void ScrollToBottom(void) const;
332 * Scrolls to the top of %ScrollPanel.
336 void ScrollToTop(void) const;
340 * Closes the overlay Window for supporting the overlay keypad.
344 * @exception E_SUCCESS The method is successful.
345 * @exception E_SYSTEM A system error has occurred.
347 result CloseOverlayWindow(void);
351 * Gets the bounds of the client area.
355 * @return The bounds of the client area
358 Tizen::Graphics::Rectangle GetClientAreaBounds(void) const;
362 * Sets the width of the client area.
366 * @return An error code
367 * @param[in] width The width of the client area to set
368 * @exception E_SUCCESS The method is successful.
369 * @exception E_INVALID_ARG @c width is less than the width of %ScrollPanel
370 * @exception E_INVALID_OPERATION The width of the client area cannot be set when auto resizing of the client area is off, or the scroll direction is vertical.
373 result SetClientAreaWidth(int width);
377 * Sets the height of the client area.
381 * @return An error code
382 * @param[in] height The height of the client area to set
383 * @exception E_SUCCESS The method is successful.
384 * @exception E_INVALID_ARG @c height is less than the height of %ScrollPanel
385 * @exception E_INVALID_OPERATION The height of the client area cannot be set when auto resizing of the client area is off, or the scroll direction is horizontal.
388 result SetClientAreaHeight(int height);
392 * Gets the scroll direction of the %ScrollPanel.
396 * @return Direction of %ScrollPanel
399 ScrollPanelScrollDirection GetScrollDirection(void) const;
403 * Gets how the scroll area the %ScrollPanel is resized.
407 * @return Whether to resize the client area automatically
410 bool IsScrollAreaAutoResizingEnabled(void) const;
414 * Enables or disables scrolling by page, where page size is determined by the size of the %ScrollPanel.
418 * @param[in] enable Set to @c true to enable page scroll.
421 void SetPageScrollEnabled(bool enable);
425 * Checks whether scrolling by page feature is enabled.
429 * @return @c true if the page scroll is enabled. @n
433 bool IsPageScrollEnabled(void) const;
437 * Sets the visibility of scroll bar.
441 * @param[in] visible Set to @c true to show scroll bar. @n
445 void SetScrollBarVisible(bool visible);
449 * Gets the visibility of scroll bar.
454 bool IsScrollBarVisible(void) const;
458 * Sets the scroll input handling mode.
462 * @param[in] mode The scroll input handling mode
463 * @see GetScrollInputMode()
465 void SetScrollInputMode(ScrollInputMode mode);
469 * Gets the scroll input handling mode.
473 * @return The scroll input handling mode
474 * @see SetScrollInputMode()
476 ScrollInputMode GetScrollInputMode(void) const;
481 friend class _ScrollPanelImpl;
483 // Reserved virtual methods for later extension
485 // The following methods are reserved and may change its name at any time without prior notice.
486 virtual void ScrollPanel_Reserved1(void) {}
488 virtual void ScrollPanel_Reserved2(void) {}
490 virtual void ScrollPanel_Reserved3(void) {}
493 // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
494 ScrollPanel(const ScrollPanel& rhs);
496 // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
497 ScrollPanel& operator =(const ScrollPanel& rhs);
501 }}} // Tizen::Ui::Controls
503 #endif // _FUI_CTRL_SCROLL_PANEL_H_