[Monodevelop-patches-list] r750 - in trunk/MonoDevelop: samples samples/PropertyGridTest src/Libraries/MonoDevelop.Gui.Widgets src/Libraries/MonoDevelop.Gui.Widgets/PropertyGrid
commit-watcher at mono-cvs.ximian.com
commit-watcher at mono-cvs.ximian.com
Sun Feb 1 22:44:48 EST 2004
Author: tberman
Date: 2004-02-01 22:44:48 -0500 (Sun, 01 Feb 2004)
New Revision: 750
Added:
trunk/MonoDevelop/samples/PropertyGridTest/
trunk/MonoDevelop/samples/PropertyGridTest/Main.cs
trunk/MonoDevelop/samples/PropertyGridTest/Makefile
trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui.Widgets/PropertyGrid/
trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui.Widgets/PropertyGrid/ELabel.cs
trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui.Widgets/PropertyGrid/PropertyGrid.cs
trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui.Widgets/PropertyGrid/PropertyGridGroup.cs
trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui.Widgets/PropertyGrid/PropertyGridItem.cs
trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui.Widgets/PropertyGrid/PropertyGridWidget.cs
Log:
work in progress commit, ill sleep easier knowing my HD isnt the only place it is.
This needs so much love in so many ways, visually first, then functionally
Copied: trunk/MonoDevelop/samples/PropertyGridTest/Main.cs (from rev 739, trunk/MonoDevelop/samples/MonoPad/Main.cs)
===================================================================
--- trunk/MonoDevelop/samples/MonoPad/Main.cs 2004-02-01 01:37:34 UTC (rev 739)
+++ trunk/MonoDevelop/samples/PropertyGridTest/Main.cs 2004-02-02 03:44:48 UTC (rev 750)
@@ -0,0 +1,50 @@
+using Gtk;
+using GtkSharp;
+using Pango;
+
+using System;
+using System.IO;
+using System.Drawing;
+
+using MonoDevelop.Gui.Widgets;
+
+namespace MonoDevelop.Test
+{
+
+ public class PropertyGridTest
+ {
+ PropertyGrid propgrid;
+ Window window;
+
+ public PropertyGridTest () {
+ Application.Init ();
+
+ Window win = new Gtk.Window ("PropertyGridTest");
+ window = win;
+ win.DeleteEvent += new DeleteEventHandler (Main_Closed);
+
+ propgrid = new PropertyGrid (this);
+
+ win.Add(propgrid);
+ win.ShowAll ();
+ Application.Run ();
+
+ }
+
+ private void Main_Closed (object o, DeleteEventArgs e)
+ {
+ Quit ();
+ }
+
+ private void Quit() {
+ Application.Quit();
+ }
+
+ public static int Main (string[] args)
+ {
+ PropertyGridTest shell = new PropertyGridTest();
+ return 0;
+ }
+ }
+}
+
Copied: trunk/MonoDevelop/samples/PropertyGridTest/Makefile (from rev 739, trunk/MonoDevelop/samples/MonoPad/Makefile)
===================================================================
--- trunk/MonoDevelop/samples/MonoPad/Makefile 2004-02-01 01:37:34 UTC (rev 739)
+++ trunk/MonoDevelop/samples/PropertyGridTest/Makefile 2004-02-02 03:44:48 UTC (rev 750)
@@ -0,0 +1,10 @@
+SOURCES=Main.cs
+EXE=../../build/bin/PropertyGridTest.exe
+
+all: $(EXE)
+
+$(EXE): $(SOURCES)
+ @ mcs /debug /target:exe /out:$(EXE) /r:gtk-sharp.dll /r:pango-sharp.dll /r:../../build/bin/MonoDevelop.Gui.Widgets.dll /r:System.Drawing.dll $(SOURCES)
+
+run: all
+ @ mono --debug ../../build/bin/PropertyGridTest.exe
Added: trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui.Widgets/PropertyGrid/ELabel.cs
===================================================================
--- trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui.Widgets/PropertyGrid/ELabel.cs 2004-02-02 03:21:09 UTC (rev 749)
+++ trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui.Widgets/PropertyGrid/ELabel.cs 2004-02-02 03:44:48 UTC (rev 750)
@@ -0,0 +1,122 @@
+//
+// elabel.cs: An ellipsizing label widget
+//
+// Author:
+// Alp Toker (alp at atoker.com)
+//
+// (C) 2003 Alp Toker
+//
+using System;
+using Gtk;
+using GtkSharp;
+
+namespace MonoDevelop.Gui.Widgets {
+ public class ELabel : Label {
+ string text = "";
+ const string ellipsis = "...";
+ const string en_char = "n";
+ int ellipsis_width, en_width, tmp;
+ int old_width;
+ Pango.Layout layout;
+ bool refreshed = false;
+
+ public ELabel (string text) : base (text)
+ {
+ SetSizeRequest (0, RequestSize.Height);
+ SizeAllocated += new SizeAllocatedHandler (OnSizeAllocated);
+
+ Text = text;
+ }
+
+ new public string Text
+ {
+ get {
+ return text;
+ } set {
+ text = value;
+ Reload ();
+ Refresh ();
+ }
+ }
+
+ void OnSizeAllocated (object o, SizeAllocatedArgs args)
+ {
+ if (refreshed) {
+ refreshed = false;
+ return;
+ }
+
+ if (Allocation.width != old_width)
+ Refresh ();
+ old_width = Allocation.width;
+
+ refreshed = true;
+ }
+
+ void Reload ()
+ {
+ layout = Layout.Copy ();
+
+ layout.SetText (ellipsis);
+ layout.GetPixelSize (out ellipsis_width, out tmp);
+
+ layout.SetText (en_char);
+ layout.GetPixelSize (out en_width, out tmp);
+ }
+
+ void Refresh ()
+ {
+ string ellipsized = Ellipsize (layout, text, Allocation.width, ellipsis_width, en_width);
+ if (base.Text != ellipsized)
+ base.Text = ellipsized;
+ }
+
+ public static string Ellipsize (Pango.Layout layout, string newtext, int bound, int ellipsis_width, int en_width)
+ {
+ int width, tmp;
+
+ layout.SetText (newtext);
+ layout.GetPixelSize (out width, out tmp);
+
+ if (width < bound)
+ return newtext;
+
+ if (bound <= ellipsis_width)
+ return ellipsis;
+
+ string ellipsized = "";
+ int i = 0;
+
+ //make a guess of where to start
+ i = (bound - ellipsis_width) / (en_width);
+ if (i >= newtext.Length)
+ i = 0;
+ ellipsized = newtext.Substring (0, i);
+
+ //add chars one by one to determine how many are allowed
+ while (true)
+ {
+ ellipsized = ellipsized + newtext[i];
+ layout.SetText (ellipsized);
+ layout.GetPixelSize (out width, out tmp);
+
+ if (i == newtext.Length - 1) {
+ //bad guess, start from the beginning
+ ellipsized = "";
+ i = 0;
+ continue;
+ }
+
+ if (width > bound - ellipsis_width)
+ break;
+
+ i++;
+ }
+
+ ellipsized = ellipsized.Remove (ellipsized.Length - 1, 1);
+ ellipsized += ellipsis;
+
+ return ellipsized;
+ }
+ }
+}
Added: trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui.Widgets/PropertyGrid/PropertyGrid.cs
===================================================================
--- trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui.Widgets/PropertyGrid/PropertyGrid.cs 2004-02-02 03:21:09 UTC (rev 749)
+++ trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui.Widgets/PropertyGrid/PropertyGrid.cs 2004-02-02 03:44:48 UTC (rev 750)
@@ -0,0 +1,27 @@
+using System;
+
+using Gtk;
+
+namespace MonoDevelop.Gui.Widgets
+{
+
+ public class PropertyGrid : Frame
+ {
+
+ public PropertyGridWidget internalTable;
+
+ object gridding;
+
+ public PropertyGrid () : base ()
+ {
+ internalTable = new PropertyGridWidget ();
+ internalTable.HscrollbarPolicy = Gtk.PolicyType.Never;
+ this.Add (internalTable);
+ }
+
+ public PropertyGrid (object togrid) : this ()
+ {
+ gridding = togrid;
+ }
+ }
+}
Added: trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui.Widgets/PropertyGrid/PropertyGridGroup.cs
===================================================================
--- trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui.Widgets/PropertyGrid/PropertyGridGroup.cs 2004-02-02 03:21:09 UTC (rev 749)
+++ trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui.Widgets/PropertyGrid/PropertyGridGroup.cs 2004-02-02 03:44:48 UTC (rev 750)
@@ -0,0 +1,49 @@
+using System;
+using System.Collections;
+
+using Gtk;
+
+namespace MonoDevelop.Gui.Widgets
+{
+ public class PropertyGridGroup : Gtk.Table
+ {
+ ELabel header;
+ Button expandButton;
+
+ Table internalTable;
+
+ ArrayList PropertyGridItems;
+
+ public PropertyGridGroup (string header) : base (2, 2, false)
+ {
+ PropertyGridItems = new ArrayList ();
+ this.expandButton = new Button (".");
+ Attach (this.expandButton, 0, 1, 0, 1, Gtk.AttachOptions.Shrink, Gtk.AttachOptions.Shrink, 0, 0);
+ this.header = new ELabel (header);
+ Attach (this.header, 1, 2, 0, 1, Gtk.AttachOptions.Fill, Gtk.AttachOptions.Shrink, 0, 0);
+
+ internalTable = new Gtk.Table (1, 2, true);
+ Attach (internalTable, 1, 2, 1, 2, Gtk.AttachOptions.Expand, Gtk.AttachOptions.Shrink, 0, 0);
+ }
+
+ public void AddGridItem (string name, Gtk.Widget editor)
+ {
+ PropertyGridItem newItem = new PropertyGridItem (name, editor);
+ PropertyGridItems.Add (newItem);
+
+ Refresh ();
+ }
+
+ void Refresh ()
+ {
+ internalTable.NRows = (uint)PropertyGridItems.Count;
+ foreach (Gtk.Widget child in internalTable.Children) {
+ internalTable.Remove (child);
+ }
+ for (uint i = 0; i < PropertyGridItems.Count; i++) {
+ internalTable.Attach (((PropertyGridItem)PropertyGridItems[(int)i]).Label, 0, 1, i, i + 1);
+ internalTable.Attach (((PropertyGridItem)PropertyGridItems[(int)i]).Editor, 1, 2, i, i + 1);
+ }
+ }
+ }
+}
Added: trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui.Widgets/PropertyGrid/PropertyGridItem.cs
===================================================================
--- trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui.Widgets/PropertyGrid/PropertyGridItem.cs 2004-02-02 03:21:09 UTC (rev 749)
+++ trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui.Widgets/PropertyGrid/PropertyGridItem.cs 2004-02-02 03:44:48 UTC (rev 750)
@@ -0,0 +1,35 @@
+using System;
+
+using Gtk;
+using Gnome;
+
+namespace MonoDevelop.Gui.Widgets
+{
+
+ public class PropertyGridItem
+ {
+
+ ELabel name;
+ Frame label;
+ Gtk.Widget editor;
+
+ public PropertyGridItem (string text, Gtk.Widget itemEditor)
+ {
+ name = new ELabel (text);
+ EventBox evnt = new EventBox ();
+ evnt.Add (name);
+ label = new Gtk.Frame ();
+ evnt.ModifyBg (Gtk.StateType.Normal, new Gdk.Color (System.Drawing.Color.White));
+ label.Add (evnt);
+ editor = itemEditor;
+ }
+
+ public Gtk.Widget Label {
+ get { return label; }
+ }
+
+ public Gtk.Widget Editor {
+ get { return editor; }
+ }
+ }
+}
Added: trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui.Widgets/PropertyGrid/PropertyGridWidget.cs
===================================================================
--- trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui.Widgets/PropertyGrid/PropertyGridWidget.cs 2004-02-02 03:21:09 UTC (rev 749)
+++ trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui.Widgets/PropertyGrid/PropertyGridWidget.cs 2004-02-02 03:44:48 UTC (rev 750)
@@ -0,0 +1,40 @@
+using System;
+using System.Collections;
+
+using Gtk;
+using Gdk;
+using Gnome;
+
+namespace MonoDevelop.Gui.Widgets
+{
+
+ public class PropertyGridWidget : ScrolledWindow
+ {
+ HBox intFrame;
+ ArrayList propertyGroups;
+
+ public PropertyGridWidget () : base ()
+ {
+ HBox intFrame = new HBox (true, 0);
+ propertyGroups = new ArrayList ();
+ PropertyGridGroup a = new PropertyGridGroup ("Appearence");
+ Gtk.Entry test = new Gtk.Entry ();
+ test.WidthChars = 10;
+ Gtk.Entry test2 = new Gtk.Entry ();
+ test2.WidthChars = 10;
+ Gtk.Entry test3 = new Gtk.Entry ();
+ test3.WidthChars = 10;
+ a.AddGridItem ("test", test);
+ a.AddGridItem ("test2", test2);
+ a.AddGridItem ("testing elipsizing", test3);
+ intFrame.PackStart (a);
+ AddWithViewport (intFrame);
+ }
+
+ public ArrayList PropertyGroups {
+ get { return propertyGroups; }
+ }
+
+ }
+
+}
More information about the Monodevelop-patches-list
mailing list