Tizen 2.1 base
[framework/osp/uifw.git] / inc / FUiCtrlColorPicker.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 //     http://floralicense.org/license/
10 //
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.
16 //
17
18 /**
19  * @file                        FUiCtrlColorPicker.h
20  * @brief       This is the header file for the %ColorPicker class.
21  *
22  * This header file contains the declarations of the %ColorPicker class.
23  */
24 #ifndef _FUI_CTRL_COLOR_PICKER_H_
25 #define _FUI_CTRL_COLOR_PICKER_H_
26
27 #include <FUiControl.h>
28 #include <FUiIColorChangeEventListener.h>
29 #include <FUiIOrientationEventListener.h>
30
31 namespace Tizen { namespace Ui { namespace Controls
32 {
33
34 /**
35  * @class       ColorPicker
36  * @brief This class defines the common behavior of a %ColorPicker control.
37  *
38  * @since 2.0
39  *
40  * The %ColorPicker class displays a set of 3 sliders (hue, saturation, and luminance) with which the user can define a color.
41  *
42  * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/ui/implementing_colorpicker.htm">ColorPicker</a>.
43  *
44  * The following example demonstrates how to use the %ColorPicker class.
45  *
46  * @code
47 // Sample code for ColorPickerSample.h
48 #include <FUi.h>
49 #include <FGraphics.h>
50
51 class ColorPickerSample
52         : public Tizen::Ui::Controls::Form
53     , public Tizen::Ui::IColorChangeEventListener
54 {
55 public:
56         ColorPickerSample(void)
57         : __pColorPicker(null){}
58
59         bool Initialize(void);
60         virtual result OnInitializing(void);
61
62         // IColorChangeEventListener
63         virtual void OnColorChanged(const Tizen::Ui::Control& source, const Tizen::Graphics::Color& color);
64
65 private:
66         Tizen::Ui::Controls::ColorPicker* __pColorPicker;
67 };
68
69  *      @endcode
70  *
71  *      @code
72
73 // Sample code for ColorPickerSample.cpp
74 #include "ColorPickerSample.h"
75
76 using namespace Tizen::Graphics;
77 using namespace Tizen::Ui::Controls;
78
79 bool
80 ColorPickerSample::Initialize(void)
81 {
82         Construct(FORM_STYLE_NORMAL);
83         return true;
84 }
85
86 result
87 ColorPickerSample::OnInitializing(void)
88 {
89         result r = E_SUCCESS;
90
91         // Creates an instance of ColorPicker
92         __pColorPicker = new ColorPicker();
93         __pColorPicker->Construct(Point(10,50));
94         __pColorPicker->AddColorChangeEventListener(*this);
95
96         // Adds the color picker to the form
97         AddControl(*__pColorPicker);
98
99         return r;
100 }
101
102 // IColorChangeEventListener implementation
103 void
104 ColorPickerSample::OnColorChanged(const Control& source, const Color& color)
105 {
106         // ....
107 }
108  * @endcode
109  */
110
111 class _OSP_EXPORT_ ColorPicker
112         : public Tizen::Ui::Control
113 {
114 public:
115         /**
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.
117          *
118          * @since       2.0
119          */
120         ColorPicker(void);
121
122         /**
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.
124          *
125          * @since       2.0
126          */
127         virtual ~ColorPicker(void);
128
129         /**
130          * Initializes this instance of %ColorPicker with the specified parameter.
131          *
132          * @since                       2.0
133          *
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.
139          */
140         result Construct(const Tizen::Graphics::Point& point);
141
142         /**
143          * Gets the current color value of %ColorPicker.
144          *
145          * @since               2.0
146          *
147          * @return              The current color value
148          */
149         Tizen::Graphics::Color GetColor(void) const;
150
151         /**
152          * Gets the current hue value of %ColorPicker.
153          *
154          * @since               2.0
155          *
156          * @return              The current hue value
157          * @remarks             The return value is between @c 0 to @c 100.
158          */
159         int GetHue(void) const;
160
161         /**
162          * Gets the current saturation value of %ColorPicker.
163          *
164          * @since               2.0
165          *
166          * @return              The current saturation value
167          * @remarks             The return value is between @c 0 to @c 100.
168          */
169         int GetSaturation(void) const;
170
171         /**
172          * Gets the current luminance value of %ColorPicker.
173          *
174          * @since               2.0
175          *
176          * @return              The current luminance value
177          * @remarks             The return value is between @c 0 to @c 100.
178          */
179         int GetLuminance(void) const;
180
181         /**
182          * Sets the color value of %ColorPicker.
183          *
184          * @since                       2.0
185          *
186          * @param[in]   color   The color value
187          */
188         void SetColor(const Tizen::Graphics::Color& color);
189
190         /**
191          * Sets the hue value of %ColorPicker.
192          *
193          * @since                       2.0
194          *
195          * @param[in]   hue     The hue value of this object
196          * @remarks                     The value should be between @c 0 to @c 100.
197          *
198          */
199         void SetHue(int hue);
200
201         /**
202          * Sets the saturation value of %ColorPicker.
203          *
204          * @since                       2.0
205          *
206          * @param[in]   saturation      The saturation value of this object
207          * @remarks                     The value should be between @c 0 to @c 100.
208          *
209          */
210         void SetSaturation(int saturation);
211
212         /**
213          * Sets the luminance value of %ColorPicker.
214          *
215          * @since                       2.0
216          *
217          * @param[in]   luminance       The luminance value of this object
218          * @remarks                     The value should be between @c 0 to @c 100.
219          *
220          */
221         void SetLuminance(int luminance);
222
223         /**
224          * Adds a listener instance.
225          * The added listener can listen to events on the given event dispatcher's context when they are fired.
226          *
227          * @since                       2.0
228          *
229          * @param[in]   listener    The event listener to be added
230          * @see                         RemoveColorChangeEventListener()
231          */
232         void AddColorChangeEventListener(Tizen::Ui::IColorChangeEventListener& listener);
233
234         /**
235          * Removes a listener instance.
236          * The removed listener cannot listen to events when they are fired.
237          *
238          * @since                       2.0
239          *
240          * @param[in]   listener    The event listener to be removed
241          * @see                         AddColorChangeEventListener()
242          */
243         void RemoveColorChangeEventListener(Tizen::Ui::IColorChangeEventListener& listener);
244
245 private:
246         //
247         // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
248         //
249         ColorPicker(const ColorPicker& rhs);
250
251         //
252         // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
253         //
254         ColorPicker& operator =(const ColorPicker& rhs);
255
256         friend class _ColorPickerImpl;
257 };      // ColorPicker
258
259 }}}     // Tizen::Ui::Controls
260
261 #endif // _FUI_CTRL_COLOR_PICKER_H_