Author: dsnell
Date: 2006-08-11 00:42:38 -0400 (Fri, 11 Aug 2006)
New Revision: 63631

Added:
   branches/dmsnell/heap-buddy/analyzer/memgraph.glade
Modified:
   branches/dmsnell/heap-buddy/analyzer/GraphReport.cs
   branches/dmsnell/heap-buddy/analyzer/Makefile.am
   branches/dmsnell/heap-buddy/analyzer/Makefile.in
Log:
Moved into a glade gui, cleaned up the font scaling


Modified: branches/dmsnell/heap-buddy/analyzer/GraphReport.cs
===================================================================
--- branches/dmsnell/heap-buddy/analyzer/GraphReport.cs 2006-08-11 02:28:50 UTC 
(rev 63630)
+++ branches/dmsnell/heap-buddy/analyzer/GraphReport.cs 2006-08-11 04:42:38 UTC 
(rev 63631)
@@ -29,6 +29,7 @@
 using System.Collections;
 using Cairo;
 using Gtk;
+using Glade;
 
 namespace HeapBuddy {
 
@@ -40,41 +41,30 @@
                public Gdk.Window Window;
                
                public OutfileReader Reader;
-               
                public ArrayList Stamps;
                
+               [Widget] VBox vbox1;
+               [Widget] Gtk.Window MainWindow;
+               
                override public void Run (OutfileReader reader, string [] args)
                {
                        Reader = reader;
                        Stamps = new ArrayList ();
                        CollectStamps ();
                        Sort ();
-               
+                                       
                        Application.Init ();
                        
-                       Window MainWindow = new Window ("Heap-Buddy");
-                       MainWindow.SetDefaultSize (640, 480);
-                       MainWindow.DeleteEvent += QuitApplication;
-                       
-                       VPaned box1 = new VPaned ();
-                       MainWindow.Add (box1);
-                       
-                       MenuBar MainMenu = new MenuBar ();
-                       Menu FileMenu = new Menu ();
-                       MenuItem ExitItem = new MenuItem ("E_xit");
-                       ExitItem.Activated += QuitApplication;
-                       FileMenu.Append (ExitItem);
-                       MenuItem FileItem = new MenuItem ("_File");
-                       FileItem.Submenu = FileMenu;
-                       MainMenu.Append (FileItem);     
-                       box1.Add (MainMenu);
-                       
+                       Glade.XML gxml = new Glade.XML (null, "memgraph.glade", 
"MainWindow", null);
+                       gxml.Autoconnect (this);
+
                        CairoGraph cg = new CairoGraph (this);
-                       box1.Add (cg);
+                       vbox1.Add (cg);
                        
-                       box1.ResizeChildren ();
-                       
-                       MainWindow.ShowAll ();                  
+                       MainWindow.ShowAll ();
+                       MainWindow.Resize (640, 480);
+                       MainWindow.DeleteEvent += QuitApplication;
+                                               
                        Application.Run ();
                }
                
@@ -117,10 +107,18 @@
                        //*********Scaling
                        
                        // How much room for the labels?
-                       c.FontSize = 15;
+                       c.FontSize = 15 * w / 640;
+                       if (15 * w / 640 > 20)
+                               c.FontSize = 20;
+
                        string label = Util.PrettySize (HighBytes);
+                       double GOY = h - c.TextExtents (label).Height - 30;
+                       
+                       c.FontSize = 15 * h / 480;
+                       if (15 * h / 480 > 20)
+                               c.FontSize = 20;
+                               
                        double GOX = c.TextExtents (label).Width + 15;
-                       double GOY = h - 30;
                        double GW = w - GOX - 10;
                        double GH = GOY - 10;
                        
@@ -130,20 +128,55 @@
                        
                        // Border
                        c.Color = new Color (0, 0, 0, 1);
-                       c.LineWidth = 5;
+                       c.LineWidth = 2;
                        c.Rectangle (GOX, GOY, GW, -GH);
+                       c.Stroke ();
                        
                        // Memory line
                        c.MoveTo (GOX, GOY);
                        long LowTime = ((MemStamp)Stamps [0]).TimeT;
+                       
+                       Color Black       = new Color (0, 0, 0, 1);
+                       Color GcColor     = new Color (0, 0, 1, 1);
+                       Color ResizeColor = new Color (1, 0, 0, 1);
+                       
+                       double oldX = GOX;
+                       double oldY = GOY;
+                       double newX, newY;
+                       
+                       c.LineWidth = 1.5;
                        foreach (MemStamp ms in Stamps) {
-                               c.LineTo (GOX + (double)(ms.TimeT - LowTime) / 
xscale, GOY - (double)(ms.LiveBytes - LowBytes) / yscale);
+                               switch (ms.Op) {
+                                       case MemAction.Gc:
+                                               c.Color = GcColor;
+                                               break;
+                                               
+                                       case MemAction.Resize:
+                                               c.Color = ResizeColor;
+                                               break;
+                                               
+                                       default:
+                                               c.Color = Black;
+                                               break;
+                               }
+                               
+                               newX = GOX + (double)(ms.TimeT - LowTime) / 
xscale;
+                               newY = GOY - (double)(ms.LiveBytes - LowBytes) 
/ yscale;
+                               
+                               c.MoveTo (oldX, oldY);
+                               c.LineTo (newX, newY);
+                               c.Stroke ();
+                               
+                               oldX = newX;
+                               oldY = newY;
                        }
-                       c.LineWidth = 1.5;
-                       c.Stroke ();
+                       c.Color = Black;
                        
                        // Labels
                        c.LineWidth = 1;
+                       c.FontSize = 15 * h / 480;
+                       if (15 * h / 480 > 20)
+                               c.FontSize = 20;
                        
                        // Memory
                        for (int i = 0; i <= 10; i++) {
@@ -158,6 +191,10 @@
                        }
                        
                        // Time
+                       c.FontSize = 15 * w / 640;
+                       if (15 * w / 640 > 20)
+                               c.FontSize = 20;
+                       
                        for (int i = 0; i < 15; i++) {
                                c.MoveTo (GOX + i * GW / 15, GOY);
                                c.LineTo (GOX + i * GW / 15, GOY + 5);
@@ -170,14 +207,28 @@
                        }
                }
                
+               public enum MemAction {
+                       NoOp,
+                       Gc,
+                       Resize
+               }
+               
                public class MemStamp {
                        public long LiveBytes;
                        public long TimeT;
+                       public MemAction Op;
                        
                        public MemStamp (long bytes, long time) {
                                LiveBytes = bytes;
                                TimeT = time;
+                               Op = MemAction.NoOp;
                        }
+                       
+                       public MemStamp (long bytes, long time, MemAction op) {
+                               LiveBytes = bytes;
+                               TimeT = time;
+                               Op = op;
+                       }
                }
                
                public class MemStampComparer : IComparer {
@@ -194,11 +245,11 @@
                public void CollectStamps ()
                {
                        foreach (Gc gc in Reader.Gcs) {
-                               Stamps.Add (new MemStamp (gc.PostGcLiveBytes, 
gc.TimeT));
+                               Stamps.Add (new MemStamp (gc.PostGcLiveBytes, 
gc.TimeT, MemAction.Gc));
                        }
                        
                        foreach (Resize r in Reader.Resizes) {
-                               Stamps.Add (new MemStamp (r.TotalLiveBytes, 
r.time_t));
+                               Stamps.Add (new MemStamp (r.TotalLiveBytes, 
r.time_t, MemAction.Resize));
                        }
                }
 
@@ -207,8 +258,31 @@
                        IComparer ic = new MemStampComparer ();
                        Stamps.Sort (ic);
                }
+               
+               protected void SaveGraph (object o, EventArgs e)
+               {
+                       FileChooserDialog chooser = new FileChooserDialog 
("Save As", MainWindow, FileChooserAction.Save);
+                       chooser.AddButton (Stock.Cancel, ResponseType.Cancel);
+                       chooser.AddButton (Stock.Save, ResponseType.Ok);
+                       
+                       int response = chooser.Run ();
+                       
+                       if ((ResponseType)response == ResponseType.Ok) {
+                               int x, y, w, h, d;
+                               Window.GetGeometry (out x, out y, out w, out h, 
out d);
+                               
+                               Surface s = new ImageSurface (Format.RGB24, w, 
h);
+                               Context.Target = s;
+                               this.Continue ();
+
+                               s.WriteToPng (chooser.Filename);
+                               s.Finish ();
+                       }
+                       
+                       chooser.Destroy ();
+               }
        
-               protected static void QuitApplication (object o, EventArgs e)
+               protected void QuitApplication (object o, EventArgs e)
                {
                        Application.Quit ();
                }

Modified: branches/dmsnell/heap-buddy/analyzer/Makefile.am
===================================================================
--- branches/dmsnell/heap-buddy/analyzer/Makefile.am    2006-08-11 02:28:50 UTC 
(rev 63630)
+++ branches/dmsnell/heap-buddy/analyzer/Makefile.am    2006-08-11 04:42:38 UTC 
(rev 63631)
@@ -1,6 +1,6 @@
 
 CSC = mcs -debug
-CSFLAGS = -target:exe -r:Mono.Cairo -pkg:gtk-sharp-2.0 -r:System.Drawing.dll 
+CSFLAGS = -target:exe -r:Mono.Cairo -pkg:gtk-sharp-2.0 -r:System.Drawing.dll 
-pkg:glade-sharp-2.0 -resource:memgraph.glade
 
 TARGET = HeapBuddy.exe
 WRAPPER = heap-buddy

Modified: branches/dmsnell/heap-buddy/analyzer/Makefile.in
===================================================================
--- branches/dmsnell/heap-buddy/analyzer/Makefile.in    2006-08-11 02:28:50 UTC 
(rev 63630)
+++ branches/dmsnell/heap-buddy/analyzer/Makefile.in    2006-08-11 04:42:38 UTC 
(rev 63631)
@@ -153,7 +153,7 @@
 sysconfdir = @sysconfdir@
 target_alias = @target_alias@
 CSC = mcs -debug
-CSFLAGS = -target:exe -r:Mono.Cairo -pkg:gtk-sharp-2.0 -r:System.Drawing.dll 
+CSFLAGS = -target:exe -r:Mono.Cairo -pkg:gtk-sharp-2.0 -r:System.Drawing.dll 
-pkg:glade-sharp-2.0 -resource:memgraph.glade
 TARGET = HeapBuddy.exe
 WRAPPER = heap-buddy
 REPORT_CSFILES = \

Added: branches/dmsnell/heap-buddy/analyzer/memgraph.glade
===================================================================
--- branches/dmsnell/heap-buddy/analyzer/memgraph.glade 2006-08-11 02:28:50 UTC 
(rev 63630)
+++ branches/dmsnell/heap-buddy/analyzer/memgraph.glade 2006-08-11 04:42:38 UTC 
(rev 63631)
@@ -0,0 +1,191 @@
+<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
+<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd";>
+
+<glade-interface>
+
+<widget class="GtkWindow" id="MainWindow">
+  <property name="visible">True</property>
+  <property name="title" translatable="yes">Heap Buddy : Graph</property>
+  <property name="type">GTK_WINDOW_TOPLEVEL</property>
+  <property name="window_position">GTK_WIN_POS_NONE</property>
+  <property name="modal">False</property>
+  <property name="default_width">640</property>
+  <property name="default_height">480</property>
+  <property name="resizable">True</property>
+  <property name="destroy_with_parent">False</property>
+  <property name="decorated">True</property>
+  <property name="skip_taskbar_hint">False</property>
+  <property name="skip_pager_hint">False</property>
+  <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
+  <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
+  <property name="focus_on_map">True</property>
+  <property name="urgency_hint">False</property>
+  <signal name="delete_event" handler="QuitApplication" 
last_modification_time="Fri, 11 Aug 2006 03:07:18 GMT"/>
+
+  <child>
+    <widget class="GtkVBox" id="vbox1">
+      <property name="visible">True</property>
+      <property name="homogeneous">False</property>
+      <property name="spacing">0</property>
+
+      <child>
+       <widget class="GtkMenuBar" id="MainMenu">
+         <property name="visible">True</property>
+         <property name="pack_direction">GTK_PACK_DIRECTION_LTR</property>
+         <property 
name="child_pack_direction">GTK_PACK_DIRECTION_LTR</property>
+
+         <child>
+           <widget class="GtkMenuItem" id="menuitem1">
+             <property name="visible">True</property>
+             <property name="label" translatable="yes">_File</property>
+             <property name="use_underline">True</property>
+
+             <child>
+               <widget class="GtkMenu" id="menu1">
+
+                 <child>
+                   <widget class="GtkImageMenuItem" id="new1">
+                     <property name="visible">True</property>
+                     <property name="label">gtk-new</property>
+                     <property name="use_stock">True</property>
+                   </widget>
+                 </child>
+
+                 <child>
+                   <widget class="GtkImageMenuItem" id="open1">
+                     <property name="visible">True</property>
+                     <property name="label">gtk-open</property>
+                     <property name="use_stock">True</property>
+                   </widget>
+                 </child>
+
+                 <child>
+                   <widget class="GtkImageMenuItem" id="save1">
+                     <property name="visible">True</property>
+                     <property name="label">gtk-save</property>
+                     <property name="use_stock">True</property>
+                     <signal name="activate" handler="SaveGraph" 
last_modification_time="Fri, 11 Aug 2006 03:41:07 GMT"/>
+                   </widget>
+                 </child>
+
+                 <child>
+                   <widget class="GtkImageMenuItem" id="save_as1">
+                     <property name="visible">True</property>
+                     <property name="label">gtk-save-as</property>
+                     <property name="use_stock">True</property>
+                   </widget>
+                 </child>
+
+                 <child>
+                   <widget class="GtkSeparatorMenuItem" 
id="separatormenuitem1">
+                     <property name="visible">True</property>
+                   </widget>
+                 </child>
+
+                 <child>
+                   <widget class="GtkImageMenuItem" id="QuitItem">
+                     <property name="visible">True</property>
+                     <property name="label">gtk-quit</property>
+                     <property name="use_stock">True</property>
+                     <signal name="activate" handler="QuitApplication" 
last_modification_time="Fri, 11 Aug 2006 02:47:32 GMT"/>
+                   </widget>
+                 </child>
+               </widget>
+             </child>
+           </widget>
+         </child>
+
+         <child>
+           <widget class="GtkMenuItem" id="menuitem2">
+             <property name="visible">True</property>
+             <property name="label" translatable="yes">_Edit</property>
+             <property name="use_underline">True</property>
+
+             <child>
+               <widget class="GtkMenu" id="menu2">
+
+                 <child>
+                   <widget class="GtkImageMenuItem" id="cut1">
+                     <property name="visible">True</property>
+                     <property name="label">gtk-cut</property>
+                     <property name="use_stock">True</property>
+                   </widget>
+                 </child>
+
+                 <child>
+                   <widget class="GtkImageMenuItem" id="copy1">
+                     <property name="visible">True</property>
+                     <property name="label">gtk-copy</property>
+                     <property name="use_stock">True</property>
+                   </widget>
+                 </child>
+
+                 <child>
+                   <widget class="GtkImageMenuItem" id="paste1">
+                     <property name="visible">True</property>
+                     <property name="label">gtk-paste</property>
+                     <property name="use_stock">True</property>
+                   </widget>
+                 </child>
+
+                 <child>
+                   <widget class="GtkImageMenuItem" id="delete1">
+                     <property name="visible">True</property>
+                     <property name="label">gtk-delete</property>
+                     <property name="use_stock">True</property>
+                   </widget>
+                 </child>
+               </widget>
+             </child>
+           </widget>
+         </child>
+
+         <child>
+           <widget class="GtkMenuItem" id="menuitem3">
+             <property name="visible">True</property>
+             <property name="label" translatable="yes">_View</property>
+             <property name="use_underline">True</property>
+
+             <child>
+               <widget class="GtkMenu" id="menu3">
+               </widget>
+             </child>
+           </widget>
+         </child>
+
+         <child>
+           <widget class="GtkMenuItem" id="menuitem4">
+             <property name="visible">True</property>
+             <property name="label" translatable="yes">_Help</property>
+             <property name="use_underline">True</property>
+
+             <child>
+               <widget class="GtkMenu" id="menu4">
+
+                 <child>
+                   <widget class="GtkMenuItem" id="about1">
+                     <property name="visible">True</property>
+                     <property name="label" 
translatable="yes">_About</property>
+                     <property name="use_underline">True</property>
+                   </widget>
+                 </child>
+               </widget>
+             </child>
+           </widget>
+         </child>
+       </widget>
+       <packing>
+         <property name="padding">0</property>
+         <property name="expand">False</property>
+         <property name="fill">False</property>
+       </packing>
+      </child>
+
+      <child>
+       <placeholder/>
+      </child>
+    </widget>
+  </child>
+</widget>
+
+</glade-interface>

_______________________________________________
Mono-patches maillist  -  Mono-patches@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to