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 FUiCtrlCheckButton.h
20 * @brief This is the header file for the %CheckButton class.
22 * This header file contains the declarations of the %CheckButton class and its helper classes.
25 #ifndef _FUI_CTRL_CHECK_BUTTON_H_
26 #define _FUI_CTRL_CHECK_BUTTON_H_
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 #include <FUiCtrlGroupTypes.h>
37 namespace Tizen { namespace Ui { namespace Controls
40 * @enum CheckButtonStatus
42 * Defines the %CheckButton status.
46 enum CheckButtonStatus
48 CHECK_BUTTON_STATUS_NORMAL, /**< The normal status */
49 CHECK_BUTTON_STATUS_DISABLED, /**< The disabled status */
50 CHECK_BUTTON_STATUS_PRESSED, /**< The pressed status */
51 CHECK_BUTTON_STATUS_HIGHLIGHTED /**< The highlighted status */
55 * @enum CheckButtonStyle
57 * Defines the %CheckButton style.
63 CHECK_BUTTON_STYLE_MARK, /**< The mark style for multiple selection */
64 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
65 Instead of using the divider style, use the detailed button style. @endif */
66 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
67 Instead of using the on-off style, use the on-off sliding style @endif */
68 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 */
69 CHECK_BUTTON_STYLE_RADIO, /**< The radio style for single selection */
70 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
71 Instead of using the divider style, use the detailed button style @endif */
72 CHECK_BUTTON_STYLE_ONOFF_SLIDING, /**< The slider style on/off */
73 CHECK_BUTTON_STYLE_MARK_WITH_DETAILED_BUTTON, /**< The mark style with detail button */
74 CHECK_BUTTON_STYLE_RADIO_WITH_DETAILED_BUTTON, /**< The radio style with detail button */
79 * @brief This class defines the common behavior of a %CheckButton control.
83 * The %CheckButton class displays a rectangular area, which can be selected, and shows the current selection.
85 * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/ui/implementing_button.htm">Buttons</a>.
87 * The following example demonstrates how to use the %CheckButton class.
91 // Sample code for CheckButtonSample.h
94 class CheckButtonSample
95 : public Tizen::Ui::Controls::Form
96 , public Tizen::Ui::IActionEventListener
99 CheckButtonSample(void)
100 : __pCheckButton(null){}
102 bool Initialize(void);
103 virtual result OnInitializing(void);
105 // IActionEventListener
106 virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId);
109 static const int ID_BUTTON_CHECKED = 101;
110 static const int ID_BUTTON_UNCHECKED = 102;
111 static const int ID_BUTTON_SELECTED = 103;
113 Tizen::Ui::Controls::CheckButton* __pCheckButton;
119 // Sample Code for CheckButtonSample.cpp
120 #include <FGraphics.h>
122 #include "CheckButtonSample.h"
124 using namespace Tizen::Graphics;
125 using namespace Tizen::Ui::Controls;
128 CheckButtonSample::Initialize(void)
130 Construct(FORM_STYLE_NORMAL);
135 CheckButtonSample::OnInitializing(void)
137 result r = E_SUCCESS;
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);
146 // Add a CheckButton to the Form
147 AddControl(*__pCheckButton);
152 // Implements an IActionEventListener
154 CheckButtonSample::OnActionPerformed(const Control& source, int actionId)
158 case ID_BUTTON_CHECKED:
161 case ID_BUTTON_UNCHECKED:
164 case ID_BUTTON_SELECTED:
175 class _OSP_EXPORT_ CheckButton
176 : public Tizen::Ui::Control
180 * This is the default constructor for this class.
187 * This is the destructor for this class.
191 virtual ~CheckButton(void);
194 * Initializes this instance of %CheckButton with the specified parameters.
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
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
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);
220 * Sets the selected status of the %CheckButton control.
224 * @param[in] select Set to @c true if the %CheckButton control is selected, @n
227 void SetSelected(bool select);
230 * Checks whether the %CheckButton control has been selected.
234 * @return @c true if the %CheckButton is selected, @n
237 bool IsSelected(void) const;
241 * Adds an IActionEventListener instance. @n
242 * The added listener can listen to events on the context of the given event dispatcher when they are fired.
246 * @param[in] listener The event listener to be added
248 void AddActionEventListener(Tizen::Ui::IActionEventListener& listener);
251 * Removes an IActionEventListener instance. @n
252 * The removed listener cannot listen to events when they are fired.
256 * @param[in] listener The event listener to be removed
258 void RemoveActionEventListener(Tizen::Ui::IActionEventListener& listener);
261 * Sets the action IDs for the %CheckButton control.
265 * @param[in] checkedActionId The action ID for the checked state
266 * @param[in] uncheckedActionId The action ID for the unchecked state
267 * @param[in] selectedActionId The action ID for the selected state
269 void SetActionId(int checkedActionId, int uncheckedActionId, int selectedActionId = -1);
272 * Gets the action ID for the checked state.
276 * @return An integer value representing the action ID
278 int GetCheckedActionId(void) const;
281 * Gets the action ID for the unchecked state.
285 * @return An integer value representing the action ID
287 int GetUncheckedActionId(void) const;
290 * Gets the action ID for the selected state.
294 * @return An integer value representing the action ID
296 int GetSelectedActionId(void) const;
300 * Sets the text that the %CheckButton control displays.
304 * @param[in] text The text of the %CheckButton control
306 void SetText(const Tizen::Base::String& text);
309 * Sets the horizontal alignment of the text of the %CheckButton control.
313 * @param[in] alignment The horizontal text alignment
315 void SetTextHorizontalAlignment(HorizontalAlignment alignment);
318 * Sets the vertical alignment of the text of the %CheckButton control.
322 * @param[in] alignment The vertical text alignment
324 void SetTextVerticalAlignment(VerticalAlignment alignment);
328 * Gets the text of the %CheckButton control.
332 * @return The text of the %CheckButton control
334 Tizen::Base::String GetText(void) const;
337 * Gets the horizontal alignment of the text of the %CheckButton control.
340 * @return The horizontal text alignment
342 HorizontalAlignment GetTextHorizontalAlignment(void) const;
345 * Gets the vertical alignment of the text of the %CheckButton control.
348 * @return The vertical text alignment
350 VerticalAlignment GetTextVerticalAlignment(void) const;
353 * Sets the title text of the %CheckButton control.
356 * @return An error code
357 * @param[in] title The title text to be set
358 * @exception E_SUCCESS The method is successful.
359 * @exception E_SYSTEM A system error has occurred.
361 result SetTitleText(const Tizen::Base::String& title);
364 * Gets the title text of the %CheckButton control.
367 * @return The title text
369 Tizen::Base::String GetTitleText(void) const;
373 * Sets the text color of the %CheckButton control.
377 * @param[in] color The text color to be set
379 void SetTextColor(const Tizen::Graphics::Color& color);
382 * Gets the text color of the %CheckButton control.
386 * @return The text color
388 Tizen::Graphics::Color GetTextColor(void) const;
392 * Sets the title text color of the %CheckButton control.
396 * @param[in] color The text color to be set
398 void SetTitleTextColor(const Tizen::Graphics::Color& color);
401 * Gets the title text color of the %CheckButton control.
405 * @return The text color
407 Tizen::Graphics::Color GetTitleTextColor(void) const;
410 * Sets the color of the %CheckButton control for the specified status.
413 * @return An error code
414 * @param[in] color The color to be set
415 * @param[in] status The status
416 * @exception E_SUCCESS The method is successful.
417 * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation.@n
418 * The operation is not supported if the background style is BACKGROUND_STYLE_NONE.
419 * @exception E_SYSTEM A system error has occurred.
421 result SetColor(CheckButtonStatus status, const Tizen::Graphics::Color& color);
424 * Gets the color of the %CheckButton control for the specified status.
427 * @return The color, @n
428 * else RGBA (0, 0, 0, 0) if an error occurs
429 * @param[in] status The status
430 * @exception E_SUCCESS The method is successful.
431 * @exception E_INVALID_OPERATION The background style is not proper.
432 * @remarks The specific error code can be accessed using the GetLastResult() method.
434 Tizen::Graphics::Color GetColor(CheckButtonStatus status) const;
437 * Sets the text color of the %CheckButton control for the pressed status.
441 * @return An error code
442 * @param[in] color The text color to be set
443 * @exception E_SUCCESS The method is successful.
444 * @exception E_SYSTEM A system error has occurred.
446 result SetPressedTextColor(const Tizen::Graphics::Color& color);
449 * Gets the text color of the %CheckButton control for the pressed status.
452 * @return The text color, @n
453 * else RGBA (0, 0, 0, 0) if an error occurs
454 * @exception E_SUCCESS The method is successful.
455 * @remarks The specific error code can be accessed using the GetLastResult() method.
457 Tizen::Graphics::Color GetPressedTextColor(void) const;
460 * Sets the title text color of the %CheckButton control for the pressed status.
464 * @return An error code
465 * @param[in] color The pressed title text color
466 * @exception E_SUCCESS The method is successful.
467 * @exception E_SYSTEM A system error has occurred.
469 result SetPressedTitleTextColor(const Tizen::Graphics::Color& color);
472 * Gets the title text color of the %CheckButton for the pressed status.
476 * @return The title text color, @n
477 * else RGBA (0, 0, 0, 0) if an error occurs
478 * @exception E_SUCCESS The method is successful.
479 * @remarks The specific error code can be accessed using the GetLastResult() method.
481 Tizen::Graphics::Color GetPressedTitleTextColor(void) const;
484 * Sets the text color of the %CheckButton control for the highlighted status.
488 * @return An error code
489 * @param[in] color The text color to be set
490 * @exception E_SUCCESS The method is successful.
491 * @exception E_SYSTEM A system error has occurred.
493 result SetHighlightedTextColor(const Tizen::Graphics::Color& color);
496 * Gets the text color of the %CheckButton control for the highlighted status.
500 * @return The text color, @n
501 * else RGBA (0, 0, 0, 0) if an error occurs
502 * @exception E_SUCCESS The method is successful.
503 * @remarks The specific error code can be accessed using the GetLastResult() method.
505 Tizen::Graphics::Color GetHighlightedTextColor(void) const;
508 * Sets the title text color of the %CheckButton control for the highlighted status.
512 * @return An error code
513 * @param[in] color The highlighted title text color
514 * @exception E_SUCCESS The method is successful.
515 * @exception E_SYSTEM A system error has occurred.
517 result SetHighlightedTitleTextColor(const Tizen::Graphics::Color& color);
520 * Gets the title text color of the %CheckButton control for the highlighted status.
524 * @return The title text color, @n
525 * else RGBA (0, 0, 0, 0) if an error occurs
526 * @exception E_SUCCESS The method is successful.
527 * @remarks The specific error code can be accessed using the GetLastResult() method.
529 Tizen::Graphics::Color GetHighlightedTitleTextColor(void) const;
532 * Sets the text color of the %CheckButton control for the disabled status.
536 * @return An error code
537 * @param[in] color The text color to be set
538 * @exception E_SUCCESS The method is successful.
539 * @exception E_SYSTEM A system error has occurred.
541 result SetDisabledTextColor(const Tizen::Graphics::Color& color);
544 * Gets the text color of the %CheckButton control for the disabled status.
548 * @return The text color, @n
549 * else RGBA (0, 0, 0, 0) if an error occurs
550 * @exception E_SUCCESS The method is successful.
551 * @remarks The specific error code can be accessed using the GetLastResult() method.
553 Tizen::Graphics::Color GetDisabledTextColor(void) const;
556 * Sets the title text color of the %CheckButton control for the disabled status.
560 * @return An error code
561 * @param[in] color The disabled title text color
562 * @exception E_SUCCESS The method is successful.
563 * @exception E_SYSTEM A system error has occurred.
565 result SetDisabledTitleTextColor(const Tizen::Graphics::Color& color);
568 * Gets the title text color of %CheckButton for the disabled status.
572 * @return The title text color, @n
573 * else RGBA (0, 0, 0, 0) if an error occurs
574 * @exception E_SUCCESS The method is successful.
575 * @remarks The specific error code can be accessed using the GetLastResult() method.
577 Tizen::Graphics::Color GetDisabledTitleTextColor(void) const;
580 friend class _CheckButtonImpl;
583 friend class RadioGroup;
586 // This is the copy constructor for this class.
588 CheckButton(const CheckButton& rhs);
591 // Assigns the value of the specified instance to the current instance of %CheckButton.
593 CheckButton& operator =(const CheckButton& rhs);
597 }}} // Tizen::Ui::Controls
599 #endif // _FUI_CTRL_CHECK_BUTTON_H_