my log
[synfig.git] / synfig-studio / trunk / src / gtkmm / dialog_color.cpp
1 /* === S Y N F I G ========================================================= */
2 /*!     \file dialog_gradient.cpp
3 **      \brief Template File
4 **
5 **      $Id: dialog_color.cpp,v 1.1.1.1 2005/01/07 03:34:36 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 "dialog_color.h"
32 #include "widget_color.h"
33 #include <gtkmm/frame.h>
34 #include <gtkmm/table.h>
35 #include <gtkmm/label.h>
36 #include <synfig/general.h>
37 #include <synfigapp/canvasinterface.h>
38 #include <synfigapp/value_desc.h>
39 #include "widget_color.h"
40 #include <gtkmm/spinbutton.h>
41 #include <synfigapp/main.h>
42 #include <sigc++/retype_return.h>
43 #include <sigc++/retype.h>
44 #include <sigc++/hide.h>
45 #include "app.h"
46
47 #endif
48
49 /* === U S I N G =========================================================== */
50
51 using namespace std;
52 using namespace etl;
53 using namespace synfig;
54 using namespace studio;
55
56 /* === M A C R O S ========================================================= */
57
58 /* === G L O B A L S ======================================================= */
59
60 /* === P R O C E D U R E S ================================================= */
61
62 /* === M E T H O D S ======================================================= */
63
64 Dialog_Color::Dialog_Color():
65         Dialog(_("Colors"),false,true),
66         dialog_settings(this,"color"),
67         busy_(false)
68 //      adjustment_pos(0,0.0,1.0,0.001,0.001,0.001)
69 {
70         set_type_hint(Gdk::WINDOW_TYPE_HINT_UTILITY);
71         // Setup the buttons
72         //Gtk::Button *ok_button(manage(new class Gtk::Button(Gtk::StockID("gtk-ok"))));
73         //ok_button->show();
74         //add_action_widget(*ok_button,2);
75         //ok_button->signal_clicked().connect(sigc::mem_fun(*this, &Dialog_Color::on_ok_pressed));
76
77         //Gtk::Button *apply_button(manage(new class Gtk::Button(Gtk::StockID("gtk-apply"))));
78         //apply_button->show();
79         //add_action_widget(*apply_button,1);
80         //apply_button->signal_clicked().connect(sigc::mem_fun(*this, &Dialog_Color::on_apply_pressed));
81
82         Gtk::Button *cancel_button(manage(new class Gtk::Button(Gtk::StockID("gtk-close"))));
83         cancel_button->show();
84         add_action_widget(*cancel_button,0);
85         cancel_button->signal_clicked().connect(sigc::hide_return(sigc::mem_fun(*this, &Dialog_Color::on_close_pressed)));      
86         signal_delete_event().connect(sigc::hide(sigc::mem_fun(*this, &Dialog_Color::on_close_pressed)));
87
88         Gtk::Table* table(manage(new Gtk::Table(2,2,false)));
89         get_vbox()->pack_start(*table);
90
91         widget_color=manage(new Widget_ColorEdit());
92         widget_color->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Dialog_Color::on_color_changed));
93         //widget_color->signal_activate().connect(sigc::mem_fun(*this,&studio::Dialog_Color::on_color_changed));
94         table->attach(*widget_color, 0, 1, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);   
95
96         add_accel_group(App::ui_manager()->get_accel_group());
97
98         show_all_children();
99 }
100
101 Dialog_Color::~Dialog_Color()
102 {
103 }
104
105 void
106 Dialog_Color::reset()
107 {
108         signal_edited_.clear();
109 }
110
111 bool
112 Dialog_Color::on_close_pressed()
113 {
114 //      signal_edited_(get_color());
115         busy_=false;
116         grab_focus();
117         reset();
118         hide();
119         return true;
120 }
121
122 void
123 Dialog_Color::on_apply_pressed()
124 {
125         busy_=true;
126         signal_edited_(get_color());
127         busy_=false;
128 }
129
130 void
131 Dialog_Color::on_color_changed()
132 {
133         busy_=true;
134         signal_edited_(get_color());
135         busy_=false;
136 }