superkaramba
input.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef INPUT_H
00023 #define INPUT_H
00024
00025 #include <QTextLayout>
00026 #include <QTimer>
00027
00028 #include "meter.h"
00029
00030 class TextField;
00031 class Karamba;
00032 class Input : public Meter
00033 {
00034 Q_OBJECT
00035 public:
00036 Input(Karamba* k, int ix, int iy, int iw, int ih);
00037 Input();
00038 ~Input();
00039
00040 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
00041 QWidget *widget);
00042
00043 void setValue(const QString &text);
00044 QString getStringValue() const;
00045
00046 void setBGColor(QColor c);
00047 QColor getBGColor() const;
00048 void setColor(QColor c);
00049 QColor getColor() const;
00050 void setFontColor(QColor fontColor);
00051 QColor getFontColor() const;
00052 void setSelectionColor(QColor selectionColor);
00053 QColor getSelectionColor() const;
00054 void setSelectedTextColor(QColor selectedTextColor);
00055 QColor getSelectedTextColor() const;
00056 void setTextProps(TextField*);
00057
00058 void hide();
00059 void show();
00060
00061 void setSize(int ix, int iy, int iw, int ih);
00062 void setX(int ix);
00063 void setY(int iy);
00064 void setWidth(int iw);
00065 void setHeight(int ih);
00066
00067 void setFont(const QString &f);
00068 QString getFont() const;
00069 void setFontSize(int size);
00070 int getFontSize() const;
00071
00072 void setInputFocus();
00073 void clearInputFocus();
00074 void keyPress(QKeyEvent *event);
00075 void mouseEvent(QEvent *e);
00076 void mouseEventRelease(QGraphicsSceneMouseEvent *e);
00077 void mouseEventMove(QGraphicsSceneHoverEvent *e);
00078
00079 int getTextWidth() const;
00080
00081 void setSelection(int start, int length);
00082 void clearSelection();
00083 QTextLayout::FormatRange getSelection() const;
00084
00085 protected:
00086 void focusOutEvent(QFocusEvent *event);
00087
00088 private Q_SLOTS:
00089 void blinkCursor();
00090
00091 private:
00092 QFont m_font;
00093
00094 QColor m_bgColor;
00095 QColor m_fgColor;
00096 QColor m_fontColor;
00097 QColor m_selectedTextColor;
00098 QColor m_selectionColor;
00099
00100 QString m_text;
00101
00102 QTextLayout m_textLayout;
00103
00104 double m_hscroll;
00105 int m_cursorPos;
00106 bool m_cursorVisible;
00107
00108 QTimer m_cursorTimer;
00109
00110 bool m_mouseMoved;
00111 int m_selStart;
00112 int m_selLength;
00113
00114 QVector<QTextLayout::FormatRange> m_selection;
00115
00116 void layoutText();
00117 };
00118
00119 #endif