Added the new ZoomButtonPanel class
authorPekka Nissinen <pekka.nissinen@ixonos.com>
Wed, 12 May 2010 13:49:30 +0000 (16:49 +0300)
committerPekka Nissinen <pekka.nissinen@ixonos.com>
Wed, 12 May 2010 13:49:30 +0000 (16:49 +0300)
src/ui/zoombuttonpanel.cpp [new file with mode: 0644]
src/ui/zoombuttonpanel.h [new file with mode: 0644]

diff --git a/src/ui/zoombuttonpanel.cpp b/src/ui/zoombuttonpanel.cpp
new file mode 100644 (file)
index 0000000..9eb7992
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+   Situare - A location system for Facebook
+   Copyright (C) 2010  Ixonos Plc. Authors:
+
+       Pekka Nissinen - pekka.nissinen@ixonos.com
+
+   Situare is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License
+   version 2 as published by the Free Software Foundation.
+
+   Situare is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with Situare; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+   USA.
+*/
+
+#include <QDebug>
+
+#include "zoombuttonpanel.h"
+#include "panelcommon.h"
+
+ZoomButtonPanel::ZoomButtonPanel(QWidget *parent, int x, int y)
+    : QWidget(parent),
+      m_panelLayout(this),
+      m_x(x),
+      m_y(y)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    m_zoomInBtn = new ImageButton(this, ":/res/images/zoom_in.png");
+    m_zoomOutBtn = new ImageButton(this, ":/res/images/zoom_out.png");
+
+    m_panelLayout.setMargin(0);
+    m_panelLayout.setSpacing(0);
+    m_panelLayout.setVerticalSpacing(ZOOM_BUTTON_PANEL_BUTTON_SPACING);
+
+    m_panelLayout.addWidget(m_zoomInBtn, 0, 0);
+    m_panelLayout.addWidget(m_zoomOutBtn, 1, 0);
+
+    setFixedSize(m_zoomInBtn->size().width(), m_zoomInBtn->height()
+                 + ZOOM_BUTTON_PANEL_BUTTON_SPACING + m_zoomInBtn->height());
+    move(m_x, m_y);
+}
+
+ZoomButtonPanel::~ZoomButtonPanel()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    delete m_zoomInBtn;
+    delete m_zoomOutBtn;
+    m_zoomInBtn = 0;
+    m_zoomOutBtn = 0;
+}
+
+void ZoomButtonPanel ::paintEvent(QPaintEvent *event)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    Q_UNUSED(event);
+
+    QPainter painter(this);
+
+    // Temporary border
+    painter.setPen(Qt::red);
+    painter.drawRect(this->rect().x(), this->rect().y(),
+                     this->rect().width() - 1, this->rect().height() - 1);
+}
diff --git a/src/ui/zoombuttonpanel.h b/src/ui/zoombuttonpanel.h
new file mode 100644 (file)
index 0000000..aab6dee
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+   Situare - A location system for Facebook
+   Copyright (C) 2010  Ixonos Plc. Authors:
+
+       Pekka Nissinen - pekka.nissinen@ixonos.com
+
+   Situare is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License
+   version 2 as published by the Free Software Foundation.
+
+   Situare is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with Situare; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+   USA.
+*/
+
+#ifndef ZOOMBUTTONPANEL_H
+#define ZOOMBUTTONPANEL_H
+
+#include <QRectF>
+#include <QWidget>
+#include <QPainter>
+#include <QGraphicsItem>
+#include <QGridLayout>
+#include <QStyleOptionGraphicsItem>
+#include <QGraphicsSceneMouseEvent>
+
+#include "imagebutton.h"
+
+/**
+* @brief Panel for zoom buttons
+*
+* @author Pekka Nissinen - pekka.nissinen (at) ixonos.com
+*/
+class ZoomButtonPanel : public QWidget
+{
+    Q_OBJECT
+
+public:
+    /**
+    * @brief Constructor
+    *
+    * @param parent Parent
+    * @param x Panel x coordinate
+    * @param y Panel y coordinate
+    */
+    ZoomButtonPanel(QWidget *parent = 0, int x = 0, int y = 0);
+
+    /**
+    * @brief Destructor
+    */
+    ~ZoomButtonPanel();
+
+/*******************************************************************************
+ * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
+ ******************************************************************************/
+protected:
+    void paintEvent(QPaintEvent *event);
+
+/*******************************************************************************
+ * DATA MEMBERS
+ ******************************************************************************/
+public:
+    ImageButton *m_zoomInBtn;     ///< Button for zoom in
+    ImageButton *m_zoomOutBtn;    ///< Button for zoom out
+
+private:
+    QGridLayout m_panelLayout;  ///< Panel layout
+    int m_x;                    ///< Panel x coordinate
+    int m_y;                    ///< Panel y coordinate
+};
+
+#endif // ZOOMBUTTONPANEL_H