Changed the "tagrelease" and "tagstable" make targets to use subversion. Also increme...
[synfig.git] / synfig-studio / tags / stable / src / gtkmm / widget_enum.cpp
1 /* === S I N F G =========================================================== */
2 /*!     \file widget_enum.cpp
3 **      \brief Template File
4 **
5 **      $Id: widget_enum.cpp,v 1.1.1.1 2005/01/07 03:34:37 darco Exp $
6 **
7 **      \legal
8 **      Copyright (c) 2002 Robert B. Quattlebaum Jr.
9 **
10 **      This software and associated documentation
11 **      are CONFIDENTIAL and PROPRIETARY property of
12 **      the above-mentioned copyright holder.
13 **
14 **      You may not copy, print, publish, or in any
15 **      other way distribute this software without
16 **      a prior written agreement with
17 **      the copyright holder.
18 **      \endlegal
19 */
20 /* ========================================================================= */
21
22 /* === H E A D E R S ======================================================= */
23
24 #ifdef USING_PCH
25 #       include "pch.h"
26 #else
27 #ifdef HAVE_CONFIG_H
28 #       include <config.h>
29 #endif
30
31 #include <gtkmm/menu.h>
32 #include "widget_enum.h"
33 #include <ETL/stringf>
34 #include <sinfg/valuenode.h>
35
36 #endif
37
38 /* === U S I N G =========================================================== */
39
40 using namespace std;
41 using namespace etl;
42 using namespace sinfg;
43 using namespace studio;
44
45 /* === M A C R O S ========================================================= */
46
47 /* === G L O B A L S ======================================================= */
48
49 /* === P R O C E D U R E S ================================================= */
50
51 /* === M E T H O D S ======================================================= */
52
53 Widget_Enum::Widget_Enum()
54 {
55 }
56
57 Widget_Enum::~Widget_Enum()
58 {
59 }
60
61 void
62 Widget_Enum::set_param_desc(const sinfg::ParamDesc &x)
63 {
64         param_desc=x;
65         //refresh();
66 }
67
68 void
69 Widget_Enum::set_value_(int data)
70 {
71         set_value(data);
72         activate();
73 }
74
75 void
76 Widget_Enum::refresh()
77 {
78         enum_menu = manage(new class Gtk::Menu());
79
80         std::list<sinfg::ParamDesc::EnumData> enum_list=param_desc.get_enum_list();
81         std::list<sinfg::ParamDesc::EnumData>::iterator iter;
82         
83         String name=strprintf("(%d)",value);
84         
85         for(iter=enum_list.begin();iter!=enum_list.end();iter++)
86                 if(iter->value!=value)
87                         enum_menu->items().push_back(Gtk::Menu_Helpers::MenuElem(iter->local_name,
88                                 sigc::bind(sigc::mem_fun(*this,&Widget_Enum::set_value_),iter->value)
89                         ));
90                 else
91                         name=iter->local_name;
92
93         enum_menu->items().push_front(Gtk::Menu_Helpers::MenuElem(name));
94                 
95         set_menu(*enum_menu);   
96 }
97
98 void
99 Widget_Enum::set_value(int data)
100 {
101         value=data;
102         
103         refresh();
104         
105         set_history(0);
106 }
107
108 int
109 Widget_Enum::get_value() const
110 {
111         return value;
112 }