24c71a1de06cb161bc15c8e9e712c64f255036e3
[mussa.git] / qui / ZoomWidget.cpp
1 #include <QHBoxLayout>
2 #include <QIcon>
3 #include <QLabel>
4
5 #include "qui/ZoomWidget.hpp"
6 #include <iostream>
7 using namespace std;
8
9 ZoomWidget::ZoomWidget(QWidget *parent)
10   : QWidget(parent),
11     max_zoom_size(10000)
12 {
13   zoom.setRange(0.01, max_zoom_size);
14   zoom.setSingleStep(0.1);
15   connect(&zoom, SIGNAL(valueChanged(double)), this, SLOT(setValue(double)));
16
17   auto_ptr<QLabel> zoomLabel(new QLabel());
18   zoomLabel->setPixmap(QIcon(":/icons/viewmag.png").pixmap(16, 16));
19   QHBoxLayout *layout = new QHBoxLayout;
20   layout->addWidget(zoomLabel.get());
21   layout->addWidget(&zoom);
22   layout->addWidget(new QLabel("bp/pix"));
23   setLayout(layout);
24
25   setToolTip(tr("Zoom"));
26   setWhatsThis(tr("Zoom magnification factor (base pairs per pixel)"));
27 }
28
29 void ZoomWidget::setValue(double value)
30 {
31   if (cur_value != value)
32   {
33     cur_value = value;
34     zoom.setValue(cur_value);
35     emit valueChanged(cur_value);
36   }
37 }
38
39 void ZoomWidget::setRange(double min, double max)
40 {
41   zoom.setRange(min, max);
42 }
43
44 void ZoomWidget::setSingleStep(double val)
45 {
46   zoom.setSingleStep(val);
47 }
48
49 double ZoomWidget::singleStep() const
50 {
51   return zoom.singleStep();
52 }
53
54 double ZoomWidget::minimum() const
55 {
56   return zoom.minimum();
57 }
58
59 double ZoomWidget::maximum() const
60 {
61   return zoom.maximum();
62 }
63