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 Radio is a widget that allows for 1 or more options to be displayed and have the user choose only 1 of them.
24 public class Radio : Layout
29 /// Creates and initializes a new instance of the Radio class.
31 /// <param name="parent">The EvasObject to which the new Radio will be attached as a child.</param>
32 public Radio(EvasObject parent) : base(parent)
34 _changed = new SmartEvent(this, this.RealHandle, "changed");
35 _changed.On += (s, e) => ValueChanged?.Invoke(this, EventArgs.Empty);
39 /// ValueChanged will be triggered when value of Radio change.
41 public event EventHandler ValueChanged;
44 /// Sets or gets a unique value to each Radio button.
50 return Interop.Elementary.elm_radio_state_value_get(RealHandle);
54 Interop.Elementary.elm_radio_state_value_set(RealHandle, value);
59 /// Sets or gets the value of the radio group.
65 return Interop.Elementary.elm_radio_value_get(RealHandle);
69 Interop.Elementary.elm_radio_value_set(RealHandle, value);
74 /// Adds this radio to a group of other radio objects.
76 /// <param name="group">Group which add radio in.</param>
77 public void SetGroup(Radio group)
81 throw new ArgumentNullException("group");
83 Interop.Elementary.elm_radio_group_add(RealHandle, group.RealHandle);
87 /// Creates a widget handle.
89 /// <param name="parent">Parent EvasObject</param>
90 /// <returns>Handle IntPtr</returns>
91 protected override IntPtr CreateHandle(EvasObject parent)
93 IntPtr handle = Interop.Elementary.elm_layout_add(parent.Handle);
94 Interop.Elementary.elm_layout_theme_set(handle, "layout", "elm_widget", "default");
96 RealHandle = Interop.Elementary.elm_radio_add(handle);
97 Interop.Elementary.elm_object_part_content_set(handle, "elm.swallow.content", RealHandle);