2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0/
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. @n
117 * For full construction, the %Construct() method must be called right after calling this constructor.
124 * This polymorphic destructor should be overridden if required. @n
125 * This way, the destructors of the derived classes are called when the destructor of this interface is called.
129 virtual ~ColorPicker(void);
132 * Initializes this instance of %ColorPicker with the specified parameter.
136 * @return An error code
137 * @param[in] point The position of this %ColorPicker in the container @n
138 * The optimal size of the control is defined in
139 * <a href="../org.tizen.native.appprogramming/html/guide/ui/control_optimalsize.htm">Optimal Size of UI Controls</a>.
140 * @exception E_SUCCESS The method is successful.
141 * @exception E_SYSTEM A system error has occurred.
142 * @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.
144 result Construct(const Tizen::Graphics::Point& point);
147 * Initializes this instance of %ColorPicker with the specified parameter.
151 * @return An error code
152 * @param[in] point The position of this %ColorPicker in the container @n
153 * The optimal size of the control is defined in
154 * <a href="../org.tizen.native.appprogramming/html/guide/ui/control_optimalsize.htm">Optimal Size of UI Controls</a>.
155 * @exception E_SUCCESS The method is successful.
156 * @exception E_SYSTEM A system error has occurred.
157 * @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.
159 result Construct(const Tizen::Graphics::FloatPoint& point);
162 * Gets the current color value of %ColorPicker.
166 * @return The current color value
168 Tizen::Graphics::Color GetColor(void) const;
171 * Gets the current hue value of %ColorPicker.
175 * @return The current hue value between @c 0 to @c 100.
177 int GetHue(void) const;
180 * Gets the current saturation value of %ColorPicker.
184 * @return The current saturation value between @c 0 to @c 100.
186 int GetSaturation(void) const;
189 * Gets the current luminance value of %ColorPicker.
193 * @return The current luminance value between @c 0 to @c 100.
195 int GetLuminance(void) const;
198 * Sets the color value of %ColorPicker.
202 * @param[in] color The color value
204 void SetColor(const Tizen::Graphics::Color& color);
207 * Sets the hue value of %ColorPicker.
211 * @param[in] hue The hue value of this object between @c 0 to @c 100.
214 void SetHue(int hue);
217 * Sets the saturation value of %ColorPicker.
221 * @param[in] saturation The saturation value between @c 0 to @c 100.
224 void SetSaturation(int saturation);
227 * Sets the luminance value of %ColorPicker.
231 * @param[in] luminance The luminance value between @c 0 to @c 100.
234 void SetLuminance(int luminance);
237 * Adds a listener instance. @n
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. @n
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_