klineal.h 2.74 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

Urs Wolfer's avatar
Urs Wolfer committed
21
#include <QWidget>
Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
22 23 24

#include <kcolordialog.h>

Urs Wolfer's avatar
Urs Wolfer committed
25 26
class QLabel;
class KMenu;
Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
27

28
class KLineal : public QWidget {
29 30
  Q_OBJECT
public:
Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
31 32
  enum { North=0, West=1, South=2, East=3 };
  /** constructor */
33
  KLineal(QWidget*parent=0);
Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
34 35 36 37 38 39 40 41
  /** destructor */
  ~KLineal();
  void move(int x, int y);
  void move(const QPoint &p);
  QPoint pos();
  int x();
  int y();
protected:
Urs Wolfer's avatar
Urs Wolfer committed
42
  void keyPressEvent(QKeyEvent *e);
43
  void mousePressEvent(QMouseEvent *e);
44
  void mouseReleaseEvent(QMouseEvent *e);
Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
45
  void mouseMoveEvent(QMouseEvent *e);
46 47
  void paintEvent(QPaintEvent *e);
  void enterEvent(QEvent *e);
48 49
  void leaveEvent(QEvent *e);

Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
50 51 52

private:
  void drawScale(QPainter &painter);
53
  void drawBackground(QPainter &painter);
Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
54 55 56 57 58 59 60 61 62
  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
63 64
  KMenu *mMenu;
  KMenu *mLenMenu;
Pascal Létourneau's avatar
porting  
Pascal Létourneau committed
65
  QAction *mFullScreenAction;
66
  QColor mColor;
Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
67 68 69 70 71 72 73 74
  QColor mStoredColor;
  QCursor mCurrentCursor;
  QCursor mNorthCursor;
  QCursor mEastCursor;
  QCursor mWestCursor;
  QCursor mSouthCursor;
  QCursor mDragCursor;
  KColorDialog mColorSelector;
75
  QFont mScaleFont;
Urs Wolfer's avatar
Urs Wolfer committed
76
  bool _clicked;
Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
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();
94
  void setFont(QFont &);
Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
95 96
  void setColor(const QColor &color);
  void choseColor();
97
  void choseFont();
Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
98
  void restoreColor();
99
  void saveSettings();
Laurent Montel's avatar
Laurent Montel committed
100
  void slotQuit();
Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
101 102
};
#endif