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
30
using System.Collections.Generic;
35
public class NotebookBackend: ViewBackend<NSTabView,IWidgetEventSink>, INotebookBackend
37
public NotebookBackend ()
39
ViewObject = new TabView ();
40
Widget.AutoresizesSubviews = true;
43
public override void EnableEvent (object eventId)
45
if (eventId is NotebookEvent) {
46
NotebookEvent ev = (NotebookEvent) eventId;
47
if (ev == NotebookEvent.CurrentTabChanged) {
48
Widget.WillSelect += HandleWidgetWillSelect;
51
base.EnableEvent (eventId);
54
public override void DisableEvent (object eventId)
56
if (eventId is NotebookEvent) {
57
NotebookEvent ev = (NotebookEvent) eventId;
58
if (ev == NotebookEvent.CurrentTabChanged) {
59
Widget.WillSelect -= HandleWidgetWillSelect;
62
base.DisableEvent (eventId);
65
void HandleWidgetWillSelect (object sender, NSTabViewItemEventArgs e)
67
((INotebookEventSink)EventSink).OnCurrentTabChanged ();
70
#region INotebookBackend implementation
71
public void Add (IWidgetBackend widget, NotebookTab tab)
73
NSTabViewItem item = new NSTabViewItem ();
74
item.Label = tab.Label;
75
item.View = GetWidget (widget);
79
public void Remove (IWidgetBackend widget)
81
var v = GetWidget (widget);
87
public void UpdateLabel (NotebookTab tab, string hint)
89
IWidgetBackend widget = (IWidgetBackend) WidgetRegistry.GetBackend (tab.Child);
90
var v = GetWidget (widget);
96
public int CurrentTab {
98
return Widget.IndexOf (Widget.Selected);
101
Widget.SelectAt (value);
105
public Xwt.NotebookTabOrientation TabOrientation {
107
NotebookTabOrientation tabPos = NotebookTabOrientation.Top;
108
switch (Widget.TabViewType) {
109
case NSTabViewType.NSBottomTabsBezelBorder:
110
tabPos = NotebookTabOrientation.Bottom;
112
case NSTabViewType.NSLeftTabsBezelBorder:
113
tabPos = NotebookTabOrientation.Left;
115
case NSTabViewType.NSRightTabsBezelBorder:
116
tabPos = NotebookTabOrientation.Right;
122
NSTabViewType type = NSTabViewType.NSTopTabsBezelBorder;
124
case NotebookTabOrientation.Bottom:
125
type = NSTabViewType.NSBottomTabsBezelBorder;
127
case NotebookTabOrientation.Left:
128
type = NSTabViewType.NSLeftTabsBezelBorder;
130
case NotebookTabOrientation.Right:
131
type = NSTabViewType.NSRightTabsBezelBorder;
134
Widget.TabViewType = type;
139
NSTabViewItem FindTab (NSView v)
141
foreach (var t in Widget.Items) {
149
class TabView: NSTabView, IViewObject
151
public Widget Frontend { get; set; }