simple custom-drawn button in registersview
This commit is contained in:
parent
29576b4bf5
commit
6d9a4520c0
|
@ -997,7 +997,8 @@ RegistersView::RegistersView(QWidget* parent) : QScrollArea(parent), mVScrollOff
|
||||||
mCip = 0;
|
mCip = 0;
|
||||||
mRegisterUpdates.clear();
|
mRegisterUpdates.clear();
|
||||||
|
|
||||||
yTopSpacing = 3; //set top spacing (in pixels)
|
mButtonHeight = 5;
|
||||||
|
yTopSpacing = 20; //set top spacing (in pixels)
|
||||||
|
|
||||||
// Context Menu
|
// Context Menu
|
||||||
this->setContextMenuPolicy(Qt::CustomContextMenu);
|
this->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
@ -1099,19 +1100,27 @@ void RegistersView::mousePressEvent(QMouseEvent* event)
|
||||||
{
|
{
|
||||||
if(!DbgIsDebugging())
|
if(!DbgIsDebugging())
|
||||||
return;
|
return;
|
||||||
// get mouse position
|
|
||||||
const int y = (event->y() - 3) / (double)mRowHeight;
|
|
||||||
const int x = event->x() / (double)mCharWidth;
|
|
||||||
|
|
||||||
REGISTER_NAME r;
|
if(event->y() < yTopSpacing - mButtonHeight)
|
||||||
// do we find a corresponding register?
|
|
||||||
if(identifyRegister(y, x, &r))
|
|
||||||
{
|
{
|
||||||
mSelected = r;
|
QMessageBox::information(this, "Troll", "You are now dead...");
|
||||||
emit refresh();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
mSelected = UNKNOWN;
|
{
|
||||||
|
// get mouse position
|
||||||
|
const int y = (event->y() - yTopSpacing) / (double)mRowHeight;
|
||||||
|
const int x = event->x() / (double)mCharWidth;
|
||||||
|
|
||||||
|
REGISTER_NAME r;
|
||||||
|
// do we find a corresponding register?
|
||||||
|
if(identifyRegister(y, x, &r))
|
||||||
|
{
|
||||||
|
mSelected = r;
|
||||||
|
emit refresh();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
mSelected = UNKNOWN;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegistersView::mouseDoubleClickEvent(QMouseEvent* event)
|
void RegistersView::mouseDoubleClickEvent(QMouseEvent* event)
|
||||||
|
@ -1120,7 +1129,7 @@ void RegistersView::mouseDoubleClickEvent(QMouseEvent* event)
|
||||||
if(!DbgIsDebugging() || event->button() != Qt::LeftButton)
|
if(!DbgIsDebugging() || event->button() != Qt::LeftButton)
|
||||||
return;
|
return;
|
||||||
// get mouse position
|
// get mouse position
|
||||||
const int y = (event->y() - 3) / (double)mRowHeight;
|
const int y = (event->y() - yTopSpacing) / (double)mRowHeight;
|
||||||
const int x = event->x() / (double)mCharWidth;
|
const int x = event->x() / (double)mCharWidth;
|
||||||
|
|
||||||
// do we find a corresponding register?
|
// do we find a corresponding register?
|
||||||
|
@ -1143,6 +1152,10 @@ void RegistersView::paintEvent(QPaintEvent* event)
|
||||||
QPainter wPainter(this->viewport());
|
QPainter wPainter(this->viewport());
|
||||||
wPainter.fillRect(wPainter.viewport(), QBrush(ConfigColor("RegistersBackgroundColor")));
|
wPainter.fillRect(wPainter.viewport(), QBrush(ConfigColor("RegistersBackgroundColor")));
|
||||||
|
|
||||||
|
wPainter.setPen(Qt::black);
|
||||||
|
wPainter.drawLine(0, yTopSpacing - mButtonHeight, this->viewport()->width(), yTopSpacing - mButtonHeight);
|
||||||
|
wPainter.drawText(0, 0, this->viewport()->width(), yTopSpacing - mButtonHeight, Qt::AlignVCenter, " Press here to die...");
|
||||||
|
|
||||||
QMap<REGISTER_NAME, QString>::const_iterator it = mRegisterMapping.begin();
|
QMap<REGISTER_NAME, QString>::const_iterator it = mRegisterMapping.begin();
|
||||||
// iterate all registers
|
// iterate all registers
|
||||||
while(it != mRegisterMapping.end())
|
while(it != mRegisterMapping.end())
|
||||||
|
|
|
@ -153,6 +153,7 @@ private:
|
||||||
int mVScrollOffset;
|
int mVScrollOffset;
|
||||||
int mRowsNeeded;
|
int mRowsNeeded;
|
||||||
int yTopSpacing;
|
int yTopSpacing;
|
||||||
|
int mButtonHeight;
|
||||||
QSet<REGISTER_NAME> mUINTDISPLAY;
|
QSet<REGISTER_NAME> mUINTDISPLAY;
|
||||||
QSet<REGISTER_NAME> mUSHORTDISPLAY;
|
QSet<REGISTER_NAME> mUSHORTDISPLAY;
|
||||||
QSet<REGISTER_NAME> mDWORDDISPLAY;
|
QSet<REGISTER_NAME> mDWORDDISPLAY;
|
||||||
|
|
Loading…
Reference in New Issue