78 lines
2.0 KiB
C++
78 lines
2.0 KiB
C++
#ifndef PICSCENE_H
|
|
#define PICSCENE_H
|
|
#include <QGraphicsScene>
|
|
#include "pictextitem.h"
|
|
#include <QGraphicsSceneMouseEvent>
|
|
#include <QPoint>
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
class QGraphicsSceneMouseEvent;
|
|
class QMenu;
|
|
class QPointF;
|
|
class QGraphicsLineItem;
|
|
class QFont;
|
|
class QGraphicsTextItem;
|
|
class QColor;
|
|
QT_END_NAMESPACE
|
|
|
|
class PicScene : public QGraphicsScene
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
enum Mode { InsertItem, InsertLine, InsertText, InsertPic, MoveItem };
|
|
explicit PicScene(QObject *parent = 0);
|
|
|
|
QFont font() const
|
|
{ return myFont; }
|
|
QColor textColor() const
|
|
{ return myTextColor; }
|
|
QColor itemColor() const
|
|
{ return myItemColor; }
|
|
QColor lineColor() const
|
|
{ return myLineColor; }
|
|
void setLineColor(const QColor &color);
|
|
void setTextColor(const QColor &color);
|
|
void setItemColor(const QColor &color);
|
|
void setFont(const QFont &font);
|
|
void keyPressEvent(QKeyEvent *event);
|
|
|
|
public slots:
|
|
void setMode(Mode mode);
|
|
void setIsdrawBackground(bool newIsdrawBackground);
|
|
signals:
|
|
void textInserted(QGraphicsTextItem *item);
|
|
void itemSelected(QGraphicsItem *item);
|
|
void xmlContentChanged();
|
|
void showTextWidthHeight();
|
|
void adjustItemsPos();
|
|
void focusedItemPosChanged(QPoint p);
|
|
|
|
private slots:
|
|
void onFocusItemChanged(QGraphicsItem *newFocusItem, QGraphicsItem *oldFocusItem, Qt::FocusReason reason);
|
|
void onFocusedItemPosChanged();
|
|
|
|
protected:
|
|
void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent);
|
|
void mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent);
|
|
void mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent);
|
|
void drawBackground(QPainter *painter, const QRectF &rect);
|
|
private:
|
|
bool isItemChange(int type);
|
|
|
|
QMenu *myItemMenu;
|
|
Mode myMode;
|
|
bool leftButtonDown;
|
|
QPointF startPoint;
|
|
QGraphicsLineItem *line;
|
|
QFont myFont;
|
|
PicTextItem *textItem;
|
|
QColor myTextColor;
|
|
QColor myItemColor;
|
|
QColor myLineColor;
|
|
|
|
bool IsdrawBackground;
|
|
|
|
QGraphicsObject* currFocusItem;
|
|
};
|
|
#endif // PICSCENE_H
|