klineal.h 3.18 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
  void keyPressEvent( QKeyEvent *e );
  void mousePressEvent( QMouseEvent *e );
  void mouseReleaseEvent( QMouseEvent *e );
  void mouseMoveEvent( QMouseEvent *e );
48
  void wheelEvent( QWheelEvent *e );
Mathias Soeken's avatar
Mathias Soeken committed
49 50 51
  void paintEvent( QPaintEvent *e );
  void enterEvent( QEvent *e );
  void leaveEvent( QEvent *e );
52

Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
53 54

private:
Mathias Soeken's avatar
Mathias Soeken committed
55 56 57
  void drawScale( QPainter &painter );
  void drawBackground( QPainter &painter );
  void reLength( int percentOfScreen );
58 59
  void updateScaleDirectionMenuItem();

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

Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
89
public slots:
Mathias Soeken's avatar
Mathias Soeken committed
90
  void setOrientation( int );
Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
91 92 93 94 95 96 97 98 99 100 101 102 103 104
  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();
105
  void switchDirection();
106 107
  void centerOrigin();
  void slotOffset();
108
  void switchRelativeScale( bool checked );
Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
109
  void setColor();
Mathias Soeken's avatar
Mathias Soeken committed
110 111 112 113
  void setFont( const QFont &font );
  void setColor( const QColor &color );
  void chooseColor();
  void chooseFont();
Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
114
  void restoreColor();
115
  void copyColor();
116
  void saveSettings();
Laurent Montel's avatar
Laurent Montel committed
117
  void slotQuit();
Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
118 119
};
#endif