[go: up one dir, main page]

Menu

[r692]: / mimage.h  Maximize  Restore  History

Download this file

132 lines (115 with data), 4.4 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
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/* Marcion
Copyright (C) 2009-2015 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; either version 2 of the License, or
(at your option) any later version.
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; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
#ifndef MIMAGE_H
#define MIMAGE_H
//
#include <QGraphicsView>
#include <QGraphicsItem>
#include <QGraphicsScene>
#include <QMouseEvent>
#include <QPixmap>
#include <QMenu>
#include <QAction>
#include <QClipboard>
#include <QMatrix>
#include <QBrush>
#include <QBitmap>
#include <QApplication>
#include "messages.h"
#include "settings.h"
#include "mnavwnd.h"
//
class CMImage : public QGraphicsView
{
friend class MImageWidget;
Q_OBJECT
public:
enum ImageMode{Image,Pdf,Map};
enum MouseMode{Move,Select};
enum CopyTextTarget{Clip,Dict,Conv};
enum SelMoveMode{Normal,LeftTop,LeftBottom,RightTop,RightBottom};
CMImage(QWidget * parent = 0);
~CMImage();
//void init(CMessages * const messages);
bool loadPage(QString const &,qreal,qreal rotate=0);
void setPixmap(QPixmap const &);
QPixmap const & getPixmap() const {return pixmap;}
QPixmap const * ptrPixmap() const {return &pixmap;}
void clearPixmap();
void deleteNavigator();
void scale(qreal zoom,qreal angle=0);
void showPopupOnButton(QAbstractButton * button);
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();}
QRectF selectionRectF() const {return selection;}
void setImageMode(ImageMode imode,QAbstractButton * find_button=0);
ImageMode imageMode(){return _i_mode;}
//void rotate(qreal);
QSizeF currentPageSize() const;
void copyImage(),clearSelection();
void grid(bool show);
void enableGrid(bool enable);
void setNavButton(QAbstractButton * button,MNavWnd ** w) {_nav_butt=button; _w=w;}
void selectAll();
protected:
void mousePressEvent ( QMouseEvent * e );
void mouseMoveEvent ( QMouseEvent * e );
void mouseReleaseEvent ( QMouseEvent * e );
void keyPressEvent ( QKeyEvent * e );
private:
QPointF start;
QGraphicsScene scene;
QGraphicsItem * current;
//QSize _cur_size;
QGraphicsRectItem * sel_rect;
QPixmap pixmap;
MButtonMenu popup;
QMenu popupSel;
QRectF selection;
QPen sel_pen;
QBrush sel_brush;
MouseMode _m_mode;
SelMoveMode _s_mode;
ImageMode _i_mode;
QActionGroup agrp,agrpSel;
QList<QGraphicsLineItem*> _grid;
bool _grid_enabled;
QAction * a_move,*a_select,*a_select_all,*a_copy,*a_copy_text,*a_dictionary,*a_conv,*a_clr_selection,*a_repaint,*a_sett,*a_links,*a_fonts,*a_find,*a_zoomplus,*a_zoomminus,*a_navigate;
QAction *a_sel_lt,*a_sel_lb,*a_sel_rt,*a_sel_rb,*a_sel_norm;
QAbstractButton * _findbutt,*_nav_butt;
MNavWnd ** _w;
private slots:
void slot_customContextMenuRequested(QPoint);
signals:
void positionChanged(QPointF);
void copyTextRequested(QRectF,int);
void showLinksRequested();
void showFontsRequested();
//void findTextRequested();
void mouseModeChanged(int);
void settingsActivated(bool);
void resizeRequested(bool smaller);
void beforeSceneResized();
void afterSceneResized();
void selectionChanged(QRectF selection);
};
#endif