Code

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