diff options
Diffstat (limited to 'src/sp-guide.h')
| -rw-r--r-- | src/sp-guide.h | 78 |
1 files changed, 49 insertions, 29 deletions
diff --git a/src/sp-guide.h b/src/sp-guide.h index fa4f0033b..382ea56f0 100644 --- a/src/sp-guide.h +++ b/src/sp-guide.h @@ -13,15 +13,21 @@ * */ +#include <2geom/point.h> #include <vector> -#include <2geom/point.h> #include "sp-object.h" #include "sp-guide-attachment.h" +typedef unsigned int guint32; +extern "C" { + typedef void (*GCallback) (void); + typedef struct _GSList GSList; +} + +class SPDesktop; struct SPCanvas; struct SPCanvasGroup; -class SPDesktop; #define SP_GUIDE(obj) (dynamic_cast<SPGuide*>((SPObject*)obj)) #define SP_IS_GUIDE(obj) (dynamic_cast<const SPGuide*>((SPObject*)obj) != NULL) @@ -29,51 +35,65 @@ class SPDesktop; /* Represents the constraint on p that dot(g.direction, p) == g.position. */ class SPGuide : public SPObject { public: - SPGuide(); - virtual ~SPGuide(); + SPGuide(); + virtual ~SPGuide() {} - char* label; - Geom::Point normal_to_line; - Geom::Point point_on_line; + void set_color(const unsigned r, const unsigned g, const unsigned b, bool const commit); + void setColor(guint32 c); + void setHiColor(guint32 h) { hicolor = h; } - guint32 color; - guint32 hicolor; - GSList *views; - std::vector<SPGuideAttachment> attached_items; + guint32 getColor() const { return color; } + guint32 getHiColor() const { return hicolor; } + Geom::Point getPoint() const { return point_on_line; } + Geom::Point getNormal() const { return normal_to_line; } - guint32 getColor() const; - guint32 getHiColor() const; - void setColor(guint32 c); - void setHiColor(guint32 h); + void moveto(Geom::Point const point_on_line, bool const commit); + void set_normal(Geom::Point const normal_to_line, bool const commit); + + void set_label(const char* label, bool const commit); + char const* getLabel() const { return label; } - inline bool isHorizontal() const { return (normal_to_line[Geom::X] == 0.); }; - inline bool isVertical() const { return (normal_to_line[Geom::Y] == 0.); }; - inline double angle() const { return std::atan2( - normal_to_line[Geom::X], normal_to_line[Geom::Y] ); }; static SPGuide *createSPGuide(SPDocument *doc, Geom::Point const &pt1, Geom::Point const &pt2); + void showSPGuide(SPCanvasGroup *group, GCallback handler); void hideSPGuide(SPCanvas *canvas); - void sensitize(SPCanvas *canvas, gboolean sensitive); - Geom::Point getPositionFrom(Geom::Point const &pt) const; + void showSPGuide(); // argument-free versions + void hideSPGuide(); + + void sensitize(SPCanvas *canvas, bool sensitive); + + bool isHorizontal() const { return (normal_to_line[Geom::X] == 0.); }; + bool isVertical() const { return (normal_to_line[Geom::Y] == 0.); }; + + char* description(bool const verbose = true) const; + + double angle() const { return std::atan2( - normal_to_line[Geom::X], normal_to_line[Geom::Y] ); } double getDistanceFrom(Geom::Point const &pt) const; + Geom::Point getPositionFrom(Geom::Point const &pt) const; protected: - virtual void build(SPDocument* doc, Inkscape::XML::Node* repr); - virtual void release(); - virtual void set(unsigned int key, const gchar* value); + virtual void build(SPDocument* doc, Inkscape::XML::Node* repr); + virtual void release(); + virtual void set(unsigned int key, const char* value); + + char* label; + GSList *views; // contains an object of type SPGuideline (see display/guideline.cpp for definition) + Geom::Point normal_to_line; + Geom::Point point_on_line; + + guint32 color; + guint32 hicolor; +public: + std::vector<SPGuideAttachment> attached_items; // unused }; +// These functions rightfully belong to SPDesktop. What gives?! void sp_guide_pt_pairs_to_guides(SPDocument *doc, std::list<std::pair<Geom::Point, Geom::Point> > &pts); void sp_guide_create_guides_around_page(SPDesktop *dt); void sp_guide_delete_all_guides(SPDesktop *dt); -void sp_guide_moveto(SPGuide &guide, Geom::Point const point_on_line, bool const commit); -void sp_guide_set_normal(SPGuide &guide, Geom::Point const normal_to_line, bool const commit); -void sp_guide_set_label(SPGuide &guide, const char* label, bool const commit); -void sp_guide_set_color(SPGuide &guide, const unsigned r, const unsigned g, const unsigned b, bool const commit); void sp_guide_remove(SPGuide *guide); -char *sp_guide_description(SPGuide const *guide, const bool verbose = true); - #endif // SEEN_SP_GUIDE_H /* |
