зеркало из
1
0
Форкнуть 0
* sample/glade/gui.glade: Cleaned up.
        * glue/dia-canvas-item.c: Added
        * dia/CanvasItem.custom: Added access to connected_handles
        * glue/dia-canvas-view.c:
        * dia/CanvasView.custom: Added access to handle_layer
        * dia/PlacementTool.cs: Initial grabbing functionallity
        * PROBLEMS: Added fields which are not what they seem.

svn path=/trunk/diacanvas-sharp/; revision=18012
This commit is contained in:
Martin Willemoes Hansen 2003-09-09 11:29:37 +00:00
Родитель d402a71b80
Коммит db21c8b13b
10 изменённых файлов: 146 добавлений и 26 удалений

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

@ -1,3 +1,14 @@
2003-09-09 Martin Willemoes Hansen <mwh@sysrq.dk>
* sample/sample.cs:
* sample/glade/gui.glade: Cleaned up.
* glue/dia-canvas-item.c: Added
* dia/CanvasItem.custom: Added access to connected_handles
* glue/dia-canvas-view.c:
* dia/CanvasView.custom: Added access to handle_layer
* dia/PlacementTool.cs: Initial grabbing functionallity
* PROBLEMS: Added fields which are not what they seem.
2003-09-04 Martin Willemoes Hansen <mwh@sysrq.dk>
* dia/CanvasImage.cs:

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

@ -60,6 +60,17 @@ o Select all, then try to move stuff around.
================================================================================
Fields which are not what they seem to be
--------------------------------------------
o dia-canvas.h
DiaCanvasItem *root is realy a DiaCanvasGroup
o dia-canvas-view.h
GnomeCanvasItem *handle_layer is realy a DiaHandleLayer
================================================================================
Character encoding problem (FIXED)
----------------------------------

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

@ -12,3 +12,15 @@ extern static IntPtr dia_canvas_item_create (uint object_type, IntPtr dummy);
public static CanvasItem ItemCreate (uint object_type) {
return new CanvasItem (dia_canvas_item_create (object_type, IntPtr.Zero));
}
[DllImport("diasharpglue")]
extern static IntPtr diasharp_canvas_item_get_handles (IntPtr item);
public IList Handles {
get {
GLib.List glist = new GLib.List (diasharp_canvas_item_get_handles (Handle));
ArrayList list = new ArrayList (glist.Count);
foreach (object o in glist) list.Add (o);
return list;
}
}

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

@ -27,4 +27,14 @@ public CanvasViewItem FocusItem {
}
}
[DllImport ("diasharpglue")]
extern static IntPtr diasharp_canvas_view_get_handle_layer (IntPtr view);
public HandleLayer HandleLayer {
get {
return new HandleLayer (diasharp_canvas_view_get_handle_layer (Handle));
}
}

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

