зеркало из
1
0
Форкнуть 0
Add AssemblyInfo.cs
        * sample/AssemblyInfo.cs.in: Added
        * sample/sample.cs: Cleaned up a bit
        * sample/CanvasClock.cs: Added IntPtr ctor
        * sample/CanvasClock.cs: Removed RegisterGType, not needed anymore
        * sample/CanvasFigure.cs: Ditto
        * sample/CanvasTextBox.cs: Ditto
        * NEWS: Updated with new customizing feature
        * dia/CanvasItem.custom: Change return type in delegate 'ShapeValueDelegate'
          and method 'ShapeValue_Callback' from Shape to IntPtr, for fixed bug
          produced when method ShapeValueFunc are override.
        * sample/CanvasClock.cs: Added a custom item.
        * sample/sample.cs: Added a Clock item.
        * sample/makefile.am: Added CanvasClock.cs.

svn path=/trunk/diacanvas-sharp/; revision=31849
This commit is contained in:
Martin Willemoes Hansen 2004-08-04 09:04:08 +00:00
Родитель c709e35498
Коммит 55902c8292
11 изменённых файлов: 232 добавлений и 54 удалений

Просмотреть файл

@ -1,2 +1,2 @@
Maintainer and founder:
Martin Willemoes Hansen <mwh@sysrq.dk>
Martin Willemoes Hansen <mwh@sysrq.dk> (Maintainer and founder)
Mario Fuentes <mario@gnome.cl>

Просмотреть файл

@ -1,3 +1,24 @@
2004-08-04 Martin Willemoes Hansen <mwh@sysrq.dk>
* configure.in: Bump version
Add AssemblyInfo.cs
* sample/AssemblyInfo.cs.in: Added
* sample/sample.cs: Cleaned up a bit
* sample/CanvasClock.cs: Added IntPtr ctor
* sample/CanvasClock.cs: Removed RegisterGType, not needed anymore
* sample/CanvasFigure.cs: Ditto
* sample/CanvasTextBox.cs: Ditto
* NEWS: Updated with new customizing feature
2004-08-03 Mario Fuentes <mario@gnome.cl>
* dia/CanvasItem.custom: Change return type in delegate 'ShapeValueDelegate'
and method 'ShapeValue_Callback' from Shape to IntPtr, for fixed bug
produced when method ShapeValueFunc are override.
* sample/CanvasClock.cs: Added a custom item.
* sample/sample.cs: Added a Clock item.
* sample/makefile.am: Added CanvasClock.cs.
2004-08-01 Martin Willemoes Hansen <mwh@sysrq.dk>
* dia/glue/dia-canvas-line.c: Added, more than one dash, test code.

6
NEWS
Просмотреть файл

@ -1,3 +1,9 @@
0.5.0
=====
* Posible to create customized items
* Sample custom item clock added
0.4.1
=====

Просмотреть файл

@ -1,10 +1,10 @@
AC_INIT(README)
AC_CANONICAL_SYSTEM
AM_INIT_AUTOMAKE(diacanvas-sharp, 0.4.1)
AM_INIT_AUTOMAKE(diacanvas-sharp, 0.5.0)
AM_MAINTAINER_MODE
AM_PROG_LIBTOOL
API_VERSION=0.4.1.0
API_VERSION=0.5.0.0
AC_SUBST(API_VERSION)
dnl Defines CC to avoid warnings
@ -133,6 +133,7 @@ dia/glue/makefile
doc/makefile
doc/en/makefile
doc/en/Dia/makefile
sample/AssemblyInfo.cs
sample/diacanvas-sharp-sample
sample/makefile
sample/pixmaps/makefile

Просмотреть файл

@ -139,15 +139,19 @@ protected virtual bool ShapeNextFunc (ref CanvasIter iter)
return ret_val;
}
delegate Shape ShapeValueDelegate (IntPtr item, ref CanvasIter iter);
delegate IntPtr ShapeValueDelegate (IntPtr item, ref CanvasIter iter);
static ShapeValueDelegate ShapeValueCallback;
static Shape ShapeValue_Callback (IntPtr item, ref CanvasIter iter)
static IntPtr ShapeValue_Callback (IntPtr item, ref CanvasIter iter)
{
CanvasItem obj = GLib.Object.GetObject (item, false) as CanvasItem;
return obj.ShapeValueFunc (ref iter);
Shape shape = obj.ShapeValueFunc (ref iter);
if (shape == null)
return IntPtr.Zero;
return shape.Handle;
}
[DllImport("diacanvassharpglue")]
@ -167,8 +171,8 @@ static extern IntPtr dia_canvas_item_base_shape_value (IntPtr raw, ref Dia.Canva
[GLib.DefaultSignalHandler (Type=typeof(Dia.CanvasItem), ConnectionMethod="OverrideShapeValue")]
protected virtual Shape ShapeValueFunc (ref CanvasIter iter)
{
Console.WriteLine ("protected virtual Shape ShapeValueFunc (ref CanvasIter iter)");
IntPtr raw_ret = dia_canvas_item_base_shape_value (Handle, ref iter);
Shape ret;
if (raw_ret == IntPtr.Zero)

23
sample/AssemblyInfo.cs.in Normal file
Просмотреть файл

@ -0,0 +1,23 @@
// AssemblyInfo.cs.in information about the sample
//
// Author: Martin Willemoes Hansen <mwh@sysrq.dk>
// Copyright (C) 2004 Martin Willemoes Hansen <mwh@sysrq.dk>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
using System.Reflection;
using System.Runtime.CompilerServices;
[assembly:AssemblyVersion("@API_VERSION@")]

119
sample/CanvasClock.cs Normal file
Просмотреть файл

@ -0,0 +1,119 @@
/// DiaCanvas# sample, based on dia-clock.[ch] from diacanvas2 demos.
/// Copyright (C) 2004 Mario Fuentes <mario@gnome.cl>
///
/// This library is free software; you can redistribute it and/or
/// modify it under the terms of the GNU Lesser General Public
/// License as published by the Free Software Foundation; either
/// version 2.1 of the License, or (at your option) any later version.
///
/// This library is distributed in the hope that it will be useful,
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
/// Lesser General Public License for more details.
///
/// You should have received a copy of the GNU Lesser General Public
/// License along with this library; if not, write to the Free Software
/// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
using System;
using GLib;
using Dia;
public class CanvasClock : CanvasElement {
Shape circle, hours, minutes, seconds;
uint timer;
int sec = 0;
protected CanvasClock (IntPtr intptr) : base (intptr) {}
public CanvasClock ()
{
circle = new Shape (ShapeType.Ellipse);
hours = new Shape (ShapeType.Path);
minutes = new Shape (ShapeType.Path);
seconds = new Shape (ShapeType.Path);
timer = GLib.Timeout.Add (500, new TimeoutHandler (TimeoutFunc));
}
protected override void Update (double [] affine)
{
Point center, p;
double r, t;
BaseUpdate (affine);
center = new Point (Width / 2.0, Height / 2.0);
r = Math.Min (Width, Height) / 2.0;
circle.Ellipse (center, 2 * r, 2 * r);
circle.Color = 255;
ShapeEllipse.SetFill (circle, FillStyle.Solid);
ShapeEllipse.SetFillColor (circle, 8888888);
ShapeEllipse.SetLineWidth (circle, 5.0);
//circle.RequestUpdate ();
t = sec * Math.PI / 21600.0;
p = new Point (Math.Sin (t) * r * 0.7 * center.X,
-Math.Cos (t) * r * 0.7 * center.Y);
hours.Line (center, p);
ShapePath.SetLineWidth (hours, 5.0);
hours.RequestUpdate ();
t = sec * Math.PI / 1800.0;
p = new Point (Math.Sin (t) * r * 0.85 * center.X,
-Math.Cos (t) * r * 0.85 * center.Y);
minutes.Line (center, p);
ShapePath.SetLineWidth (minutes, 4.0);
minutes.RequestUpdate ();
t = sec * Math.PI / 30.0;
p = new Point (Math.Sin (t) * r * 0.9 * center.X,
-Math.Cos (t) * r * 0.9 * center.Y);
seconds.Line (center, p);
seconds.Color = 242424;
ShapePath.SetLineWidth (seconds, 3.0);
seconds.RequestUpdate ();
}
protected override bool GetShapeIterFunc (ref CanvasIter iter)
{
iter.Data[0] = circle.Handle;
return true;
}
protected override bool ShapeNextFunc (ref CanvasIter iter)
{
if (iter.Data[0] == circle.Handle)
iter.Data[0] = hours.Handle;
else if (iter.Data[0] == hours.Handle)
iter.Data[0] = minutes.Handle;
else if (iter.Data[0] == minutes.Handle)
iter.Data[0] = seconds.Handle;
else
iter.Data[0] = IntPtr.Zero;
return (iter.Data[0] != IntPtr.Zero);
}
protected override Shape ShapeValueFunc (ref CanvasIter iter)
{
if (iter.Data[0] == IntPtr.Zero)
return null;
return new Shape (iter.Data[0]);
}
bool TimeoutFunc ()
{
DateTime dt = DateTime.Now;
int lsec = (((dt.Hour * 60) + dt.Minute) * 60) + dt.Second;
if (lsec != sec)
{
sec = lsec;
RequestUpdate ();
}
return true;
}
}

Просмотреть файл

@ -20,14 +20,7 @@ using Dia;
public class CanvasFigure : CanvasBox {
static GLib.GType gtype;
static CanvasFigure()
{
gtype = RegisterGType (typeof (CanvasFigure));
}
public CanvasFigure() : base (gtype)
public CanvasFigure()
{
ShapeEllipse ellipse = new ShapeEllipse();
ellipse.Center = new Point (20, 20);

Просмотреть файл

@ -23,15 +23,9 @@ using Pango;
public class CanvasTextBox : CanvasGroup {
static GLib.GType gtype;
CanvasText text;
static CanvasTextBox()
{
gtype = RegisterGType (typeof (CanvasTextBox));
}
public CanvasTextBox() : base (gtype)
public CanvasTextBox()
{
text = new CanvasText();
text.Font = FontDescription.FromString ("sans 20");

Просмотреть файл

@ -4,7 +4,7 @@ assemblydir= $(bindir)
assembly_DATA= diacanvas-sharp-sample.exe
bin_SCRIPTS= diacanvas-sharp-sample
CLEANFILES= $(assembly_DATA)
DISTCLEANFILES= $(bin_SCRIPTS)
DISTCLEANFILES= $(bin_SCRIPTS) AssemblyInfo.cs
resources= -resource:glade/gui.glade,gui.glade \
-resource:pixmaps/logo.png,logo.png \
@ -19,12 +19,13 @@ references= -pkg:gnome-sharp,glade-sharp -r:../dia/diacanvas-sharp.dll
sources= CanvasFigure.cs \
CanvasTextBox.cs \
CanvasClock.cs \
sample.cs
build_sources = $(addprefix $(srcdir)/, $(sources))
dist_sources = $(sources)
build_sources = $(addprefix $(srcdir)/, $(sources)) AssemblyInfo.cs
EXTRA_DIST= $(dist_sources)
EXTRA_DIST= $(sources) \
AssemblyInfo.cs.in
$(assembly_DATA): *.cs ../dia/diacanvas-sharp.dll
$(CSC) /out:$(assembly_DATA) $(resources) $(references) $(build_sources)

Просмотреть файл

@ -17,6 +17,7 @@
using System;
using System.Collections;
using System.Reflection;
using Dia;
using GLib;
@ -60,6 +61,26 @@ public class Sample {
}
void CreateItemsProgramatically() {
// Adding image
CanvasImage image = new CanvasImage (new Pixbuf (null, "logo.png"));
image.Move (50, 50);
canvas.Root.Add (image);
// Adding textbox
CanvasTextBox textbox = new CanvasTextBox();
textbox.Move (50, 150);
canvas.Root.Add (textbox);
// Adding text
Dia.CanvasText text = new Dia.CanvasText();
text.Text = "Hello, World!";
text.Font = FontDescription.FromString ("sans 20");
text.Height = 50;
text.Width = 190;
text.Move (300, 150);
canvas.Root.Add (text);
// Adding line
Dia.CanvasLine line = new Dia.CanvasLine();
line.LineWidth = 10;
line.Color = 8327327;
@ -68,37 +89,29 @@ public class Sample {
line.HeadPos = new Dia.Point (50, 70);;
line.TailPos = new Dia.Point (100, 170);
line.Cap = Dia.CapStyle.Butt;
line.Move (100, 150);
line.Move (50, 150);
canvas.Root.Add (line);
// Adding box
CanvasBox box = new CanvasBox();
box.Move (300, 200);
box.BorderWidth = 8.5;
box.Color = 2134231;
box.Move (250, 225);
canvas.Root.Add (box);
Dia.CanvasText text = new Dia.CanvasText();
text.Move (250, 150);
text.Text = "Hello, World!";
text.Font = FontDescription.FromString ("sans 20");
text.Height = 50;
text.Width = 190;
canvas.Root.Add (text);
// Adding custom clock
CanvasClock clock = new CanvasClock ();
clock.Width = 100;
clock.Height = 100;
clock.Move (450, 225);
canvas.Root.Add (clock);
CanvasTextBox textbox = new CanvasTextBox();
textbox.Move (50, 120);
canvas.Root.Add (textbox);
// Adding custom figure
CanvasFigure figure = new CanvasFigure();
figure.Move (50, 325);
canvas.Root.Add (figure);
//Exposes some bug
//CanvasFigure figure = new CanvasFigure();
//figure.Move (50, 250);
//canvas.Root.Add (figure);
CanvasImage image = new CanvasImage (new Pixbuf (null, "logo.png"));
image.Move (50, 50);
canvas.Root.Add (image);
view.UnselectAll();
view.UnselectAll();
CanvasViewItem vitem = view.FindViewItem (image);
view.Focus (vitem);
}
@ -240,22 +253,25 @@ public class Sample {
void About (object sender, EventArgs args)
{
Assembly assembly = Assembly.GetExecutingAssembly();
string [] authors = new String [] {
"Martin Willemoes Hansen",
"Martin Willemoes Hansen <mwh@sysrq.dk> (Maintainer and founder)",
"Mario Fuentes <mario@gnome.cl>",
};
string [] documenters = new String [] {};
string translators = null;
Pixbuf pixbuf = new Pixbuf(null, "logo.png");
new Gnome.About ("DiaCanvas# Sample", "0.1",
new Gnome.About ("DiaCanvas# Sample", assembly.GetName().Version.ToString(),
@"Copyright (C) 2003 2004 Martin Willemoes Hansen
DiaCanvas# Sample comes with ABSOLUTELY NO WARRANTY;
This is free software, and you are welcome to
redistribute it under certain conditions;
see the text file: COPYRIGHT, distributed
with this program.",
"DiaCanvas, Mono and Gtk# rocks!",
"DiaCanvas, Mono and Gtk# rock!",
authors, documenters, translators, pixbuf).Show();
}