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

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

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
  Q_OBJECT
Mathias Soeken's avatar
Mathias Soeken committed
30

31
public:
Mathias Soeken's avatar
Mathias Soeken committed
32
  enum { North = 0, West, South, East };
Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
33
  /** constructor */
Mathias Soeken's avatar
Mathias Soeken committed
34
  KLineal( QWidget *parent = 0 );
Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
35 36
  /** destructor */
  ~KLineal();
Mathias Soeken's avatar
Mathias Soeken committed
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();
42

Mathias Soeken's avatar
Mathias Soeken committed
43 44 45 46 47 48 49 50
protected:
  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 );
Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
51 52

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

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

Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
105
#endif