##// END OF EJS Templates
GUI almost finished, need work on data managing.
GUI almost finished, need work on data managing.

File last commit:

r4:bd9421acc1c2 default
r4:bd9421acc1c2 default
Show More
registerwidget.h
130 lines | 3.3 KiB | text/x-c | CLexer
WIP
r1 #ifndef REGISTERWIDGET_H
#define REGISTERWIDGET_H
#include <QtWidgets>
#include <QWidget>
Jeandet Alexis
sync
r3 #include <QTimer>
WIP
r1
class regWidgetElement
{
public:
regWidgetElement(const QString& value,QFont font,int xMargin,int yMargin)
{
p_valueStr = value;
p_font = font;
p_xMargins = xMargin;
p_yMargins = yMargin;
updateBoundingRect();
}
void setValue(const QString& value)
{
p_valueStr = value;
updateBoundingRect();
}
void setFont(QFont font)
{
p_font = font;
updateBoundingRect();
}
QSize boundingRect(){return p_boundingRec;}
QString value(){return p_valueStr;}
const QChar at ( int position ) const{return p_valueStr.at(position);}
QFont font(){return p_font;}
int xMargin(){return p_xMargins;}
int yMargin(){return p_yMargins;}
QFontMetrics fontMetrics(){return QFontMetrics(p_font);}
QPoint paint(QPainter* painter)
{
painter->setFont(p_font);
painter->drawText(0,QFontMetrics(p_font).ascent()+p_yMargins,p_valueStr);
return QPoint(p_boundingRec.width(),0);
}
void updateBoundingRect()
{
p_boundingRec.setHeight(QFontMetrics(p_font).boundingRect(p_valueStr).height()+(p_yMargins*2));
p_boundingRec.setWidth(QFontMetrics(p_font).boundingRect(p_valueStr).width()+(p_xMargins*2));
}
protected:
QString p_valueStr;
QFont p_font;
QSize p_boundingRec;
int p_xMargins;
int p_yMargins;
};
class bitfieldsElement: public regWidgetElement
{
Jeandet Alexis
Sync
r2 class bitFieldAttribute
WIP
r1 {
Jeandet Alexis
Sync
r2 public:
bitFieldAttribute(bool rw,QString description)
{
this->rw = rw;
this->description = description;
}
WIP
r1 bool rw;
Jeandet Alexis
Sync
r2 QString description;
WIP
r1 };
public:
Jeandet Alexis
sync
r3 bitfieldsElement(const QString& value,QFont font,int xMargin,int yMargin);
QPoint paint(QPainter* painter);
WIP
r1
Jeandet Alexis
sync
r3 void updateBoundingRect();
void setValue(const QString& value);
void blinkCursor();
void moveCursorLeft(int count);
void moveCursorRight(int count);
GUI almost finished, need work on data managing.
r4 void enter(int index);
void leave();
uint cursorIndex();
uint cursorIndex(int xPos);
void setFont(QFont font);
WIP
r1 private:
Jeandet Alexis
Sync
r2 int attributesIndex[32];
Jeandet Alexis
sync
r3 uint p_cursorIndex;
GUI almost finished, need work on data managing.
r4 bool p_cursorBlinkEnable;
int p_dx;
Jeandet Alexis
Sync
r2 QList<bitFieldAttribute*> attributesLUT;
GUI almost finished, need work on data managing.
r4 QColor p_blinkTextColor,p_blinkTextBgColor;
WIP
r1 };
GUI almost finished, need work on data managing.
r4 class registerWidget : public QObject
WIP
r1 {
Q_OBJECT
public:
GUI almost finished, need work on data managing.
r4 explicit registerWidget(const QString& name,qint32 address,QObject *parent = 0);
WIP
r1 ~registerWidget();
GUI almost finished, need work on data managing.
r4 int contains(const QPointF &point);
QPoint paint(QPainter* painter,QPoint offset);
QRect boundingRect();
uint cursorIndex();
uint cursorIndex(int xPos);
WIP
r1 signals:
void cursorUp(int pos);
void cursorDown(int pos);
Jeandet Alexis
sync
r3 void valueChanged(qint32 value);
GUI almost finished, need work on data managing.
r4 void repaint();
WIP
r1
public slots:
void setValue(qint32 value);
Jeandet Alexis
sync
r3 void blinkCursor();
void moveCursorLeft(int count);
void moveCursorRight(int count);
GUI almost finished, need work on data managing.
r4 void enter(int index=0);
void leave();
void clear(int index);
void set(int index);
WIP
r1 private:
void updateBoundingRect();
qint32 p_address;
qint32 p_value;
GUI almost finished, need work on data managing.
r4 QRect p_boundingRect;
WIP
r1 int p_xMargins;
int p_yMargins;
regWidgetElement* p_addressEl,*p_nameEl;
bitfieldsElement* p_fieldsEl;
};
#endif // REGISTERWIDGET_H