diff options
| author | Nicholas Bishop <nicholasbishop@gmail.com> | 2007-07-14 20:55:43 +0000 |
|---|---|---|
| committer | nicholasbishop <nicholasbishop@users.sourceforge.net> | 2007-07-14 20:55:43 +0000 |
| commit | 28d142f1596cfa9e4dd6b63509205d528394c779 (patch) | |
| tree | f0285a821f510a0193ff2c78bd5e6627e3c2f075 /src/util/enums.h | |
| parent | Move check for unlinked paths of 3D box faces to the correct location (diff) | |
| download | inkscape-28d142f1596cfa9e4dd6b63509205d528394c779.tar.gz inkscape-28d142f1596cfa9e4dd6b63509205d528394c779.zip | |
Filter effects:
* As coded by Johan Engelen, made the filter-effect-enums code more generic; the data and conversion classes are now in src/util, filter-specific data is in filter-enums.h
* Improved filter_add_primitive so that default values are filled in appropriately to prevent errors or possible crashes
(bzr r3241)
Diffstat (limited to 'src/util/enums.h')
| -rw-r--r-- | src/util/enums.h | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/src/util/enums.h b/src/util/enums.h new file mode 100644 index 000000000..e7a6fd868 --- /dev/null +++ b/src/util/enums.h @@ -0,0 +1,93 @@ +/** + * \brief Simplified management of enumerations of svg items with UI labels + * + * Authors: + * Nicholas Bishop <nicholasbishop@gmail.com> + * Johan Engelen <j.b.c.engelen@ewi.utwente.nl> + * + * Copyright (C) 2007 Authors + * + * Released under GNU GPL. Read the file 'COPYING' for more information. + */ + +#ifndef INKSCAPE_UTIL_ENUMS_H +#define INKSCAPE_UTIL_ENUMS_H + +#include <glibmm/ustring.h> + +namespace Inkscape { +namespace Util { + +template<typename E> class EnumData +{ +public: + E id; + const Glib::ustring label; + const Glib::ustring key; +}; + +template<typename E> class EnumDataConverter +{ +public: + typedef EnumData<E> Data; + + EnumDataConverter(const EnumData<E>* cd, const int endval) + : end(endval), _data(cd) + {} + + E get_id_from_label(const Glib::ustring& label) const + { + for(int i = 0; i < end; ++i) { + if(_data[i].label == label) + return (E)i; + } + + return (E)0; + } + + E get_id_from_key(const Glib::ustring& key) const + { + for(int i = 0; i < end; ++i) { + if(_data[i].key == key) + return (E)i; + } + + return (E)0; + } + + const Glib::ustring& get_label(const E e) const + { + return _data[e].label; + } + + const Glib::ustring& get_key(const E e) const + { + return _data[e].key; + } + + const EnumData<E>& data(const int i) const + { + return _data[i]; + } + + const int end; +private: + const EnumData<E>* _data; +}; + + +} +} + +#endif + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : |
