Merge pull request #355 from mono/fix_tree_operations

[Xwt] Fixed/Added Tree Operations:
This commit is contained in:
Lluis Sanchez 2014-07-10 21:46:50 +02:00
Родитель aa7e600b56 43a1c7131c
Коммит 1472bacb89
3 изменённых файлов: 33 добавлений и 1 удалений

Просмотреть файл

@ -209,7 +209,17 @@ namespace Xwt.GtkBackend
public TreePosition GetPrevious (TreePosition pos) public TreePosition GetPrevious (TreePosition pos)
{ {
throw new NotImplementedException (); IterPos tpos = GetIterPos (pos);
Gtk.TreePath path = Tree.GetPath (tpos.Iter);
int [] indices = path.Indices;
if (indices.Length < 1 || indices [indices.Length - 1] == 0)
return null;
indices [indices.Length - 1] --;
Gtk.TreePath previousPath = new Gtk.TreePath (indices);
Gtk.TreeIter previous;
if (!Tree.GetIter (out previous, previousPath))
return null;
return new IterPos (version, previous);
} }
public TreePosition GetParent (TreePosition pos) public TreePosition GetParent (TreePosition pos)

Просмотреть файл

@ -94,6 +94,16 @@ namespace Xwt
return CommitPos (backend.GetParent (pos)); return CommitPos (backend.GetParent (pos));
} }
public bool MoveToFirstSibling ()
{
return CommitPos (backend.GetChild (backend.GetParent (pos), 0));
}
public bool MoveToLastSibling ()
{
return CommitPos (backend.GetChild (backend.GetParent (pos), backend.GetChildrenCount (backend.GetParent (pos)) - 1));
}
public TreeNavigator InsertBefore () public TreeNavigator InsertBefore ()
{ {
pos = backend.InsertBefore (pos); pos = backend.InsertBefore (pos);

Просмотреть файл

@ -92,6 +92,18 @@ namespace Xwt
var pos = Backend.AddChild (position); var pos = Backend.AddChild (position);
return new TreeNavigator (Backend, pos); return new TreeNavigator (Backend, pos);
} }
public TreeNavigator InsertNodeAfter (TreePosition positon)
{
var pos = Backend.InsertAfter (positon);
return new TreeNavigator (Backend, pos);
}
public TreeNavigator InsertNodeBefore (TreePosition positon)
{
var pos = Backend.InsertBefore (positon);
return new TreeNavigator (Backend, pos);
}
public void Clear () public void Clear ()
{ {