GuideText Color settings in SB as per new UX
[platform/framework/native/uifw.git] / inc / FUiCtrlCheckButton.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        FUiCtrlCheckButton.h
20  * @brief       This is the header file for the %CheckButton class.
21  *
22  * This header file contains the declarations of the %CheckButton class and its helper classes.
23  */
24
25 #ifndef _FUI_CTRL_CHECK_BUTTON_H_
26 #define _FUI_CTRL_CHECK_BUTTON_H_
27
28 #include <FBaseResult.h>
29 #include <FBaseObject.h>
30 #include <FBaseTypes.h>
31 #include <FUiControl.h>
32 #include <FUiContainer.h>
33 #include <FUiCtrlButton.h>
34 #include <FUiCtrlControlsTypes.h>
35
36 namespace Tizen { namespace Ui { namespace Controls
37 {
38 /**
39  * @enum CheckButtonStatus
40  *
41  * Defines the %CheckButton status.
42  *
43  * @since       2.0
44  */
45 enum CheckButtonStatus
46 {
47         CHECK_BUTTON_STATUS_NORMAL,         /**< The normal status */
48         CHECK_BUTTON_STATUS_DISABLED,       /**< The disabled status */
49         CHECK_BUTTON_STATUS_PRESSED,        /**< The pressed status */
50         CHECK_BUTTON_STATUS_HIGHLIGHTED     /**< The highlighted status */
51 };
52
53 /**
54  * @enum CheckButtonStyle
55  *
56  * Defines the %CheckButton style.
57  *
58  * @since       2.0
59  */
60 enum CheckButtonStyle
61 {
62         CHECK_BUTTON_STYLE_MARK,                        /**< The mark style for multiple selection */
63         CHECK_BUTTON_STYLE_MARK_WITH_DIVIDER,           /**< @if OSPDEPREC @deprecated This enumeration field is deprecated because the use of the divider style is no longer recommended @n
64                                                                              Instead of using the divider style, use the detailed button style. @endif */
65         CHECK_BUTTON_STYLE_ONOFF,                       /**< @if OSPDEPREC @deprecated This enumeration field is deprecated because the use of the on-off style is no longer recommended @n
66                                                                              Instead of using the on-off style, use the on-off sliding style @endif*/
67         CHECK_BUTTON_STYLE_ONOFF_WITH_DIVIDER,          /**< @if OSPDEPREC @deprecated This enumeration field is deprecated because the use of the on-off style is no longer recommended @endif */
68         CHECK_BUTTON_STYLE_RADIO,                       /**< The radio style for single selection */
69         CHECK_BUTTON_STYLE_RADIO_WITH_DIVIDER,          /**< @if OSPDEPREC @deprecated This enumeration field is deprecated because the use of the divider style is no longer recommended @n
70                                                                              Instead of using the divider style, use the detailed button style @endif*/
71         CHECK_BUTTON_STYLE_ONOFF_SLIDING,               /**< The slider style on/off */
72         CHECK_BUTTON_STYLE_MARK_WITH_DETAILED_BUTTON,   /**< The mark style with detail button */
73         CHECK_BUTTON_STYLE_RADIO_WITH_DETAILED_BUTTON,  /**< The radio style with detail button */
74         CHECK_BUTTON_STYLE_ONOFF_SLIDING_WITH_DIVIDER,  /**< The slider style On/Off with divider @b Since: @b 2.1 */
75 };
76
77 /**
78  * @class       CheckButton
79  * @brief       This class defines the common behavior of a %CheckButton control.
80  *
81  * @since       2.0
82  *
83  * The %CheckButton class displays a rectangular area, which can be selected, and shows the current selection.
84  *
85  * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/ui/implementing_button.htm">Buttons</a>.
86  *
87  * The following example demonstrates how to use the %CheckButton class.
88  *
89  *
90  * @code
91 // Sample code for CheckButtonSample.h
92 #include <FUi.h>
93
94 class CheckButtonSample
95         : public Tizen::Ui::Controls::Form
96         , public Tizen::Ui::IActionEventListener
97 {
98 public:
99         CheckButtonSample(void)
100         : __pCheckButton(null){}
101
102         bool Initialize(void);
103         virtual result OnInitializing(void);
104
105         // IActionEventListener
106         virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId);
107
108 private :
109         static const int ID_BUTTON_CHECKED   = 101;
110         static const int ID_BUTTON_UNCHECKED = 102;
111         static const int ID_BUTTON_SELECTED  = 103;
112
113         Tizen::Ui::Controls::CheckButton* __pCheckButton;
114 };
115
116  *      @endcode
117  *
118  *      @code
119 // Sample Code for CheckButtonSample.cpp
120 #include <FGraphics.h>
121
122 #include "CheckButtonSample.h"
123
124 using namespace Tizen::Graphics;
125 using namespace Tizen::Ui::Controls;
126
127 bool
128 CheckButtonSample::Initialize(void)
129 {
130         Construct(FORM_STYLE_NORMAL);
131         return true;
132 }
133
134 result
135 CheckButtonSample::OnInitializing(void)
136 {
137         result r = E_SUCCESS;
138
139         // Creates a CheckButton
140         __pCheckButton = new CheckButton();
141         __pCheckButton->Construct(Rectangle(50, 50, 400, 100),
142                         CHECK_BUTTON_STYLE_RADIO_WITH_DIVIDER, BACKGROUND_STYLE_DEFAULT, false, L"CheckButton");
143         __pCheckButton->SetActionId(ID_BUTTON_CHECKED, ID_BUTTON_UNCHECKED, ID_BUTTON_SELECTED);
144         __pCheckButton->AddActionEventListener(*this);
145
146         // Add a CheckButton to the Form
147         AddControl(*__pCheckButton);
148
149         return r;
150 }
151
152 // Implements an IActionEventListener
153 void
154 CheckButtonSample::OnActionPerformed(const Control& source, int actionId)
155 {
156         switch (actionId)
157         {
158         case ID_BUTTON_CHECKED:
159                 // Todo:
160                 break;
161         case ID_BUTTON_UNCHECKED:
162                 // Todo:
163                 break;
164         case ID_BUTTON_SELECTED:
165                 // Todo:
166                 break;
167         default:
168                 break;
169         }
170 }
171
172  * @endcode
173  *
174  */
175 class _OSP_EXPORT_ CheckButton
176         : public Tizen::Ui::Control
177 {
178 public:
179         /**
180          * This is the default constructor for this class.
181          *
182          * @since       2.0
183          */
184         CheckButton(void);
185
186         /**
187          * This is the destructor for this class.
188          *
189          * @since       2.0
190          */
191         virtual ~CheckButton(void);
192
193         /**
194          * Initializes this instance of %CheckButton with the specified parameters.
195          *
196          * @since               2.0
197          *
198          * @return              An error code
199          * @param[in]   rect                    An instance of the Rectangle class @n
200          *                                                                      This instance represents the x and y coordinates of the top-left corner of the created window
201          *                                                                      along with the width and height of the window.
202          * @param[in]   style                           The style of the %CheckButton control
203          * @param[in]   backgroundStyle         The background style set of the %CheckButton control
204          * @param[in]   showTitle               Set to @c true to enable the title, @n
205          *                                                              else @c false
206          * @param[in]   text                            The text of the %CheckButton control
207          * @param[in]   groupStyle                      The group style of the %CheckButton control
208          * @exception   E_SUCCESS                       The method is successful.
209          * @exception   E_INVALID_ARG       A specified input parameter is invalid.@n
210          *                                                                      The specified size is less than the minimum size of the control.
211          * @exception   E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. @n
212          *                                  The background style of BACKGROUND_STYLE_NONE does not work with group styles except GROUP_STYLE_NONE.
213          * @exception   E_SYSTEM                        A system error has occurred.
214          * @remarks             A control is fully usable only after it has been added to a container, therefore some methods may fail if used earlier. @n
215          */
216         result Construct(const Tizen::Graphics::Rectangle& rect, CheckButtonStyle style, BackgroundStyle backgroundStyle =
217                                                  BACKGROUND_STYLE_DEFAULT, bool showTitle = false, const Tizen::Base::String& text = L"", GroupStyle groupStyle = GROUP_STYLE_NONE);
218
219         /**
220          * Initializes this instance of %CheckButton with the specified parameters.
221          *
222      * @since           2.1
223          *
224          * @return              An error code
225          * @param[in]   rect                    An instance of the Rectangle class @n
226          *                                                                      This instance represents the x and y coordinates of the top-left corner of the created window
227          *                                                                      along with the width and height of the window.
228          * @param[in]   style                           The style of the %CheckButton control
229          * @param[in]   backgroundStyle         The background style set of the %CheckButton control
230          * @param[in]   showTitle               Set to @c true to enable the title, @n
231          *                                                              else @c false
232          * @param[in]   text                            The text of the %CheckButton control
233          * @param[in]   groupStyle                      The group style of the %CheckButton control
234          * @exception   E_SUCCESS                       The method is successful.
235          * @exception   E_INVALID_ARG       A specified input parameter is invalid.@n
236          *                                                                      The specified size is less than the minimum size of the control.
237          * @exception   E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. @n
238          *                                  The background style of BACKGROUND_STYLE_NONE does not work with group styles except GROUP_STYLE_NONE.
239          * @exception   E_SYSTEM                        A system error has occurred.
240          * @remarks             A control is fully usable only after it has been added to a container, therefore some methods may fail if used earlier. @n
241          */
242         result Construct(const Tizen::Graphics::FloatRectangle& rect, CheckButtonStyle style, BackgroundStyle backgroundStyle =
243                                                          BACKGROUND_STYLE_DEFAULT, bool showTitle = false, const Tizen::Base::String& text = L"", GroupStyle groupStyle = GROUP_STYLE_NONE);
244
245         /**
246          * Sets the selected status of the %CheckButton control.
247          *
248          * @since               2.0
249          *
250          * @param[in]   select  Set to @c true if the %CheckButton control is selected, @n
251          *                              else @c false
252          */
253         void SetSelected(bool select);
254
255         /**
256          * Checks whether the %CheckButton control has been selected.
257          *
258          * @since               2.0
259          *
260          * @return              @c true if the %CheckButton is selected, @n
261          *                              else @c false
262          */
263         bool IsSelected(void) const;
264
265 public:
266         /**
267          * Adds an IActionEventListener instance. @n
268          * The added listener can listen to events on the context of the given event dispatcher when they are fired.
269          *
270          * @since               2.0
271          *
272          * @param[in]   listener        The event listener to be added
273          */
274         void AddActionEventListener(Tizen::Ui::IActionEventListener& listener);
275
276         /**
277          * Removes an IActionEventListener instance. @n
278          * The removed listener cannot listen to events when they are fired.
279          *
280          * @since               2.0
281          *
282          * @param[in]   listener        The event listener to be removed
283          */
284         void RemoveActionEventListener(Tizen::Ui::IActionEventListener& listener);
285
286         /**
287          * Sets the action IDs for the %CheckButton control.
288          *
289          * @since               2.0
290          *
291          * @param[in]   checkedActionId                 The action ID for the checked state
292          * @param[in]   uncheckedActionId               The action ID for the unchecked state
293          * @param[in]   selectedActionId                The action ID for the selected state
294          */
295         void SetActionId(int checkedActionId, int uncheckedActionId, int selectedActionId = -1);
296
297         /**
298          * Gets the action ID for the checked state.
299          *
300          * @since               2.0
301          *
302          * @return              An integer value representing the action ID
303          */
304         int GetCheckedActionId(void) const;
305
306         /**
307          * Gets the action ID for the unchecked state.
308          *
309          * @since               2.0
310          *
311          * @return              An integer value representing the action ID
312          */
313         int GetUncheckedActionId(void) const;
314
315         /**
316          * Gets the action ID for the selected state.
317          *
318          * @since               2.0
319          *
320          * @return              An integer value representing the action ID
321          */
322         int GetSelectedActionId(void) const;
323
324 public:
325         /**
326          * Sets the text that the %CheckButton control displays.
327          *
328          * @since               2.0
329          *
330          * @param[in]   text    The text of the %CheckButton control
331          */
332         void SetText(const Tizen::Base::String& text);
333
334         /**
335          * Sets the horizontal alignment of the text of the %CheckButton control.
336          *
337          * @since               2.0
338          *
339          * @param[in]   alignment       The horizontal text alignment
340          */
341         void SetTextHorizontalAlignment(HorizontalAlignment alignment);
342
343         /**
344          * Sets the vertical alignment of the text of the %CheckButton control.
345          *
346          * @since               2.0
347          *
348          * @param[in]   alignment       The vertical text alignment
349          */
350         void SetTextVerticalAlignment(VerticalAlignment alignment);
351
352 public:
353         /**
354          * Gets the text of the %CheckButton control.
355          *
356          * @since       2.0
357          *
358          * @return      The text of the %CheckButton control
359          */
360         Tizen::Base::String GetText(void) const;
361
362         /**
363          * Gets the horizontal alignment of the text of the %CheckButton control.
364          *
365          * @since       2.0
366          * @return      The horizontal text alignment
367          */
368         HorizontalAlignment GetTextHorizontalAlignment(void) const;
369
370         /**
371          * Gets the vertical alignment of the text of the %CheckButton control.
372          *
373          * @since       2.0
374          * @return      The vertical text alignment
375          */
376         VerticalAlignment GetTextVerticalAlignment(void) const;
377
378         /**
379          * Sets the title text of the %CheckButton control.
380          *
381          * @since               2.0
382          * @return              An error code
383          * @param[in]   title                           The title text to be set
384          * @exception   E_SUCCESS                       The method is successful.
385          * @exception   E_SYSTEM                        A system error has occurred.
386          */
387         result SetTitleText(const Tizen::Base::String& title);
388
389         /**
390          * Gets the title text of the %CheckButton control.
391          *
392          * @since               2.0
393          * @return              The title text
394          */
395         Tizen::Base::String GetTitleText(void) const;
396
397         //Normal color
398         /**
399          * Sets the text color of the %CheckButton control.
400          *
401          * @since                       2.0
402          *
403          * @param[in]   color   The text color to be set
404          */
405         void SetTextColor(const Tizen::Graphics::Color& color);
406
407         /**
408          * Gets the text color of the %CheckButton control.
409          *
410          * @since                       2.0
411          *
412          * @return    The text color
413          */
414         Tizen::Graphics::Color GetTextColor(void) const;
415
416         //Normal color
417         /**
418          * Sets the title text color of the %CheckButton control.
419          *
420          * @since                       2.0
421          *
422          * @param[in]   color   The text color to be set
423          */
424         void SetTitleTextColor(const Tizen::Graphics::Color& color);
425
426         /**
427          * Gets the title text color of the %CheckButton control.
428          *
429          * @since                       2.0
430          *
431          * @return              The text color
432          */
433         Tizen::Graphics::Color GetTitleTextColor(void) const;
434
435         /**
436          * Sets the color of the %CheckButton control for the specified status.
437          *
438          * @since       2.0
439          * @return      An error code
440          * @param[in]   color                                   The color to be set
441          * @param[in]   status                  The status
442          * @exception   E_SUCCESS                               The method is successful.
443          * @exception   E_INVALID_OPERATION             The current state of the instance prohibits the execution of the specified operation.@n
444          *                                                                              The operation is not supported if the background style is BACKGROUND_STYLE_NONE.
445          * @exception   E_SYSTEM                A system error has occurred.
446          */
447         result SetColor(CheckButtonStatus status, const Tizen::Graphics::Color& color);
448
449         /**
450          * Gets the color of the %CheckButton control for the specified status.
451          *
452          * @since       2.0
453          * @return      The color, @n
454          *                              else RGBA (0, 0, 0, 0) if an error occurs
455          * @param[in]   status              The status
456          * @exception   E_SUCCESS           The method is successful.
457          * @exception   E_INVALID_OPERATION The background style is not proper.
458          * @remarks     The specific error code can be accessed using the GetLastResult() method.
459          */
460         Tizen::Graphics::Color GetColor(CheckButtonStatus status) const;
461
462         /**
463          * Sets the text color of the %CheckButton control for the pressed status.
464          *
465          * @since     2.0
466          *
467          * @return    An error code
468          * @param[in]   color                           The text color to be set
469          * @exception   E_SUCCESS                       The method is successful.
470          * @exception   E_SYSTEM                        A system error has occurred.
471          */
472         result SetPressedTextColor(const Tizen::Graphics::Color& color);
473
474         /**
475          * Gets the text color of the %CheckButton control for the pressed status.
476          *
477          * @since      2.0
478          * @return     The text color, @n
479          *                         else RGBA (0, 0, 0, 0) if an error occurs
480          * @exception   E_SUCCESS                       The method is successful.
481          * @remarks    The specific error code can be accessed using the GetLastResult() method.
482          */
483         Tizen::Graphics::Color GetPressedTextColor(void) const;
484
485         /**
486          * Sets the title text color of the %CheckButton control for the pressed status.
487          *
488          * @since     2.0
489          *
490          * @return    An error code
491          * @param[in] color                             The pressed title text color
492          * @exception   E_SUCCESS                       The method is successful.
493          * @exception   E_SYSTEM                        A system error has occurred.
494          */
495         result SetPressedTitleTextColor(const Tizen::Graphics::Color& color);
496
497         /**
498          * Gets the title text color of the %CheckButton for the pressed status.
499          *
500          * @since      2.0
501          *
502          * @return     The title text color, @n
503          *                         else RGBA (0, 0, 0, 0) if an error occurs
504          * @exception   E_SUCCESS                       The method is successful.
505          * @remarks    The specific error code can be accessed using the GetLastResult() method.
506          */
507         Tizen::Graphics::Color GetPressedTitleTextColor(void) const;
508
509         /**
510          * Sets the text color of the %CheckButton control for the highlighted status.
511          *
512          * @since     2.0
513          *
514          * @return    An error code
515          * @param[in]   color                           The text color to be set
516          * @exception   E_SUCCESS                       The method is successful.
517          * @exception   E_SYSTEM                        A system error has occurred.
518          */
519         result SetHighlightedTextColor(const Tizen::Graphics::Color& color);
520
521         /**
522          * Gets the text color of the %CheckButton control for the highlighted status.
523          *
524          * @since      2.0
525          *
526          * @return     The text color, @n
527          *                         else RGBA (0, 0, 0, 0) if an error occurs
528          * @exception   E_SUCCESS                       The method is successful.
529          * @remarks    The specific error code can be accessed using the GetLastResult() method.
530          */
531         Tizen::Graphics::Color GetHighlightedTextColor(void) const;
532
533         /**
534          * Sets the title text color of the %CheckButton control for the highlighted status.
535          *
536          * @since     2.0
537          *
538          * @return    An error code
539          * @param[in] color                             The highlighted title text color
540          * @exception   E_SUCCESS                       The method is successful.
541          * @exception   E_SYSTEM                        A system error has occurred.
542          */
543         result SetHighlightedTitleTextColor(const Tizen::Graphics::Color& color);
544
545         /**
546          * Gets the title text color of the %CheckButton control for the highlighted status.
547          *
548          * @since      2.0
549          *
550          * @return     The title text color, @n
551          *                         else RGBA (0, 0, 0, 0) if an error occurs
552          * @exception   E_SUCCESS                       The method is successful.
553          * @remarks    The specific error code can be accessed using the GetLastResult() method.
554          */
555         Tizen::Graphics::Color GetHighlightedTitleTextColor(void) const;
556
557         /**
558          * Sets the text color of the %CheckButton control for the disabled status.
559          *
560          * @since     2.0
561          *
562          * @return    An error code
563          * @param[in]   color                           The text color to be set
564          * @exception   E_SUCCESS                       The method is successful.
565          * @exception   E_SYSTEM                        A system error has occurred.
566          */
567         result SetDisabledTextColor(const Tizen::Graphics::Color& color);
568
569         /**
570          * Gets the text color of the %CheckButton control for the disabled status.
571          *
572          * @since      2.0
573          *
574          * @return     The text color, @n
575          *                         else RGBA (0, 0, 0, 0) if an error occurs
576          * @exception   E_SUCCESS                       The method is successful.
577          * @remarks    The specific error code can be accessed using the GetLastResult() method.
578          */
579         Tizen::Graphics::Color GetDisabledTextColor(void) const;
580
581         /**
582          * Sets the title text color of the %CheckButton control for the disabled status.
583          *
584          * @since     2.0
585          *
586          * @return    An error code
587          * @param[in] color                The disabled title text color
588          * @exception   E_SUCCESS                       The method is successful.
589          * @exception   E_SYSTEM                        A system error has occurred.
590          */
591         result SetDisabledTitleTextColor(const Tizen::Graphics::Color& color);
592
593         /**
594          * Gets the title text color of %CheckButton for the disabled status.
595          *
596          * @since      2.0
597          *
598          * @return     The title text color, @n
599          *                         else RGBA (0, 0, 0, 0) if an error occurs
600          * @exception   E_SUCCESS                       The method is successful.
601          * @remarks    The specific error code can be accessed using the GetLastResult() method.
602          */
603         Tizen::Graphics::Color GetDisabledTitleTextColor(void) const;
604
605 protected:
606         friend class _CheckButtonImpl;
607
608 private:
609         friend class RadioGroup;
610
611         //
612         // This is the copy constructor for this class.
613         //
614         CheckButton(const CheckButton& rhs);
615
616         //
617         // Assigns the value of the specified instance to the current instance of %CheckButton.
618         //
619         CheckButton& operator =(const CheckButton& rhs);
620
621 }; // CheckButton
622
623 }}} // Tizen::Ui::Controls
624
625 #endif // _FUI_CTRL_CHECK_BUTTON_H_