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 FUiCtrlSlider.h
20 * @brief This is the header file for the %Slider class.
22 * This header file contains the declarations of the %Slider class and its helper classes.
25 #ifndef _FUI_CTRL_SLIDER_H_
26 #define _FUI_CTRL_SLIDER_H_
28 #include <FBaseObject.h>
29 #include <FBaseTypes.h>
30 #include <FBaseColArrayListT.h>
31 #include <FBaseString.h>
32 #include <FGrpBitmap.h>
33 #include <FGrpRectangle.h>
34 #include <FUiControl.h>
35 #include <FUiContainer.h>
36 #include <FUiIAdjustmentEventListener.h>
37 #include <FUiCtrlControlsTypes.h>
38 #include <FUiCtrlSliderTypes.h>
39 #include <FUiCtrlISliderEventListener.h>
42 namespace Tizen { namespace Ui { namespace Controls
47 * @brief This class is an implementation of a %Slider control.
51 * The %Slider class displays a slider that represents changing progress or setting information. The difference between %Slider
52 * and Progress is that the former accepts user input by the touch of the slider icon.
54 * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/ui/implementing_slider.htm">Slider</a>.
56 * The following example demonstrates how to use the %Slider class.
59 // Sample code for SliderSample.h
63 : public Tizen::Ui::Controls::Form
64 , public Tizen::Ui::IAdjustmentEventListener
70 bool Initialize(void);
71 virtual result OnInitializing(void);
72 virtual void OnAdjustmentValueChanged(const Tizen::Ui::Control& source, int adjustment);
75 Tizen::Ui::Controls::Slider* __pSlider;
80 // Sample code for SliderSample.cpp
81 #include <FGraphics.h>
83 #include "SliderSample.h"
85 using namespace Tizen::Graphics;
86 using namespace Tizen::Ui::Controls;
89 SliderSample::Initialize(void)
91 Construct(FORM_STYLE_NORMAL);
96 SliderSample::OnInitializing(void)
100 // Creates an instance of Slider
101 __pSlider = new Slider();
102 __pSlider->Construct(Rectangle(0, 200, GetClientAreaBounds().width, 200), BACKGROUND_STYLE_DEFAULT, false, 0, 100);
103 __pSlider->SetValue(50);
104 __pSlider->AddAdjustmentEventListener(*this);
106 // Adds the slider to the form
107 AddControl(*__pSlider);
112 // IAdjustmentEventListener implementation
114 SliderSample::OnAdjustmentValueChanged(const Control& source, int adjustment)
121 class _OSP_EXPORT_ Slider
122 : public Tizen::Ui::Control
127 * 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.
134 * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called.
138 virtual ~Slider(void);
141 * Initializes this instance of %Slider with the specified parameters.
145 * @return An error code
146 * @param[in] rect An instance of the Graphics::Rectangle class @n
147 * This instance represents the x and y coordinates of the top-left corner of the created window along with
148 * the width and height of the control.
149 * @param[in] backgroundStyle The background style set of the slider
150 * @param[in] showTitle Set to @c true to enable the show title, @n
152 * @param[in] minValue The minimum slider value
153 * @param[in] maxValue The maximum slider value
154 * @param[in] groupStyle The table view style of the slider
155 * @exception E_SUCCESS The method is successful.
156 * @exception E_INVALID_ARG A specified input parameter is invalid.
157 * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. @n
158 * The background style of @c BACKGROUND_STYLE_NONE does not work with group styles except @c GROUP_STYLE_NONE.
159 * @exception E_OUT_OF_RANGE The specified values are less than @c -99 or greater than @c 999.
160 * @exception E_SYSTEM A system error has occurred.
161 * @remarks A control is fully usable only after it has been added to a container. Therefore, some methods may fail if used earlier. @n
162 * If the given size is less than the minimum, it returns @c E_INVALID_ARG.
163 * @remarks The size of the control must be within the range defined by the minimum size and the maximum size.
165 result Construct(const Tizen::Graphics::Rectangle& rect, BackgroundStyle backgroundStyle = BACKGROUND_STYLE_DEFAULT, bool showTitle = false, int minValue = 0, int maxValue = 100, GroupStyle groupStyle = GROUP_STYLE_NONE);
168 * Initializes this instance of %Slider with the specified parameters.
172 * @return An error code
173 * @param[in] rect An instance of the Graphics::FloatRectangle class @n
174 * This instance represents the x and y coordinates of the top-left corner of the created window along with
175 * the width and height of the control.
176 * @param[in] backgroundStyle The background style set of the slider
177 * @param[in] showTitle Set to @c true to enable the show title, @n
179 * @param[in] minValue The minimum slider value
180 * @param[in] maxValue The maximum slider value
181 * @param[in] groupStyle The table view style of the slider
182 * @exception E_SUCCESS The method is successful.
183 * @exception E_INVALID_ARG A specified input parameter is invalid.
184 * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. @n
185 * The background style of @c BACKGROUND_STYLE_NONE does not work with group styles except @c GROUP_STYLE_NONE.
186 * @exception E_OUT_OF_RANGE The specified values are less than @c -99 or greater than @c 999.
187 * @exception E_SYSTEM A system error has occurred.
188 * @remarks A control is fully usable only after it has been added to a container. Therefore, some methods may fail if used earlier. @n
189 * If the given size is less than the minimum, it returns @c E_INVALID_ARG.
190 * @remarks The size of the control must be within the range defined by the minimum size and the maximum size.
192 result Construct(const Tizen::Graphics::FloatRectangle& rect, BackgroundStyle backgroundStyle = BACKGROUND_STYLE_DEFAULT, bool showTitle = false, int minValue = 0, int maxValue = 100, GroupStyle groupStyle = GROUP_STYLE_NONE);
195 * Adds a IAdjustmentEventListener instance. @n
196 * The added listener listens to events on the context of the specified event dispatcher when they are fired.
200 * @param[in] listener The event listener to add
202 void AddAdjustmentEventListener(Tizen::Ui::IAdjustmentEventListener& listener);
205 * Removes a IAdjustmentEventListener instance. @n
206 * The removed listener cannot listen to events when they are fired.
210 * @param[in] listener The event listener to remove
212 void RemoveAdjustmentEventListener(Tizen::Ui::IAdjustmentEventListener& listener);
217 * Sets the range of the %Slider control.
221 * @return An error code
222 * @param[in] minValue The minimum value of the %Slider control
223 * @param[in] maxValue The maximum value of the %Slider control
224 * @exception E_SUCCESS The method is successful.
225 * @exception E_INVALID_ARG A specified input parameter is invalid.
226 * @exception E_OUT_OF_RANGE The specified values are greater than @c -99 or less than @c 999.
227 * @exception E_SYSTEM A system error has occurred.
229 result SetRange(int minValue, int maxValue);
232 * Gets the minimum value and the maximum value of the slider.
236 * @param[out] minValue The minimum value of the slider
237 * @param[out] maxValue The maximum value of the slider
239 void GetRange(int& minValue, int& maxValue) const;
242 * Sets the value of the current thumb position. @n
243 * If the specified @c value is greater than @c maxValue, the value is set to @c maxValue, and
244 * if the specified @c value is less than @c minValue, the value is set to @c minValue.
248 * @param[in] value The value of the position
250 void SetValue(int value);
253 * Gets the value of the current thumb position.
257 * @return The current thumb position
259 int GetValue(void) const;
262 * Sets the icon of the slider.
266 * @param[in] position The position of the icon (@c ICON_POSITION_LEFT/@c ICON_POSITION_RIGHT)
267 * @param[in] icon The bitmap image of the icon
268 * @remarks If the size of the bitmap is greater than the default size, the bitmap image is scaled down.
270 void SetIcon(IconPosition position, const Tizen::Graphics::Bitmap& icon);
273 * Sets the title of the slider.
277 * @return An error code
278 * @param[in] title The title to set
279 * @exception E_SUCCESS The method is successful.
280 * @exception E_SYSTEM A system error has occurred.
282 result SetTitleText(const Tizen::Base::String& title);
285 * Gets the title of the slider.
289 * @return The title text of the entered string
291 * @remarks By default returns an empty string.
293 Tizen::Base::String GetTitleText(void) const;
296 * Sets the title text color of the %Slider control.
300 * @param[in] color The title text color to set
302 void SetTitleTextColor(const Tizen::Graphics::Color& color);
305 * Gets the title text color of the %Slider control.
309 * @return The title text color
311 Tizen::Graphics::Color GetTitleTextColor(void) const;
314 * Initializes this instance of %Slider with the specified parameters.
318 * @return An error code
319 * @param[in] rect An instance of the Graphics::Rectangle class @n
320 * This instance represents the x and y coordinates of the top-left corner of the created window along with
321 * its width and height.
322 * @param[in] sliderStyle The style of the slider @n
323 * Multiple link types can be combined using bitwise OR operator. See Tizen::Ui::Controls::SliderStyle.
324 * @param[in] minValue The minimum slider value
325 * @param[in] maxValue The maximum slider value
326 * @exception E_SUCCESS The method is successful.
327 * @exception E_OUT_OF_RANGE The specified minimum and maximum values are less than @c -99, or greater than @c 999.
328 * @exception E_INVALID_ARG A specified input parameter is invalid, or the specified @c minValue is greater than @c maxVaue.
329 * @exception E_SYSTEM A system error has occurred.
330 * @remarks A control is fully functional only after it has been added to a container. Therefore, some methods may fail if they are used before
331 * adding the control to the container. @n
332 * If the specified size is less than the minimum size, the %Slider control is constructed with the minimum size.
333 * @remarks The width and the height of the control must be greater than @c 0.
334 * @remarks The size of the control must be within the range defined by the minimum size and the maximum size.
336 result Construct(const Tizen::Graphics::Rectangle& rect, unsigned long sliderStyle, int minValue = 0, int maxValue = 100);
339 * Initializes this instance of %Slider with the specified parameters.
343 * @return An error code
344 * @param[in] rect An instance of the Graphics::FloatRectangle class @n
345 * This instance represents the x and y coordinates of the top-left corner of the created window along with
346 * its width and height.
347 * @param[in] sliderStyle The style of the slider @n
348 * Multiple link types can be combined using bitwise OR operator. See Tizen::Ui::Controls::SliderStyle.
349 * @param[in] minValue The minimum slider value
350 * @param[in] maxValue The maximum slider value
351 * @exception E_SUCCESS The method is successful.
352 * @exception E_OUT_OF_RANGE The specified minimum and maximum values are less than @c -99, or greater than @c 999.
353 * @exception E_INVALID_ARG A specified input parameter is invalid, or the specified @c minValue is greater than @c maxVaue.
354 * @exception E_SYSTEM A system error has occurred.
355 * @remarks A control is fully functional only after it has been added to a container. Therefore, some methods may fail if they are used before
356 * adding the control to the container. @n
357 * If the specified size is less than the minimum size, the %Slider control is constructed with the minimum size.
358 * @remarks The width and the height of the control must be greater than @c 0.
359 * @remarks The size of the control must be within the range defined by the minimum size and the maximum size.
361 result Construct(const Tizen::Graphics::FloatRectangle& rect, unsigned long sliderStyle, int minValue = 0, int maxValue = 100);
364 * Adds a ISliderEventListener instance. @n
365 * The added listener can listen to the slider-related events.
369 * @param[in] listener The event listener to add
371 void AddSliderEventListener(ISliderEventListener& listener);
374 * Removes a ISliderEventListener instance. @n
375 * The removed listener cannot listen to events when they are fired.
379 * @param[in] listener The event listener to remove
381 void RemoveSliderEventListener(ISliderEventListener& listener);
384 * Sets the color of the bar.
388 * @return An error code
389 * @param[in] color The color to set
390 * @exception E_SUCCESS The method is successful.
391 * @exception E_SYSTEM A system error has occurred.
392 * @remarks The method ignores the alpha value of the @c color parameter and sets the alpha value to @c 255.
394 result SetBarColor(const Tizen::Graphics::Color& color);
397 * Gets the color of the bar.
401 * @return The color of the bar, @n
402 * else RGBA(0, 0, 0, 0) if an error occurs
403 * @exception E_SUCCESS The method is successful.
404 * @remarks The specific error code can be accessed using the GetLastResult() method.
406 Tizen::Graphics::Color GetBarColor(void) const;
409 * Sets the background color of the bar.
413 * @param[in] color The color to be set
414 * @remarks The method ignores the alpha value of the @c color parameter and sets the alpha value to @c 255.
415 * @see GetBarBackgroundColor()
417 void SetBarBackgroundColor(const Tizen::Graphics::Color& barBackgroundColor);
420 * Gets the background color of the bar.
424 * @return The background color of the bar, @n
425 * else RGBA(0, 0, 0, 0) if an error occurs
426 * @remarks The specific error code can be accessed using the GetLastResult() method.
427 * @see SetBarBackgroundColor()
429 Tizen::Graphics::Color GetBarBackgroundColor(void) const;
432 * Sets the color of the slider.
436 * @return An error code
437 * @param[in] color The color to set
438 * @exception E_SUCCESS The method is successful.
439 * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. @n
440 * The operation is not supported if the background style of the %Slider control is @c BACKGROUND_STYLE_NONE.
441 * @exception E_SYSTEM A system error has occurred.
442 * @remarks If a device supports only the 16-bit color space, this method considers the color as opaque by ignoring the alpha value of @c color.
444 result SetColor(const Tizen::Graphics::Color& color);
447 * Gets the color of the slider.
451 * @return The color , @n
452 * else RGBA(0, 0, 0, 0) if an instance is invalid or the background style is @c BACKGROUND_STYLE_NONE
453 * @exception E_SUCCESS The method is successful.
454 * @exception E_INVALID_OPERATION The background style is not proper.
455 * @remarks The specific error code can be accessed using the GetLastResult() method.
457 Tizen::Graphics::Color GetColor(void) const;
460 * Sets the bitmap image to the %Slider control Thumb.
464 * @return An error code
465 * @param[in] status The state of the slider thumb
466 * @param[in] bitmap The Thumb bitmap image
467 * @exception E_SUCCESS The method is successful.
468 * @exception E_OUT_OF_MEMORY The memory is insufficient.
470 result SetThumbBitmap(SliderThumbStatus status, const Tizen::Graphics::Bitmap& bitmap);
473 * Sets the text color of the %Slider control Thumb.
477 * @return An error code
478 * @param[in] status The state of the slider thumb
479 * @param[in] color The color should be set for the thumb text
481 void SetThumbTextColor(SliderThumbStatus status, const Tizen::Graphics::Color& color);
485 // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
487 Slider(const Slider&);
490 // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
492 Slider& operator =(const Slider&);
494 friend class _SliderImpl;
498 }}} // Tizen::Ui::Controls
500 #endif // _FUI_CTRL_SLIDER_H_