diff options
Diffstat (limited to 'src/ui/tools/tool-base.h')
| -rw-r--r-- | src/ui/tools/tool-base.h | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/src/ui/tools/tool-base.h b/src/ui/tools/tool-base.h index 43edc4bd7..79bdfe89d 100644 --- a/src/ui/tools/tool-base.h +++ b/src/ui/tools/tool-base.h @@ -110,7 +110,8 @@ public: void enableGrDrag (bool enable=true); bool deleteSelectedDrag(bool just_one); - ToolBase(); + ToolBase(gchar const *const *cursor_shape, gint hot_x, gint hot_y); + virtual ~ToolBase(); Inkscape::Preferences::Observer *pref_observer; @@ -179,8 +180,11 @@ public: SPDesktop *desktop; protected: + /// An xpm containing the shape of the tool's cursor. gchar const *const *cursor_shape; - gint hot_x, hot_y; ///< indicates the cursor's hot spot + + /// The cursor's hot spot + gint hot_x, hot_y; private: ToolBase(const ToolBase&); @@ -211,9 +215,31 @@ void sp_toggle_dropper(SPDesktop *dt); bool sp_event_context_knot_mouseover(ToolBase *ec); +} // namespace Tools + +//#include <type_traits> + +namespace Tool { + +template<class Derived, typename T> +bool is_a(const T* t) { + //static_assert(std::is_base_of<Tools::ToolBase, Derived>(), "Destination type not derived from ToolBase."); + //static_assert(std::is_convertible<const Tools::ToolBase*, const T*>(), "Cannot cast passed pointer to ToolBase*."); + + return dynamic_cast<const Derived*>(static_cast<const Tools::ToolBase*>(t)) != NULL; } + +template<class Derived, typename T> +Derived* to(T* t) { + //static_assert(std::is_base_of<Tools::ToolBase, Derived>(), "Destination type not derived from ToolBase."); + //static_assert(std::is_convertible<Tools::ToolBase*, T*>(), "Cannot cast passed pointer to ToolBase*."); + + return dynamic_cast<Derived*>(static_cast<Tools::ToolBase*>(t)); } -} + +} // namespace Tool +} // namespace UI +} // namespace Inkscape #endif // SEEN_SP_EVENT_CONTEXT_H |
