1 /* === S Y N F I G ========================================================= */
2 /*! \file cellrenderer_time.cpp
3 ** \brief Template File
5 ** $Id: cellrenderer_time.cpp,v 1.1.1.1 2005/01/07 03:34:35 darco Exp $
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 "cellrenderer_time.h"
36 #include "widget_time.h"
40 /* === U S I N G =========================================================== */
43 //using namespace etl;
44 using namespace synfig;
45 using namespace studio;
47 /* === M A C R O S ========================================================= */
53 /* === G L O B A L S ======================================================= */
55 /* === P R O C E D U R E S ================================================= */
57 /* === M E T H O D S ======================================================= */
59 CellRenderer_Time::CellRenderer_Time():
60 Glib::ObjectBase (typeid(CellRenderer_Time)),
61 Gtk::CellRendererText (),
62 property_time_(*this,"time",synfig::Time(0)),
63 property_fps_(*this,"fps", float(0))
65 CellRendererText::signal_edited().connect(sigc::mem_fun(*this,&studio::CellRenderer_Time::string_edited_));
68 CellRenderer_Time::~CellRenderer_Time()
70 synfig::info("CellRenderer_Time::~CellRenderer_Time(): deleted");
74 CellRenderer_Time::string_edited_(const Glib::ustring&path,const Glib::ustring&str)
76 signal_edited_(path,Time((String)str,(Real)Time(property_fps_)));
80 CellRenderer_Time::render_vfunc(
81 const Glib::RefPtr<Gdk::Drawable>& window,
83 const Gdk::Rectangle& background_area,
84 const Gdk::Rectangle& ca,
85 const Gdk::Rectangle& expose_area,
86 Gtk::CellRendererState flags)
90 //int height = ca.get_height();
92 Gtk::StateType state = Gtk::STATE_INSENSITIVE;
93 if(property_editable())
94 state = Gtk::STATE_NORMAL;
95 if((flags & Gtk::CELL_RENDERER_SELECTED) != 0)
96 state = (widget.has_focus()) ? Gtk::STATE_SELECTED : Gtk::STATE_ACTIVE;
98 const Time time(property_time_);
99 const float fps((Real)Time(property_fps_));
101 property_text()=(Glib::ustring)time.get_string(fps,App::get_time_format());
103 CellRendererText::render_vfunc(window,widget,background_area,ca,expose_area,flags);
108 CellRenderer_Time::start_editing_vfunc(
111 const Glib::ustring& path,
112 const Gdk::Rectangle& background_area,
113 const Gdk::Rectangle& cell_area,
114 Gtk::CellRendererState flags)
116 // If we aren't editable, then there is nothing to do
117 if(!property_editable())
120 const Time time(property_time_);
121 const float fps((Real)Time(property_fps_));
123 property_text()=(Glib::ustring)time.get_string(fps,App::get_time_format()|Time::FORMAT_FULL);
125 Widget_Time* widget_time(manage(new Widget_Time));
126 widget_time->set_fps(fps);
127 widget_time->set_value(time);
128 widget_time->signal_editing_done().connect(sigc::mem_fun(*this, &CellRenderer_Time::on_value_editing_done));
131 return CellRendererText::start_editing_vfunc(event,widget,path,background_area,cell_area,flags);