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"
41 /* === U S I N G =========================================================== */
44 //using namespace etl;
45 using namespace synfig;
46 using namespace studio;
48 /* === M A C R O S ========================================================= */
50 /* === G L O B A L S ======================================================= */
52 /* === P R O C E D U R E S ================================================= */
54 /* === M E T H O D S ======================================================= */
56 Widget_Time::Widget_Time():
60 signal_activate().connect(sigc::mem_fun(*this,&studio::Widget_Time::refresh_value));
61 signal_activate().connect(sigc::mem_fun(*this,&studio::Widget_Time::refresh_text));
64 Widget_Time::~Widget_Time()
69 Widget_Time::refresh_text()
71 set_text(time_.get_string(fps_,App::get_time_format()));
76 Widget_Time::set_value(const synfig::Time &data)
83 Widget_Time::get_value() const
89 Widget_Time::set_fps(float x)
96 Widget_Time::refresh_value()
100 Time newtime(get_text(),fps_);
101 if(abs(newtime-time_)>=0.001)
105 signal_value_changed()();
110 throw string("Caught unknown exception");
115 Widget_Time::on_event(GdkEvent* event)
117 const Time scroll_amount(0.25);
122 if(event->scroll.direction==GDK_SCROLL_DOWN)
124 time_-=scroll_amount;
126 signal_value_changed()();
128 else if(event->scroll.direction==GDK_SCROLL_UP)
130 time_+=scroll_amount;
132 signal_value_changed()();
140 return Gtk::Entry::on_event(event);
144 Widget_Time::on_focus_out_event(GdkEventFocus* event)
148 return Gtk::Entry::on_focus_out_event(event);
152 Widget_Time::on_focus_in_event(GdkEventFocus* event)
154 set_text(time_.get_string(fps_,App::get_time_format()|Time::FORMAT_FULL));
155 return Gtk::Entry::on_focus_in_event(event);