5
// Lluis Sanchez <lluis@xamarin.com>
7
// Copyright (c) 2011 Xamarin Inc
9
// Permission is hereby granted, free of charge, to any person obtaining a copy
10
// of this software and associated documentation files (the "Software"), to deal
11
// in the Software without restriction, including without limitation the rights
12
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
// copies of the Software, and to permit persons to whom the Software is
14
// furnished to do so, subject to the following conditions:
16
// The above copyright notice and this permission notice shall be included in
17
// all copies or substantial portions of the Software.
19
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
29
using System.ComponentModel;
35
public class MenuItem: XwtComponent, ICellContainer
37
CellViewCollection cells;
42
protected class MenuItemBackendHost: BackendHost<MenuItem,IMenuItemBackend>, IMenuItemEventSink
44
protected override void OnBackendCreated ()
46
base.OnBackendCreated ();
47
Backend.Initialize (this);
50
public void OnClicked ()
56
protected override Xwt.Backends.BackendHost CreateBackendHost ()
58
return new MenuItemBackendHost ();
63
MapEvent (MenuItemEvent.Clicked, typeof(MenuItem), "OnClicked");
70
public MenuItem (Command command): this ()
72
Label = command.Label;
73
if (!string.IsNullOrEmpty (command.Icon))
74
Image = Image.FromIcon (command.Icon, IconSize.Small);
77
public MenuItem (string label): this ()
82
IMenuItemBackend Backend {
83
get { return (IMenuItemBackend) base.BackendHost.Backend; }
88
get { return Backend.Label; }
89
set { Backend.Label = value; }
93
public bool Sensitive {
94
get { return Backend.Sensitive; }
95
set { Backend.Sensitive = value; }
100
get { return Backend.Visible; }
101
set { Backend.Visible = value; }
105
get { return image; }
106
set { image = value; Backend.SetImage (XwtObject.GetBackend (value)); }
119
public CellViewCollection Cells {
122
cells = new CellViewCollection (this);
127
public Menu SubMenu {
128
get { return subMenu; }
131
Backend.SetSubmenu ((IMenuBackend) WidgetRegistry.GetBackend (subMenu));
135
public void NotifyCellChanged ()
137
throw new NotImplementedException ();
140
internal virtual void DoClick ()
142
OnClicked (EventArgs.Empty);
145
protected virtual void OnClicked (EventArgs e)
151
public event EventHandler Clicked {
153
base.BackendHost.OnBeforeEventAdd (MenuItemEvent.Clicked, clicked);
158
base.BackendHost.OnAfterEventRemove (MenuItemEvent.Clicked, clicked);
163
public enum MenuItemType