Inkscape
Vector Graphics Editor
parameter.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
5/* Authors:
6 * Ted Gould <ted@gould.cx>
7 * Jon A. Cruz <jon@joncruz.org>
8 *
9 * Copyright (C) 2005-2006 Authors
10 *
11 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
12 */
13
14#ifndef SEEN_INK_EXTENSION_PARAM_H__
15#define SEEN_INK_EXTENSION_PARAM_H__
16
17#include <string>
18#include "widget.h"
19
20namespace Glib {
21class ustring;
22} // namespace Glib
23
24namespace Inkscape::Extension {
25
34class InxParameter : public InxWidget {
35public:
38
39 ~InxParameter() override;
40
42 bool get_bool() const;
43
45 int get_int() const;
46
48 double get_float() const;
49
51 const char *get_string() const;
52
54 const char *get_optiongroup() const;
55 bool get_optiongroup_contains(const char *value) const;
56
58 unsigned int get_color() const;
59
61 bool set_bool(bool in);
62
64 int set_int(int in);
65
67 double set_float(double in);
68
70 const char *set_string(const char *in);
71
73 const char *set_optiongroup(const char *in);
74
76 unsigned int set_color(unsigned int in);
77
78 char const *name() const { return _name; }
79
93
94 const char *get_tooltip() const override { return _description; }
95
105 virtual std::string value_to_string() const;
106
111 virtual void string_to_value(const std::string &in);
112
116 virtual const std::string &set(const std::string &in);
117
119 static constexpr int GUI_PARAM_WIDGETS_SPACING = 4;
120
130
131protected:
133 char *_name = nullptr;
134
136 char *_text = nullptr;
137
139 char *_description = nullptr;
140
141 /* **** member functions **** */
142
151 Glib::ustring pref_name() const;
152};
153
154} // namespace Inkscape::Extension
155
156#endif // SEEN_INK_EXTENSION_PARAM_H__
157
158/*
159 Local Variables:
160 mode:c++
161 c-file-style:"stroustrup"
162 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
163 indent-tabs-mode:nil
164 fill-column:99
165 End:
166*/
167// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
The object that is the basis for the Extension system.
Definition: extension.h:130
An error class for when a parameter is called on a type it is not.
Definition: parameter.h:122
A class to represent the parameter of an extension.
Definition: parameter.h:34
bool get_bool() const
Wrapper to cast to the object and use its function.
Definition: parameter.cpp:110
double set_float(double in)
Wrapper to cast to the object and use it's function.
Definition: parameter.cpp:191
const char * get_optiongroup() const
Wrapper to cast to the object and use it's function.
Definition: parameter.cpp:148
unsigned int set_color(unsigned int in)
Wrapper to cast to the object and use it's function.
Definition: parameter.cpp:217
bool get_optiongroup_contains(const char *value) const
Definition: parameter.cpp:157
char * _name
The name of this parameter.
Definition: parameter.h:133
const char * get_tooltip() const override
Definition: parameter.h:94
unsigned int get_color() const
Wrapper to cast to the object and use it's function.
Definition: parameter.cpp:166
virtual const std::string & set(const std::string &in)
Calls string_to_value and then saves the result in the prefs.
Definition: parameter.cpp:301
static InxParameter * make(Inkscape::XML::Node *in_repr, Inkscape::Extension::Extension *in_ext)
Creates a new extension parameter for usage in a prefdialog.
Definition: parameter.cpp:66
const char * set_optiongroup(const char *in)
Wrapper to cast to the object and use it's function.
Definition: parameter.cpp:208
virtual std::string value_to_string() const
Gets the current value of the parameter in a string form.
Definition: parameter.cpp:286
int set_int(int in)
Wrapper to cast to the object and use it's function.
Definition: parameter.cpp:183
const char * get_string() const
Wrapper to cast to the object and use it's function.
Definition: parameter.cpp:139
double get_float() const
Wrapper to cast to the object and use it's function.
Definition: parameter.cpp:130
char const * name() const
Definition: parameter.h:78
char * _description
Extended description of the parameter (currently shown as tooltip on hover).
Definition: parameter.h:139
const char * set_string(const char *in)
Wrapper to cast to the object and use it's function.
Definition: parameter.cpp:200
int get_int() const
Wrapper to cast to the object and use it's function.
Definition: parameter.cpp:119
static constexpr int GUI_PARAM_WIDGETS_SPACING
Recommended spacing between the widgets making up a single Parameter (e.g.
Definition: parameter.h:119
Glib::ustring pref_name() const
Build preference name for the current parameter.
Definition: parameter.cpp:281
InxParameter(Inkscape::XML::Node *in_repr, Inkscape::Extension::Extension *ext)
Definition: parameter.cpp:226
char * _text
Parameter text to show as the GUI label.
Definition: parameter.h:136
bool set_bool(bool in)
Wrapper to cast to the object and use it's function.
Definition: parameter.cpp:175
virtual void string_to_value(const std::string &in)
Sets the current value of the parameter from a string.
Definition: parameter.cpp:294
Base class to represent all widgets of an extension (including parameters)
Definition: widget.h:36
Interface for refcounted XML nodes.
Definition: node.h:80
Extension support.
Base class for extension widgets.