[go: up one dir, main page]

Menu

[r303]: / mimage.h  Maximize  Restore  History

Download this file

97 lines (83 with data), 2.9 kB

 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/* Marcion
Copyright (C) 2009 - 2011 Milan Konvicka
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program 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 this program */
#ifndef MIMAGE_H
#define MIMAGE_H
//
#include <QGraphicsView>
#include <QGraphicsItem>
#include <QGraphicsScene>
#include <QMouseEvent>
#include <QPixmap>
#include <QMenu>
#include <QAction>
#include <QClipboard>
#include "messages.h"
#include "settings.h"
//
class CMImage : public QGraphicsView
{
Q_OBJECT
public:
enum ImageMode{Image,Pdf,Map};
enum MouseMode{Move,Select};
enum SelMoveMode{Normal,LeftTop,LeftBottom,RightTop,RightBottom};
CMImage(QWidget * parent = 0);
~CMImage();
//void init(CMessages * const messages);
bool loadPage(QString const & ,qreal );
void setPixmap(QPixmap const &);
QPixmap const & getPixmap(){return pixmap;}
void clearPixmap();
void scale(qreal zoom);
void showPopupOnButton(QPoint);
QGraphicsScene * grScene(){return &scene;}
//void enablePdfMenu();
void setMouseMode(MouseMode,bool signal=true);
void setSettingsState(bool);
void setSelectionBorderColor(QColor const &);
void setSelectionBorderWidth(int);
void setSelectionFillColor(QColor const &);
//void setSelectionFillOpacity(int);
void cancelSelection();
QRect selectionRect() const {return selection.toRect();}
void setImageMode(ImageMode imode);
ImageMode imageMode(){return _i_mode;}
protected:
void mousePressEvent ( QMouseEvent * e );
void mouseMoveEvent ( QMouseEvent * e );
void mouseReleaseEvent ( QMouseEvent * e );
private:
QPointF start;
QGraphicsScene scene;
QGraphicsItem * current;
QGraphicsRectItem * sel_rect;
QPixmap pixmap;
//CMessages * const messages;
QMenu popup,popupSel;
QRectF selection;
QPen sel_pen;
QBrush sel_brush;
MouseMode _m_mode;
SelMoveMode _s_mode;
ImageMode _i_mode;
bool bt_popup;
QAction * a_move,*a_select,*a_copy,*a_copy_text,*a_clr_selection,*a_repaint,*a_sett;
QAction *a_sel_lt,*a_sel_lb,*a_sel_rt,*a_sel_rb,*a_sel_norm;
private slots:
void slot_customContextMenuRequested(QPoint);
signals:
void positionChanged(QPointF);
void copyTextRequested(QRectF);
void mouseModeChanged(int);
void settingsActivated(bool);
};
#endif