2 * This file is part of RawTherapee.
4 * Copyright (c) 2004-2010 Gabor Horvath <hgabor@rawtherapee.com>
6 * RawTherapee is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * RawTherapee is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with RawTherapee. If not, see <http://www.gnu.org/licenses/>.
19 #include <zoompanel.h>
20 #include <multilangmgr.h>
21 #include <imagearea.h>
23 ZoomPanel::ZoomPanel (ImageArea
* iarea
) : iarea(iarea
) {
27 Gtk::Label
* label
= Gtk::manage (new Gtk::Label (Glib::ustring("<b>") + "Zoom" + ":</b> "));
28 label
->set_use_markup (true);
30 pack_start (*label
, Gtk::PACK_SHRINK
, 4);
32 Gtk::Image
* imageOut
= Gtk::manage (new Gtk::Image (Gtk::StockID ("gtk-zoom-out"), Gtk::ICON_SIZE_SMALL_TOOLBAR
));
33 imageOut
->set_padding(0,0);
34 Gtk::Image
* imageIn
= Gtk::manage (new Gtk::Image (Gtk::StockID ("gtk-zoom-in"), Gtk::ICON_SIZE_SMALL_TOOLBAR
));
35 imageIn
->set_padding(0,0);
36 Gtk::Image
* image11
=Gtk::manage ( new Gtk::Image (Gtk::StockID ("gtk-zoom-100"), Gtk::ICON_SIZE_SMALL_TOOLBAR
));
37 image11
->set_padding(0,0);
38 Gtk::Image
* imageFit
= Gtk::manage (new Gtk::Image (Gtk::StockID ("gtk-zoom-fit"), Gtk::ICON_SIZE_SMALL_TOOLBAR
));
39 imageFit
->set_padding(0,0);
41 zoomOut
= Gtk::manage (new Gtk::Button());
42 zoomOut
->add (*imageOut
);
43 zoomOut
->set_relief(Gtk::RELIEF_NONE
);
44 zoomIn
= Gtk::manage (new Gtk::Button());
45 zoomIn
->add (*imageIn
);
46 zoomIn
->set_relief(Gtk::RELIEF_NONE
);
47 zoomFit
= Gtk::manage (new Gtk::Button());
48 zoomFit
->add (*imageFit
);
49 zoomFit
->set_relief(Gtk::RELIEF_NONE
);
50 zoom11
= Gtk::manage (new Gtk::Button());
51 zoom11
->add (*image11
);
52 zoom11
->set_relief(Gtk::RELIEF_NONE
);
54 pack_start (*zoomOut
, Gtk::PACK_SHRINK
, 0);
55 pack_start (*zoomIn
, Gtk::PACK_SHRINK
, 0);
56 pack_start (*zoomFit
, Gtk::PACK_SHRINK
, 0);
57 pack_start (*zoom11
, Gtk::PACK_SHRINK
, 0);
59 zoomLabel
= Gtk::manage (new Gtk::Label ());
60 pack_start (*zoomLabel
, Gtk::PACK_SHRINK
, 4);
62 Gtk::Image
* imageCrop
= Gtk::manage (new Gtk::Image (Gtk::StockID ("gtk-add"), Gtk::ICON_SIZE_SMALL_TOOLBAR
));
63 imageCrop
->set_padding(0,0);
64 newCrop
= Gtk::manage (new Gtk::Button());
65 newCrop
->add (*imageCrop
);
66 newCrop
->set_relief(Gtk::RELIEF_NONE
);
67 pack_start (*newCrop
, Gtk::PACK_SHRINK
, 4);
71 zoomIn
->signal_clicked().connect ( sigc::mem_fun(*this, &ZoomPanel::zoomInClicked
) );
72 zoomOut
->signal_clicked().connect( sigc::mem_fun(*this, &ZoomPanel::zoomOutClicked
) );
73 zoomFit
->signal_clicked().connect( sigc::mem_fun(*this, &ZoomPanel::zoomFitClicked
) );
74 zoom11
->signal_clicked().connect ( sigc::mem_fun(*this, &ZoomPanel::zoom11Clicked
) );
75 newCrop
->signal_clicked().connect ( sigc::mem_fun(*this, &ZoomPanel::newCropClicked
) );
77 zoomIn
->set_tooltip_text ("Zoom In");
78 zoomOut
->set_tooltip_text ("Zoom Out");
79 zoom11
->set_tooltip_text ("Zoom to 100%");
80 zoomFit
->set_tooltip_text ("Fit to screen");
81 newCrop
->set_tooltip_text ("Add new crop window");
83 zoomLabel
->set_text ("(100%)");
86 void ZoomPanel::zoomInClicked () {
88 if (iarea
->mainCropWindow
)
89 iarea
->mainCropWindow
->zoomIn ();
92 void ZoomPanel::zoomOutClicked () {
94 if (iarea
->mainCropWindow
)
95 iarea
->mainCropWindow
->zoomOut ();
98 void ZoomPanel::zoomFitClicked () {
100 if (iarea
->mainCropWindow
)
101 iarea
->mainCropWindow
->zoomFit ();
104 void ZoomPanel::zoom11Clicked () {
106 if (iarea
->mainCropWindow
)
107 iarea
->mainCropWindow
->zoom11 ();
110 void ZoomPanel::refreshZoomLabel () {
112 if (iarea
->mainCropWindow
) {
113 int z
= (int)(iarea
->mainCropWindow
->getZoom () * 100);
114 zoomLabel
->set_text (Glib::ustring::compose("%1%%", z
));
118 void ZoomPanel::newCropClicked () {
120 iarea
->addCropWindow ();