summaryrefslogtreecommitdiffstats
path: root/kbarcode/mycanvasview.h
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-02-15 18:34:54 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-02-15 18:34:54 +0000
commit8805e6b17b1460f3316ccb28629e8ad78e4b9c2c (patch)
treedc9b702962ecf0060cc473397b9f80268c2456c9 /kbarcode/mycanvasview.h
downloadkbarcode-8805e6b17b1460f3316ccb28629e8ad78e4b9c2c.tar.gz
kbarcode-8805e6b17b1460f3316ccb28629e8ad78e4b9c2c.zip
Added abandoned KDE3 version of kbarcode
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/kbarcode@1090667 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kbarcode/mycanvasview.h')
-rw-r--r--kbarcode/mycanvasview.h175
1 files changed, 175 insertions, 0 deletions
diff --git a/kbarcode/mycanvasview.h b/kbarcode/mycanvasview.h
new file mode 100644
index 0000000..0922717
--- /dev/null
+++ b/kbarcode/mycanvasview.h
@@ -0,0 +1,175 @@
+/***************************************************************************
+ mycanvasview.h - description
+ -------------------
+ begin : Die Apr 23 2002
+ copyright : (C) 2002 by Dominik Seichter
+ email : domseichter@web.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+
+#ifndef MYCANVASVIEW_H
+#define MYCANVASVIEW_H
+
+#include <qcanvas.h>
+#include <qvaluelist.h>
+#include "documentitem.h"
+
+class TCanvasItem;
+
+typedef QValueList<TCanvasItem*> TCanvasItemList;
+
+
+class QRect;
+class QPainter;
+class MyCanvas : public QCanvas {
+ Q_OBJECT
+
+ public:
+ MyCanvas( QObject* parent, const char* name = 0 );
+ ~MyCanvas();
+
+ void setRect( QRect r ) {
+ m_rect = r;
+ }
+
+ QRect rect() const {
+ return m_rect;
+ }
+
+ void setGrid( bool enabled ) {
+ m_grid = enabled;
+ }
+
+ bool grid() const { return m_grid; }
+
+ protected:
+ void drawBackground( QPainter & painter, const QRect & clip );
+
+ private:
+ QRect m_rect;
+ bool m_grid;
+};
+
+class Definition;
+class QColor;
+class QLabel;
+class QPoint;
+class KCommandHistory;
+class KMacroCommand;
+class KRuler;
+class KStatusBar;
+class MyCanvasView : public QCanvasView
+{
+ Q_OBJECT
+
+ enum edges {
+ TopLeft,
+ TopMiddle,
+ TopRight,
+ RightMiddle,
+ LeftMiddle,
+ BottomLeft,
+ BottomMiddle,
+ BottomRight,
+ Inside,
+ Outside,
+ Barcode
+ };
+
+ public:
+ MyCanvasView( Definition* d, MyCanvas *c, QWidget* parent=0, const char* name=0, WFlags f=0);
+ ~MyCanvasView();
+
+ /** return a list of all DocumentItems on the canvas
+ */
+ DocumentItemList getAllItems();
+
+ TCanvasItemList getSelected();
+
+ TCanvasItem* getActive();
+ void setActive( QCanvasItem* item = 0, bool control = false );
+
+ void setCurrent( QCanvasItem* item );
+
+ void setHistory( KCommandHistory* hist ) {
+ history = hist;
+ }
+
+ QPoint getTranslation() const {
+ return translation;
+ }
+
+ void setDefinition( Definition* d );
+ void setPosLabel( KStatusBar* s, int id ) {
+ mouseid = id;
+ statusbar = s;
+ }
+
+ static int getLowestZ( QCanvasItemList list );
+ static int getHighestZ( QCanvasItemList list );
+
+ void snapPoint(QPoint* point, TCanvasItem* item) ;
+
+ public slots:
+ void selectAll();
+ void deSelectAll();
+
+ void deleteCurrent();
+
+ void updateGUI() {
+ canvas()->update();
+ repaintContents();
+ }
+
+ protected:
+ void contentsMousePressEvent(QMouseEvent*);
+ void contentsMouseMoveEvent(QMouseEvent*);
+ void contentsMouseReleaseEvent(QMouseEvent *);
+ void contentsMouseDoubleClickEvent(QMouseEvent*);
+ void resizeEvent( QResizeEvent * r );
+
+ signals:
+ void selectionChanged();
+ void movedSomething();
+ void doubleClickedItem( TCanvasItem* );
+ void showContextMenu( QPoint );
+
+ private:
+ void setSelected( QCanvasItem* item = 0, bool control = false );
+ KMacroCommand* getMoveCommand();
+
+ Definition* def;
+
+ KRuler* rulerv;
+ KRuler* rulerh;
+
+ KCommandHistory* history;
+ KMacroCommand* m_commov;
+ MyCanvas* canv;
+
+ int mouseid;
+ KStatusBar* statusbar;
+
+ QPoint moving_start;
+ QPoint translation;
+
+ QRect old;
+
+ bool isInside( QPoint p, QCanvasItem* item );
+ int isEdge( QPoint p, QCanvasItem* item );
+ void reposition();
+ void updateRuler();
+ int updateCursor( QPoint pos, bool pressed = false );
+ int m_mode;
+ QPoint delta_pt ;
+};
+
+#endif