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

Andreas Beckermann's avatar
Andreas Beckermann committed
21
#include <kapplication.h>
Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
22 23 24 25
#include <kpopupmenu.h>
#include <kmainwindow.h>

#include <kcolordialog.h>
26
#include <kfontdialog.h>
Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
27 28 29 30

#include <qlabel.h>
#include <qpainter.h>
#include <qwidget.h>
George Staikos's avatar
build  
George Staikos committed
31
#include <qcursor.h>
Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46

class KLineal : public KMainWindow {
  Q_OBJECT 
public: 
  enum { North=0, West=1, South=2, East=3 };
  /** constructor */
  KLineal(QWidget*parent=0,const char* name=0);
  /** destructor */
  ~KLineal();
  void move(int x, int y);
  void move(const QPoint &p);
  QPoint pos();
  int x();
  int y();
protected:
47 48
	void keyPressEvent(QKeyEvent *e);
  void mousePressEvent(QMouseEvent *e);
Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
49 50 51 52
  void mouseReleaseEvent(QMouseEvent *e); 
  void mouseMoveEvent(QMouseEvent *e);
  void paintEvent(QPaintEvent *e); 
  void enterEvent(QEvent *e); 
53 54 55
  void leaveEvent(QEvent *e);
  void setupBackground();

Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
56 57 58 59 60 61 62 63 64 65 66 67 68 69

private:
  void drawScale(QPainter &painter);
  void reLength(int percentOfScreen);
  bool mDragging;
  QPoint mLastClickPos;
  QPoint mDragOffset;
  QLabel *mLabel;
  QLabel *mColorLabel;
  QFrame *mColorRect;
  int mOrientation;
  int mLongEdgeLen;
  int mShortEdgeLen;
  KPopupMenu *mMenu;
70
  QColor mColor;
Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
71 72 73 74 75 76 77 78
  QColor mStoredColor;
  QCursor mCurrentCursor;
  QCursor mNorthCursor;
  QCursor mEastCursor;
  QCursor mWestCursor;
  QCursor mSouthCursor;
  QCursor mDragCursor;
  KColorDialog mColorSelector;
79
  QFont mScaleFont;
Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
	bool _clicked;
public slots:
  void setOrientation(int);
  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();
98
  void setFont(QFont &);
Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
99 100
  void setColor(const QColor &color);
  void choseColor();
101
  void choseFont();
Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
102
  void restoreColor();
103
  void saveSettings();
Carsten Pfeiffer's avatar
Carsten Pfeiffer committed
104 105
};
#endif