[NUI] Add Menu, MenuItem, MenuItemGroup classes
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI.Components / Controls / MenuItemGroup.cs
1 /*
2  * Copyright(c) 2021 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 using System;
19 using System.ComponentModel;
20
21 namespace Tizen.NUI.Components
22 {
23     /// <summary>
24     /// MenuItemGroup class is used to group together a set of MenuItems.
25     /// It enables a user to select exclusively single MenuItem of a group.
26     /// </summary>
27     [EditorBrowsable(EditorBrowsableState.Never)]
28     public class MenuItemGroup : SelectGroup
29     {
30         /// <summary>
31         /// Constructs MenuItemGroup
32         /// </summary>
33         [EditorBrowsable(EditorBrowsableState.Never)]
34         public MenuItemGroup() : base()
35         {
36             EnableMultiSelection = false;
37         }
38
39         /// <summary>
40         /// Adds a menu item to the end of MenuItemGroup.
41         /// </summary>
42         /// <param name="menuItem">A menu item to be added to the group.</param>
43         /// <exception cref="ArgumentNullException">Thrown when the argument menuItem is null.</exception>
44         [EditorBrowsable(EditorBrowsableState.Never)]
45         public void Add(MenuItem menuItem)
46         {
47             if (menuItem == null)
48             {
49                 throw new ArgumentNullException(nameof(menuItem), "menuItem should not be null.");
50             }
51
52             base.AddSelection(menuItem);
53         }
54
55         /// <summary>
56         /// Removes a menu item from MenuItemGroup.
57         /// </summary>
58         /// <param name="menuItem">A menu item to be removed from the group.</param>
59         /// <exception cref="ArgumentNullException">Thrown when the argument menuItem is null.</exception>
60         [EditorBrowsable(EditorBrowsableState.Never)]
61         public void Remove(MenuItem menuItem)
62         {
63             if (menuItem == null)
64             {
65                 throw new ArgumentNullException(nameof(menuItem), "menuItem should not be null.");
66             }
67
68             base.RemoveSelection(menuItem);
69         }
70     }
71 }