Code

Filter effects dialog:
[inkscape.git] / src / extension / effect.h
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 <gtkmm/dialog.h>
18 #include <gtk/gtkdialog.h>
19 #include "verbs.h"
21 #include "extension.h"
23 struct SPDocument;
25 namespace Inkscape {
26 namespace UI {
27 namespace View {
28 typedef View View;
29 };
30 };
32 namespace Extension {
34 /** \brief  Effects are extensions that take a document and do something
35             to it in place.  This class adds the extra functions required
36             to make extensions effects.
37 */
38 class Effect : public Extension {
39     /** \brief  This is the last effect that was used.  This is used in
40                 a menu item to rapidly recall the same effect. */
41     static Effect * _last_effect;
42     /** \brief  The location of the effects menu on the menu structure
43                 XML file.  This is saved so it only has to be discovered
44                 once. */
45     static Inkscape::XML::Node * _effects_list;
46     bool find_effects_list (Inkscape::XML::Node * menustruct);
47     void merge_menu (Inkscape::XML::Node * base, Inkscape::XML::Node * start, Inkscape::XML::Node * patern, Inkscape::XML::Node * mergee);
49     /** \brief  This is the verb type that is used for all effect's verbs.
50                 It provides convience functions and maintains a pointer
51                 back to the effect that created it.  */
52     class EffectVerb : public Inkscape::Verb {
53         private:
54             static void perform (SPAction * action, void * mydata, void * otherdata);
55             /** \brief  Function to call for specific actions */
56             static SPActionEventVector vector;
58             /** \brief  The effect that this verb represents. */
59             Effect * _effect;
60             /** \brief  Whether or not to show preferences on display */
61             bool _showPrefs;
62         protected:
63             virtual SPAction * make_action (Inkscape::UI::View::View * view);
64         public:
65             /** \brief Use the Verb initializer with the same parameters. */
66             EffectVerb(gchar const * id,
67                        gchar const * name,
68                        gchar const * tip,
69                        gchar const * image,
70                        Effect *      effect,
71                        bool          showPrefs) :
72                     Verb(id, _(name), _(tip), image), _effect(effect), _showPrefs(showPrefs) {
73                 /* No clue why, but this is required */
74                 this->set_default_sensitive(true);
75             }
76     };
78     /** \brief  ID used for the verb without preferences */
79     Glib::ustring _id_noprefs;
80     /** \brief  Name used for the verb without preferences */
81     Glib::ustring _name_noprefs;
83     /** \brief  The verb representing this effect. */
84     EffectVerb _verb;
85     /** \brief  The verb representing this effect.  Without preferences. */
86     EffectVerb _verb_nopref;
87     /** \brief  Menu node created for this effect */
88     Inkscape::XML::Node * _menu_node;
89     /** \brief  Whehter a working dialog should be shown */
90     bool _workingDialog;
91 public:
92                  Effect  (Inkscape::XML::Node * in_repr,
93                           Implementation::Implementation * in_imp);
94     virtual     ~Effect  (void);
95     virtual bool check                (void);
96     bool         prefs   (Inkscape::UI::View::View * doc);
97     void         effect  (Inkscape::UI::View::View * doc);
98     /** \brief  Accessor function for a pointer to the verb */
99     Inkscape::Verb * get_verb (void) { return &_verb; };
101     /** \brief  Static function to get the last effect used */
102     static Effect *  get_last_effect (void) { return _last_effect; };
103     static void      set_last_effect (Effect * in_effect);
105     static void      place_menus (void);
106     void             place_menu (Inkscape::XML::Node * menus);
108     Gtk::VBox *    get_info_widget(void);
110     bool no_doc; // if true, the effect does not process SVG document at all, so no need to save, read, and watch for errors
112 private:
113     static gchar *   remove_ (gchar * instr);
114 };
116 } }  /* namespace Inkscape, Extension */
117 #endif /* INKSCAPE_EXTENSION_EFFECT_H__ */
119 /*
120   Local Variables:
121   mode:c++
122   c-file-style:"stroustrup"
123   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
124   indent-tabs-mode:nil
125   fill-column:99
126   End:
127 */
128 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :