klineal.h 2.82 KB
Newer Older
Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
1 2 3 4
/***************************************************************************
                          klineal.h  -  description
                             -------------------
    begin                : Fri Oct 13 2000
5 6
    Copyright            : (C) 2000 - 2008 by Till Krech <till@snafu.de>
                           (C) 2009        by Mathias Soeken <msoeken@tzi.de>
Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
7 8 9 10 11 12 13 14 15 16 17 18 19 20
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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

Mathias Soeken's avatar
Mathias Soeken committed
23
#include <KColorDialog>
Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
24

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

28
class KLineal : public QWidget {
29
  Q_OBJECT
Mathias Soeken's avatar
Mathias Soeken committed
30

31
public:
Mathias Soeken's avatar
Mathias Soeken committed
32 33 34
  enum { North = 0, West, South, East };

  KLineal( QWidget *parent = 0 );
Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
35
  ~KLineal();
Mathias Soeken's avatar
Mathias Soeken committed
36 37 38

  void move( int x, int y );
  void move( const QPoint &p );
Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
39 40 41
  QPoint pos();
  int x();
  int y();
Mathias Soeken's avatar
Mathias Soeken committed
42

Mathias Soeken's avatar
Mathias Soeken committed
43
protected:
Mathias Soeken's avatar
Mathias Soeken committed
44 45 46 47 48 49 50
  void keyPressEvent( QKeyEvent *e );
  void mousePressEvent( QMouseEvent *e );
  void mouseReleaseEvent( QMouseEvent *e );
  void mouseMoveEvent( QMouseEvent *e );
  void paintEvent( QPaintEvent *e );
  void enterEvent( QEvent *e );
  void leaveEvent( QEvent *e );
51

Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
52 53

private:
Mathias Soeken's avatar
Mathias Soeken committed
54 55 56
  void drawScale( QPainter &painter );
  void drawBackground( QPainter &painter );
  void reLength( int percentOfScreen );
Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
57 58 59
  bool mDragging;
  QPoint mLastClickPos;
  QPoint mDragOffset;
60 61
  QAutoSizeLabel *mLabel;
  QAutoSizeLabel *mColorLabel;
Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
62 63 64
  int mOrientation;
  int mLongEdgeLen;
  int mShortEdgeLen;
Laurent Montel's avatar
Laurent Montel committed
65 66
  KMenu *mMenu;
  KMenu *mLenMenu;
Pascal Létourneau's avatar
porting  
Pascal Létourneau committed
67
  QAction *mFullScreenAction;
68
  QColor mColor;
Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
69 70 71 72 73 74 75 76
  QColor mStoredColor;
  QCursor mCurrentCursor;
  QCursor mNorthCursor;
  QCursor mEastCursor;
  QCursor mWestCursor;
  QCursor mSouthCursor;
  QCursor mDragCursor;
  KColorDialog mColorSelector;
77
  QFont mScaleFont;
Urs Wolfer's avatar
Urs Wolfer committed
78
  bool _clicked;
Mathias Soeken's avatar
Mathias Soeken committed
79

Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
80
public slots:
Mathias Soeken's avatar
Mathias Soeken committed
81
  void setOrientation( int );
Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
  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();
Mathias Soeken's avatar
Mathias Soeken committed
97 98 99 100
  void setFont( const QFont &font );
  void setColor( const QColor &color );
  void chooseColor();
  void chooseFont();
Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
101
  void restoreColor();
102
  void saveSettings();
Laurent Montel's avatar
Laurent Montel committed
103
  void slotQuit();
Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
104 105
};
#endif