5
// Lluis Sanchez <lluis@xamarin.com>
7
// Copyright (c) 2012 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
namespace Xwt.GtkBackend
32
public class ListBoxBackend: ListViewBackend, IListBoxBackend
34
Gtk.TreeViewColumn theColumn;
36
public ListBoxBackend ()
40
protected new IListBoxEventSink EventSink {
41
get { return (IListBoxEventSink)((WidgetBackend)this).EventSink; }
44
public override void Initialize ()
47
Widget.HeadersVisible = false;
49
theColumn = new Gtk.TreeViewColumn ();
50
Widget.AppendColumn (theColumn);
52
var cr = new Gtk.CellRendererText ();
53
theColumn.PackStart (cr, false);
54
theColumn.AddAttribute (cr, "text", 0);
57
public void SetViews (CellViewCollection views)
60
foreach (var v in views)
61
CellUtil.CreateCellRenderer (this, theColumn, v);
64
public override void EnableEvent (object eventId)
66
base.EnableEvent (eventId);
67
if (eventId is ListBoxEvent) {
68
if (((ListBoxEvent)eventId) == ListBoxEvent.SelectionChanged)
69
Widget.Selection.Changed += HandleWidgetSelectionChanged;
73
public override void DisableEvent (object eventId)
75
base.DisableEvent (eventId);
76
if (eventId is ListBoxEvent) {
77
if (((ListBoxEvent)eventId) == ListBoxEvent.SelectionChanged)
78
Widget.Selection.Changed -= HandleWidgetSelectionChanged;
82
void HandleWidgetSelectionChanged (object sender, EventArgs e)
84
Toolkit.Invoke (delegate {
85
EventSink.OnSelectionChanged ();