summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 40e75a0)
raw | patch | inline | side by side (parent: 40e75a0)
author | cilix42 <cilix42@users.sourceforge.net> | |
Wed, 30 Jul 2008 10:57:19 +0000 (10:57 +0000) | ||
committer | cilix42 <cilix42@users.sourceforge.net> | |
Wed, 30 Jul 2008 10:57:19 +0000 (10:57 +0000) |
index d28f63600ddc2d78170ae00cfcad1a2fa68c6e48..5b0acb31d1cd932ece1e8fa1bdd736ad4928dd2b 100644 (file)
**/
#include <sstream>
#include <string.h>
+#include <desktop.h>
/**
#ifdef HAVE_CONFIG_H
canvastext->affine = NR::identity();
canvastext->fontsize = 10.0;
canvastext->item = NULL;
+ canvastext->desktop = NULL;
canvastext->text = NULL;
}
@@ -426,12 +428,14 @@ sp_canvastext_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned int
}
SPCanvasItem *
-sp_canvastext_new(SPCanvasGroup *parent, Geom::Point pos, char *new_text)
+sp_canvastext_new(SPCanvasGroup *parent, SPDesktop *desktop, Geom::Point pos, char *new_text)
{
SPCanvasItem *item = sp_canvas_item_new(parent, SP_TYPE_CANVASTEXT, NULL);
SPCanvasText *ct = SP_CANVASTEXT(item);
+ ct->desktop = desktop;
+
ct->s = pos;
g_free(ct->text);
ct->text = g_strdup(new_text);
void
sp_canvastext_set_coords (SPCanvasText *ct, gdouble x0, gdouble y0)
{
+ sp_canvastext_set_coords(ct, NR::Point(x0, y0));
+}
+
+void
+sp_canvastext_set_coords (SPCanvasText *ct, const NR::Point start)
+{
+ NR::Point pos = ct->desktop->doc2dt(start);
+
g_return_if_fail (ct != NULL);
g_return_if_fail (SP_IS_CANVASTEXT (ct));
- if (DIFFER (x0, ct->s[NR::X]) || DIFFER (y0, ct->s[NR::Y])) {
- ct->s[NR::X] = x0;
- ct->s[NR::Y] = y0;
+ if (DIFFER (pos[0], ct->s[NR::X]) || DIFFER (pos[1], ct->s[NR::Y])) {
+ ct->s[NR::X] = pos[0];
+ ct->s[NR::Y] = pos[1];
sp_canvas_item_request_update (SP_CANVAS_ITEM (ct));
}
sp_canvas_item_request_update (SP_CANVAS_ITEM (ct));
}
-void
-sp_canvastext_set_coords (SPCanvasText *ct, const NR::Point start)
-{
- sp_canvastext_set_coords(ct, start[0], start[1]);
-}
-
void
sp_canvastext_set_text (SPCanvasText *ct, const char* new_text)
{
index 0f0b444844dbf018883e8be40eba84fd88996b3d..5a6e6e7ff6bc810c0c63bc5fb24f9d215bb2248c 100644 (file)
@@ -101,6 +101,7 @@ void sp_canvas_bpath_set_stroke (SPCanvasBPath *cbp, guint32 rgba, gdouble width
*/
struct SPItem;
+struct SPDesktop;
#define SP_TYPE_CANVASTEXT (sp_canvastext_get_type ())
#define SP_CANVASTEXT(obj) (GTK_CHECK_CAST ((obj), SP_TYPE_CANVASTEXT, SPCanvasText))
struct SPCanvasText : public SPCanvasItem{
SPItem *item; // the item to which this line belongs in some sense; may be NULL for some users
guint32 rgba;
+ SPDesktop *desktop; // the desktop to which this text is attached; needed for coordinate transforms (TODO: these should be eliminated)
char* text;
NR::Point s;
GtkType sp_canvastext_get_type (void);
-SPCanvasItem *sp_canvastext_new(SPCanvasGroup *parent, Geom::Point pos, char *text);
+SPCanvasItem *sp_canvastext_new(SPCanvasGroup *parent, SPDesktop *desktop, Geom::Point pos, char *text);
void sp_canvastext_set_rgba32 (SPCanvasText *ct, guint32 rgba);
void sp_canvastext_set_coords (SPCanvasText *ct, gdouble x0, gdouble y0);
index e90163781203c7f60f5ee5be5edd9867650e77a6..f41e752cbd46bcce6b3998334c4250a2a36d6f09 100644 (file)
g_free(dist);
double angle = Geom::angle_between(dir, Geom::Point(1,0));
- info_text.setPos(inkscape_active_desktop()->doc2dt((A + B) / 2 + 2.0 * n).to_2geom());
+ info_text.setPos((A + B) / 2 + 2.0 * n);
info_text.setAnchor(std::sin(angle), -std::cos(angle));
Point C, D;
index f55dca4d8826ecea2040e366da53d8e1b15482a8..fab69578ad20fbd86d11d2ec87928f13b9ae8ebc 100644 (file)
value(default_value),
defvalue(default_value)
{
- canvas_text = (SPCanvasText *) sp_canvastext_new(sp_desktop_tempgroup(inkscape_active_desktop()), Geom::Point(0,0), "");
+ SPDesktop *desktop = inkscape_active_desktop(); // FIXME: we shouldn't use this!
+ canvas_text = (SPCanvasText *) sp_canvastext_new(sp_desktop_tempgroup(desktop), desktop, Geom::Point(0,0), "");
sp_canvastext_set_text (canvas_text, default_value.c_str());
sp_canvastext_set_coords (canvas_text, 0, 0);
}