--- /dev/null
+/*
+ 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 <QPixmap>
+
+#include "mapbutton.h"
+#include "mapcommon.h"
+
+MapButton::MapButton(QString fileName)
+ : m_buttonMode(QIcon::Normal),
+ m_buttonWidth(MAP_ZOOM_PANEL_BUTTON_SIZE),
+ m_buttonHeight(MAP_ZOOM_PANEL_BUTTON_SIZE)
+{
+ QPixmap pixmap(fileName);
+
+ // Temporary (lazy fix) solution to get the buttons larger
+ addPixmap(pixmap.scaled(m_buttonWidth, m_buttonHeight, Qt::KeepAspectRatio, Qt::FastTransformation));
+}
+
+void MapButton::draw(QPainter *painter, int x, int y)
+{
+ paint(painter, x, y, m_buttonWidth, m_buttonHeight, NULL, m_buttonMode);
+}
+
+void MapButton::setMode(QIcon::Mode mode)
+{
+ m_buttonMode = mode;
+}
--- /dev/null
+/*
+ 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 MAPBUTTON_H
+#define MAPBUTTON_H
+
+#include <QIcon>
+#include <QString>
+#include <QPainter>
+
+class MapButton : public QIcon
+{
+public:
+ MapButton(QString fileName);
+ void draw(QPainter *painter, int x, int y);
+ void setMode(QIcon::Mode mode);
+
+private:
+ QIcon::Mode m_buttonMode;
+ int m_buttonWidth;
+ int m_buttonHeight;
+};
+
+#endif // MAPBUTTON_H
--- /dev/null
+/*
+ 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 "mapcommon.h"
+#include "mapzoompanel.h"
+
+MapZoomPanel::MapZoomPanel(QGraphicsItem *parent, int x, int y) : QGraphicsItem(parent)
+{
+ m_x = x;
+ m_y = y;
+ m_width = MAP_ZOOM_PANEL_BUTTON_SIZE;
+ m_height = MAP_ZOOM_PANEL_BUTTON_SIZE * 2;
+
+ m_zoomInBtn = new MapButton(":/resources/zoom_in.png");
+ m_zoomOutBtn = new MapButton(":/resources/zoom_out.png");
+
+ setFlag(QGraphicsItem::ItemIgnoresTransformations);
+ setZValue(static_cast<qreal>(MAP_ZOOM_PANEL_LEVEL));
+}
+
+QRectF MapZoomPanel::boundingRect() const
+{
+ return QRectF(m_x, m_y, m_width, m_height);
+}
+
+void MapZoomPanel::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
+{
+ Q_UNUSED(option);
+ Q_UNUSED(widget);
+
+ m_zoomInBtn->draw(painter, m_x, m_y);
+ m_zoomOutBtn->draw(painter, m_x, m_y + MAP_ZOOM_PANEL_BUTTON_SIZE);
+}
+
+void MapZoomPanel::mousePressEvent(QGraphicsSceneMouseEvent *event)
+{
+ if ( event->pos().y() < (m_y + MAP_ZOOM_PANEL_BUTTON_SIZE) )
+ m_zoomInBtn->setMode(QIcon::Selected);
+ else
+ m_zoomOutBtn->setMode(QIcon::Selected);
+
+ update();
+
+// qDebug() << __PRETTY_FUNCTION__;
+}
+
+void MapZoomPanel::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
+{
+ Q_UNUSED(event);
+
+ m_zoomInBtn->setMode(QIcon::Normal);
+ m_zoomOutBtn->setMode(QIcon::Normal);
+
+ if ( event->pos().y() < (m_y + MAP_ZOOM_PANEL_BUTTON_SIZE) )
+ emit zoomInPressed();
+ else
+ emit zoomOutPressed();
+
+ update();
+
+// qDebug() << __PRETTY_FUNCTION__;
+}
--- /dev/null
+/*
+ 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 MAPZOOMPANEL_H
+#define MAPZOOMPANEL_H
+
+#include <QRectF>
+#include <QWidget>
+#include <QPainter>
+#include <QGraphicsItem>
+#include <QStyleOptionGraphicsItem>
+#include <QGraphicsSceneMouseEvent>
+
+#include "mapbutton.h"
+
+class MapZoomPanel : public QObject, public QGraphicsItem
+{
+ Q_OBJECT
+
+public:
+ MapZoomPanel(QGraphicsItem *parent = 0, int x = 0, int y = 0);
+ QRectF boundingRect() const;
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
+
+protected:
+ void mousePressEvent(QGraphicsSceneMouseEvent *event);
+ void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
+
+signals:
+ void zoomInPressed();
+ void zoomOutPressed();
+
+private:
+ MapButton *m_zoomInBtn;
+ MapButton *m_zoomOutBtn;
+
+ qreal m_x;
+ qreal m_y;
+ qreal m_width;
+ qreal m_height;
+};
+
+#endif // MAPZOOMPANEL_H