Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/xwt.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLluis Sanchez Gual <lluis@xamarin.com>2016-05-24 12:00:08 +0300
committerLluis Sanchez Gual <lluis@xamarin.com>2016-05-24 12:00:08 +0300
commit4c990b204468dd187d38bf88933e659dee86fb80 (patch)
treeb4ff550b142c38b6cc4c5352c22a38313255ff87
parent22a30b1c6706ae4d93b025b728b1b986a6828ffe (diff)
[ListView] Add method for start editing a cell
-rw-r--r--TestApps/Samples/MainWindow.cs3
-rw-r--r--TestApps/Samples/Samples.csproj1
-rw-r--r--TestApps/Samples/Samples/ListViewEntries.cs66
-rw-r--r--Xwt.Gtk/Xwt.GtkBackend/ListViewBackend.cs7
-rw-r--r--Xwt.Gtk/Xwt.GtkBackend/TableViewBackend.cs5
-rw-r--r--Xwt.WPF/Xwt.WPFBackend/ListViewBackend.cs5
-rw-r--r--Xwt.XamMac/Xwt.Mac/TableViewBackend.cs7
-rw-r--r--Xwt/Xwt.Backends/IListViewBackend.cs1
-rw-r--r--Xwt/Xwt/ListView.cs10
9 files changed, 102 insertions, 3 deletions
diff --git a/TestApps/Samples/MainWindow.cs b/TestApps/Samples/MainWindow.cs
index 2b2a8eb4..3dc9dd9c 100644
--- a/TestApps/Samples/MainWindow.cs
+++ b/TestApps/Samples/MainWindow.cs
@@ -86,8 +86,9 @@ namespace Samples
AddSample (w, "ListBox", typeof(ListBoxSample));
AddSample (w, "LinkLabels", typeof(LinkLabels));
var listView = AddSample (w, "ListView", typeof(ListView1));
- AddSample (listView, "Editable checkboxes", typeof(ListView2));
+ AddSample (listView, "Editable Checkboxes", typeof(ListView2));
AddSample (listView, "Cell Bounds", typeof(ListViewCellBounds));
+ AddSample (listView, "Editable Entries", typeof (ListViewEntries));
AddSample (w, "Markdown", typeof (MarkDownSample));
AddSample (w, "Menu", typeof(MenuSamples));
AddSample (w, "Mnemonics", typeof (Mnemonics));
diff --git a/TestApps/Samples/Samples.csproj b/TestApps/Samples/Samples.csproj
index a30c9026..2c1b576f 100644
--- a/TestApps/Samples/Samples.csproj
+++ b/TestApps/Samples/Samples.csproj
@@ -113,6 +113,7 @@
<Compile Include="Samples\TreeViewCellBounds.cs" />
<Compile Include="Samples\CalendarSample.cs" />
<Compile Include="Samples\FontSelectorSample.cs" />
+ <Compile Include="Samples\ListViewEntries.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
diff --git a/TestApps/Samples/Samples/ListViewEntries.cs b/TestApps/Samples/Samples/ListViewEntries.cs
new file mode 100644
index 00000000..095e6c27
--- /dev/null
+++ b/TestApps/Samples/Samples/ListViewEntries.cs
@@ -0,0 +1,66 @@
+//
+// ListViewEntries.cs
+//
+// Author:
+// Lluis Sanchez Gual <lluis@xamarin.com>
+//
+// Copyright (c) 2016 Xamarin, Inc (http://www.xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+using System;
+using Xwt;
+using System.IO;
+
+namespace Samples
+{
+ public class ListViewEntries: VBox
+ {
+ public ListViewEntries ()
+ {
+ ListView list = new ListView ();
+ var editableTextField = new DataField<string> ();
+ var nonEditableTextField = new DataField<string> ();
+
+ ListStore store = new ListStore (editableTextField, nonEditableTextField);
+ list.DataSource = store;
+ list.GridLinesVisible = GridLines.Horizontal;
+
+ var textCellView = new TextCellView { Editable = true, TextField = editableTextField };
+ list.Columns.Add (new ListViewColumn ("Editable", textCellView));
+ list.Columns.Add (new ListViewColumn ("Not Editable", new TextCellView { Editable = false, TextField = nonEditableTextField }));
+
+ Random rand = new Random ();
+
+ for (int n = 0; n < 10; n++) {
+ var r = store.AddRow ();
+ store.SetValue (r, editableTextField, "Editable value " + n);
+ store.SetValue (r, nonEditableTextField, "Non-editable value " + n);
+ }
+ PackStart (list, true);
+ var btn = new Button ("Add Row");
+ btn.Clicked += delegate {
+ var row = store.AddRow ();
+ store.SetValues (row, editableTextField, "New editable text", nonEditableTextField, "New non-editable text");
+ list.StartEditingCell (row, textCellView);
+ };
+ PackStart (btn, false, hpos: WidgetPlacement.Start);
+ }
+ }
+}
+
diff --git a/Xwt.Gtk/Xwt.GtkBackend/ListViewBackend.cs b/Xwt.Gtk/Xwt.GtkBackend/ListViewBackend.cs
index 8d6f16c7..06e3e3f2 100644
--- a/Xwt.Gtk/Xwt.GtkBackend/ListViewBackend.cs
+++ b/Xwt.Gtk/Xwt.GtkBackend/ListViewBackend.cs
@@ -96,6 +96,13 @@ namespace Xwt.GtkBackend
ScrollToRow (it);
}
+ public void StartEditingCell (int row, CellView cell)
+ {
+ var col = GetCellColumn (cell);
+ if (col != null)
+ Widget.SetCursor (new Gtk.TreePath (new [] { row }), col, true);
+ }
+
public int[] SelectedRows {
get {
var sel = Widget.Selection.GetSelectedRows ();
diff --git a/Xwt.Gtk/Xwt.GtkBackend/TableViewBackend.cs b/Xwt.Gtk/Xwt.GtkBackend/TableViewBackend.cs
index 3f39c806..b66a967b 100644
--- a/Xwt.Gtk/Xwt.GtkBackend/TableViewBackend.cs
+++ b/Xwt.Gtk/Xwt.GtkBackend/TableViewBackend.cs
@@ -246,7 +246,10 @@ namespace Xwt.GtkBackend
protected Gtk.TreeViewColumn GetCellColumn (CellView cell)
{
- return cellViews [cell].Column;
+ CellInfo ci;
+ if (cellViews.TryGetValue (cell, out ci))
+ return ci.Column;
+ return null;
}
#region ICellRendererTarget implementation
diff --git a/Xwt.WPF/Xwt.WPFBackend/ListViewBackend.cs b/Xwt.WPF/Xwt.WPFBackend/ListViewBackend.cs
index 5ef427a2..e86e8e93 100644
--- a/Xwt.WPF/Xwt.WPFBackend/ListViewBackend.cs
+++ b/Xwt.WPF/Xwt.WPFBackend/ListViewBackend.cs
@@ -241,6 +241,11 @@ namespace Xwt.WPFBackend
ListView.ScrollIntoView (ListView.Items [row]);
}
+ public void StartEditingCell (int row, CellView cell)
+ {
+ // TODO
+ }
+
public void SetSource (IListDataSource source, IBackend sourceBackend)
{
var dataSource = sourceBackend as ListDataSource;
diff --git a/Xwt.XamMac/Xwt.Mac/TableViewBackend.cs b/Xwt.XamMac/Xwt.Mac/TableViewBackend.cs
index 7a5a8b72..b861f8e7 100644
--- a/Xwt.XamMac/Xwt.Mac/TableViewBackend.cs
+++ b/Xwt.XamMac/Xwt.Mac/TableViewBackend.cs
@@ -273,7 +273,12 @@ namespace Xwt.Mac
{
Table.ScrollRowToVisible (row);
}
-
+
+ public void StartEditingCell (int row, CellView cell)
+ {
+ // TODO
+ }
+
public abstract object GetValue (object pos, int nField);
public abstract void SetValue (object pos, int nField, object value);
diff --git a/Xwt/Xwt.Backends/IListViewBackend.cs b/Xwt/Xwt.Backends/IListViewBackend.cs
index de26b232..408bea87 100644
--- a/Xwt/Xwt.Backends/IListViewBackend.cs
+++ b/Xwt/Xwt.Backends/IListViewBackend.cs
@@ -36,6 +36,7 @@ namespace Xwt.Backends
void SelectRow (int pos);
void UnselectRow (int pos);
void ScrollToRow (int row);
+ void StartEditingCell (int row, CellView cell);
bool BorderVisible { get; set; }
GridLines GridLinesVisible { get; set; }
diff --git a/Xwt/Xwt/ListView.cs b/Xwt/Xwt/ListView.cs
index f62240b1..15728f86 100644
--- a/Xwt/Xwt/ListView.cs
+++ b/Xwt/Xwt/ListView.cs
@@ -236,6 +236,16 @@ namespace Xwt
}
/// <summary>
+ /// Focuses and starts editing a cell, so the user can start interacting with it
+ /// </summary>
+ /// <param name="row">Row</param>
+ /// <param name="cell">Cell to edit</param>
+ public void StartEditingCell (int row, CellView cell)
+ {
+ Backend.StartEditingCell (row, cell);
+ }
+
+ /// <summary>
/// Returns the row at the given widget coordinates
/// </summary>
/// <returns>The row index</returns>