1 /* === S Y N F I G ========================================================= */
2 /*! \file widget_time.cpp
3 ** \brief Template File
8 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
10 ** This package is free software; you can redistribute it and/or
11 ** modify it under the terms of the GNU General Public License as
12 ** published by the Free Software Foundation; either version 2 of
13 ** the License, or (at your option) any later version.
15 ** This package is distributed in the hope that it will be useful,
16 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 ** General Public License for more details.
21 /* ========================================================================= */
23 /* === H E A D E R S ======================================================= */
32 #include <gtkmm/entry.h>
33 #include <gtkmm/button.h>
34 #include "widget_time.h"
39 /* === U S I N G =========================================================== */
42 //using namespace etl;
43 using namespace synfig;
44 using namespace studio;
46 /* === M A C R O S ========================================================= */
52 /* === G L O B A L S ======================================================= */
54 /* === P R O C E D U R E S ================================================= */
56 /* === M E T H O D S ======================================================= */
58 Widget_Time::Widget_Time():
62 signal_activate().connect(sigc::mem_fun(*this,&studio::Widget_Time::refresh_value));
63 signal_activate().connect(sigc::mem_fun(*this,&studio::Widget_Time::refresh_text));
66 Widget_Time::~Widget_Time()
71 Widget_Time::refresh_text()
73 set_text(time_.get_string(fps_,App::get_time_format()));
78 Widget_Time::set_value(const synfig::Time &data)
85 Widget_Time::get_value() const
91 Widget_Time::set_fps(float x)
98 Widget_Time::refresh_value()
102 Time newtime(get_text(),fps_);
103 if(abs(newtime-time_)>=0.001)
107 signal_value_changed()();
112 throw string("Caught unknown exception");
117 Widget_Time::on_event(GdkEvent* event)
119 const Time scroll_amount(0.25);
124 if(event->scroll.direction==GDK_SCROLL_DOWN)
126 time_-=scroll_amount;
128 signal_value_changed()();
130 else if(event->scroll.direction==GDK_SCROLL_UP)
132 time_+=scroll_amount;
134 signal_value_changed()();
142 return Gtk::Entry::on_event(event);
146 Widget_Time::on_focus_out_event(GdkEventFocus* event)
150 return Gtk::Entry::on_focus_out_event(event);
154 Widget_Time::on_focus_in_event(GdkEventFocus* event)
156 set_text(time_.get_string(fps_,App::get_time_format()|Time::FORMAT_FULL));
157 return Gtk::Entry::on_focus_in_event(event);