2009-03-16 Mike Kestner <mkestner@novell.com>

* gtk/NodeSelection.cs: use new Adapter prop on NodeStore.
	* gtk/NodeStore.cs: some encapsulation rework.
	* gtk/NodeView.cs: use new Adapter prop on NodeStore. new methods
	to support manipulation of the view by TreeNode, like scrolling
	and cell bounds lookups.  
	* gtk/TreeView.cs: use new Adapter prop on NodeStore.
	* doc/en/Gtk/NodeView.xml: new doc updates. 
	Patch provided by Vladimir Giszpenc.  [Fixes #480067]

svn path=/trunk/gtk-sharp/; revision=129498
This commit is contained in:
Mike Kestner 2009-03-16 21:05:08 +00:00
parent 41ef366e9f
commit 80d16bd3a2
6 changed files with 369 additions and 21 deletions

View file

@ -1,3 +1,14 @@
2009-03-16 Mike Kestner <mkestner@novell.com>
* gtk/NodeSelection.cs: use new Adapter prop on NodeStore.
* gtk/NodeStore.cs: some encapsulation rework.
* gtk/NodeView.cs: use new Adapter prop on NodeStore. new methods
to support manipulation of the view by TreeNode, like scrolling
and cell bounds lookups.
* gtk/TreeView.cs: use new Adapter prop on NodeStore.
* doc/en/Gtk/NodeView.xml: new doc updates.
Patch provided by Vladimir Giszpenc. [Fixes #480067]
2009-03-07 Mike Kestner <mkestner@novell.com>
* configure.in.in: add --disable-glade-sharp configure option

View file

@ -39,7 +39,7 @@
<Parameters />
<Docs>
<summary>The store containing the view's data.</summary>
<value>a <see cref="T:Gtk.NodeStore" /></value>
<value>an object of type <see cref="T:Gtk.NodeStore" /></value>
<remarks />
</Docs>
</Member>
@ -52,7 +52,7 @@
<Parameters />
<Docs>
<summary>Used to obtain and manipulate the currently selected node(s).</summary>
<value>a <see cref="T:Gtk.NodeSelection" /></value>
<value>an object of type <see cref="T:Gtk.NodeSelection" /></value>
<remarks />
</Docs>
</Member>
@ -76,6 +76,241 @@
<remarks />
</Docs>
</Member>
<Member MemberName="ActivateRow">
<MemberSignature Language="C#" Value="public void ActivateRow (Gtk.ITreeNode node, Gtk.treeViewColumn coumn);" />
<MemberType>Method</MemberType>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="node" Type="Gtk.ITreeNode" />
<Parameter Name="column" Type="Gtk.TreeViewColumn" />
</Parameters>
<Docs>
<summary>Collapses a row (hides its child rows, if they exist).</summary>
<param name="node">an object of type <see cref="T:Gtk.ITreeNode" /></param>
<param name="column">an object of type <see cref="T:Gtk.TreeViewColumn" /></param>
<remarks />
<since version="Gtk# 2.14" />
</Docs>
</Member>
<Member MemberName="CollapseRow">
<MemberSignature Language="C#" Value="public bool CollapseRow (Gtk.ITreeNode node);" />
<MemberType>Method</MemberType>
<ReturnValue>
<ReturnType>System.Boolean</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="node" Type="Gtk.ITreeNode" />
</Parameters>
<Docs>
<summary>Activates the cell determined by <paramref name="node" /> and <paramref name="column" />.</summary>
<param name="node">an object of type <see cref="T:Gtk.ITreeNode" /> identifying the row to be activated</param>
<remarks />
<since version="Gtk# 2.14" />
</Docs>
</Member>
<Member MemberName="CreateRowDragIcon">
<MemberSignature Language="C#" Value="public Gdk.Pixmap CreateRowDragIcon (Gtk.ITreeNode node);" />
<MemberType>Method</MemberType>
<ReturnValue>
<ReturnType>Gdk.Pixmap</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="node" Type="Gtk.ITreeNode" />
</Parameters>
<Docs>
<summary>This image is used for a drag icon..</summary>
<param name="node">a <see cref="T:Gtk.ITreeNode" /></param>
<remarks />
<since version="Gtk# 2.14" />
</Docs>
</Member>
<Member MemberName="GetBackgroundArea">
<MemberSignature Language="C#" Value="public Gdk.Rectangle GetBackgroundArea (ITreeNode node, Gtk.TreeViewColumn column);" />
<MemberType>Method</MemberType>
<ReturnValue>
<ReturnType>Gdk.Rectangle</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="node" Type="Gtk.ITreeNode" />
<Parameter Name="column" Type="Gtk.TreeViewColumn" />
</Parameters>
<Docs>
<summary>Fills the bounding rectangle in tree window coordinates for the cell at the row specified by <paramref name="node" /> and the column specified by <paramref name="column" />.</summary>
<param name="node">an object of type <see cref="T:Gtk.ITreeNode" /> identifying the row</param>
<param name="column">an object of type <see cref="T:Gtk.TreeViewColumn" /> identifying the column</param>
<remarks>See the remark in <see cref="T:Gtk.TreeView" />.
</remarks>
<since version="Gtk# 2.14" />
</Docs>
</Member>
<Member MemberName="GetCellArea">
<MemberSignature Language="C#" Value="public Gdk.Rectangle GetCellArea (ITreeNode node, Gtk.TreeViewColumn column);" />
<MemberType>Method</MemberType>
<ReturnValue>
<ReturnType>Gdk.Rectangle</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="node" Type="Gtk.ITreeNode" />
<Parameter Name="column" Type="Gtk.TreeViewColumn" />
</Parameters>
<Docs>
<summary>Fills the bounding rectangle in tree window coordinates for the cell at the row specified by <paramref name="node" /> and the column specified by <paramref name="column" />.</summary>
<param name="node">an object of type <see cref="T:Gtk.ITreeNode" /> identifying the row</param>
<param name="column">an object of type <see cref="T:Gtk.TreeViewColumn" /> identifying the column</param>
<remarks>See the remark in <see cref="T:Gtk.TreeView" />.
</remarks>
<since version="Gtk# 2.14" />
</Docs>
</Member>
<Member MemberName="GetNodeAtPos">
<MemberSignature Language="C#" Value="public ITreeNode GetNodeAtPos (int x, int y);" />
<MemberType>Method</MemberType>
<ReturnValue>
<ReturnType>Gtk.ITreeNode</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="x" Type="System.Int32" />
<Parameter Name="y" Type="System.Int32" />
</Parameters>
<Docs>
<summary>Finds the ITreeNode at the point (x, y), relative to widget coordinates.</summary>
<param name="x">an <see cref="T:System.Int32" /> X coordinate</param>
<param name="y">an <see cref="T:System.Int32" /> Y coordinate</param>
<returns>an object of type <see cref="T:Gtk.ITreeNode" /></returns>
<remarks>It is primarily for things like popup menus. This function is only meaningful if TreeView is realized. This function can return null.</remarks>
<since version="Gtk# 2.14" />
</Docs>
</Member>
<Member MemberName="GetRowExpanded">
<MemberSignature Language="C#" Value="public bool GetRowExpanded (ITreeNode node);" />
<MemberType>Method</MemberType>
<ReturnValue>
<ReturnType>System.Boolean</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="node" Type="Gtk.ITreeNode" />
</Parameters>
<Docs>
<summary>Returns <see langword="true" /> if the node pointed to by <paramref name="node" /> is expanded.</summary>
<param name="node">an object of type <see cref="T:Gtk.ITreeNode" /></param>
<returns>a <see cref="T:System.Boolean" /></returns>
<remarks>
</remarks>
<since version="Gtk# 2.14" />
</Docs>
</Member>
<Member MemberName="GetVisibleRange">
<MemberSignature Language="C#" Value="public bool GetVisibleRange (out ITreeNode startNode, out ITreeNode endNode);" />
<MemberType>Method</MemberType>
<ReturnValue>
<ReturnType>System.Boolean</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="startNode" Type="Gtk.ITreeNode" RefType="out" />
<Parameter Name="endNode" Type="Gtk.ITreeNode" RefType="out" />
</Parameters>
<Docs>
<param name="startNode">returns a <see cref="T:Gtk.ITreeNode" /> to the first visible row.</param>
<param name="endNode">returns a <see cref="T:Gtk.ITreeNode" /> to the last visible row.</param>
<summary>Gets the visible rows of the view.</summary>
<returns>
<see langword="true" /> if the start and end nodes were set.</returns>
<remarks>Note: there may be invisible nodes between the start and end nodes returned.</remarks>
<since version="Gtk# 2.14" />
</Docs>
</Member>
<Member MemberName="ScrollToCell">
<MemberSignature Language="C#" Value="public void ScrollToCell (ITreeNode node, TreeViewColumn column, bool use_align, float row_align, float col_align);" />
<MemberType>Method</MemberType>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="node" Type="Gtk.ITreeNode" />
<Parameter Name="column" Type="Gtk.TreeViewColumn" />
<Parameter Name="use_align" Type="System.Boolean" />
<Parameter Name="row_align" Type="System.Single" />
<Parameter Name="col_align" Type="System.Single" />
</Parameters>
<Docs>
<summary>Moves the alignments of the <see cref="T:Gtk.TreeView" /> to the position specified by <paramref name="column" /> and <paramref name="node" />.</summary>
<param name="node">an object of type <see cref="T:Gtk.ITreeNode" /> identifying a row to scroll to</param>
<param name="column">an object of type <see cref="T:Gtk.TreeViewColumn" />identifying a column to scroll to</param>
<param name="use_align">a <see cref="T:System.Boolean" /></param>
<param name="row_align">a <see cref="T:System.Single" /></param>
<param name="col_align">a <see cref="T:System.Single" /></param>
<remarks>
<para>
If <paramref name="column" /> is <see langword="null" />, then no horizontal scrolling occurs. Likewise, if <paramref name="node" /> is <see langword="null" /> no vertical scrolling occurs. At a minimum, one of <paramref name="column" /> or <paramref name="null" /> need to be non-<see langword="null" />. <paramref name="row_align" /> determines where the row is placed, and <paramref name="col_align" /> determines where the column is placed. Both are expected to be between 0.0 and 1.0. 0.0 means left/top alignment, 1.0 means right/bottom alignment, 0.5 means center.
</para>
<para>
If <paramref name="use_align" /> is <see langword="false" />, then the alignment arguments are ignored, and the tree does the minimum amount of work to scroll the cell onto the screen. This means that the cell will be scrolled to the edge closest to its current position. If the cell is currently visible on the screen, nothing is done.
</para>
<para>
This function only works if the model is set, and <paramref name="node" /> is a valid row on the model. If the model changes before the <see cref="T:Gtk.NodeView" /> is realized, the centered path will be modified to reflect this change.
</para>
</remarks>
<since version="Gtk# 2.14" />
</Docs>
</Member>
<Member MemberName="SetTooltipCell">
<MemberSignature Language="C#" Value="public void SetTooltipCell (Tooltip tooltip, ITreeNode node, TreeViewColumn column, CellRenderer renderer);" />
<MemberType>Method</MemberType>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="tooltip" Type="Gtk.Tooltip" />
<Parameter Name="node" Type="Gtk.ITreeNode" />
<Parameter Name="column" Type="Gtk.TreeViewColumn" />
<Parameter Name="cell" Type="Gtk.CellRenderer" />
</Parameters>
<Docs>
<param name="tooltip">an object of type <see cref="T:Gtk.Tooltip" /></param>
<param name="node">an object of type <see cref="T:Gtk.ITreeNode" /></param>
<param name="column">an object of type <see cref="T:Gtk.TreeViewColumn" /></param>
<param name="renderer">an object of type <see cref="T:Gtk.CellRenderer" /></param>
<summary>Sets the tip area of <paramref name="tooltip" /> to the area which cell occupies in the item pointed to by node. See also <see cref="SetTipArea" />..</summary>
<remarks></remarks>
<since version="Gtk# 2.14" />
</Docs>
</Member>
<Member MemberName="ExpandRow">
<MemberSignature Language="C#" Value="public void ExpandRow (Gtk.ITreeNode node, bool open_all);" />
<MemberType>Method</MemberType>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="node" Type="Gtk.ITreeNode" />
<Parameter Name="open_all" Type="System.Boolean" />
</Parameters>
<Docs>
<summary>Expands the row at <paramref name="node" /> so its children are visible.</summary>
<param name="node">an object of type <see cref="T:Gtk.ITreeNode" /> identifying the row to expand</param>
<param name="open_all">a <see cref="T:System.Boolean" /> to determine whether to recursively expand or just expand immediate children</param>
<remarks />
<since version="Gtk# 2.14" />
</Docs>
</Member>
<Member MemberName="ExpandToNode">
<MemberSignature Language="C#" Value="public void ExpandToNode (Gtk.ITreeNode node);" />
<MemberType>Method</MemberType>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="node" Type="Gtk.ITreeNode" />
</Parameters>
<Docs>
<summary>Expands the row at <paramref name="node" />. This will also expand all parent rows of <paramref name="node" /> as necessary.</summary>
<param name="node">an object of type <see cref="T:Gtk.ITreeNode" /> identifying the row to expand</param>
<remarks />
<since version="Gtk# 2.14" />
</Docs>
</Member>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public NodeView ();" />
<MemberType>Constructor</MemberType>

View file

@ -43,7 +43,7 @@ namespace Gtk {
public bool NodeIsSelected (ITreeNode node)
{
return selection.IterIsSelected (NodeView.NodeStore.Implementor.GetIter (node));
return selection.IterIsSelected (NodeView.NodeStore.GetIter (node));
}
public bool PathIsSelected (TreePath path)
@ -58,7 +58,7 @@ namespace Gtk {
public void SelectNode (ITreeNode node)
{
selection.SelectIter (NodeView.NodeStore.Implementor.GetIter (node));
selection.SelectIter (NodeView.NodeStore.GetIter (node));
}
public void SelectPath (TreePath path)
@ -68,8 +68,8 @@ namespace Gtk {
public void SelectRange (ITreeNode begin_node, ITreeNode end_node)
{
TreePath begin = NodeView.NodeStore.Implementor.GetPath (begin_node);
TreePath end = NodeView.NodeStore.Implementor.GetPath (end_node);
TreePath begin = NodeView.NodeStore.GetPath (begin_node);
TreePath end = NodeView.NodeStore.GetPath (end_node);
selection.SelectRange (begin, end);
}
@ -81,7 +81,7 @@ namespace Gtk {
public void UnselectNode (ITreeNode node)
{
selection.UnselectIter (NodeView.NodeStore.Implementor.GetIter (node));
selection.UnselectIter (NodeView.NodeStore.GetIter (node));
}
public void UnselectPath (TreePath path)
@ -96,8 +96,8 @@ namespace Gtk {
public void UnselectRange (ITreeNode begin_node, ITreeNode end_node)
{
TreePath begin = NodeView.NodeStore.Implementor.GetPath (begin_node);
TreePath end = NodeView.NodeStore.Implementor.GetPath (end_node);
TreePath begin = NodeView.NodeStore.GetPath (begin_node);
TreePath end = NodeView.NodeStore.GetPath (end_node);
selection.UnselectRange (begin, end);
}

View file

@ -28,20 +28,57 @@ namespace Gtk {
using System.Runtime.InteropServices;
public class NodeStore : GLib.Object, IEnumerable {
internal readonly NodeStoreImplementor Implementor;
NodeStoreImplementor implementor;
public NodeStore (Type node_type)
{
Implementor = new NodeStoreImplementor (node_type);
implementor = new NodeStoreImplementor (node_type);
}
// Redirect calls to implementor class
public ITreeNode GetNode (TreePath path) { return Implementor.GetNode (path); }
public void AddNode (ITreeNode node) { Implementor.AddNode (node); }
public void AddNode (ITreeNode node, int position) { Implementor.AddNode (node, position); }
public void RemoveNode (ITreeNode node) { Implementor.RemoveNode (node); }
public void Clear () { Implementor.Clear (); }
public IEnumerator GetEnumerator () { return Implementor.GetEnumerator (); }
internal TreeModelAdapter Adapter {
get { return new TreeModelAdapter (implementor); }
}
internal TreeIter GetIter (ITreeNode node)
{
return implementor.GetIter (node);
}
internal TreePath GetPath (ITreeNode node)
{
return implementor.GetPath (node);
}
public ITreeNode GetNode (TreePath path)
{
return implementor.GetNode (path);
}
public void AddNode (ITreeNode node)
{
implementor.AddNode (node);
}
public void AddNode (ITreeNode node, int position)
{
implementor.AddNode (node, position);
}
public void RemoveNode (ITreeNode node)
{
implementor.RemoveNode (node);
}
public void Clear ()
{
implementor.Clear ();
}
public IEnumerator GetEnumerator ()
{
return implementor.GetEnumerator ();
}
internal class NodeStoreImplementor : GLib.Object, TreeModelImplementor, IEnumerable {
TreeModelAdapter model_adapter;

View file

@ -30,7 +30,7 @@ namespace Gtk {
NodeStore store;
NodeSelection selection;
public NodeView (NodeStore store) : base (store == null ? null : new Gtk.TreeModelAdapter (store.Implementor))
public NodeView (NodeStore store) : base (store == null ? null : store.Adapter)
{
this.store = store;
}
@ -43,7 +43,7 @@ namespace Gtk {
}
set {
store = value;
this.Model = store == null ? null : new Gtk.TreeModelAdapter (store.Implementor);
this.Model = store == null ? null : store.Adapter;
}
}
@ -65,6 +65,71 @@ namespace Gtk {
AppendColumn (col);
return col;
}
public void ActivateRow (ITreeNode node, Gtk.TreeViewColumn column) {
ActivateRow (store.GetPath (node), column);
}
public bool CollapseRow (ITreeNode node) {
return CollapseRow (store.GetPath (node));
}
public Gdk.Pixmap CreateRowDragIcon (ITreeNode node) {
return CreateRowDragIcon (store.GetPath (node));
}
public Gdk.Rectangle GetBackgroundArea (ITreeNode node, Gtk.TreeViewColumn column) {
return GetBackgroundArea (store.GetPath (node), column);
}
public Gdk.Rectangle GetCellArea (ITreeNode node, Gtk.TreeViewColumn column) {
return GetBackgroundArea (store.GetPath (node), column);
}
public ITreeNode GetNodeAtPos (int x, int y) {
Gtk.TreePath nodePath;
ITreeNode node = null;
if (this.GetPathAtPos (x, y, out nodePath))
node = store.GetNode (nodePath);
return node;
}
public bool GetRowExpanded (ITreeNode node) {
return GetRowExpanded (store.GetPath (node));
}
public bool GetVisibleRange (out ITreeNode startNode, out ITreeNode endNode) {
Gtk.TreePath start_path, end_path;
bool retVal = GetVisibleRange (out start_path, out end_path);
if (retVal) {
startNode = store.GetNode (start_path);
endNode = store.GetNode (end_path);
}
else {
startNode = null;
endNode = null;
}
return retVal;
}
public void ScrollToCell (ITreeNode node, TreeViewColumn column, bool use_align, float row_align, float col_align) {
ScrollToCell (store.GetPath (node), column, use_align, row_align, col_align);
}
public void SetTooltipCell (Tooltip tooltip, ITreeNode node, TreeViewColumn column, CellRenderer renderer) {
SetTooltipCell (tooltip, store.GetPath (node), column, renderer);
}
public void ExpandRow (ITreeNode node, bool open_all) {
ExpandRow (store.GetPath (node), open_all);
}
public void ExpandToNode (ITreeNode node) {
ExpandToPath (store.GetPath (node));
}
}
}

View file

@ -25,7 +25,7 @@
[Obsolete ("Use NodeView with NodeStores")]
public TreeView (NodeStore store) : this (store == null ? null : new Gtk.TreeModelAdapter (store.Implementor)) { }
public TreeView (NodeStore store) : this (store == null ? null : store.Adapter) {}
public Gdk.Color OddRowColor {
get {