Code

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