Permalink
Browse files

* Examples/Demo/MainWindow.cs:

* Examples/Demo/gtk-gui/gui.stetic:
* Examples/Demo/gtk-gui/MainWindow.cs: Demo/MainWindow updated to
  control zooming and show visible area

* MonoHotDraw/StandardDrawingView.cs: Added zooming support

* MonoHotDraw/MonoHotDraw.Handles/PixbufHandle.cs:
* MonoHotDraw/MonoHotDraw.Handles/PolyLineHandle.cs:
* MonoHotDraw/MonoHotDraw.Handles/UndoableHandle.cs:
* MonoHotDraw/MonoHotDraw.Handles/ToggleButtonHandle.cs:
* MonoHotDraw/MonoHotDraw.Handles/ChangeConnectionHandle.cs: Updated
  references to DisplayBox

* MonoHotDraw/MonoHotDraw.csproj: SelectAreaTool Renamed

* MonoHotDraw/MonoHotDraw.Handles/IHandle.cs:
* MonoHotDraw/MonoHotDraw.Handles/AbstractHandle.cs: Removed
  DisplayBox property. Changed Size. Added Width and Height
  properties.

* MonoHotDraw/IDrawingView.cs: Added Scale Property and
  VisibleAreaChanged event

* MonoHotDraw/MonoHotDraw.Tools/SelectionTool.cs:
* MonoHotDraw/MonoHotDraw.Tools/SelectAreaTool.cs:
* MonoHotDraw/MonoHotDraw.Tools/SelectAreaTracker.cs:
  SelectAreaTracker renamed to SelectAreaTool

svn path=/trunk/monohotdraw/; revision=139988
  • Loading branch information...
2 parents db93d39 + 761f8dc commit 82a3d37ef419c644101bdeae53d8c85b05e3a250 Manuel Cerón committed Aug 15, 2009
View
@@ -1,3 +1,8 @@
+2009-08-14 Manuel Cerón <ceronman@gmail.com>
+
+ * MainWindow.cs: Demo/MainWindow updated to control zooming
+ and show visible area
+
2009-07-27 Manuel Cerón <ceronman@gmail.com>
* MainWindow.cs: Added simple demo of the new
@@ -11,6 +11,11 @@ public partial class MainWindow: Gtk.Window
mhdcanvas.UndoStackChanged += delegate {
UpdateUndoRedo();
};
+
+ visiblearea.Text = mhdcanvas.View.VisibleArea.ToString();
+ mhdcanvas.View.VisibleAreaChanged += delegate {
+ visiblearea.Text = mhdcanvas.View.VisibleArea.ToString();
+ };
}
protected void OnDeleteEvent (object sender, DeleteEventArgs a) {
@@ -60,4 +65,9 @@ protected virtual void OnUndoActionActivated (object sender, System.EventArgs e)
UndoAction.Sensitive = mhdcanvas.UndoManager.Undoable;
RedoAction.Sensitive = mhdcanvas.UndoManager.Redoable;
}
+
+ protected virtual void OnHscale1ValueChanged (object sender, System.EventArgs e)
+ {
+ mhdcanvas.View.Scale = zoomscale.Value / 100.0;
+ }
}
@@ -1,3 +1,9 @@
+2009-08-14 Manuel Cerón <ceronman@gmail.com>
+
+ * gui.stetic:
+ * MainWindow.cs: Demo/MainWindow updated to control zooming
+ and show visible area
+
2009-06-10 Manuel Cerón <ceronman@gmail.com>
* gui.stetic:
@@ -40,6 +40,18 @@ public partial class MainWindow {
private MonoHotDraw.SteticComponent mhdcanvas;
+ private Gtk.HBox hbox1;
+
+ private Gtk.HBox hbox2;
+
+ private Gtk.Label label2;
+
+ private Gtk.HScale zoomscale;
+
+ private Gtk.Label label3;
+
+ private Gtk.Label visiblearea;
+
protected virtual void Build() {
Stetic.Gui.Initialize(this);
// Widget MainWindow
@@ -100,6 +112,63 @@ public partial class MainWindow {
this.vbox1.Add(this.mhdcanvas);
Gtk.Box.BoxChild w3 = ((Gtk.Box.BoxChild)(this.vbox1[this.mhdcanvas]));
w3.Position = 1;
+ // Container child vbox1.Gtk.Box+BoxChild
+ this.hbox1 = new Gtk.HBox();
+ this.hbox1.Name = "hbox1";
+ this.hbox1.Spacing = 6;
+ // Container child hbox1.Gtk.Box+BoxChild
+ this.hbox2 = new Gtk.HBox();
+ this.hbox2.Name = "hbox2";
+ this.hbox2.Spacing = 6;
+ // Container child hbox2.Gtk.Box+BoxChild
+ this.label2 = new Gtk.Label();
+ this.label2.Name = "label2";
+ this.label2.LabelProp = Mono.Unix.Catalog.GetString("Zoom:");
+ this.hbox2.Add(this.label2);
+ Gtk.Box.BoxChild w4 = ((Gtk.Box.BoxChild)(this.hbox2[this.label2]));
+ w4.Position = 0;
+ w4.Expand = false;
+ w4.Fill = false;
+ // Container child hbox2.Gtk.Box+BoxChild
+ this.zoomscale = new Gtk.HScale(null);
+ this.zoomscale.CanFocus = true;
+ this.zoomscale.Name = "zoomscale";
+ this.zoomscale.Adjustment.Lower = 10;
+ this.zoomscale.Adjustment.Upper = 500;
+ this.zoomscale.Adjustment.PageIncrement = 50;
+ this.zoomscale.Adjustment.StepIncrement = 1;
+ this.zoomscale.Adjustment.Value = 100;
+ this.zoomscale.DrawValue = true;
+ this.zoomscale.Digits = 0;
+ this.zoomscale.ValuePos = ((Gtk.PositionType)(3));
+ this.hbox2.Add(this.zoomscale);
+ Gtk.Box.BoxChild w5 = ((Gtk.Box.BoxChild)(this.hbox2[this.zoomscale]));
+ w5.Position = 1;
+ // Container child hbox2.Gtk.Box+BoxChild
+ this.label3 = new Gtk.Label();
+ this.label3.Name = "label3";
+ this.label3.LabelProp = Mono.Unix.Catalog.GetString("Visible Area:");
+ this.hbox2.Add(this.label3);
+ Gtk.Box.BoxChild w6 = ((Gtk.Box.BoxChild)(this.hbox2[this.label3]));
+ w6.Position = 2;
+ w6.Expand = false;
+ w6.Fill = false;
+ this.hbox1.Add(this.hbox2);
+ Gtk.Box.BoxChild w7 = ((Gtk.Box.BoxChild)(this.hbox1[this.hbox2]));
+ w7.Position = 0;
+ // Container child hbox1.Gtk.Box+BoxChild
+ this.visiblearea = new Gtk.Label();
+ this.visiblearea.Name = "visiblearea";
+ this.visiblearea.LabelProp = Mono.Unix.Catalog.GetString("~");
+ this.hbox1.Add(this.visiblearea);
+ Gtk.Box.BoxChild w8 = ((Gtk.Box.BoxChild)(this.hbox1[this.visiblearea]));
+ w8.Position = 1;
+ w8.Expand = false;
+ w8.Fill = false;
+ this.vbox1.Add(this.hbox1);
+ Gtk.Box.BoxChild w9 = ((Gtk.Box.BoxChild)(this.vbox1[this.hbox1]));
+ w9.Position = 2;
+ w9.Expand = false;
this.Add(this.vbox1);
if ((this.Child != null)) {
this.Child.ShowAll();
@@ -116,5 +185,6 @@ public partial class MainWindow {
this.AddLineConnectionAction.Activated += new System.EventHandler(this.OnAddLineConnectionActionActivated);
this.UndoAction.Activated += new System.EventHandler(this.OnUndoActionActivated);
this.RedoAction.Activated += new System.EventHandler(this.OnRedoActionActivated);
+ this.zoomscale.ValueChanged += new System.EventHandler(this.OnHscale1ValueChanged);
}
}
@@ -117,6 +117,82 @@
<property name="AutoSize">False</property>
</packing>
</child>
+ <child>
+ <widget class="Gtk.HBox" id="hbox1">
+ <property name="MemberName" />
+ <property name="Spacing">6</property>
+ <child>
+ <widget class="Gtk.HBox" id="hbox2">
+ <property name="MemberName" />
+ <property name="Spacing">6</property>
+ <child>
+ <widget class="Gtk.Label" id="label2">
+ <property name="MemberName" />
+ <property name="LabelProp" translatable="yes">Zoom:</property>
+ </widget>
+ <packing>
+ <property name="Position">0</property>
+ <property name="AutoSize">True</property>
+ <property name="Expand">False</property>
+ <property name="Fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="Gtk.HScale" id="zoomscale">
+ <property name="MemberName" />
+ <property name="CanFocus">True</property>
+ <property name="Lower">10</property>
+ <property name="Upper">500</property>
+ <property name="PageIncrement">50</property>
+ <property name="StepIncrement">1</property>
+ <property name="Value">100</property>
+ <property name="DrawValue">True</property>
+ <property name="Digits">0</property>
+ <property name="ValuePos">Bottom</property>
+ <signal name="ValueChanged" handler="OnHscale1ValueChanged" />
+ </widget>
+ <packing>
+ <property name="Position">1</property>
+ <property name="AutoSize">True</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="Gtk.Label" id="label3">
+ <property name="MemberName" />
+ <property name="LabelProp" translatable="yes">Visible Area:</property>
+ </widget>
+ <packing>
+ <property name="Position">2</property>
+ <property name="AutoSize">True</property>
+ <property name="Expand">False</property>
+ <property name="Fill">False</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="Position">0</property>
+ <property name="AutoSize">True</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="Gtk.Label" id="visiblearea">
+ <property name="MemberName" />
+ <property name="LabelProp" translatable="yes">~</property>
+ </widget>
+ <packing>
+ <property name="Position">1</property>
+ <property name="AutoSize">True</property>
+ <property name="Expand">False</property>
+ <property name="Fill">False</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="Position">2</property>
+ <property name="AutoSize">False</property>
+ <property name="Expand">False</property>
+ </packing>
+ </child>
</widget>
</child>
</widget>
View
@@ -1,3 +1,12 @@
+2009-08-14 Manuel Cerón <ceronman@gmail.com>
+
+ * StandardDrawingView.cs: Added zooming support
+
+ * MonoHotDraw.csproj: SelectAreaTool Renamed
+
+ * IDrawingView.cs: Added Scale Property and VisibleAreaChanged
+ event
+
2009-07-09 Manuel Cerón <ceronman@gmail.com>
* MonoHotDraw.csproj: Renamed VerStackFigure to VStackFigure
@@ -26,6 +26,7 @@
using Cairo;
using Gdk;
+using System;
using System.Collections.Generic;
using MonoHotDraw.Figures;
using MonoHotDraw.Handles;
@@ -57,15 +58,14 @@ public interface IDrawingView {
IEnumerable <IFigure> SelectionEnumerator { get; }
int SelectionCount { get; }
RectangleD VisibleArea { get; }
+ double Scale { get; set; }
void AddWidget (Gtk.Widget w, double x, double y);
void MoveWidget (Gtk.Widget w, double x, double y);
void RemoveWidget (Gtk.Widget w);
void ClearWidgets ();
-
-// bool IsFrozenView { get; }
-// void FreezeView ();
-// void UnfreezeView ();
+
+ event EventHandler VisibleAreaChanged;
}
}
@@ -34,7 +34,7 @@ namespace MonoHotDraw.Handles {
public abstract class AbstractHandle : IHandle {
- public static readonly double Size = 4.0;
+ public static readonly double Size = 8.0;
protected AbstractHandle (IFigure owner) {
Owner = owner;
@@ -46,15 +46,15 @@ public abstract class AbstractHandle : IHandle {
public virtual Gdk.Cursor CreateCursor () {
return null;
}
-
- public virtual RectangleD DisplayBox {
- get {
- PointD p = Locate ();
- RectangleD rect = new RectangleD (p, p);
- rect.Inflate (Size, Size);
- rect.OffsetDot5 ();
- return rect;
- }
+
+ public virtual double Width {
+ get { return Size; }
+ set {}
+ }
+
+ public virtual double Height {
+ get { return Size; }
+ set {}
}
public virtual IFigure Owner { get; set; }
@@ -75,13 +75,16 @@ public abstract class AbstractHandle : IHandle {
public Color LineColor { get; set; }
public bool ContainsPoint (double x, double y) {
- return DisplayBox.Contains (x, y);
+ RectangleD displayBox = new RectangleD(Locate());
+ displayBox.Inflate(Width/2, Height/2);
+ return displayBox.Contains(x, y);
}
- public virtual void Draw (Context context) {
+ public virtual void Draw (Context context, IDrawingView view) {
+ RectangleD rect = ViewDisplayBox(view);
context.Save();
context.LineWidth = LineWidth;
- context.Rectangle (GdkCairoHelper.CairoRectangle (DisplayBox));
+ context.Rectangle (GdkCairoHelper.CairoRectangle (rect));
context.Color = FillColor;
context.FillPreserve ();
context.Color = LineColor;
@@ -107,6 +110,19 @@ public abstract class AbstractHandle : IHandle {
protected virtual void UpdateUndoActivity() {
}
+
+ protected virtual RectangleD ViewDisplayBox(IDrawingView view) {
+ if (view == null)
+ throw new ArgumentNullException("view");
+
+ PointD center = Locate();
+ center = view.DrawingToView(center.X, center.Y);
+ RectangleD displayBox = new RectangleD(center);
+ displayBox.Inflate(Width/2, Height/2);
+ displayBox.OffsetDot5();
+
+ return displayBox;
+ }
private double _lineWidth;
}
@@ -63,14 +63,16 @@ public abstract class ChangeConnectionHandle: AbstractHandle {
Connection.UpdateConnection ();
}
- public override void Draw (Context context) {
+ public override void Draw (Context context, IDrawingView view) {
+ RectangleD rect = ViewDisplayBox(view);
+
context.LineWidth = LineWidth;
- context.MoveTo (DisplayBox.Center.X, DisplayBox.Top);
- context.LineTo (DisplayBox.Right, DisplayBox.Center.Y);
- context.LineTo (DisplayBox.Center.X, DisplayBox.Bottom);
- context.LineTo (DisplayBox.Left, DisplayBox.Center.Y);
- context.LineTo (DisplayBox.Center.X, DisplayBox.Top);
+ context.MoveTo (rect.Center.X, rect.Top);
+ context.LineTo (rect.Right, rect.Center.Y);
+ context.LineTo (rect.Center.X, rect.Bottom);
+ context.LineTo (rect.Left, rect.Center.Y);
+ context.LineTo (rect.Center.X, rect.Top);
context.Color = new Cairo.Color (1.0, 0.0, 0.0, 0.8);
context.FillPreserve ();
@@ -1,3 +1,15 @@
+2009-08-14 Manuel Cerón <ceronman@gmail.com>
+
+ * PixbufHandle.cs:
+ * PolyLineHandle.cs:
+ * UndoableHandle.cs:
+ * ToggleButtonHandle.cs:
+ * ChangeConnectionHandle.cs: Updated references to DisplayBox
+
+ * IHandle.cs:
+ * AbstractHandle.cs: Removed DisplayBox property. Changed
+ Size. Added Width and Height properties.
+
2009-07-10 Manuel Cerón <ceronman@gmail.com>
* AbstractHandle.cs:
@@ -41,11 +41,12 @@ public interface IHandle {
void InvokeStart (double x, double y, IDrawingView view);
void InvokeStep (double x, double y, IDrawingView view);
void InvokeEnd (double x, double y, IDrawingView view);
- void Draw (Context context);
+ void Draw (Context context, IDrawingView view);
Gdk.Cursor CreateCursor ();
- RectangleD DisplayBox { get; }
IFigure Owner { get; }
IUndoActivity UndoActivity { get; set; }
+ double Width { get; }
+ double Height { get; }
}
}
Oops, something went wrong.

0 comments on commit 82a3d37

Please sign in to comment.