klineal.h 2.94 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 );
57 58
  void updateScaleDirectionMenuItem();

Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
59 60 61
  bool mDragging;
  QPoint mLastClickPos;
  QPoint mDragOffset;
62 63
  QAutoSizeLabel *mLabel;
  QAutoSizeLabel *mColorLabel;
Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
64 65 66
  int mOrientation;
  int mLongEdgeLen;
  int mShortEdgeLen;
Laurent Montel's avatar
Laurent Montel committed
67 68
  KMenu *mMenu;
  KMenu *mLenMenu;
Pascal Létourneau's avatar
porting  
Pascal Létourneau committed
69
  QAction *mFullScreenAction;
70
  QAction *mScaleDirectionAction;
71
  QColor mColor;
Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
72 73 74 75 76 77 78 79
  QColor mStoredColor;
  QCursor mCurrentCursor;
  QCursor mNorthCursor;
  QCursor mEastCursor;
  QCursor mWestCursor;
  QCursor mSouthCursor;
  QCursor mDragCursor;
  KColorDialog mColorSelector;
80
  QFont mScaleFont;
81 82
  bool mClicked;
  bool mLeftToRight;
Mathias Soeken's avatar
Mathias Soeken committed
83

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