Code

67cceff60c935a00ef6b001d2d431d43d30230cc
[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 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;
51     gchar *       pref_name (void);
53 public:
54                   Parameter  (const gchar * name,
55                               const gchar * guitext,
56                               const gchar * desc,
57                               const Parameter::_scope_t scope,
58                               Inkscape::Extension::Extension * ext);
59                   Parameter  (const gchar * name,
60                               const gchar * guitext,
61                               Inkscape::Extension::Extension * ext) {
62                       Parameter(name, guitext, NULL, Parameter::SCOPE_USER, ext);
63                   };
64     virtual      ~Parameter  (void);
65     bool          get_bool   (const Inkscape::XML::Document * doc,
66                               const Inkscape::XML::Node * node);
67     int           get_int    (const Inkscape::XML::Document * doc,
68                               const Inkscape::XML::Node * node);
69     float         get_float  (const Inkscape::XML::Document * doc,
70                               const Inkscape::XML::Node * node);
71     const gchar * get_string (const Inkscape::XML::Document * doc,
72                               const Inkscape::XML::Node * node);
74     bool          set_bool   (bool in,          Inkscape::XML::Document * doc, Inkscape::XML::Node * node);
75     int           set_int    (int  in,          Inkscape::XML::Document * doc, Inkscape::XML::Node * node);
76     float         set_float  (float in,         Inkscape::XML::Document * doc, Inkscape::XML::Node * node);
77     const gchar * set_string (const gchar * in, Inkscape::XML::Document * doc, Inkscape::XML::Node * node);
79     const gchar * name       (void) {return _name;}
81     static Parameter * make (Inkscape::XML::Node * in_repr, Inkscape::Extension::Extension * in_ext);
82     virtual Gtk::Widget * get_widget (void);
83     virtual Glib::ustring * string (void);
84     gchar const * get_tooltip (void) { return _desc; }
85 };
88 }  /* namespace Extension */
89 }  /* namespace Inkscape */
91 #endif /* __INK_EXTENSION_PARAM_H__ */
93 /*
94   Local Variables:
95   mode:c++
96   c-file-style:"stroustrup"
97   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
98   indent-tabs-mode:nil
99   fill-column:99
100   End:
101 */
102 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :