1
0
Fork 0

simple custom-drawn button in registersview

This commit is contained in:
Mr. eXoDia 2014-11-02 02:50:09 +01:00
parent 29576b4bf5
commit 6d9a4520c0
2 changed files with 25 additions and 11 deletions

View File

@ -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,8 +1100,15 @@ void RegistersView::mousePressEvent(QMouseEvent* event)
{ {
if(!DbgIsDebugging()) if(!DbgIsDebugging())
return; return;
if(event->y() < yTopSpacing - mButtonHeight)
{
QMessageBox::information(this, "Troll", "You are now dead...");
}
else
{
// 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;
REGISTER_NAME r; REGISTER_NAME r;
@ -1112,6 +1120,7 @@ void RegistersView::mousePressEvent(QMouseEvent* event)
} }
else else
mSelected = UNKNOWN; 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())

View File

@ -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;