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.
18 * @file FUiCtrlSlider.h
19 * @brief This is the header file for the %Slider class.
21 * This header file contains the declarations of the %Slider class and its helper classes.
24 #ifndef _FUI_CTRL_SLIDER_H_
25 #define _FUI_CTRL_SLIDER_H_
27 #include <FBaseObject.h>
28 #include <FBaseTypes.h>
29 #include <FBaseColArrayListT.h>
30 #include <FBaseString.h>
31 #include <FGrpBitmap.h>
32 #include <FGrpRectangle.h>
33 #include <FUiControl.h>
34 #include <FUiContainer.h>
35 #include <FUiIAdjustmentEventListener.h>
36 #include <FUiCtrlControlsTypes.h>
37 #include <FUiCtrlGroupTypes.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 BACKGROUND_STYLE_NONE does not work with group styles except 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 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 * Adds a IAdjustmentEventListener instance. @n
169 * The added listener listens to events on the context of the specified event dispatcher when they are fired.
173 * @param[in] listener The event listener to be added
175 void AddAdjustmentEventListener(Tizen::Ui::IAdjustmentEventListener& listener);
178 * Removes a IAdjustmentEventListener instance. @n
179 * The removed listener cannot listen to events when they are fired.
183 * @param[in] listener The event listener to be removed
185 void RemoveAdjustmentEventListener(Tizen::Ui::IAdjustmentEventListener& listener);
190 * Sets the range of the %Slider control.
194 * @return An error code
195 * @param[in] minValue The minimum value of the %Slider control
196 * @param[in] maxValue The maximum value of the %Slider control
197 * @exception E_SUCCESS The method is successful.
198 * @exception E_INVALID_ARG A specified input parameter is invalid.
199 * @exception E_OUT_OF_RANGE The specified values are greater than @c -99 or less than @c 999.
200 * @exception E_SYSTEM A system error has occurred.
202 result SetRange(int minValue, int maxValue);
205 * Gets the minimum value and the maximum value of the slider.
209 * @param[out] minValue The minimum value of the slider
210 * @param[out] maxValue The maximum value of the slider
212 void GetRange(int& minValue, int& maxValue) const;
215 * Sets the value of the current thumb position. @n
216 * If the specified @c value is greater than @c maxValue, the value is set to @c maxValue, and
217 * if the specified @c value is less than @c minValue, the value is set to @c minValue.
221 * @param[in] value The value of the position
223 void SetValue(int value);
226 * Gets the value of the current thumb position.
230 * @return The current thumb position
232 int GetValue(void) const;
235 * Sets the icon of the slider.
239 * @param[in] position The position of the icon (ICON_POSITION_LEFT/ICON_POSITION_RIGHT)
240 * @param[in] icon The bitmap image of the icon
241 * @remarks If the size of the bitmap is greater than the default size, the bitmap image is scaled down.
243 void SetIcon(IconPosition position, const Tizen::Graphics::Bitmap& icon);
246 * Sets the title of the slider.
250 * @return An error code
251 * @param[in] title The title to be set
252 * @exception E_SUCCESS The method is successful.
253 * @exception E_SYSTEM A system error has occurred.
255 result SetTitleText(const Tizen::Base::String& title);
258 * Gets the title of the slider.
262 * @return The title text of the entered string, @n
263 * else an empty string if the %Slider instance is not constructed
265 Tizen::Base::String GetTitleText(void) const;
268 * Sets the title text color of the %Slider control.
272 * @param[in] color The title text color to be set
274 void SetTitleTextColor(const Tizen::Graphics::Color& color);
277 * Gets the title text color of the %Slider control.
281 * @return The title text color
283 Tizen::Graphics::Color GetTitleTextColor(void) const;
286 * Initializes this instance of %Slider with the specified parameters.
290 * @return An error code
291 * @param[in] rect An instance of the Graphics::Rectangle class @n
292 * This instance represents the x and y coordinates of the top-left corner of the created window along with
293 * its width and height.
294 * @param[in] sliderStyle The style of the slider @n
295 * Multiple link types can be combined using bitwise OR operator. See Tizen::Ui::Controls::SliderStyle.
296 * @param[in] minValue The minimum slider value
297 * @param[in] maxValue The maximum slider value
298 * @exception E_SUCCESS The method is successful.
299 * @exception E_OUT_OF_RANGE The specified minimum and maximum values are less than @c -99, or greater than @c 999.
300 * @exception E_INVALID_ARG A specified input parameter is invalid, or the specified @c minValue is greater than @c maxVaue.
301 * @exception E_SYSTEM A system error has occurred.
302 * @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
303 * adding the control to the container. @n
304 * If the specified size is less than the minimum size, the %Slider control is constructed with the minimum size.
305 * @remarks The width and the height of the control must be greater than @c 0.
306 * @remarks The size of the control must be within the range defined by the minimum size and the maximum size.
308 result Construct(const Tizen::Graphics::Rectangle& rect, unsigned long sliderStyle, int minValue = 0, int maxValue = 100);
311 * Adds a ISliderEventListener instance. @n
312 * The added listener can listen to the slider-related events.
316 * @param[in] listener The event listener to be added
318 void AddSliderEventListener(ISliderEventListener& listener);
321 * Removes a ISliderEventListener instance. @n
322 * The removed listener cannot listen to events when they are fired.
326 * @param[in] listener The event listener to be removed
328 void RemoveSliderEventListener(ISliderEventListener& listener);
331 * Sets the color of the bar.
335 * @return An error code
336 * @param[in] color The color to be set
337 * @exception E_SUCCESS The method is successful.
338 * @exception E_SYSTEM A system error has occurred.
339 * @remarks The method ignores the alpha value of the @c color parameter and sets the alpha value to @c 255.
341 result SetBarColor(const Tizen::Graphics::Color& color);
344 * Gets the color of the bar.
348 * @return The color of the bar, @n
349 * else RGBA(0, 0, 0, 0) if an error occurs
350 * @exception E_SUCCESS The method is successful.
351 * @remarks The specific error code can be accessed using the GetLastResult() method.
353 Tizen::Graphics::Color GetBarColor(void) const;
356 * Sets the color of the slider.
360 * @return An error code
361 * @param[in] color The color to be set
362 * @exception E_SUCCESS The method is successful.
363 * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. @n
364 * The operation is not supported if the background style of the %Slider control is BACKGROUND_STYLE_NONE.
365 * @exception E_SYSTEM A system error has occurred.
366 * @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.
368 result SetColor(const Tizen::Graphics::Color& color);
371 * Gets the color of the slider.
375 * @return The color , @n
376 * else RGBA(0, 0, 0, 0) if an instance is invalid or the background style is BACKGROUND_STYLE_NONE
377 * @exception E_SUCCESS The method is successful.
378 * @exception E_INVALID_OPERATION The background style is not proper.
379 * @remarks The specific error code can be accessed using the GetLastResult() method.
381 Tizen::Graphics::Color GetColor(void) const;
384 * Sets the bitmap image to the %Slider control Thumb.
388 * @return An error code
389 * @param[in] status The state of the slider thumb
390 * @param[in] bitmap The Thumb bitmap image
391 * @exception E_SUCCESS The method is successful.
392 * @exception E_OUT_OF_MEMORY The memory is insufficient.
394 result SetThumbBitmap(SliderThumbStatus status, const Tizen::Graphics::Bitmap& bitmap);
397 * Sets the text color of the %Slider control Thumb.
401 * @return An error code
402 * @param[in] status The state of the slider thumb
403 * @param[in] color The color should be set for the thumb text
405 void SetThumbTextColor(SliderThumbStatus status, const Tizen::Graphics::Color& color);
409 // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
411 Slider(const Slider&);
414 // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
416 Slider& operator =(const Slider&);
418 friend class _SliderImpl;
422 }}} // Tizen::Ui::Controls
424 #endif // _FUI_CTRL_SLIDER_H_