~valavanisalex/ubuntu/oneiric/inkscape/inkscape_0.48.1-2ubuntu4

« back to all changes in this revision

Viewing changes to src/live_effects/parameter/enum.h

  • Committer: Bazaar Package Importer
  • Author(s): Kees Cook, Kees Cook, Ted Gould
  • Date: 2008-02-10 14:20:16 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20080210142016-vcnb2zqyhszu0xvb
Tags: 0.46~pre1-0ubuntu1
[ Kees Cook ]
* debian/control:
  - add libgtkspell-dev build-dep to gain GtkSpell features (LP: #183547).
  - update Standards version (no changes needed).
  - add Vcs and Homepage fields.
  - switch to new python-lxml dep.
* debian/{control,rules}: switch from dpatch to quilt for more sanity.
* debian/patches/20_fix_glib_and_gxx43_ftbfs.patch:
  - merged against upstream fixes.
  - added additional fixes for newly written code.
* debian/rules: enable parallel building.

[ Ted Gould ]
* Updating POTFILES.in to make it so things build correctly.
* debian/control:
  - add ImageMagick++ and libboost-dev to build-deps

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef INKSCAPE_LIVEPATHEFFECT_PARAMETER_ENUM_H
 
2
#define INKSCAPE_LIVEPATHEFFECT_PARAMETER_ENUM_H
 
3
 
 
4
/*
 
5
 * Inkscape::LivePathEffectParameters
 
6
 *
 
7
* Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
 
8
 *
 
9
 * Released under GNU GPL, read the file 'COPYING' for more information
 
10
 */
 
11
 
 
12
#include <glib/gtypes.h>
 
13
 
 
14
#include "ui/widget/registry.h"
 
15
#include "ui/widget/registered-enums.h"
 
16
#include <gtkmm/tooltips.h>
 
17
 
 
18
#include "live_effects/parameter/parameter.h"
 
19
#include "verbs.h"
 
20
 
 
21
namespace Inkscape {
 
22
 
 
23
namespace LivePathEffect {
 
24
 
 
25
template<typename E> class EnumParam : public Parameter {
 
26
public:
 
27
    EnumParam(  const Glib::ustring& label,
 
28
                const Glib::ustring& tip,
 
29
                const Glib::ustring& key,
 
30
                const Util::EnumDataConverter<E>& c,
 
31
                Inkscape::UI::Widget::Registry* wr,
 
32
                Effect* effect,
 
33
                E default_value)
 
34
        : Parameter(label, tip, key, wr, effect)
 
35
    {
 
36
        enumdataconv = &c;
 
37
        defvalue = default_value;
 
38
        value = defvalue;
 
39
    };
 
40
 
 
41
    virtual ~EnumParam() { };
 
42
 
 
43
    virtual Gtk::Widget * param_newWidget(Gtk::Tooltips * /*tooltips*/) {
 
44
        Inkscape::UI::Widget::RegisteredEnum<E> *regenum = Gtk::manage ( 
 
45
            new Inkscape::UI::Widget::RegisteredEnum<E>( param_label, param_tooltip,
 
46
                       param_key, *enumdataconv, *param_wr, param_effect->getRepr(), param_effect->getSPDoc() ) );
 
47
 
 
48
        regenum->set_active_by_id(value);
 
49
        regenum->combobox()->setProgrammatically = false;
 
50
        regenum->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change enumeration parameter"));
 
51
 
 
52
        return dynamic_cast<Gtk::Widget *> (regenum);
 
53
    };
 
54
 
 
55
    bool param_readSVGValue(const gchar * strvalue) {
 
56
        if (!strvalue) {
 
57
            param_set_default();
 
58
            return true;
 
59
        }
 
60
 
 
61
        param_set_value( enumdataconv->get_id_from_key(Glib::ustring(strvalue)) );
 
62
 
 
63
        return true;
 
64
    };
 
65
    gchar * param_writeSVGValue() const {
 
66
        gchar * str = g_strdup( enumdataconv->get_key(value).c_str() );
 
67
        return str;
 
68
    };
 
69
 
 
70
    E get_value() const {
 
71
        return value;
 
72
    }
 
73
 
 
74
    void param_set_default() {
 
75
        param_set_value(defvalue);
 
76
    }
 
77
 
 
78
    void param_set_value(E val) {
 
79
        value = val;
 
80
    }
 
81
 
 
82
private:
 
83
    EnumParam(const EnumParam&);
 
84
    EnumParam& operator=(const EnumParam&);
 
85
 
 
86
    E value;
 
87
    E defvalue;
 
88
 
 
89
    const Util::EnumDataConverter<E> * enumdataconv;
 
90
};
 
91
 
 
92
 
 
93
}; //namespace LivePathEffect
 
94
 
 
95
}; //namespace Inkscape
 
96
 
 
97
#endif