summaryrefslogtreecommitdiffstats
path: root/src/ui/tools-switch.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/ui/tools-switch.cpp (renamed from src/tools-switch.cpp)80
1 files changed, 43 insertions, 37 deletions
diff --git a/src/tools-switch.cpp b/src/ui/tools-switch.cpp
index fe9d32f43..47b9d2832 100644
--- a/src/tools-switch.cpp
+++ b/src/ui/tools-switch.cpp
@@ -4,16 +4,14 @@
* Authors:
* bulia byak <buliabyak@users.sf.net>
* Josh Andler <scislac@users.sf.net>
+ * Jon A. Cruz <jon@joncruz.org>
*
* Copyright (C) 2003-2007 authors
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
+#include <gtkmm.h> // prevents deprecation warnings
#include <cstring>
#include <string>
@@ -25,40 +23,44 @@
#include <xml/repr.h>
-#include "ui/tools/select-tool.h"
-#include "ui/tools/node-tool.h"
-#include "ui/tools/tweak-tool.h"
-#include "ui/tools/spray-tool.h"
-#include "sp-path.h"
-#include "ui/tools/rect-tool.h"
-#include "sp-rect.h"
-#include "ui/tools/box3d-tool.h"
+#include "ui/tools-switch.h"
+
#include "box3d.h"
-#include "ui/tools/arc-tool.h"
#include "sp-ellipse.h"
-#include "ui/tools/tweak-tool.h"
+#include "sp-flowtext.h"
+#include "sp-offset.h"
+#include "sp-path.h"
+#include "sp-rect.h"
#include "sp-star.h"
-#include "ui/tools/spiral-tool.h"
#include "sp-spiral.h"
+#include "sp-text.h"
+
+// TODO: How many of these are actually needed?
+#include "ui/tools/arc-tool.h"
+#include "ui/tools/box3d-tool.h"
#include "ui/tools/calligraphic-tool.h"
+#include "ui/tools/connector-tool.h"
+#include "ui/tools/dropper-tool.h"
#include "ui/tools/eraser-tool.h"
+#include "ui/tools/flood-tool.h"
+#include "ui/tools/gradient-tool.h"
+#include "ui/tools/lpe-tool.h"
+#include "ui/tools/measure-tool.h"
+#include "ui/tools/mesh-tool.h"
+#include "ui/tools/node-tool.h"
#include "ui/tools/pen-tool.h"
#include "ui/tools/pencil-tool.h"
-#include "ui/tools/lpe-tool.h"
+#include "ui/tools/rect-tool.h"
+#include "ui/tools/select-tool.h"
+#include "ui/tools/spiral-tool.h"
+#include "ui/tools/spray-tool.h"
#include "ui/tools/text-tool.h"
-#include "sp-text.h"
-#include "sp-flowtext.h"
-#include "ui/tools/gradient-tool.h"
-#include "ui/tools/mesh-tool.h"
+#include "ui/tools/tweak-tool.h"
#include "ui/tools/zoom-tool.h"
-#include "ui/tools/measure-tool.h"
-#include "ui/tools/dropper-tool.h"
-#include "ui/tools/connector-tool.h"
-#include "ui/tools/flood-tool.h"
-#include "sp-offset.h"
+
#include "message-context.h"
-#include "tools-switch.h"
+using Inkscape::UI::Tools::ToolBase;
static char const *const tool_names[] = {
NULL,
@@ -86,6 +88,8 @@ static char const *const tool_names[] = {
"/tools/lpetool",
NULL
};
+
+// TODO: HEY! these belong to the tools themselves!
static char const *const tool_msg[] = {
NULL,
N_("<b>Click</b> to Select and Transform objects, <b>Drag</b> to select many objects."),
@@ -129,9 +133,11 @@ int
tools_isactive(SPDesktop *dt, unsigned num)
{
g_assert( num < G_N_ELEMENTS(tool_names) );
- if (SP_IS_EVENT_CONTEXT(dt->event_context))
+ if (dynamic_cast<ToolBase *>(dt->event_context)) {
return dt->event_context->pref_observer->observed_path == tool_names[num];
- else return FALSE;
+ } else {
+ return FALSE;
+ }
}
int
@@ -158,27 +164,27 @@ tools_switch(SPDesktop *dt, int num)
void tools_switch_by_item(SPDesktop *dt, SPItem *item, Geom::Point const p)
{
- if (SP_IS_RECT(item)) {
+ if (dynamic_cast<SPRect *>(item)) {
tools_switch(dt, TOOLS_SHAPES_RECT);
- } else if (SP_IS_BOX3D(item)) {
+ } else if (dynamic_cast<SPBox3D *>(item)) {
tools_switch(dt, TOOLS_SHAPES_3DBOX);
- } else if (SP_IS_GENERICELLIPSE(item)) {
+ } else if (dynamic_cast<SPGenericEllipse *>(item)) {
tools_switch(dt, TOOLS_SHAPES_ARC);
- } else if (SP_IS_STAR(item)) {
+ } else if (dynamic_cast<SPStar *>(item)) {
tools_switch(dt, TOOLS_SHAPES_STAR);
- } else if (SP_IS_SPIRAL(item)) {
+ } else if (dynamic_cast<SPSpiral *>(item)) {
tools_switch(dt, TOOLS_SHAPES_SPIRAL);
- } else if (SP_IS_PATH(item)) {
+ } else if (dynamic_cast<SPPath *>(item)) {
if (Inkscape::UI::Tools::cc_item_is_connector(item)) {
tools_switch(dt, TOOLS_CONNECTOR);
}
else {
tools_switch(dt, TOOLS_NODES);
}
- } else if (SP_IS_TEXT(item) || SP_IS_FLOWTEXT(item)) {
+ } else if (dynamic_cast<SPText *>(item) || dynamic_cast<SPFlowtext *>(item)) {
tools_switch(dt, TOOLS_TEXT);
- sp_text_context_place_cursor_at (SP_TEXT_CONTEXT(dt->event_context), SP_OBJECT(item), p);
- } else if (SP_IS_OFFSET(item)) {
+ sp_text_context_place_cursor_at (SP_TEXT_CONTEXT(dt->event_context), item, p);
+ } else if (dynamic_cast<SPOffset *>(item)) {
tools_switch(dt, TOOLS_NODES);
}
}