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

23
class QAutoSizeLabel;
24
class QToolButton;
25 26 27 28

class KAction;
class KActionCollection;
class KIcon;
Urs Wolfer's avatar
Urs Wolfer committed
29
class KMenu;
30
class KRulerSystemTray;
Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
31

32
class KLineal : public QWidget {
33
  Q_OBJECT
Mathias Soeken's avatar
Mathias Soeken committed
34

35
public:
Mathias Soeken's avatar
Mathias Soeken committed
36 37 38
  enum { North = 0, West, South, East };

  KLineal( QWidget *parent = 0 );
Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
39
  ~KLineal();
Mathias Soeken's avatar
Mathias Soeken committed
40 41 42

  void move( int x, int y );
  void move( const QPoint &p );
Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
43 44 45
  QPoint pos();
  int x();
  int y();
Mathias Soeken's avatar
Mathias Soeken committed
46

Mathias Soeken's avatar
Mathias Soeken committed
47
protected:
Mathias Soeken's avatar
Mathias Soeken committed
48 49 50 51
  void keyPressEvent( QKeyEvent *e );
  void mousePressEvent( QMouseEvent *e );
  void mouseReleaseEvent( QMouseEvent *e );
  void mouseMoveEvent( QMouseEvent *e );
52
  void wheelEvent( QWheelEvent *e );
Mathias Soeken's avatar
Mathias Soeken committed
53 54 55
  void paintEvent( QPaintEvent *e );
  void enterEvent( QEvent *e );
  void leaveEvent( QEvent *e );
56

57 58
    void createSystemTray();

Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
59
private:
60 61 62
  KAction* addAction( KMenu *menu, KIcon icon, const QString& text,
                      const QObject* receiver, const char* member,
                      const QKeySequence &shortcut, const QString& name );
Mathias Soeken's avatar
Mathias Soeken committed
63 64 65
  void drawScale( QPainter &painter );
  void drawBackground( QPainter &painter );
  void reLength( int percentOfScreen );
66
  void reLengthAbsolute( int length );
67 68
  void updateScaleDirectionMenuItem();

Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
69 70 71
  bool mDragging;
  QPoint mLastClickPos;
  QPoint mDragOffset;
72 73
  QAutoSizeLabel *mLabel;
  QAutoSizeLabel *mColorLabel;
Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
74 75 76
  int mOrientation;
  int mLongEdgeLen;
  int mShortEdgeLen;
Laurent Montel's avatar
Laurent Montel committed
77 78
  KMenu *mMenu;
  KMenu *mLenMenu;
Pascal Létourneau's avatar
porting  
Pascal Létourneau committed
79
  QAction *mFullScreenAction;
80
  QAction *mScaleDirectionAction;
81 82
  QAction *mCenterOriginAction;
  QAction *mOffsetAction;
83
  QColor mColor;
Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
84 85 86 87 88 89
  QCursor mCurrentCursor;
  QCursor mNorthCursor;
  QCursor mEastCursor;
  QCursor mWestCursor;
  QCursor mSouthCursor;
  QCursor mDragCursor;
90
  QFont mScaleFont;
91 92
  bool mClicked;
  bool mLeftToRight;
93
  int mOffset;
94
  bool mRelativeScale;
95
  KActionCollection *mActionCollection;
96
  int mOpacity;
97
  QToolButton *mBtnRotateLeft, *mBtnRotateRight;
98
  QToolButton *mCloseButton;
99
    KRulerSystemTray *mTrayIcon;
Mathias Soeken's avatar
Mathias Soeken committed
100

Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
101
public slots:
Mathias Soeken's avatar
Mathias Soeken committed
102
  void setOrientation( int );
Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
103 104 105 106 107 108 109 110 111 112
  void setNorth();
  void setEast();
  void setSouth();
  void setWest();
  void turnLeft();
  void turnRight();
  void showMenu();
  void hideLabel();
  void showLabel();
  void adjustLabel();
113
  void adjustButtons();
Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
114 115 116 117
  void setShortLength();
  void setMediumLength();
  void setTallLength();
  void setFullLength();
118
  void switchDirection();
119 120
  void centerOrigin();
  void slotOffset();
Mathias Soeken's avatar
Mathias Soeken committed
121
  void slotLength();
122
  void slotOpacity( int value );
123
  void slotKeyBindings();
124
  void slotPreferences();
125
  void switchRelativeScale( bool checked );
126
  void copyColor();
127
  void saveSettings();
128
  void slotClose();
Laurent Montel's avatar
Laurent Montel committed
129
  void slotQuit();
130
    void loadConfig();
Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
131 132
};
#endif