@ -11,7 +11,7 @@ namespace Dia {
public class PlacementTool : Tool {
static GLib.Type gtype;
object [] attr;
object [] properties;
Type type;
static PlacementTool()
@ -19,33 +19,33 @@ namespace Dia {
gtype = RegisterGType (typeof (PlacementTool));
}
public PlacementTool (Type type, params object [] attributes)
public PlacementTool (Type type, params object [] properties)
: base (gtype)
{
if (attributes.Length % 2 == 1)
throw new ArgumentException ("A pair of attributes has only 1 member, it must have 2.");
if (properties.Length % 2 == 1)
throw new ArgumentException ("A property name does not have a value associated.");
this.attr = attributes;
this.properties = properties;
this.type = type;
ButtonPressEvent += new DiaSharp.ButtonPressEventHandler (ButtonPress);
}
public void ButtonPress (object o, DiaSharp.ButtonPressEventArgs args)
void ButtonPress (object o, DiaSharp.ButtonPressEventArgs args)
{
CanvasItem item = CreateItem();
MoveItem (args.View, args.Button, item);
args.View.Canvas.Root.Add (item);
GrabHandle (args.View, args.Button, item);
MoveItem (args.View, args.Button, item);
//GrabHandle (args.View, args.Button, item);
}
CanvasItem CreateItem()
{
CanvasItem item = (CanvasItem) Activator.CreateInstance (type);
for (int i = 0; i < attr.Length; i += 2) {
item.SetProperty ((string)attr [i],
new GLib.Value (attr [i + 1]));
for (int i = 0; i < properties.Length; i += 2) {
item.SetProperty ((string)properties [i],
new GLib.Value (properties [i + 1]));
}
return item;
}
@ -59,7 +59,41 @@ namespace Dia {
void GrabHandle (CanvasView view, Gdk.EventButton evnt, CanvasItem item)
{
if (item is CanvasLine) {
/*
wx, wy = view.window_to_world(event.x, event.y)
dist, glue, glue_to = view.canvas.glue_handle (first, wx, wy)
if glue_to and (dist <= view.handle_layer.glue_distance):
glue_to.connect_handle(first)
view.handle_layer.grab_handle(last)
*/
Handle first = null;
Handle last = null;
bool started = true;
foreach (Handle handle in item.Handles) {
if (started)
first = handle;
else
last = handle;
started = false;
}
view.HandleLayer.GrabHandle (first);
} else if (item is CanvasElement) {
Handle handle_se = null;
int counter = 0;
foreach (Handle handle in item.Handles) {
if (counter++ != (int)CanvasElementHandle.Se) {
continue;
}
handle_se = handle;
}
view.HandleLayer.GrabHandle (handle_se);
}
}
}
}

20
glue/dia-canvas-item.c Normal file
Просмотреть файл

@ -0,0 +1,20 @@
/* dia-canvas-item.c : Glue for accessing fields in the DiaCanvasItem class.
*
* Author: Martin Willemoes Hansen
*
* Copyright (C) 2003 Martin Willemoes Hansen
*
*/
#include <diacanvas/dia-canvas-item.h>
/* Forward declarations */
GList * diasharp_canvas_item_get_handles (DiaCanvasItem * item);
/* */
GList *
diasharp_canvas_item_get_handles (DiaCanvasItem * item)
{
return item->handles;
}

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

@ -11,6 +11,8 @@
/* Forward declarations */
GList * diasharp_canvas_view_get_selected_items (DiaCanvasView * view);
DiaCanvasViewItem * diasharp_canvas_view_get_focus_item (DiaCanvasView * view);
GnomeCanvasItem * diasharp_canvas_view_get_handle_layer (DiaCanvasView * view);
/* */
GList *
@ -24,3 +26,9 @@ diasharp_canvas_view_get_focus_item (DiaCanvasView * view)
{
return view->focus_item;
}
GnomeCanvasItem *
diasharp_canvas_view_get_handle_layer (DiaCanvasView * view)
{
return view->handle_layer;
}

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

@ -332,7 +332,7 @@
<property name="inconsistent">False</property>
<property name="draw_indicator">False</property>
<property name="group">tool1</property>
<signal name="clicked" handler="ZoomTool" last_modification_time="Fri, 11 Jul 2003 08:01:57 GMT"/>
<signal name="toggled" handler="ZoomTool" last_modification_time="Fri, 05 Sep 2003 08:50:37 GMT"/>
<child>
<widget class="GtkImage" id="image2">

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

@ -171,6 +171,7 @@
<property name="visible">True</property>
<property name="label">gtk-delete</property>
<property name="use_stock">True</property>
<signal name="activate" handler="DeleteSelectedItems" last_modification_time="Fri, 08 Aug 2003 08:58:21 GMT"/>
</widget>
</child>
@ -331,7 +332,7 @@
<property name="inconsistent">False</property>
<property name="draw_indicator">False</property>
<property name="group">tool1</property>
<signal name="clicked" handler="ZoomTool" last_modification_time="Fri, 11 Jul 2003 08:01:57 GMT"/>
<signal name="toggled" handler="ZoomTool" last_modification_time="Fri, 05 Sep 2003 08:50:37 GMT"/>
<child>
<widget class="GtkImage" id="image2">

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

@ -1,3 +1,20 @@
/// DiaCanvas# sample
/// Copyright (C) 2003 Martin Willemoes Hansen <mwh@sysrq.dk>
///
/// This program is free software; you can redistribute it and/or modify
/// it under the terms of the GNU General Public License as published by
/// the Free Software Foundation; either version 2 of the License, or
/// (at your option) any later version.
///
/// This program 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 General Public License for more details.
///
/// You should have received a copy of the GNU General Public License
/// along with this program; if not, write to the Free Software
/// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
using System;
using System.Collections;
@ -83,20 +100,23 @@ public class Sample {
void SelectionTool (object sender, EventArgs args)
{
ToolCleanUp();
view.Tool = new StackTool();
}
bool zoom_enabled = false;
void ZoomTool (object sender, EventArgs args)
{
ToolCleanUp();
view.Tool = new Tool (IntPtr.Zero);
view.ButtonPressEvent += new ButtonPressEventHandler (Zoom);
zoom_enabled = !zoom_enabled;
if (zoom_enabled) {
view.Tool = new Tool (IntPtr.Zero);
view.ButtonPressEvent += new ButtonPressEventHandler (Zoom);
} else
view.ButtonPressEvent -= new ButtonPressEventHandler (Zoom);
}
void LineTool (object sender, EventArgs args)
{
ToolCleanUp();
view.Tool = new PlacementTool (typeof (CanvasLine),
"line_width", 4,
"color", 480975);
@ -105,14 +125,12 @@ public class Sample {
void BoxTool (object sender, EventArgs args)
{
ToolCleanUp();
view.Tool = new PlacementTool (typeof (CanvasBox));
view.Tool.ButtonReleaseEvent += new DiaSharp.ButtonReleaseEventHandler (UnsetTool);
}
void ImageTool (object sender, EventArgs args)
{
ToolCleanUp();
Pixbuf pixbuf = new Pixbuf (null, "pixmaps/logo.png");
view.Tool = new PlacementTool (typeof (CanvasImage),
"image", pixbuf,
@ -121,13 +139,7 @@ public class Sample {
view.Tool.ButtonReleaseEvent += new DiaSharp.ButtonReleaseEventHandler (UnsetTool);
}
void ToolCleanUp()
{
view.ButtonPressEvent -= new ButtonPressEventHandler (Zoom);
}
[Glade.Widget] RadioButton tool1;
void UnsetTool (object sender, DiaSharp.ButtonReleaseEventArgs args)
{
if (ctrl)
@ -138,6 +150,7 @@ public class Sample {
void Zoom (object sender, ButtonPressEventArgs args)
{
if (ctrl)
ZoomOut (this, null);
else