klineal.h 2.93 KB
Newer Older
Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
/***************************************************************************
                          klineal.h  -  description
                             -------------------
    begin                : Fri Oct 13 2000
    copyright            : (C) 2000 by Till Krech
    email                : till@snafu.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 KLINEAL_H
#define KLINEAL_H

Andreas Beckermann's avatar
Andreas Beckermann committed
21
#include <kapplication.h>
Laurent Montel's avatar
Laurent Montel committed
22
#include <kmenu.h>
Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
23 24 25
#include <kmainwindow.h>

#include <kcolordialog.h>
26
#include <kfontdialog.h>
Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
27 28 29 30

#include <qlabel.h>
#include <qpainter.h>
#include <qwidget.h>
George Staikos's avatar
build  
George Staikos committed
31
#include <qcursor.h>
32 33 34 35 36
//Added by qt3to4:
#include <QMouseEvent>
#include <QKeyEvent>
#include <QEvent>
#include <QPaintEvent>
Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
37

38
class KLineal : public QWidget {
39 40
  Q_OBJECT
public:
Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
41 42
  enum { North=0, West=1, South=2, East=3 };
  /** constructor */
43
  KLineal(QWidget*parent=0);
Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
44 45 46 47 48 49 50 51
  /** destructor */
  ~KLineal();
  void move(int x, int y);
  void move(const QPoint &p);
  QPoint pos();
  int x();
  int y();
protected:
52 53
	void keyPressEvent(QKeyEvent *e);
  void mousePressEvent(QMouseEvent *e);
54
  void mouseReleaseEvent(QMouseEvent *e);
Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
55
  void mouseMoveEvent(QMouseEvent *e);
56 57
  void paintEvent(QPaintEvent *e);
  void enterEvent(QEvent *e);
58 59 60
  void leaveEvent(QEvent *e);
  void setupBackground();

Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
61 62 63 64 65 66 67 68 69 70 71 72

private:
  void drawScale(QPainter &painter);
  void reLength(int percentOfScreen);
  bool mDragging;
  QPoint mLastClickPos;
  QPoint mDragOffset;
  QLabel *mLabel;
  QLabel *mColorLabel;
  int mOrientation;
  int mLongEdgeLen;
  int mShortEdgeLen;
Laurent Montel's avatar
Laurent Montel committed
73 74
  KMenu *mMenu;
  KMenu *mLenMenu;
Pascal Létourneau's avatar
porting  
Pascal Létourneau committed
75
  QAction *mFullScreenAction;
76
  QColor mColor;
Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
77 78 79 80 81 82 83 84
  QColor mStoredColor;
  QCursor mCurrentCursor;
  QCursor mNorthCursor;
  QCursor mEastCursor;
  QCursor mWestCursor;
  QCursor mSouthCursor;
  QCursor mDragCursor;
  KColorDialog mColorSelector;
85
  QFont mScaleFont;
Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
	bool _clicked;
public slots:
  void setOrientation(int);
  void setNorth();
  void setEast();
  void setSouth();
  void setWest();
  void turnLeft();
  void turnRight();
  void showMenu();
  void hideLabel();
  void showLabel();
  void adjustLabel();
  void setShortLength();
  void setMediumLength();
  void setTallLength();
  void setFullLength();
  void setColor();
104
  void setFont(QFont &);
Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
105 106
  void setColor(const QColor &color);
  void choseColor();
107
  void choseFont();
Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
108
  void restoreColor();
109
  void saveSettings();
Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
110 111
};
#endif