1
0
Fork 0

GUI: color commenting

This commit is contained in:
Mr. eXoDia 2014-04-26 23:01:01 +02:00
parent 4c848c16c3
commit 0a115ec8f3
5 changed files with 58 additions and 51 deletions

View File

@ -19,7 +19,7 @@ AbstractTableView::AbstractTableView(QWidget *parent) : QAbstractScrollArea(pare
font.setStyleHint(QFont::Monospace);
this->setFont(font);
backgroundColor=QColor("#FFFBF0");
backgroundColor=QColor("#FFFBF0"); //AbstractTableViewBackgroundColor
int wRowsHeight = QFontMetrics(this->font()).height();
wRowsHeight = (wRowsHeight * 105) / 100;
@ -117,7 +117,7 @@ void AbstractTableView::paintEvent(QPaintEvent* event)
// Paints cell right borders
wPainter.save();
wPainter.setPen(QColor("#808080"));
wPainter.setPen(QColor("#808080")); //AbstractTableViewSeparatorColor
wPainter.drawLine(x + getColumnWidth(j) - 1, y, x + getColumnWidth(j) - 1, y + getRowHeight() - 1);
wPainter.restore();

View File

@ -32,6 +32,8 @@ Disassembly::Disassembly(QWidget *parent) : AbstractTableView(parent)
setShowHeader(false); //hide header
backgroundColor=QColor("#FFFBF0"); //DisassemblyBackgroundColor
connect(Bridge::getBridge(), SIGNAL(disassembleAt(int_t, int_t)), this, SLOT(disassembleAt(int_t, int_t)));
connect(Bridge::getBridge(), SIGNAL(dbgStateChanged(DBGSTATE)), this, SLOT(debugStateChangedSlot(DBGSTATE)));
connect(Bridge::getBridge(), SIGNAL(repaintGui()), this, SLOT(reloadData()));
@ -57,13 +59,12 @@ Disassembly::Disassembly(QWidget *parent) : AbstractTableView(parent)
*/
QString Disassembly::paintContent(QPainter* painter, int_t rowBase, int rowOffset, int col, int x, int y, int w, int h)
{
QString wStr = "";
int_t wRVA = mInstBuffer.at(rowOffset).rva;
bool wIsSelected = isSelected(&mInstBuffer, rowOffset); // isSelected(rowBase, rowOffset);
// Highlight if selected
if(wIsSelected)
painter->fillRect(QRect(x, y, w, h), QBrush(QColor("#C0C0C0")));
painter->fillRect(QRect(x, y, w, h), QBrush(QColor("#C0C0C0"))); //DisassemblySelectionColor
switch(col)
{
@ -87,21 +88,21 @@ QString Disassembly::paintContent(QPainter* painter, int_t rowBase, int rowOffse
painter->save();
if(mInstBuffer.at(rowOffset).rva == mCipRva) //cip
{
painter->fillRect(QRect(x, y, w, h), QBrush(QColor("#000000")));
painter->fillRect(QRect(x, y, w, h), QBrush(QColor("#000000"))); //DisassemblyCipColor
if(!isbookmark)
{
if(bpxtype&bp_normal) //breakpoint
{
painter->setPen(QPen(QColor("#FF0000")));
painter->setPen(QPen(QColor("#FF0000"))); //DisassemblyMainBpColor
}
else
{
painter->setPen(QPen(QColor("#FFFBF0")));
painter->setPen(QPen(QColor("#FFFBF0"))); //DisassemblyOtherBpColor
}
}
else
{
painter->setPen(QPen(QColor("#FEE970")));
painter->setPen(QPen(QColor("#FEE970"))); //DisassemblyBookmarkColor
}
}
else //other address
@ -111,16 +112,16 @@ 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 (DisassemblyMainLabelColor)
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 (DisassemblyMainBpColor)
}
else
{
painter->setPen(QPen(QColor("#000000"))); //black address
painter->setPen(QPen(QColor("#000000"))); //black address (???)
}
}
}
@ -129,33 +130,33 @@ QString Disassembly::paintContent(QPainter* painter, int_t rowBase, int rowOffse
if(bpxtype==bp_none) //no label, no breakpoint
{
if(wIsSelected)
painter->setPen(QPen(QColor("#000000"))); //black address
painter->setPen(QPen(QColor("#000000"))); //black address (DisassemblySelectedAddressColor)
else
painter->setPen(QPen(QColor("#808080")));
painter->setPen(QPen(QColor("#808080"))); //DisassemblyAddressColor
}
else //breakpoint only
{
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 (DisassemblyMainBpColor)
}
else
{
if(wIsSelected)
painter->setPen(QPen(QColor("#000000"))); //black address
painter->setPen(QPen(QColor("#000000"))); //black address (DisassemblySelectedAddressColor)
else
painter->setPen(QPen(QColor("#808080")));
painter->setPen(QPen(QColor("#808080"))); //DisassemblyAddressColor
}
}
}
}
else
else //bookmark
{
painter->fillRect(QRect(x, y, w, h), QBrush(QColor("#FEE970")));
painter->fillRect(QRect(x, y, w, h), QBrush(QColor("#FEE970"))); //DisassemblyBookmarkColor
if(wIsSelected)
painter->setPen(QPen(QColor("#000000"))); //black address
painter->setPen(QPen(QColor("#000000"))); //black address (DisassemblySelectedAddressColor)
else
painter->setPen(QPen(QColor("#808080")));
painter->setPen(QPen(QColor("#808080"))); //DisassemblyAddressColor
}
}
painter->drawText(QRect(x + 4, y , w - 4 , h), Qt::AlignVCenter | Qt::AlignLeft, addrText);
@ -192,13 +193,14 @@ QString Disassembly::paintContent(QPainter* painter, int_t rowBase, int rowOffse
int jumpsize = paintJumpsGraphic(painter, x + funcsize, y, wRVA); //jump line
//draw bytes
painter->save();
painter->setPen(QColor("#000000")); //DisassemblyBytesColor
QString wBytes = "";
for(int i = 0; i < mInstBuffer.at(rowOffset).dump.size(); i++)
wStr += QString("%1").arg((unsigned char)(mInstBuffer.at(rowOffset).dump.at(i)), 2, 16, QChar('0')).toUpper();
painter->drawText(QRect(x + jumpsize + funcsize, y, getColumnWidth(col) - jumpsize - funcsize, getRowHeight()), 0, wStr);
wStr = "";
wBytes += QString("%1").arg((unsigned char)(mInstBuffer.at(rowOffset).dump.at(i)), 2, 16, QChar('0')).toUpper();
painter->drawText(QRect(x + jumpsize + funcsize, y, getColumnWidth(col) - jumpsize - funcsize, getRowHeight()), 0, wBytes);
painter->restore();
break;
}
@ -245,9 +247,12 @@ QString Disassembly::paintContent(QPainter* painter, int_t rowBase, int rowOffse
{
char comment[MAX_COMMENT_SIZE]="";
if(DbgGetCommentAt(mInstBuffer.at(rowOffset).rva+mBase, comment))
wStr=QString(comment);
else
wStr="";
{
painter->save();
painter->setPen(QColor("#000000")); //DisassemblyCommentColor
painter->drawText(QRect(x + 4, y , w - 4 , h), Qt::AlignVCenter | Qt::AlignLeft, QString(comment));
painter->restore();
}
}
break;
@ -255,7 +260,7 @@ QString Disassembly::paintContent(QPainter* painter, int_t rowBase, int rowOffse
break;
}
return wStr;
return "";
}
@ -543,9 +548,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("#FF0000"));
painter->setPen(QColor("#FF0000")); //DisassemblyJumpLineTrueColor
else
painter->setPen(QColor("#808080"));
painter->setPen(QColor("#808080")); //DisassemblyJumpLineFalseColor
if(wPict == GD_Vert)
{

View File

@ -17,6 +17,8 @@ HexDump::HexDump(QWidget *parent) : AbstractTableView(parent)
clearDescriptors();
backgroundColor=QColor("#FFFBF0"); //HexDumpBackgroundColor
connect(Bridge::getBridge(), SIGNAL(updateDump()), this, SLOT(reloadData()));
connect(Bridge::getBridge(), SIGNAL(dbgStateChanged(DBGSTATE)), this, SLOT(debugStateChanged(DBGSTATE)));
}
@ -209,7 +211,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("#C0C0C0")));
painter->fillRect(QRect(wSelectionX, y, wSelectionWidth, h), QBrush(QColor("#C0C0C0"))); //HexDumpSelectionColor
}
}
}

View File

@ -29,7 +29,7 @@ QString ScriptView::paintContent(QPainter* painter, int_t rowBase, int rowOffset
bool wIsSelected=isSelected(rowBase, rowOffset);
// Highlight if selected
if(wIsSelected)
painter->fillRect(QRect(x, y, w, h), QBrush(QColor("#C0C0C0")));
painter->fillRect(QRect(x, y, w, h), QBrush(QColor("#C0C0C0"))); //ScriptViewSelectionColor
QString returnString;
int line=rowBase+rowOffset+1;
SCRIPTLINETYPE linetype=DbgScriptGetLineType(line);
@ -41,23 +41,23 @@ QString ScriptView::paintContent(QPainter* painter, int_t rowBase, int rowOffset
painter->save();
if(line==mIpLine) //IP
{
painter->fillRect(QRect(x, y, w, h), QBrush(QColor("#000000")));
painter->fillRect(QRect(x, y, w, h), QBrush(QColor("#000000"))); //ScriptViewIpColor
if(DbgScriptBpGet(line)) //breakpoint
painter->setPen(QPen(QColor("#FF0000"))); //red address
painter->setPen(QPen(QColor("#FF0000"))); //red address (ScriptViewMainBpColor)
else
painter->setPen(QPen(QColor("#FFFFFF"))); //white address
painter->setPen(QPen(QColor("#FFFFFF"))); //white address (ScriptViewIpTextColor)
}
else if(DbgScriptBpGet(line)) //breakpoint
{
painter->fillRect(QRect(x, y, w, h), QBrush(QColor("#FF0000")));
painter->setPen(QPen(QColor("#000000"))); //black address
painter->fillRect(QRect(x, y, w, h), QBrush(QColor("#FF0000"))); //ScriptViewMainBpColor
painter->setPen(QPen(QColor("#000000"))); //black address //ScripViewMainBpTextColor
}
else
{
if(linetype==linecommand || linetype==linebranch)
painter->setPen(QPen(QColor("#000000"))); //black address
painter->setPen(QPen(QColor("#000000"))); //black address (ScriptViewMainTextColor)
else
painter->setPen(QPen(QColor("#808080"))); //grey address
painter->setPen(QPen(QColor("#808080"))); //grey address (ScriptViewOtherTextColor)
}
painter->drawText(QRect(x + 4, y , w - 4 , h), Qt::AlignVCenter | Qt::AlignLeft, returnString);
painter->restore();

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("#00FFFF");
argument.textBackground=QColor("#00FFFF"); //DisassemblyStackPointerColor
argument.flags=FlagBackground;
//Highlight ESP || EBP memory move
}
else
{
argument.textColor=QColor("#000080");
argument.textColor=QColor("#000080"); //DisassemblyPointerColor
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("#FFFF00");
argument.textBackground=QColor("#FFFF00"); //DisassemblyModulePointerColor
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("#FFFF00");
argument.textBackground=QColor("#FFFF00"); //DisassemblyModulePointerColor
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("#FFFF00");
argument.textBackground=QColor("#FFFF00"); //DisassemblyModulePointerColor
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("#00FFFF");
mnemonic.textBackground=QColor("#00FFFF"); //DisassemblyRetCallColor
//calls && rets
}
else if(brtype==JmpType)
{
mnemonic.flags=FlagBackground;
mnemonic.textBackground=QColor("#FFFF00");
mnemonic.textBackground=QColor("#FFFF00"); //DisassemblyJumpColor
//uncond jumps
}
else
{
mnemonic.flags=FlagAll;
mnemonic.textBackground=QColor("#FFFF00");
mnemonic.textColor=QColor("#FF0000");
mnemonic.textBackground=QColor("#FFFF00"); //DisassemblyJumpColor
mnemonic.textColor=QColor("#FF0000"); //DisassemblyCondJumpColor
//cond jumps
}
}
else if(!_stricmp(mnemonicText, "push") || !_stricmp(mnemonicText, "pop"))
{
mnemonic.flags=FlagColor;
mnemonic.textColor=QColor("#0000FF");
mnemonic.textColor=QColor("#0000FF"); //DisassemblyPushPopColor
//push/pop
}
else if(!_stricmp(mnemonicText, "nop"))
{
mnemonic.flags=FlagColor;
mnemonic.textColor=QColor("#808080");
mnemonic.textColor=QColor("#808080"); //DisassemblyNopColor
//nop
}
else