initial version
[synfig.git] / synfig-studio / trunk / src / gtkmm / widget_distance.cpp
1 /* === S I N F G =========================================================== */
2 /*!     \file widget_time.cpp
3 **      \brief Template File
4 **
5 **      $Id: widget_distance.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/entry.h>
32 #include <gtkmm/button.h>
33 #include "widget_distance.h"
34 #include "app.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 #if ! defined(_)
48 #define _(x)    (x)
49 #endif
50
51 /* === G L O B A L S ======================================================= */
52
53 /* === P R O C E D U R E S ================================================= */
54
55 /* === M E T H O D S ======================================================= */
56
57 Widget_Distance::Widget_Distance():
58         Gtk::SpinButton(0.05,5),
59         adjustment(0,-100000000,100000000,1,1,1)
60 //      adjustment(0,-100000000,100000000,1,2,0)
61 {
62         set_adjustment(adjustment);
63         set_numeric(false);
64 }
65
66 Widget_Distance::~Widget_Distance()
67 {
68 }
69
70 int
71 Widget_Distance::on_input(double* new_value)
72 {
73         distance_=sinfg::String(get_text());
74         *new_value=distance_.get();
75         return 1;
76 }
77
78 bool
79 Widget_Distance::on_output()
80 {
81         try{
82         distance_=get_adjustment()->get_value();
83         set_text(distance_.get_string(get_digits()));
84         } catch (...) { /* sinfg::error("Widget_Distance::on_output(): Caught something..."); */ }
85         return true;
86 }
87
88 void
89 Widget_Distance::set_value(const sinfg::Distance &data)
90 {
91         distance_=data;
92         get_adjustment()->set_value(distance_.get());
93 }
94
95 sinfg::Distance
96 Widget_Distance::get_value() const
97 {
98         distance_=get_adjustment()->get_value();
99         return distance_;
100 }