1 /** @file
2 * @brief Parameters for extensions.
3 */
4 /* Authors:
5 * Ted Gould <ted@gould.cx>
6 *
7 * Copyright (C) 2005-2006 Authors
8 *
9 * Released under GNU GPL, read the file 'COPYING' for more information
10 */
12 #ifndef SEEN_INK_EXTENSION_PARAM_H__
13 #define SEEN_INK_EXTENSION_PARAM_H__
15 #include <gtkmm/widget.h>
16 #include <glibmm/i18n.h>
18 #include "xml/document.h"
19 #include "xml/node.h"
20 #include "document.h"
21 #include "extension/extension-forward.h"
22 #include <color.h>
24 namespace Inkscape {
25 namespace Extension {
27 /**
28 * @brief The root directory in the preferences database for extension-related parameters
29 *
30 * The directory path has both a leading and a trailing slash, so that extension_pref_root + pref_name works
31 * without having to append a separator.
32 */
33 extern Glib::ustring const extension_pref_root;
35 /** \brief A class to represent the parameter of an extension
37 This is really a super class that allows them to abstract all
38 the different types of parameters into some that can be passed
39 around. There is also a few functions that are used by all the
40 different parameters.
41 */
42 class Parameter {
43 private:
44 /** \brief Which extension is this parameter attached to? */
45 Inkscape::Extension::Extension * extension;
46 /** \brief The name of this parameter. */
47 gchar * _name;
49 protected:
50 /** \brief Description of the parameter. */
51 gchar * _desc;
52 /** \brief List of possible scopes. */
53 typedef enum {
54 SCOPE_USER, /**< Parameter value is saved in the user's configuration file. (default) */
55 SCOPE_DOCUMENT, /**< Parameter value is saved in the document. */
56 SCOPE_NODE /**< Parameter value is attached to the node. */
57 } _scope_t;
58 /** \brief Scope of the parameter. */
59 _scope_t _scope;
60 /** \brief Text for the GUI selection of this. */
61 gchar * _text;
62 /** \brief Whether the GUI is visible */
63 bool _gui_hidden;
64 /** \brief A tip for the GUI if there is one */
65 gchar * _gui_tip;
68 /* **** funcs **** */
69 gchar * pref_name (void);
70 Inkscape::XML::Node * find_child (Inkscape::XML::Node * adult);
71 Inkscape::XML::Node * document_param_node (SPDocument * doc);
72 Inkscape::XML::Node * new_child (Inkscape::XML::Node * parent);
74 public:
75 Parameter (const gchar * name,
76 const gchar * guitext,
77 const gchar * desc,
78 const Parameter::_scope_t scope,
79 bool gui_hidden,
80 const gchar * gui_tip,
81 Inkscape::Extension::Extension * ext);
82 Parameter (const gchar * name,
83 const gchar * guitext,
84 Inkscape::Extension::Extension * ext) {
85 Parameter(name, guitext, NULL, Parameter::SCOPE_USER, false, NULL, ext);
86 };
87 virtual ~Parameter (void);
88 bool get_bool (const SPDocument * doc,
89 const Inkscape::XML::Node * node);
90 int get_int (const SPDocument * doc,
91 const Inkscape::XML::Node * node);
92 float get_float (const SPDocument * doc,
93 const Inkscape::XML::Node * node);
94 const gchar * get_string (const SPDocument * doc,
95 const Inkscape::XML::Node * node);
96 guint32 get_color (const SPDocument * doc,
97 const Inkscape::XML::Node * node);
98 const gchar * get_enum (const SPDocument * doc,
99 const Inkscape::XML::Node * node);
101 bool set_bool (bool in, SPDocument * doc, Inkscape::XML::Node * node);
102 int set_int (int in, SPDocument * doc, Inkscape::XML::Node * node);
103 float set_float (float in, SPDocument * doc, Inkscape::XML::Node * node);
104 const gchar * set_string (const gchar * in, SPDocument * doc, Inkscape::XML::Node * node);
105 guint32 set_color (guint32 in, SPDocument * doc, Inkscape::XML::Node * node);
107 const gchar * name (void) {return _name;}
109 static Parameter * make (Inkscape::XML::Node * in_repr, Inkscape::Extension::Extension * in_ext);
110 virtual Gtk::Widget * get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal);
112 gchar const * get_tooltip (void) { return _desc; }
114 /** \brief Indicates if the GUI for this parameter is hidden or not */
115 bool get_gui_hidden () { return _gui_hidden; }
117 virtual void string (std::list <std::string> &list);
118 virtual void string (std::string &string);
119 };
121 } /* namespace Extension */
122 } /* namespace Inkscape */
124 #endif /* __INK_EXTENSION_PARAM_H__ */
126 /*
127 Local Variables:
128 mode:c++
129 c-file-style:"stroustrup"
130 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
131 indent-tabs-mode:nil
132 fill-column:99
133 End:
134 */
135 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :