806876e7329b65784aa1aac8abf98434ac141854
1 #ifndef __INK_EXTENSION_PARAM_H__
2 #define __INK_EXTENSION_PARAM_H__
4 /** \file
5 * Parameters for extensions.
6 */
8 /*
9 * Authors:
10 * Ted Gould <ted@gould.cx>
11 *
12 * Copyright (C) 2005-2006 Authors
13 *
14 * Released under GNU GPL, read the file 'COPYING' for more information
15 */
16 #include <gtkmm/widget.h>
18 #include "xml/document.h"
19 #include "extension-forward.h"
21 namespace Inkscape {
22 namespace Extension {
24 /** \brief A class to represent the parameter of an extension
26 This is really a super class that allows them to abstract all
27 the different types of parameters into some that can be passed
28 around. There is also a few functions that are used by all the
29 different parameters.
30 */
31 class Parameter {
32 private:
33 /** \brief Which extension is this parameter attached to? */
34 Inkscape::Extension::Extension * extension;
35 /** \brief The name of this parameter. */
36 gchar * _name;
38 protected:
39 /** \brief Description of the parameter. */
40 gchar * _desc;
41 /** \brief List of possible scopes. */
42 typedef enum {
43 SCOPE_USER, /**< Parameter value is saved in the user's configuration file. (default) */
44 SCOPE_DOCUMENT, /**< Parameter value is saved in the document. */
45 SCOPE_NODE /**< Parameter value is attached to the node. */
46 } _scope_t;
47 /** \brief Scope of the parameter. */
48 _scope_t _scope;
49 /** \brief Text for the GUI selection of this. */
50 gchar * _text;
53 /* **** funcs **** */
54 gchar * pref_name (void);
55 Inkscape::XML::Node * find_child (Inkscape::XML::Node * adult);
56 Inkscape::XML::Node * document_param_node (SPDocument * doc);
57 Inkscape::XML::Node * new_child (Inkscape::XML::Node * parent);
59 public:
60 Parameter (const gchar * name,
61 const gchar * guitext,
62 const gchar * desc,
63 const Parameter::_scope_t scope,
64 Inkscape::Extension::Extension * ext);
65 Parameter (const gchar * name,
66 const gchar * guitext,
67 Inkscape::Extension::Extension * ext) {
68 Parameter(name, guitext, NULL, Parameter::SCOPE_USER, ext);
69 };
70 virtual ~Parameter (void);
71 bool get_bool (const Inkscape::XML::Document * doc,
72 const Inkscape::XML::Node * node);
73 int get_int (const Inkscape::XML::Document * doc,
74 const Inkscape::XML::Node * node);
75 float get_float (const Inkscape::XML::Document * doc,
76 const Inkscape::XML::Node * node);
77 const gchar * get_string (const Inkscape::XML::Document * doc,
78 const Inkscape::XML::Node * node);
80 bool set_bool (bool in, Inkscape::XML::Document * doc, Inkscape::XML::Node * node);
81 int set_int (int in, Inkscape::XML::Document * doc, Inkscape::XML::Node * node);
82 float set_float (float in, Inkscape::XML::Document * doc, Inkscape::XML::Node * node);
83 const gchar * set_string (const gchar * in, Inkscape::XML::Document * doc, Inkscape::XML::Node * node);
85 const gchar * name (void) {return _name;}
87 static Parameter * make (Inkscape::XML::Node * in_repr, Inkscape::Extension::Extension * in_ext);
88 virtual Gtk::Widget * get_widget (void);
89 virtual Glib::ustring * string (void);
90 gchar const * get_tooltip (void) { return _desc; }
91 };
94 } /* namespace Extension */
95 } /* namespace Inkscape */
97 #endif /* __INK_EXTENSION_PARAM_H__ */
99 /*
100 Local Variables:
101 mode:c++
102 c-file-style:"stroustrup"
103 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
104 indent-tabs-mode:nil
105 fill-column:99
106 End:
107 */
108 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :