1
0
Fork 0

GUI: hex color codes everywhere (custom colors coming soon!)

This commit is contained in:
Mr. eXoDia 2014-04-26 21:15:40 +02:00
parent 8eb711459e
commit 9f514b2751
9 changed files with 154 additions and 153 deletions

View File

@ -19,7 +19,7 @@ AbstractTableView::AbstractTableView(QWidget *parent) : QAbstractScrollArea(pare
font.setStyleHint(QFont::Monospace);
this->setFont(font);
backgroundColor=QColor(255, 251, 240);
backgroundColor=QColor("#FFFBF0");
int wRowsHeight = QFontMetrics(this->font()).height();
wRowsHeight = (wRowsHeight * 105) / 100;
@ -110,13 +110,14 @@ void AbstractTableView::paintEvent(QPaintEvent* event)
// Paints cell contents
if(i < mNbrOfLineToPrint)
{
QString wStr = paintContent(&wPainter, mTableOffset, i, j, x, y, getColumnWidth(j), getRowHeight());
wPainter.drawText(QRect(x + 4, y, getColumnWidth(j) - 4, getRowHeight()), Qt::AlignVCenter | Qt::AlignLeft, wStr);
QString wStr = paintContent(&wPainter, mTableOffset, i, j, x, y, getColumnWidth(j), getRowHeight());
if(wStr.length())
wPainter.drawText(QRect(x + 4, y, getColumnWidth(j) - 4, getRowHeight()), Qt::AlignVCenter | Qt::AlignLeft, wStr);
}
// Paints cell right borders
wPainter.save() ;
wPainter.setPen(QColor(128, 128, 128));
wPainter.save();
wPainter.setPen(QColor("#808080"));
wPainter.drawLine(x + getColumnWidth(j) - 1, y, x + getColumnWidth(j) - 1, y + getRowHeight() - 1);
wPainter.restore();
@ -144,118 +145,118 @@ void AbstractTableView::paintEvent(QPaintEvent* event)
*/
void AbstractTableView::mouseMoveEvent(QMouseEvent* event)
{
// qDebug() << "mouseMoveEvent";
// qDebug() << "mouseMoveEvent";
switch (mGuiState)
{
case AbstractTableView::NoState:
case AbstractTableView::NoState:
{
//qDebug() << "State = NoState";
int wColIndex = getColumnIndexFromX(event->x());
int wStartPos = getColumnPosition(wColIndex); // Position X of the start of column
int wEndPos = getColumnPosition(wColIndex) + getColumnWidth(wColIndex); // Position X of the end of column
if(event->buttons() == Qt::NoButton)
{
//qDebug() << "State = NoState";
bool wHandle = true;
bool wHasCursor;
int wColIndex = getColumnIndexFromX(event->x());
int wStartPos = getColumnPosition(wColIndex); // Position X of the start of column
int wEndPos = getColumnPosition(wColIndex) + getColumnWidth(wColIndex); // Position X of the end of column
wHasCursor = cursor().shape() == Qt::SplitHCursor ? true : false;
if(event->buttons() == Qt::NoButton)
if(((wColIndex != 0) && (event->x() >= wStartPos) && (event->x() <= (wStartPos + 2))) || ((wColIndex != (getColumnCount() - 1)) && (event->x() <= wEndPos) && (event->x() >= (wEndPos - 2))))
{
bool wHandle = true;
bool wHasCursor;
wHasCursor = cursor().shape() == Qt::SplitHCursor ? true : false;
if(((wColIndex != 0) && (event->x() >= wStartPos) && (event->x() <= (wStartPos + 2))) || ((wColIndex != (getColumnCount() - 1)) && (event->x() <= wEndPos) && (event->x() >= (wEndPos - 2))))
{
wHandle = true;
}
else
{
wHandle = false;
}
if((wHandle == true) && (wHasCursor == false))
{
setCursor(Qt::SplitHCursor);
mColResizeData.splitHandle = true;
mGuiState = AbstractTableView::ReadyToResize;
}
if ((wHandle == false) && (wHasCursor == true))
{
unsetCursor();
mColResizeData.splitHandle = false;
mGuiState = AbstractTableView::NoState;
}
wHandle = true;
}
else
{
QWidget::mouseMoveEvent(event);
wHandle = false;
}
break;
}
case AbstractTableView::ReadyToResize:
{
//qDebug() << "State = ReadyToResize";
int wColIndex = getColumnIndexFromX(event->x());
int wStartPos = getColumnPosition(wColIndex); // Position X of the start of column
int wEndPos = getColumnPosition(wColIndex) + getColumnWidth(wColIndex); // Position X of the end of column
if(event->buttons() == Qt::NoButton)
if((wHandle == true) && (wHasCursor == false))
{
bool wHandle = true;
if(((wColIndex != 0) && (event->x() >= wStartPos) && (event->x() <= (wStartPos + 2))) || ((wColIndex != (getColumnCount() - 1)) && (event->x() <= wEndPos) && (event->x() >= (wEndPos - 2))))
{
wHandle = true;
}
else
{
wHandle = false;
}
if ((wHandle == false) && (mGuiState == AbstractTableView::ReadyToResize))
{
unsetCursor();
mColResizeData.splitHandle = false;
mGuiState = AbstractTableView::NoState;
}
setCursor(Qt::SplitHCursor);
mColResizeData.splitHandle = true;
mGuiState = AbstractTableView::ReadyToResize;
}
break;
}
case AbstractTableView::ResizeColumnState:
{
//qDebug() << "State = ResizeColumnState";
int delta = event->x() - mColResizeData.lastPosX;
int wNewSize = ((getColumnWidth(mColResizeData.index) + delta) >= 20) ? (getColumnWidth(mColResizeData.index) + delta) : (20);
setColumnWidth(mColResizeData.index, wNewSize);
mColResizeData.lastPosX = event->x();
repaint();
break;
}
case AbstractTableView::HeaderButtonPressed:
{
//qDebug() << "State = HeaderButtonPressed";
int wColIndex = getColumnIndexFromX(event->x());
if((wColIndex == mHeader.activeButtonIndex) && (event->y() <= getHeaderHeight()) && (event->y() >= 0))
if ((wHandle == false) && (wHasCursor == true))
{
mColumnList[mHeader.activeButtonIndex].header.isMouseOver = true;
unsetCursor();
mColResizeData.splitHandle = false;
mGuiState = AbstractTableView::NoState;
}
}
else
{
QWidget::mouseMoveEvent(event);
}
break;
}
case AbstractTableView::ReadyToResize:
{
//qDebug() << "State = ReadyToResize";
int wColIndex = getColumnIndexFromX(event->x());
int wStartPos = getColumnPosition(wColIndex); // Position X of the start of column
int wEndPos = getColumnPosition(wColIndex) + getColumnWidth(wColIndex); // Position X of the end of column
if(event->buttons() == Qt::NoButton)
{
bool wHandle = true;
if(((wColIndex != 0) && (event->x() >= wStartPos) && (event->x() <= (wStartPos + 2))) || ((wColIndex != (getColumnCount() - 1)) && (event->x() <= wEndPos) && (event->x() >= (wEndPos - 2))))
{
wHandle = true;
}
else
{
mColumnList[mHeader.activeButtonIndex].header.isMouseOver = false;
wHandle = false;
}
repaint();
if ((wHandle == false) && (mGuiState == AbstractTableView::ReadyToResize))
{
unsetCursor();
mColResizeData.splitHandle = false;
mGuiState = AbstractTableView::NoState;
}
}
default:
break;
break;
}
case AbstractTableView::ResizeColumnState:
{
//qDebug() << "State = ResizeColumnState";
int delta = event->x() - mColResizeData.lastPosX;
int wNewSize = ((getColumnWidth(mColResizeData.index) + delta) >= 20) ? (getColumnWidth(mColResizeData.index) + delta) : (20);
setColumnWidth(mColResizeData.index, wNewSize);
mColResizeData.lastPosX = event->x();
repaint();
break;
}
case AbstractTableView::HeaderButtonPressed:
{
//qDebug() << "State = HeaderButtonPressed";
int wColIndex = getColumnIndexFromX(event->x());
if((wColIndex == mHeader.activeButtonIndex) && (event->y() <= getHeaderHeight()) && (event->y() >= 0))
{
mColumnList[mHeader.activeButtonIndex].header.isMouseOver = true;
}
else
{
mColumnList[mHeader.activeButtonIndex].header.isMouseOver = false;
}
repaint();
}
default:
break;
}
}
@ -454,31 +455,31 @@ void AbstractTableView::vertSliderActionSlot(int action)
// Determine the delta
switch(action)
{
case QAbstractSlider::SliderNoAction:
break;
case QAbstractSlider::SliderSingleStepAdd:
wDelta = 1;
break;
case QAbstractSlider::SliderSingleStepSub:
wDelta = -1;
break;
case QAbstractSlider::SliderPageStepAdd:
wDelta = 30;
break;
case QAbstractSlider::SliderPageStepSub:
wDelta = -30;
break;
case QAbstractSlider::SliderToMinimum:
case QAbstractSlider::SliderToMaximum:
case QAbstractSlider::SliderMove:
case QAbstractSlider::SliderNoAction:
break;
case QAbstractSlider::SliderSingleStepAdd:
wDelta = 1;
break;
case QAbstractSlider::SliderSingleStepSub:
wDelta = -1;
break;
case QAbstractSlider::SliderPageStepAdd:
wDelta = 30;
break;
case QAbstractSlider::SliderPageStepSub:
wDelta = -30;
break;
case QAbstractSlider::SliderToMinimum:
case QAbstractSlider::SliderToMaximum:
case QAbstractSlider::SliderMove:
#ifdef _WIN64
wDelta = scaleFromScrollBarRangeToUint64(wSliderPos) - mTableOffset;
wDelta = scaleFromScrollBarRangeToUint64(wSliderPos) - mTableOffset;
#else
wDelta = wSliderPos - mTableOffset;
wDelta = wSliderPos - mTableOffset;
#endif
break;
default:
break;
break;
default:
break;
}
// Call the hook (Usefull for disassembly)
@ -783,9 +784,9 @@ void AbstractTableView::setColTitle(int index, QString title)
{
if(mColumnList.size() > 0 && index >= 0 && index < mColumnList.size())
{
Column_t wColum = mColumnList.takeAt(index);
wColum.title = title;
mColumnList.insert(index - 1, wColum);
Column_t wColum = mColumnList.takeAt(index);
wColum.title = title;
mColumnList.insert(index - 1, wColum);
}
}

View File

@ -92,16 +92,16 @@ QString Disassembly::paintContent(QPainter* painter, int_t rowBase, int rowOffse
{
if(bpxtype&bp_normal) //breakpoint
{
painter->setPen(QPen(QColor("#ff0000")));
painter->setPen(QPen(QColor("#FF0000")));
}
else
{
painter->setPen(QPen(QColor("#fffbf0")));
painter->setPen(QPen(QColor("#FFFBF0")));
}
}
else
{
painter->setPen(QPen(QColor("#fee970")));
painter->setPen(QPen(QColor("#FEE970")));
}
}
else //other address
@ -111,12 +111,12 @@ QString Disassembly::paintContent(QPainter* painter, int_t rowBase, int rowOffse
if(*label) //label
{
if(bpxtype==bp_none) //label only
painter->setPen(QPen(QColor("#ff0000"))); //red -> address + label text
painter->setPen(QPen(QColor("#FF0000"))); //red -> address + label text
else //label+breakpoint
{
if(bpxtype&bp_normal)
{
painter->fillRect(QRect(x, y, w, h), QBrush(QColor("#ff0000"))); //fill red
painter->fillRect(QRect(x, y, w, h), QBrush(QColor("#FF0000"))); //fill red
}
else
{
@ -137,7 +137,7 @@ QString Disassembly::paintContent(QPainter* painter, int_t rowBase, int rowOffse
{
if(bpxtype&bp_normal)
{
painter->fillRect(QRect(x, y, w, h), QBrush(QColor("#ff0000"))); //fill red
painter->fillRect(QRect(x, y, w, h), QBrush(QColor("#FF0000"))); //fill red
}
else
{
@ -151,7 +151,7 @@ QString Disassembly::paintContent(QPainter* painter, int_t rowBase, int rowOffse
}
else
{
painter->fillRect(QRect(x, y, w, h), QBrush(QColor("#fee970")));
painter->fillRect(QRect(x, y, w, h), QBrush(QColor("#FEE970")));
if(wIsSelected)
painter->setPen(QPen(QColor("#000000"))); //black address
else
@ -543,9 +543,9 @@ int Disassembly::paintJumpsGraphic(QPainter* painter, int x, int y, int_t addr)
painter->save() ;
if(DbgIsJumpGoingToExecute(instruction.rva+mBase)) //change pen color when jump is executed
painter->setPen(QColor(255, 0, 0));
painter->setPen(QColor("#FF0000"));
else
painter->setPen(QColor(128, 128, 128));
painter->setPen(QColor("#808080"));
if(wPict == GD_Vert)
{

View File

@ -209,7 +209,7 @@ void HexDump::printSelected(QPainter* painter, int_t rowBase, int rowOffset, int
wSelectionWidth = wItemPixWidth > w - (wSelectionX - x) ? w - (wSelectionX - x) : wItemPixWidth;
wSelectionWidth = wSelectionWidth < 0 ? 0 : wSelectionWidth;
painter->fillRect(QRect(wSelectionX, y, wSelectionWidth, h), QBrush(QColor(192,192,192)));
painter->fillRect(QRect(wSelectionX, y, wSelectionWidth, h), QBrush(QColor("#C0C0C0")));
}
}
}

View File

@ -13,7 +13,7 @@ RegistersView::RegistersView(QWidget *parent) : QWidget(parent), ui(new Ui::Regi
// Set background color
QPalette wPalette;
wPalette.setColor(QPalette::Window, QColor(255, 251, 240));
wPalette.setColor(QPalette::Window, QColor("#FFFBF0"));
this->setAutoFillBackground(true);
this->setPalette(wPalette);

View File

@ -49,7 +49,7 @@ QString ScriptView::paintContent(QPainter* painter, int_t rowBase, int rowOffset
}
else if(DbgScriptBpGet(line)) //breakpoint
{
painter->fillRect(QRect(x, y, w, h), QBrush(QColor("#ff0000")));
painter->fillRect(QRect(x, y, w, h), QBrush(QColor("#FF0000")));
painter->setPen(QPen(QColor("#000000"))); //black address
}
else
@ -95,7 +95,7 @@ QString ScriptView::paintContent(QPainter* painter, int_t rowBase, int rowOffset
if(isScriptCommand(command, "ret"))
{
newRichText.flags=FlagBackground;
newRichText.textBackground=QColor(0,255,255);
newRichText.textBackground=QColor("#00FFFF");
newRichText.text="ret";
richText.push_back(newRichText);
QString remainder=command.right(command.length()-3);
@ -125,7 +125,7 @@ QString ScriptView::paintContent(QPainter* painter, int_t rowBase, int rowOffset
{
case scriptjmp: //unconditional jumps
newRichText.flags=FlagBackground;
newRichText.textBackground=QColor(255,255,0);
newRichText.textBackground=QColor("#FFFF00");
break;
case scriptjnejnz: //conditional jumps
@ -135,13 +135,13 @@ QString ScriptView::paintContent(QPainter* painter, int_t rowBase, int rowOffset
case scriptjbejle:
case scriptjaejge:
newRichText.flags=FlagAll;
newRichText.textBackground=QColor(255,255,0);
newRichText.textColor=QColor(255,0,0);
newRichText.textBackground=QColor("#FFFF00");
newRichText.textColor=QColor("#FF0000");
break;
case scriptcall: //calls
newRichText.flags=FlagBackground;
newRichText.textBackground=QColor(0,255,255);
newRichText.textBackground=QColor("#00FFFF");
break;
default:
@ -157,7 +157,7 @@ QString ScriptView::paintContent(QPainter* painter, int_t rowBase, int rowOffset
//label
QString label=branchinfo.branchlabel;
newRichText.flags=FlagBackground;
newRichText.textBackground=QColor(255,255,0);
newRichText.textBackground=QColor("#FFFF00");
newRichText.text=label;
richText.push_back(newRichText);
//remainder

View File

@ -23,7 +23,7 @@ StdTable::StdTable(QWidget *parent) : AbstractTableView(parent)
QString StdTable::paintContent(QPainter* painter, int_t rowBase, int rowOffset, int col, int x, int y, int w, int h)
{
if(isSelected(rowBase, rowOffset) == true)
painter->fillRect(QRect(x, y, w, h), QBrush(QColor(192,192,192)));
painter->fillRect(QRect(x, y, w, h), QBrush(QColor("#808080")));
//return "c " + QString::number(col) + " r " + QString::number(rowBase + rowOffset);
return mData->at(col)->at(rowBase + rowOffset);

View File

@ -201,7 +201,7 @@ QString ThreadView::paintContent(QPainter* painter, int_t rowBase, int rowOffset
{
painter->save();
painter->fillRect(QRect(x, y, w, h), QBrush(QColor("#000000")));
painter->setPen(QPen(QColor("#ffffff"))); //white text
painter->setPen(QPen(QColor("#FFFFFF"))); //white text
painter->drawText(QRect(x + 4, y , w - 4 , h), Qt::AlignVCenter | Qt::AlignLeft, ret);
painter->restore();
ret="";

View File

@ -71,13 +71,13 @@ bool BeaHighlight::PrintArgument(QList<CustomRichText_t>* richText, const ARGTYP
int basereg=Argument->Memory.BaseRegister;
if(basereg&REG4 || basereg&REG5) //esp || ebp
{
argument.textBackground=QColor(0,255,255);
argument.textBackground=QColor("#00FFFF");
argument.flags=FlagBackground;
//Highlight ESP || EBP memory move
}
else
{
argument.textColor=QColor(0,0,128);
argument.textColor=QColor("#000080");
argument.flags=FlagColor;
}
@ -144,7 +144,7 @@ bool BeaHighlight::PrintArgument(QList<CustomRichText_t>* richText, const ARGTYP
if(argmnemonic.indexOf(label_addr_text)!=-1)
{
argument.flags=FlagBackground;
argument.textBackground=QColor(255,255,0);
argument.textBackground=QColor("#FFFF00");
argmnemonic.replace(label_addr_text, newText);
}
}
@ -154,7 +154,7 @@ bool BeaHighlight::PrintArgument(QList<CustomRichText_t>* richText, const ARGTYP
if(argmnemonic.indexOf(label_addr_text)!=-1)
{
argument.flags=FlagBackground;
argument.textBackground=QColor(255,255,0);
argument.textBackground=QColor("#FFFF00");
argmnemonic.replace(label_addr_text, newText);
}
}
@ -173,7 +173,7 @@ bool BeaHighlight::PrintArgument(QList<CustomRichText_t>* richText, const ARGTYP
if(brtype && brtype!=RetType && !(argtype&REGISTER_TYPE))
{
argument.flags=FlagBackground;
argument.textBackground=QColor(255,255,0);
argument.textBackground=QColor("#FFFF00");
unsigned char* opc=(unsigned char*)&Instruction->Opcode;
if(*opc==0xEB || *opc==0xE9 || Instruction->Opcode<0x80)
@ -207,33 +207,33 @@ void BeaHighlight::PrintBaseInstruction(QList<CustomRichText_t>* richText, const
if(brtype==RetType || brtype==CallType)
{
mnemonic.flags=FlagBackground;
mnemonic.textBackground=QColor(0,255,255);
mnemonic.textBackground=QColor("#00FFFF");
//calls && rets
}
else if(brtype==JmpType)
{
mnemonic.flags=FlagBackground;
mnemonic.textBackground=QColor(255,255,0);
mnemonic.textBackground=QColor("#FFFF00");
//uncond jumps
}
else
{
mnemonic.flags=FlagAll;
mnemonic.textBackground=QColor(255,255,0);
mnemonic.textColor=QColor(255,0,0);
mnemonic.textBackground=QColor("#FFFF00");
mnemonic.textColor=QColor("#FF0000");
//cond jumps
}
}
else if(!_stricmp(mnemonicText, "push") || !_stricmp(mnemonicText, "pop"))
{
mnemonic.flags=FlagColor;
mnemonic.textColor=QColor(0,0,255);
mnemonic.textColor=QColor("#0000FF");
//push/pop
}
else if(!_stricmp(mnemonicText, "nop"))
{
mnemonic.flags=FlagColor;
mnemonic.textColor=QColor(128,128,128);
mnemonic.textColor=QColor("#808080");
//nop
}
else

View File

@ -77,7 +77,7 @@ QString CPUStack::paintContent(QPainter* painter, int_t rowBase, int rowOffset,
if(wVa==mCsp) //CSP
{
painter->fillRect(QRect(x, y, w, h), QBrush(QColor("#000000")));
painter->setPen(QPen(QColor("#fffbf0")));
painter->setPen(QPen(QColor("#FFFBF0")));
}
else if(wIsSelected)
painter->setPen(QPen(QColor("#000000"))); //black address