textlabel.h

00001 /***************************************************************************
00002  *   Copyright (C) 2003 by Hans Karlsson                                   *
00003  *   karlsson.h@home.se                                                      *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  ***************************************************************************/
00010 #ifndef TEXTLABEL_H
00011 #define TEXTLABEL_H
00012 #include "meter.h"
00013 #include <qstring.h>
00014 #include <qpainter.h>
00015 #include <qcolor.h>
00016 #include <qfont.h>
00017 #include <qfontmetrics.h>
00018 #include <qstringlist.h>
00019 #include <qrect.h>
00020 
00021 #include "textfield.h"
00022 
00023 class TextLabel : public Meter
00024 {
00025 Q_OBJECT
00026 public:
00027     typedef enum ScrollType { ScrollNone, ScrollNormal,
00028                               ScrollBackAndForth, ScrollOnePass };
00029 
00030     TextLabel(karamba *k, int x,int y,int w,int h);
00031     TextLabel(karamba *k);
00032     ~TextLabel();
00033 
00034     void setTextProps( TextField* );
00035     void setValue( QString );
00036     void setValue( int );
00037     //virtual QString getStringValue() const { return value.join("\n"); };
00038     QString getStringValue() const { return value.join("\n"); };
00039     void setFontSize( int );
00040     void setBGColor(QColor clr);
00041     void setFont( QString );
00042     void setAlignment( QString );
00043     void setFixedPitch( bool );
00044     void setShadow( int );
00045     void mUpdate( QPainter * );
00046 
00047     virtual void show();
00048     virtual void hide();
00049     int getFontSize() const;
00050     QColor getBGColor() const;
00051     QString getFont() const;
00052     QString getAlignment() const;
00053     bool getFixedPitch() const;
00054     int getShadow() const;
00055     void setScroll(ScrollType type, QPoint speed, int gap, int pause);
00056     void setScroll(char* type, QPoint speed, int gap, int pause);
00057 
00058     void attachClickArea(QString leftMouseButton, QString middleMouseButton,
00059                          QString rightMouseButton);
00060 
00061     virtual bool click(QMouseEvent*);
00062 
00063 private:
00064     int alignment;
00065     int clip;
00066     QStringList value;
00067     QFont font;
00068     QColor bgColor;
00069     int lineHeight;
00070     QSize textSize;
00071     int shadow;
00072     TextField text;
00073     QPoint scrollSpeed;
00074     QPoint scrollPos;
00075     int scrollGap;
00076     int scrollPause;
00077     int pauseCounter;
00078     ScrollType scrollType;
00079 
00080     int drawText(QPainter *p, int x, int y, int width, int height,
00081                  QString text);
00082     bool calculateScrollCoords(QRect meterRect, QRect &textRect,
00083                                QPoint &next, int &x, int &y);
00084     void calculateTextSize();
00085 };
00086 
00087 #endif // TEXTLABEL_H
KDE Home | KDE Accessibility Home | Description of Access Keys