Merge "Unchecked GetCharacter func when index is over string length" into tizen_2.2
[platform/framework/native/uifw.git] / inc / FUiCtrlColorPicker.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0/
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. @n
117          * For full construction, the %Construct() method must be called right after calling this constructor.
118          *
119          * @since       2.0
120          */
121         ColorPicker(void);
122
123         /**
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.
126          *
127          * @since       2.0
128          */
129         virtual ~ColorPicker(void);
130
131         /**
132          * Initializes this instance of %ColorPicker with the specified parameter.
133          *
134          * @since                       2.0
135          *
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.
143          */
144         result Construct(const Tizen::Graphics::Point& point);
145
146         /**
147          * Initializes this instance of %ColorPicker with the specified parameter.
148          *
149          * @since                       2.1
150          *
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.
158          */
159         result Construct(const Tizen::Graphics::FloatPoint& point);
160
161         /**
162          * Gets the current color value of %ColorPicker.
163          *
164          * @since               2.0
165          *
166          * @return              The current color value
167          */
168         Tizen::Graphics::Color GetColor(void) const;
169
170         /**
171          * Gets the current hue value of %ColorPicker.
172          *
173          * @since               2.0
174          *
175          * @return              The current hue value between @c 0 to @c 100.
176          */
177         int GetHue(void) const;
178
179         /**
180          * Gets the current saturation value of %ColorPicker.
181          *
182          * @since               2.0
183          *
184          * @return              The current saturation value between @c 0 to @c 100.
185          */
186         int GetSaturation(void) const;
187
188         /**
189          * Gets the current luminance value of %ColorPicker.
190          *
191          * @since               2.0
192          *
193          * @return              The current luminance value between @c 0 to @c 100.
194          */
195         int GetLuminance(void) const;
196
197         /**
198          * Sets the color value of %ColorPicker.
199          *
200          * @since                       2.0
201          *
202          * @param[in]   color   The color value
203          */
204         void SetColor(const Tizen::Graphics::Color& color);
205
206         /**
207          * Sets the hue value of %ColorPicker.
208          *
209          * @since                       2.0
210          *
211          * @param[in]   hue     The hue value of this object between @c 0 to @c 100.
212          *
213          */
214         void SetHue(int hue);
215
216         /**
217          * Sets the saturation value of %ColorPicker.
218          *
219          * @since                       2.0
220          *
221          * @param[in]   saturation      The saturation value between @c 0 to @c 100.
222          *
223          */
224         void SetSaturation(int saturation);
225
226         /**
227          * Sets the luminance value of %ColorPicker.
228          *
229          * @since                       2.0
230          *
231          * @param[in]   luminance       The luminance value between @c 0 to @c 100.
232          *
233          */
234         void SetLuminance(int luminance);
235
236         /**
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.
239          *
240          * @since                       2.0
241          *
242          * @param[in]   listener    The event listener to add
243          * @see                         RemoveColorChangeEventListener()
244          */
245         void AddColorChangeEventListener(Tizen::Ui::IColorChangeEventListener& listener);
246
247         /**
248          * Removes a listener instance. @n
249          * The removed listener cannot listen to events when they are fired.
250          *
251          * @since                       2.0
252          *
253          * @param[in]   listener    The event listener to remove
254          * @see                         AddColorChangeEventListener()
255          */
256         void RemoveColorChangeEventListener(Tizen::Ui::IColorChangeEventListener& listener);
257
258 private:
259         //
260         // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
261         //
262         ColorPicker(const ColorPicker& rhs);
263
264         //
265         // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
266         //
267         ColorPicker& operator =(const ColorPicker& rhs);
268
269         friend class _ColorPickerImpl;
270 };      // ColorPicker
271
272 }}}     // Tizen::Ui::Controls
273
274 #endif // _FUI_CTRL_COLOR_PICKER_H_