don't use staticly allocated widgets
[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     zoom(new QDoubleSpinBox),
12     max_zoom_size(10000)
13 {
14   zoom->setRange(0.01, max_zoom_size);
15   zoom->setSingleStep(0.1);
16   connect(zoom, SIGNAL(valueChanged(double)), this, SLOT(setValue(double)));
17
18   QLabel *zoomLabel = new QLabel();
19   zoomLabel->setPixmap(QIcon(":/icons/viewmag.png").pixmap(16, 16));
20   QHBoxLayout *layout = new QHBoxLayout;
21   layout->addWidget(zoomLabel);
22   layout->addWidget(zoom);
23   layout->addWidget(new QLabel("bp/pix"));
24   setLayout(layout);
25
26   setToolTip(tr("Zoom"));
27   setWhatsThis(tr("Zoom magnification factor (base pairs per pixel)"));
28 }
29
30 void ZoomWidget::setValue(double value)
31 {
32   if (cur_value != value)
33   {
34     cur_value = value;
35     zoom->setValue(cur_value);
36     emit valueChanged(cur_value);
37   }
38 }
39
40 void ZoomWidget::setRange(double min, double max)
41 {
42   zoom->setRange(min, max);
43 }
44
45 void ZoomWidget::setSingleStep(double val)
46 {
47   zoom->setSingleStep(val);
48 }
49
50 double ZoomWidget::singleStep() const
51 {
52   return zoom->singleStep();
53 }
54
55 double ZoomWidget::minimum() const
56 {
57   return zoom->minimum();
58 }
59
60 double ZoomWidget::maximum() const
61 {
62   return zoom->maximum();
63 }
64