1 /*
2 * Authors:
3 * Ted Gould <ted@gould.cx>
4 *
5 * Copyright (C) 2002-2004 Authors
6 *
7 * Released under GNU GPL, read the file 'COPYING' for more information
8 */
11 #ifndef INKSCAPE_EXTENSION_EFFECT_H__
12 #define INKSCAPE_EXTENSION_EFFECT_H__
14 #include <config.h>
16 #include <glibmm/i18n.h>
17 #include <gtk/gtkdialog.h>
18 #include "verbs.h"
20 #include "extension.h"
22 struct SPDocument;
24 namespace Inkscape {
25 namespace UI {
26 namespace View {
27 typedef View View;
28 };
29 };
31 namespace Extension {
33 /** \brief Effects are extensions that take a document and do something
34 to it in place. This class adds the extra functions required
35 to make extensions effects.
36 */
37 class Effect : public Extension {
38 /** \brief This is the last effect that was used. This is used in
39 a menu item to rapidly recall the same effect. */
40 static Effect * _last_effect;
41 /** \brief The location of the effects menu on the menu structure
42 XML file. This is saved so it only has to be discovered
43 once. */
44 static Inkscape::XML::Node * _effects_list;
45 bool find_effects_list (Inkscape::XML::Node * menustruct);
46 void merge_menu (Inkscape::XML::Node * base, Inkscape::XML::Node * start, Inkscape::XML::Node * patern, Inkscape::XML::Node * mergee);
48 /** \brief This is the verb type that is used for all effect's verbs.
49 It provides convience functions and maintains a pointer
50 back to the effect that created it. */
51 class EffectVerb : public Inkscape::Verb {
52 private:
53 static void perform (SPAction * action, void * mydata, void * otherdata);
54 /** \brief Function to call for specific actions */
55 static SPActionEventVector vector;
57 /** \brief The effect that this verb represents. */
58 Effect * _effect;
59 /** \brief Whether or not to show preferences on display */
60 bool _showPrefs;
61 protected:
62 virtual SPAction * make_action (Inkscape::UI::View::View * view);
63 public:
64 /** \brief Use the Verb initializer with the same parameters. */
65 EffectVerb(gchar const * id,
66 gchar const * name,
67 gchar const * tip,
68 gchar const * image,
69 Effect * effect,
70 bool showPrefs) :
71 Verb(id, _(name), _(tip), image), _effect(effect), _showPrefs(showPrefs) {
72 /* No clue why, but this is required */
73 this->set_default_sensitive(true);
74 }
75 };
77 /** \brief ID used for the verb without preferences */
78 Glib::ustring _id_noprefs;
79 /** \brief Name used for the verb without preferences */
80 Glib::ustring _name_noprefs;
82 /** \brief The verb representing this effect. */
83 EffectVerb _verb;
84 /** \brief The verb representing this effect. Without preferences. */
85 EffectVerb _verb_nopref;
86 /** \brief Menu node created for this effect */
87 Inkscape::XML::Node * _menu_node;
88 public:
89 Effect (Inkscape::XML::Node * in_repr,
90 Implementation::Implementation * in_imp);
91 virtual ~Effect (void);
92 virtual bool check (void);
93 bool prefs (Inkscape::UI::View::View * doc);
94 void effect (Inkscape::UI::View::View * doc);
95 /** \brief Accessor function for a pointer to the verb */
96 Inkscape::Verb * get_verb (void) { return &_verb; };
98 /** \brief Static function to get the last effect used */
99 static Effect * get_last_effect (void) { return _last_effect; };
100 static void set_last_effect (Effect * in_effect);
102 static void place_menus (void);
103 void place_menu (Inkscape::XML::Node * menus);
105 Gtk::VBox * get_info_widget(void);
107 bool no_doc; // if true, the effect does not process SVG document at all, so no need to save, read, and watch for errors
109 private:
110 static gchar * remove_ (gchar * instr);
111 };
113 } } /* namespace Inkscape, Extension */
114 #endif /* INKSCAPE_EXTENSION_EFFECT_H__ */
116 /*
117 Local Variables:
118 mode:c++
119 c-file-style:"stroustrup"
120 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
121 indent-tabs-mode:nil
122 fill-column:99
123 End:
124 */
125 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :