Code

fix linking
[inkscape.git] / src / extension / parameter.h
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  */
17 /** \brief  The root directory in the preferences database for extension-related parameters. */
18 #define PREF_DIR "extensions"
20 #include <gtkmm/widget.h>
22 #include "xml/document.h"
23 #include "xml/node.h"
24 #include "document.h"
25 #include "extension-forward.h"
26 #include "prefs-utils.h"
28 #include <glibmm/i18n.h>
30 #include "color.h"
32 namespace Inkscape {
33 namespace Extension {
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;
64     /* **** funcs **** */
65     gchar *               pref_name (void);
66     Inkscape::XML::Node * find_child (Inkscape::XML::Node * adult);
67     Inkscape::XML::Node * document_param_node (SPDocument * doc);
68     Inkscape::XML::Node * new_child (Inkscape::XML::Node * parent);
70 public:
71                   Parameter  (const gchar * name,
72                               const gchar * guitext,
73                               const gchar * desc,
74                               const Parameter::_scope_t scope,
75                               Inkscape::Extension::Extension * ext);
76                   Parameter  (const gchar * name,
77                               const gchar * guitext,
78                               Inkscape::Extension::Extension * ext) {
79                       Parameter(name, guitext, NULL, Parameter::SCOPE_USER, ext);
80                   };
81     virtual      ~Parameter  (void);
82     bool          get_bool   (const SPDocument * doc,
83                               const Inkscape::XML::Node * node);
84     int           get_int    (const SPDocument * doc,
85                               const Inkscape::XML::Node * node);
86     float         get_float  (const SPDocument * doc,
87                               const Inkscape::XML::Node * node);
88     const gchar * get_string (const SPDocument * doc,
89                               const Inkscape::XML::Node * node);
90     guint32       get_color  (const SPDocument * doc,
91                               const Inkscape::XML::Node * node);
92         const gchar * get_enum   (const SPDocument * doc,
93                               const Inkscape::XML::Node * node);
95     bool          set_bool   (bool in,          SPDocument * doc, Inkscape::XML::Node * node);
96     int           set_int    (int  in,          SPDocument * doc, Inkscape::XML::Node * node);
97     float         set_float  (float in,         SPDocument * doc, Inkscape::XML::Node * node);
98     const gchar * set_string (const gchar * in, SPDocument * doc, Inkscape::XML::Node * node);
99     guint32       set_color  (guint32 in, SPDocument * doc, Inkscape::XML::Node * node);
101     const gchar * name       (void) {return _name;}
103     static Parameter * make (Inkscape::XML::Node * in_repr, Inkscape::Extension::Extension * in_ext);
104     virtual Gtk::Widget * get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal);
105     virtual Glib::ustring * string (void);
106     gchar const * get_tooltip (void) { return _desc; }
107 };
109 }  /* namespace Extension */
110 }  /* namespace Inkscape */
112 #endif /* __INK_EXTENSION_PARAM_H__ */
114 /*
115   Local Variables:
116   mode:c++
117   c-file-style:"stroustrup"
118   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
119   indent-tabs-mode:nil
120   fill-column:99
121   End:
122 */
123 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :