Merge branch 'master' into genete_canvasview-revisited
[synfig.git] / synfig-studio / src / gtkmm / resolutiondial.cpp
1 /* === S Y N F I G ========================================================= */
2 /*!     \file resolutiondial.cpp
3 **      \brief Template File
4 **
5 **      $Id$
6 **
7 **      \legal
8 **      Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 **      Copyright (c) 2009 Gerco Ballintijn
10 **      Copyright (c) 2009 Carlos Lopez
11 **
12 **      This package is free software; you can redistribute it and/or
13 **      modify it under the terms of the GNU General Public License as
14 **      published by the Free Software Foundation; either version 2 of
15 **      the License, or (at your option) any later version.
16 **
17 **      This package is distributed in the hope that it will be useful,
18 **      but WITHOUT ANY WARRANTY; without even the implied warranty of
19 **      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 **      General Public License for more details.
21 **      \endlegal
22 */
23 /* ========================================================================= */
24
25 /* === H E A D E R S ======================================================= */
26
27 #ifdef USING_PCH
28 #       include "pch.h"
29 #else
30 #ifdef HAVE_CONFIG_H
31 #       include <config.h>
32 #endif
33
34 #include "resolutiondial.h"
35 #include <gtkmm/image.h>
36 #include <gtkmm/stock.h>
37
38 #endif
39
40 /* === U S I N G =========================================================== */
41
42 using namespace std;
43 using namespace studio;
44
45 /* === M A C R O S ========================================================= */
46
47 /* === G L O B A L S ======================================================= */
48
49 /* === P R O C E D U R E S ================================================= */
50
51 /* === M E T H O D S ======================================================= */
52
53 ResolutionDial::ResolutionDial(Gtk::IconSize & size): Gtk::Table(3, 1, false)
54 {
55
56         increase_resolution = create_icon(size, Gtk::StockID("synfig-increase_resolution"), _("Increase Display Resolution"));
57         decrease_resolution = create_icon(size, Gtk::StockID("synfig-decrease_resolution"), _("Decrease Display Resolution"));
58         use_low_resolution = create_check(_("Low Res"), _("Use Low Resolution when enabled"));
59
60         attach(*decrease_resolution, 0, 1, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
61         attach(*use_low_resolution, 1, 2, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
62         attach(*increase_resolution, 2, 3, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
63 }
64
65 Gtk::Button *
66 ResolutionDial::create_icon(Gtk::IconSize size, const Gtk::StockID & stockid,
67                 const char * tooltip)
68 {
69         Gtk::Button *button = manage(new class Gtk::Button());
70         Gtk::Image *icon = manage(new Gtk::Image(stockid, size));
71         button->add(*icon);
72         tooltips.set_tip(*button, tooltip);
73         icon->set_padding(0, 0);
74         icon->show();
75         button->set_relief(Gtk::RELIEF_NONE);
76         button->show();
77
78         return button;
79 }
80
81 Gtk::CheckButton *
82 ResolutionDial::create_check(const char *label, const char * tooltip)
83 {
84         Gtk::CheckButton *cbutton = manage(new class Gtk::CheckButton());
85         cbutton->set_label(label);
86         tooltips.set_tip(*cbutton, tooltip);
87         cbutton->show();
88
89         return cbutton;
90 }
91
92 void
93 ResolutionDial::update_lowres(bool flag)
94 {
95         use_low_resolution->set_active(flag);
96 }