textlabel.h00001
00002
00003
00004
00005
00006
00007
00008
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 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( long );
00037
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
|