2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
22 /// The Check is a widget that allows for toggling a value between true and false.
24 /// <since_tizen> preview </since_tizen>
25 public class Check : Layout
27 private SmartEvent _changed;
28 private bool _currentState;
31 /// Creates and initializes a new instance of the Check class.
33 /// <param name="parent">
34 /// The EvasObject to which the new check will be attached as a child.
36 /// <since_tizen> preview </since_tizen>
37 public Check(EvasObject parent) : base(parent)
39 _changed = new SmartEvent(this, this.RealHandle, "changed");
40 _changed.On += (sender, e) =>
42 StateChanged?.Invoke(this, new CheckStateChangedEventArgs(_currentState, IsChecked));
47 /// StateChanged will be triggered when the IsChecked in the check is changed.
49 /// <since_tizen> preview </since_tizen>
50 public event EventHandler<CheckStateChangedEventArgs> StateChanged;
53 /// Sets or gets whether the given check is checked or not.
56 /// When an object is checked, the value will be set to true. Conversely, will be set to false.
58 /// <since_tizen> preview </since_tizen>
63 _currentState = Interop.Elementary.elm_check_state_get(RealHandle);
68 Interop.Elementary.elm_check_state_set(RealHandle, value);
73 /// Creates a widget handle.
75 /// <param name="parent">Parent EvasObject.</param>
76 /// <returns>Handle IntPtr.</returns>
77 /// <since_tizen> preview </since_tizen>
78 protected override IntPtr CreateHandle(EvasObject parent)
80 IntPtr handle = Interop.Elementary.elm_layout_add(parent.Handle);
81 Interop.Elementary.elm_layout_theme_set(handle, "layout", "elm_widget", "default");
83 RealHandle = Interop.Elementary.elm_check_add(handle);
84 Interop.Elementary.elm_object_part_content_set(handle, "elm.swallow.content", RealHandle);