blob: 5ac00da9f5fb314fa2c520372192d081a10fa0de (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
/*
* Copyright (c) 2012 Mateusz Piękos
* Licensed under the simplified BSD license.
* See Documentation/Licenses/BSD-simplified.txt for more information.
*/
#pragma once
#include <QGraphicsView>
#include <QGraphicsLineItem>
#include <QMouseEvent>
#include <QPen>
#include <iostream>
#include "TextDialog.h"
#include "FreehandLineItem.h"
using namespace std;
namespace Swift {
class GView : public QGraphicsView {
Q_OBJECT;
public:
enum Mode { Rubber, Line, Rect, Circle, HandLine, FilledHandLine, Text, Polygon, Select };
GView(QGraphicsScene* scene, QWidget* parent = 0);
void setLineWidth(int i);
void setLineColor(QColor color);
QColor getLineColor();
void setBrushColor(QColor color);
QColor getBrushColor();
void setMode(Mode mode);
void mouseMoveEvent(QMouseEvent* event);
void mousePressEvent(QMouseEvent* event);
void mouseReleaseEvent(QMouseEvent* event);
public slots:
void moveUpSelectedItem();
void moveDownSelectedItem();
private:
int zValue;
bool mousePressed;
QPen pen;
QBrush brush;
Mode mode;
QGraphicsItem* lastItem;
QGraphicsRectItem* selectionRect;
TextDialog* textDialog;
signals:
void lastItemChanged(QGraphicsItem* item);
};
}
|