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 <FUiCtrlIScrollEventListenerF.h>
35 #include <FUiCtrlScrollPanelTypes.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 with the specified rectangular region.
161 * @return An error code
162 * @param[in] rect The location and size of the %ScrollPanel control
163 * @exception E_SUCCESS The method is successful.
164 * @exception E_INVALID_ARG The given width or height is less than 0.
165 * @exception E_SYSTEM A system error has occurred.
166 * @remarks By default, the scroll direction is vertical and the scroll area is resized automatically.
167 * @see Tizen::Ui::Container
169 result Construct(const Tizen::Graphics::FloatRectangle& rect);
173 * Initializes this instance of %ScrollPanel and child controls with the specified resource ID @n
175 * This method first attempts to find the resource file in the folder that corresponds to the current screen resolution. @n
176 * 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
177 * the density folder that corresponds to the current screen size category "res/screen-size-normal/" folder.
181 * @return An error code
182 * @param[in] resourceId The resource ID describing the %ScrollPanel control
183 * @exception E_SUCCESS The method is successful.
184 * @exception E_FILE_NOT_FOUND The specified file cannot be found.
185 * @exception E_INVALID_FORMAT The specified XML format is invalid.
186 * @exception E_OPERATION_FAILED The operation has failed.
188 result Construct(const Tizen::Base::String& resourceId);
192 * Initializes this instance of %ScrollPanel with the specified rectangular region.
196 * @return An error code
197 * @param[in] rect The location and size of the %ScrollPanel control
198 * @param[in] scrollDirection The scroll direction of %ScrollPanel
199 * @param[in] autoResizingEnable Whether to resize the client area automatically
200 * @exception E_SUCCESS The method is successful.
201 * @exception E_INVALID_ARG The given width or height is less than 0.
202 * @see Tizen::Ui::Container
204 result Construct(const Tizen::Graphics::Rectangle& rect, ScrollPanelScrollDirection scrollDirection, bool autoResizingEnable);
208 * Initializes this instance of %ScrollPanel with the specified rectangular region.
212 * @return An error code
213 * @param[in] rect The location and size of the %ScrollPanel control
214 * @param[in] scrollDirection The scroll direction of %ScrollPanel
215 * @param[in] autoResizingEnable Whether to resize the client area automatically
216 * @exception E_SUCCESS The method is successful.
217 * @exception E_INVALID_ARG The given width or height is less than 0.
218 * @see Tizen::Ui::Container
220 result Construct(const Tizen::Graphics::FloatRectangle& rect, ScrollPanelScrollDirection scrollDirection, bool autoResizingEnable);
224 * Initializes this instance of %ScrollPanel with the specified layout and rectangular region.
228 * @return An error code
229 * @param[in] layout The layout for both the portrait and landscape mode
230 * @param[in] rect The location and size of the %ScrollPanel control
231 * @exception E_SUCCESS The method is successful.
232 * @exception E_INVALID_ARG @c layout is already bound to another container, or the given width or the height is less than 0.
233 * @exception E_SYSTEM A system error has occurred.
234 * @remarks By default, the scroll direction is vertical and the scroll area is resized automatically.
235 * @see Tizen::Ui::Container
237 result Construct(const Tizen::Ui::Layout& layout, const Tizen::Graphics::Rectangle& rect);
241 * Initializes this instance of %ScrollPanel with the specified layout and rectangular region.
245 * @return An error code
246 * @param[in] layout The layout for both the portrait and landscape mode
247 * @param[in] rect The location and size of the %ScrollPanel control
248 * @exception E_SUCCESS The method is successful.
249 * @exception E_INVALID_ARG @c layout is already bound to another container, or the given width or the height is less than 0.
250 * @exception E_SYSTEM A system error has occurred.
251 * @remarks By default, the scroll direction is vertical and the scroll area is resized automatically.
252 * @see Tizen::Ui::Container
254 result Construct(const Tizen::Ui::Layout& layout, const Tizen::Graphics::FloatRectangle& rect);
258 * Initializes this instance of %ScrollPanel with the specified layout and rectangular region.
262 * @return An error code
263 * @param[in] layout The layout for both the portrait and landscape mode
264 * @param[in] rect The location and size of the %ScrollPanel control
265 * @param[in] scrollDirection The scroll direction of %ScrollPanel
266 * @param[in] autoResizingEnable Whether to resize the client area automatically
267 * @exception E_SUCCESS The method is successful.
268 * @exception E_INVALID_ARG @c layout is already bound to another container, or the given width or height is less than 0.
269 * @see Tizen::Ui::Container
271 result Construct(const Tizen::Ui::Layout& layout, const Tizen::Graphics::Rectangle& rect, ScrollPanelScrollDirection scrollDirection, bool autoResizingEnable);
275 * Initializes this instance of %ScrollPanel with the specified layout and rectangular region.
279 * @return An error code
280 * @param[in] layout The layout for both the portrait and landscape mode
281 * @param[in] rect The location and size of the %ScrollPanel control
282 * @param[in] scrollDirection The scroll direction of %ScrollPanel
283 * @param[in] autoResizingEnable Whether to resize the client area automatically
284 * @exception E_SUCCESS The method is successful.
285 * @exception E_INVALID_ARG @c layout is already bound to another container, or the given width or height is less than 0.
286 * @see Tizen::Ui::Container
288 result Construct(const Tizen::Ui::Layout& layout, const Tizen::Graphics::FloatRectangle& rect, ScrollPanelScrollDirection scrollDirection, bool autoResizingEnable);
292 * Initializes this instance of %ScrollPanel with the specified layouts and rectangular region.
296 * @return An error code
297 * @param[in] portraitLayout The layout for the portrait mode
298 * @param[in] landscapeLayout The layout for the landscape mode
299 * @param[in] rect The location and size of the %ScrollPanel control
300 * @exception E_SUCCESS The method is successful.
301 * @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.
302 * @exception E_SYSTEM A system error has occurred.
303 * @remarks By default, the scroll direction is vertical and the scroll area is resized automatically.
304 * @see Tizen::Ui::Container
306 result Construct(const Tizen::Ui::Layout& portraitLayout, const Tizen::Ui::Layout& landscapeLayout, const Tizen::Graphics::Rectangle& rect);
310 * Initializes this instance of %ScrollPanel with the specified layouts and rectangular region.
314 * @return An error code
315 * @param[in] portraitLayout The layout for the portrait mode
316 * @param[in] landscapeLayout The layout for the landscape mode
317 * @param[in] rect The location and size of the %ScrollPanel control
318 * @exception E_SUCCESS The method is successful.
319 * @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.
320 * @exception E_SYSTEM A system error has occurred.
321 * @remarks By default, the scroll direction is vertical and the scroll area is resized automatically.
322 * @see Tizen::Ui::Container
324 result Construct(const Tizen::Ui::Layout& portraitLayout, const Tizen::Ui::Layout& landscapeLayout, const Tizen::Graphics::FloatRectangle& rect);
328 * Initializes this instance of %ScrollPanel with the specified layouts and rectangular region.
332 * @return An error code
333 * @param[in] portraitLayout The layout for the portrait mode
334 * @param[in] landscapeLayout The layout for the landscape mode
335 * @param[in] rect The location and size of the %ScrollPanel control
336 * @param[in] scrollDirection The scroll direction of %ScrollPanel
337 * @param[in] autoResizingEnable Whether to resize the client area automatically
338 * @exception E_SUCCESS The method is successful.
339 * @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.
340 * @see Tizen::Ui::Container
342 result Construct(const Tizen::Ui::Layout& portraitLayout, const Tizen::Ui::Layout& landscapeLayout, const Tizen::Graphics::Rectangle& rect, ScrollPanelScrollDirection scrollDirection, bool autoResizingEnable);
346 * Initializes this instance of %ScrollPanel with the specified layouts and rectangular region.
350 * @return An error code
351 * @param[in] portraitLayout The layout for the portrait mode
352 * @param[in] landscapeLayout The layout for the landscape mode
353 * @param[in] rect The location and size of the %ScrollPanel control
354 * @param[in] scrollDirection The scroll direction of %ScrollPanel
355 * @param[in] autoResizingEnable Whether to resize the client area automatically
356 * @exception E_SUCCESS The method is successful.
357 * @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.
358 * @see Tizen::Ui::Container
360 result Construct(const Tizen::Ui::Layout& portraitLayout, const Tizen::Ui::Layout& landscapeLayout, const Tizen::Graphics::FloatRectangle& rect, ScrollPanelScrollDirection scrollDirection, bool autoResizingEnable);
364 * Adds a listener instance that listens to the state changes of a scroll event. @n
365 * The added listener can listen to the events on the given event dispatcher's context when they are fired.
369 * @param[in] listener The listener to add
370 * @exception E_SUCCESS The method is successful.
371 * @exception E_OUT_OF_MEMORY The memory is insufficient.
372 * @see Tizen::Ui::Controls::IScrollEventListener
373 * @see RemoveScrollEventListener()
375 void AddScrollEventListener(IScrollEventListener& listener);
379 * Adds a listener instance that listens to the state changes of a scroll event. @n
380 * The added listener can listen to the events on the given event dispatcher's context when they are fired.
384 * @param[in] listener The listener to add
385 * @exception E_SUCCESS The method is successful.
386 * @exception E_OUT_OF_MEMORY The memory is insufficient.
387 * @see Tizen::Ui::Controls::IScrollEventListenerF
388 * @see RemoveScrollEventListener()
390 void AddScrollEventListener(IScrollEventListenerF& listener);
394 * Removes a listener instance that listens to the state changes of a scroll event. @n
395 * The removed listener cannot listen to the events when they are fired.
399 * @param[in] listener The listener to remove
400 * @see Tizen::Ui::Controls::IScrollEventListener
401 * @see AddScrollEventListener()
403 void RemoveScrollEventListener(IScrollEventListener& listener);
407 * Removes a listener instance that listens to the state changes of a scroll event. @n
408 * The removed listener cannot listen to the events when they are fired.
412 * @param[in] listener The listener to remove
413 * @see Tizen::Ui::Controls::IScrollEventListenerF
414 * @see AddScrollEventListener()
416 void RemoveScrollEventListener(IScrollEventListenerF& listener);
420 * Gets the scroll position.
424 * @return The scroll position
426 int GetScrollPosition(void) const;
430 * Gets the scroll position.
434 * @return The scroll position
436 float GetScrollPositionF(void) const;
441 * Sets the scroll position.
443 * @brief <i> [Deprecated] </i>
444 * @deprecated This method is deprecated. Instead of using this method, use the SetScrollPosition(int, bool), which supports animated scroll.
447 * @param[in] position The scroll position
450 void SetScrollPosition(int position);
454 * Sets the scroll position.
458 * @param[in] position The scroll position in pixel
459 * @param[in] withAnimation @c true to scroll the %ScrollPanel smoothly. @n
463 void SetScrollPosition(int position, bool withAnimation);
467 * Sets the scroll position.
471 * @param[in] position The scroll position in pixel
472 * @param[in] withAnimation @c true to scroll the %ScrollPanel smoothly. @n
476 void SetScrollPosition(float position, bool withAnimation);
480 * Scrolls to the bottom of %ScrollPanel.
484 void ScrollToBottom(void) const;
488 * Scrolls to the top of %ScrollPanel.
492 void ScrollToTop(void) const;
496 * Closes the overlay Window for supporting the overlay keypad.
500 * @exception E_SUCCESS The method is successful.
501 * @exception E_SYSTEM A system error has occurred.
503 result CloseOverlayWindow(void);
507 * Gets the bounds of the client area.
511 * @return The bounds of the client area
514 Tizen::Graphics::Rectangle GetClientAreaBounds(void) const;
518 * Gets the bounds of the client area.
522 * @return The bounds of the client area
525 Tizen::Graphics::FloatRectangle GetClientAreaBoundsF(void) const;
529 * Sets the width of the client area.
533 * @return An error code
534 * @param[in] width The width of the client area to set
535 * @exception E_SUCCESS The method is successful.
536 * @exception E_INVALID_ARG @c width is less than the width of %ScrollPanel
537 * @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.
540 result SetClientAreaWidth(int width);
544 * Sets the width of the client area.
548 * @return An error code
549 * @param[in] width The width of the client area to set
550 * @exception E_SUCCESS The method is successful.
551 * @exception E_INVALID_ARG @c width is less than the width of %ScrollPanel
552 * @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.
555 result SetClientAreaWidth(float width);
559 * Sets the height of the client area.
563 * @return An error code
564 * @param[in] height The height of the client area to set
565 * @exception E_SUCCESS The method is successful.
566 * @exception E_INVALID_ARG @c height is less than the height of %ScrollPanel
567 * @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.
570 result SetClientAreaHeight(int height);
574 * Sets the height of the client area.
578 * @return An error code
579 * @param[in] height The height of the client area to set
580 * @exception E_SUCCESS The method is successful.
581 * @exception E_INVALID_ARG @c height is less than the height of %ScrollPanel
582 * @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.
585 result SetClientAreaHeight(float height);
589 * Gets the scroll direction of the %ScrollPanel.
593 * @return Direction of %ScrollPanel
596 ScrollPanelScrollDirection GetScrollDirection(void) const;
600 * Gets how the scroll area the %ScrollPanel is resized.
604 * @return Whether to resize the client area automatically
607 bool IsScrollAreaAutoResizingEnabled(void) const;
611 * Enables or disables scrolling by page, where page size is determined by the size of the %ScrollPanel.
615 * @param[in] enable Set to @c true to enable page scroll.
618 void SetPageScrollEnabled(bool enable);
622 * Checks whether scrolling by page feature is enabled.
626 * @return @c true if the page scroll is enabled. @n
630 bool IsPageScrollEnabled(void) const;
634 * Sets the visibility of scroll bar.
638 * @param[in] visible Set to @c true to show scroll bar. @n
642 void SetScrollBarVisible(bool visible);
646 * Gets the visibility of scroll bar.
651 bool IsScrollBarVisible(void) const;
655 * Sets the scroll input handling mode.
659 * @param[in] mode The scroll input handling mode
660 * @see GetScrollInputMode()
662 void SetScrollInputMode(ScrollInputMode mode);
666 * Gets the scroll input handling mode.
670 * @return The scroll input handling mode
671 * @see SetScrollInputMode()
673 ScrollInputMode GetScrollInputMode(void) const;
678 friend class _ScrollPanelImpl;
680 // Reserved virtual methods for later extension
682 // The following methods are reserved and may change its name at any time without prior notice.
683 virtual void ScrollPanel_Reserved1(void) {}
685 virtual void ScrollPanel_Reserved2(void) {}
687 virtual void ScrollPanel_Reserved3(void) {}
690 // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
691 ScrollPanel(const ScrollPanel& rhs);
693 // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
694 ScrollPanel& operator =(const ScrollPanel& rhs);
698 }}} // Tizen::Ui::Controls
700 #endif // _FUI_CTRL_SCROLL_PANEL_H_