Hi,
2005-08-24 Rafael Teixeira <[EMAIL PROTECTED]>
* TreeView.cs : Corrected node width calculations
May I commit?
--
Rafael "Monoman" Teixeira
---------------------------------------
I'm trying to become a "Rosh Gadol" before my own eyes.
See http://www.joelonsoftware.com/items/2004/12/06.html for enlightment.
It hurts!
Index: System.Windows.Forms/ChangeLog
===================================================================
--- System.Windows.Forms/ChangeLog (revision 48794)
+++ System.Windows.Forms/ChangeLog (working copy)
@@ -1,4 +1,7 @@
2005-08-24 Rafael Teixeira <[EMAIL PROTECTED]>
+ * TreeView.cs : Corrected node width calculations
+
+2005-08-24 Rafael Teixeira <[EMAIL PROTECTED]>
-- Making Windows with Menus layout correctly --
* Form.cs : The first leg of the fix
Menu setter - adjust Client Size as needed to make space for the menu
Index: System.Windows.Forms/TreeView.cs
===================================================================
--- System.Windows.Forms/TreeView.cs (revision 48790)
+++ System.Windows.Forms/TreeView.cs (working copy)
@@ -79,6 +79,7 @@
private int hbar_offset;
private int update_stack;
+ private StringFormat string_format;
private TreeViewEventHandler on_after_check;
private TreeViewEventHandler on_after_collapse;
@@ -101,6 +102,10 @@
#region Public Constructors
public TreeView ()
{
+ string_format = new StringFormat();
+ string_format.Alignment = StringAlignment.Center;
+ string_format.LineAlignment = StringAlignment.Center;
+
base.background_color = ThemeEngine.Current.ColorWindow;
base.foreground_color = ThemeEngine.Current.ColorWindowText;
@@ -1002,15 +1007,6 @@
UpdateNode(edit_node);
}
- [MonoTODO("When Graphics.MeasureString starts to work correctly use it")]
- private void UpdateNodeBounds (TreeNode node, int x, int y, int item_height, Graphics dc)
- {
-// SizeF size = dc.MeasureString (Text, Font, ClientSize.Width, new StringFormat ());
-// int width = (int) size.Width + 3;
- int width = (int)(node.Text.Length * node.NodeFont.Size * 0.85);
- node.UpdateBounds (x, y, width, item_height);
- }
-
private void DrawSelectionAndFocus(TreeNode node, Graphics dc, Rectangle r)
{
if (!HideSelection && SelectedNode == node)
@@ -1024,18 +1020,20 @@
private void DrawStaticNode (TreeNode node, Graphics dc)
{
Rectangle r = node.Bounds;
- StringFormat format = new StringFormat ();
- format.LineAlignment = StringAlignment.Center;
r.Y += 2; // we have to adjust this to get nice middle alignment
if (!full_row_select)
DrawSelectionAndFocus(node, dc, r);
- r.X += 4;
- r.Width -= 8;
Color text_color = (Focused && SelectedNode == node ? ThemeEngine.Current.ColorHilightText : node.ForeColor);
- dc.DrawString (node.Text, node.NodeFont, ThemeEngine.Current.ResPool.GetSolidBrush (text_color), r, format);
+ dc.DrawString (node.Text, node.NodeFont, ThemeEngine.Current.ResPool.GetSolidBrush (text_color), r, string_format);
}
+ private void UpdateNodeBounds (TreeNode node, int x, int y, int item_height, Graphics dc)
+ {
+ SizeF size = dc.MeasureString (node.Text, node.NodeFont, 0, string_format);
+ node.UpdateBounds (x, y, (int) size.Width + 5, item_height);
+ }
+
private void DrawNode (TreeNode node, Graphics dc, Rectangle clip, ref int depth, int item_height, int max_height)
{
open_node_count++;
_______________________________________________
Mono-winforms-list maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-winforms-list