Updated manual
[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   QLabel *zoomLabel = new QLabel();
18   zoomLabel->setPixmap(QIcon(":/icons/viewmag.png").pixmap(16, 16));
19   QHBoxLayout *layout = new QHBoxLayout;
20   layout->addWidget(zoomLabel);
21   layout->addWidget(&zoom);
22   setLayout(layout);
23
24   setToolTip(tr("Zoom"));
25   setWhatsThis(tr("Zoom magnification factor (base pairs per pixel)"));
26 }
27
28 void ZoomWidget::setValue(double value)
29 {
30   if (cur_value != value)
31   {
32     cur_value = value;
33     zoom.setValue(cur_value);
34     emit valueChanged(cur_value);
35   }
36 }
37
38 void ZoomWidget::setRange(double min, double max)
39 {
40   zoom.setRange(min, max);
41 }
42
43 void ZoomWidget::setSingleStep(double val)
44 {
45   zoom.setSingleStep(val);
46 }
47
48 double ZoomWidget::singleStep() const
49 {
50   return zoom.singleStep();
51 }
52
53 double ZoomWidget::minimum() const
54 {
55   return zoom.minimum();
56 }
57
58 double ZoomWidget::maximum() const
59 {
60   return zoom.maximum();
61 }
62