2
* \brief Simplified management of enumerations of svg items with UI labels
5
* Nicholas Bishop <nicholasbishop@gmail.com>
6
* Johan Engelen <j.b.c.engelen@ewi.utwente.nl>
8
* Copyright (C) 2007 Authors
10
* Released under GNU GPL. Read the file 'COPYING' for more information.
14
* When initializing the EnumData struct, you cannot use _(...) to translate strings.
15
* Instead, one must use N_(...) and do the translation every time the string is retreived.
19
#ifndef INKSCAPE_UTIL_ENUMS_H
20
#define INKSCAPE_UTIL_ENUMS_H
22
#include <glibmm/ustring.h>
27
template<typename E> class EnumData
31
const Glib::ustring label;
32
const Glib::ustring key;
35
template<typename E> class EnumDataConverter
38
typedef EnumData<E> Data;
40
EnumDataConverter(const EnumData<E>* cd, const int endval)
41
: end(endval), _data(cd)
44
E get_id_from_label(const Glib::ustring& label) const
46
for(int i = 0; i < end; ++i) {
47
if(_data[i].label == label)
54
E get_id_from_key(const Glib::ustring& key) const
56
for(int i = 0; i < end; ++i) {
57
if(_data[i].key == key)
64
bool is_valid_key(const Glib::ustring& key) const
66
for(int i = 0; i < end; ++i) {
67
if(_data[i].key == key)
74
const Glib::ustring& get_label(const E e) const
76
return _data[e].label;
79
const Glib::ustring& get_key(const E e) const
84
const EnumData<E>& data(const int i) const
91
const EnumData<E>* _data;
103
c-file-style:"stroustrup"
104
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
109
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :