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 FUiCtrlColorPicker.h
20 * @brief This is the header file for the %ColorPicker class.
22 * This header file contains the declarations of the %ColorPicker class.
24 #ifndef _FUI_CTRL_COLOR_PICKER_H_
25 #define _FUI_CTRL_COLOR_PICKER_H_
27 #include <FUiControl.h>
28 #include <FUiIColorChangeEventListener.h>
29 #include <FUiIOrientationEventListener.h>
31 namespace Tizen { namespace Ui { namespace Controls
36 * @brief This class defines the common behavior of a %ColorPicker control.
40 * The %ColorPicker class displays a set of 3 sliders (hue, saturation, and luminance) with which the user can define a color.
42 * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/ui/implementing_colorpicker.htm">ColorPicker</a>.
44 * The following example demonstrates how to use the %ColorPicker class.
47 // Sample code for ColorPickerSample.h
49 #include <FGraphics.h>
51 class ColorPickerSample
52 : public Tizen::Ui::Controls::Form
53 , public Tizen::Ui::IColorChangeEventListener
56 ColorPickerSample(void)
57 : __pColorPicker(null){}
59 bool Initialize(void);
60 virtual result OnInitializing(void);
62 // IColorChangeEventListener
63 virtual void OnColorChanged(const Tizen::Ui::Control& source, const Tizen::Graphics::Color& color);
66 Tizen::Ui::Controls::ColorPicker* __pColorPicker;
73 // Sample code for ColorPickerSample.cpp
74 #include "ColorPickerSample.h"
76 using namespace Tizen::Graphics;
77 using namespace Tizen::Ui::Controls;
80 ColorPickerSample::Initialize(void)
82 Construct(FORM_STYLE_NORMAL);
87 ColorPickerSample::OnInitializing(void)
91 // Creates an instance of ColorPicker
92 __pColorPicker = new ColorPicker();
93 __pColorPicker->Construct(Point(10,50));
94 __pColorPicker->AddColorChangeEventListener(*this);
96 // Adds the color picker to the form
97 AddControl(*__pColorPicker);
102 // IColorChangeEventListener implementation
104 ColorPickerSample::OnColorChanged(const Control& source, const Color& color)
111 class _OSP_EXPORT_ ColorPicker
112 : public Tizen::Ui::Control
116 * 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.
123 * 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.
127 virtual ~ColorPicker(void);
130 * Initializes this instance of %ColorPicker with the specified parameter.
134 * @return An error code
135 * @param[in] point The position of this %ColorPicker in the container
136 * @exception E_SUCCESS The method is successful.
137 * @exception E_SYSTEM A system error has occurred.
138 * @remarks A control is fully usable only after it has been added to a container. Therefore, some methods may fail if the control is used earlier.
140 result Construct(const Tizen::Graphics::Point& point);
143 * Initializes this instance of %ColorPicker with the specified parameter.
147 * @return An error code
148 * @param[in] point The position of this %ColorPicker in the container
149 * @exception E_SUCCESS The method is successful.
150 * @exception E_SYSTEM A system error has occurred.
151 * @remarks A control is fully usable only after it has been added to a container. Therefore, some methods may fail if the control is used earlier.
153 result Construct(const Tizen::Graphics::FloatPoint& point);
156 * Gets the current color value of %ColorPicker.
160 * @return The current color value
162 Tizen::Graphics::Color GetColor(void) const;
165 * Gets the current hue value of %ColorPicker.
169 * @return The current hue value
170 * @remarks The return value is between @c 0 to @c 100.
172 int GetHue(void) const;
175 * Gets the current saturation value of %ColorPicker.
179 * @return The current saturation value
180 * @remarks The return value is between @c 0 to @c 100.
182 int GetSaturation(void) const;
185 * Gets the current luminance value of %ColorPicker.
189 * @return The current luminance value
190 * @remarks The return value is between @c 0 to @c 100.
192 int GetLuminance(void) const;
195 * Sets the color value of %ColorPicker.
199 * @param[in] color The color value
201 void SetColor(const Tizen::Graphics::Color& color);
204 * Sets the hue value of %ColorPicker.
208 * @param[in] hue The hue value of this object
209 * @remarks The value should be between @c 0 to @c 100.
212 void SetHue(int hue);
215 * Sets the saturation value of %ColorPicker.
219 * @param[in] saturation The saturation value of this object
220 * @remarks The value should be between @c 0 to @c 100.
223 void SetSaturation(int saturation);
226 * Sets the luminance value of %ColorPicker.
230 * @param[in] luminance The luminance value of this object
231 * @remarks The value should be between @c 0 to @c 100.
234 void SetLuminance(int luminance);
237 * Adds a listener instance.
238 * The added listener can listen to events on the given event dispatcher's context when they are fired.
242 * @param[in] listener The event listener to add
243 * @see RemoveColorChangeEventListener()
245 void AddColorChangeEventListener(Tizen::Ui::IColorChangeEventListener& listener);
248 * Removes a listener instance.
249 * The removed listener cannot listen to events when they are fired.
253 * @param[in] listener The event listener to remove
254 * @see AddColorChangeEventListener()
256 void RemoveColorChangeEventListener(Tizen::Ui::IColorChangeEventListener& listener);
260 // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
262 ColorPicker(const ColorPicker& rhs);
265 // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
267 ColorPicker& operator =(const ColorPicker& rhs);
269 friend class _ColorPickerImpl;
272 }}} // Tizen::Ui::Controls
274 #endif // _FUI_CTRL_COLOR_PICKER_H_