void VdkPanel::DoEraseBackground(wxDC &dc, const wxRect &rc) { if (!m_gbi) { dc.SetPen(*wxTRANSPARENT_PEN); dc.SetBrush(m_bgBrush); if (m_bi) { if (m_bi->borderPen.IsOk()) { dc.SetPen(m_bi->borderPen); } if (m_bi->bgColor.IsOk()) { wxBrush bgBrush(m_bi->bgColor); dc.SetBrush(bgBrush); } } dc.DrawRectangle(rc); } else { VdkDcClippingRegionDestroyer destroyer(dc, rc); m_Window->ResetDcOrigin(dc); TranslateDC(dc); dc.GradientFillLinear(m_Rect, m_gbi->beg, m_gbi->end, m_gbi->direction); } }
void MdiArea::paintEvent(QPaintEvent* /*e*/) { QWidget* vport = viewport(); QRect rect = vport->rect(); QPainter painter(vport); painter.setRenderHint(QPainter::SmoothPixmapTransform); //Always fill with a solid color first if(useColor) painter.fillRect(rect, bgColor); else painter.fillRect(rect, background()); //Then overlay the texture if(useTexture) { QBrush bgBrush(bgTexture); painter.fillRect(rect, bgBrush); } //Overlay the logo last if(useLogo) { //Center the pixmap int dx = (rect.width()-bgLogo.width())/2; int dy = (rect.height()-bgLogo.height())/2; painter.drawPixmap(dx, dy, bgLogo.width(), bgLogo.height(), bgLogo); } }
virtual void setUp() { m_mdc.DestroyClippingRegion(); wxBrush bgBrush(s_bgColour, wxBRUSHSTYLE_SOLID); m_mdc.SetBackground(bgBrush); m_mdc.Clear(); }
//------------------------------------------------------------------------------- //① 설 명 : 바닥에 이미지 넣자. //② 인 수 : //③ 리 턴 : //------------------------------------------------------------------------------- void CFormProgress::vDrawText(CDC* pDC) { //------------------------------------------------- // 메모리 DC를 생성한다. //------------------------------------------------- CDC MemDC; MemDC.CreateCompatibleDC( pDC); CRect rc; GetClientRect( &rc ); CBrush bgBrush(RGB(30, 30, 34)); pDC->FillRect(rc, &bgBrush); //------------------------------------------------- // 비트맵 객체를 생성한다. - TITLE BITMAP 로드한다 //------------------------------------------------- CBitmap MemBitmap; //CString sBmpPath = sGetCurrentDir() + L"\\images\\title.bmp"; //HBITMAP hBMP = hbitLoadBitFile(sBmpPath); //MemBitmap.m_hObject = hBMP; //CBitmap MemBitmap; MemBitmap.LoadBitmap(MAKEINTRESOURCE(IDB_BM_TITLE)); MemDC.SetBkMode(TRANSPARENT); CBitmap *pOldBitmap = (CBitmap *)MemDC.SelectObject(&MemBitmap); pDC->StretchBlt(0, 0, rc.Width(), 34, &MemDC, 0, 0, 52, 32, SRCCOPY); MemDC.SelectObject( pOldBitmap ); MemBitmap.DeleteObject(); MemDC.DeleteDC(); }
/*! * \brief Creates the main scene for 2D data. * * This function creates the main QGraphicsScene 'scene2D' where all 2D graphical objects will be added. * Scene span is -10 000 000 to 10 000 000 units. */ void MainWindow::createScene() { QBrush bgBrush(Qt::white); scene2D = new QGraphicsScene(this); scene2D->setItemIndexMethod(QGraphicsScene::NoIndex); scene2D->setSceneRect(-10000000, -10000000, 20000000, 20000000); scene2D->setBackgroundBrush(bgBrush); }
void PerfMon::drawSolidBackground(QPainter *painter) { painter->save(); QBrush bgBrush(m_bgClr); painter->setBrush(bgBrush); painter->drawRect(this->rect()); painter->restore(); }
virtual void setUp() { CPPUNIT_ASSERT_MESSAGE("Invalid wxGCDC", m_gcdc); wxGraphicsContext* ctx = m_gcdc->GetGraphicsContext(); ctx->SetAntialiasMode(wxANTIALIAS_NONE); ctx->DisableOffset(); m_gcdc->DestroyClippingRegion(); wxBrush bgBrush(s_bgColour, wxBRUSHSTYLE_SOLID); m_gcdc->SetBackground(bgBrush); m_gcdc->Clear(); }
/** Constructor */ GCF::Components::AboutBox::AboutBox(QWidget* parent):QDialog(parent) { d = new GCF::Components::AboutBoxData; d->ui.setupUi(this); init(); static QPixmap aboutBg( GCF::Components::MainWindowComponent::instance().aboutBackground() ); QBrush bgBrush( palette().window().color(), aboutBg ); QPalette pal = this->palette(); if(!aboutBg.isNull()) { pal.setBrush( backgroundRole(), bgBrush ); pal.setBrush( QPalette::Base, bgBrush ); pal.setBrush( QPalette::Window, bgBrush ); pal.setBrush( QPalette::Background, bgBrush ); } setPalette(pal); setAutoFillBackground(true); d->ui.lblLogo->setPixmap( QPixmap(GCF::Components::MainWindowComponent::instance().applicationLogo()) ); d->ui.lstComponents->setSortingEnabled(true); #ifdef GCF_APP_VERSION d->ui.lblVersion->setText( GCF_APP_VERSION ); #else #if QT_VERSION >= 0x040400 static QString versionStr = QString("%1 - %2").arg( qApp->applicationName() ).arg( qApp->applicationVersion() ); #else static QString versionStr = QString("%1 - 2.5").arg( qApp->applicationName() ); #endif d->ui.lblVersion->setText( versionStr ); #endif for(int i=0; i<d->ui.componentInfoTabWidget->count(); i++) { QWidget* widget = d->ui.componentInfoTabWidget->widget(i); if(widget->layout()) widget->layout()->setMargin(0); } d->ui.txtGeneral->viewport()->installEventFilter(this); d->ui.txtCredits->viewport()->installEventFilter(this); d->ui.txtCopyright->viewport()->installEventFilter(this); }
/** Write property of QColor bgColor. */ void QgsMapCanvas::setCanvasColor( const QColor & theColor ) { // background of map's pixmap mSettings.setBackgroundColor( theColor ); // background of the QGraphicsView QBrush bgBrush( theColor ); setBackgroundBrush( bgBrush ); #if 0 QPalette palette; palette.setColor( backgroundRole(), theColor ); setPalette( palette ); #endif // background of QGraphicsScene mScene->setBackgroundBrush( bgBrush ); } // setBackgroundColor
void Menu::display(){ CRect rect(openedUpperLeft.x, openedUpperLeft.y, getBottomRight().x, getBottomRight().y); Graphics::createMemDc(&rect); openButton.display(); CPen pen(0,1,style->getBGColorRGB()); CBrush brush(style->getBGColorRGB()); CPen bgPen(0,1,GlobalSettings::backgroundClr.getRGB()); CBrush bgBrush(GlobalSettings::backgroundClr.getRGB()); CPen lblPen(0,1,style->labelBGColor.getRGB()); CBrush lblBrush(style->labelBGColor.getRGB()); Graphics::drawRectangle(nullptr, openedUpperLeft.x, openedUpperLeft.y, upperLeft.x, getBottomRight().y, &bgBrush, &bgPen, true, true, true); Graphics::drawRectangle(nullptr,this->openButton.getBottomRight().x, this->upperLeft.y, this->getBottomRight().x, this->getBottomRight().y, &brush, &pen, true, true, true); if(!style->labelBGTransparent){ Graphics::drawRectangle(nullptr,openButton.getBottomRight().x, upperLeft.y, getBottomRight().x, upperLeft.y + style->labelHeight, &lblBrush, &lblPen, true, true, true); } Graphics::drawText(nullptr, openButton.getBottomRight().x, upperLeft.y, getBottomRight().x, upperLeft.y + style->labelHeight, font, label, style->labelColor, true); this->navigationButton.display(); Graphics::drawRectangle(nullptr,openButton.getBottomRight().x, navigationButton.getBottomRight().y, getBottomRight().x, navigationButton.getBottomRight().y + style->panelWidthUnderNavButton, &lblBrush, &lblPen, true, true, true); vector<ControlElement*>* list = &elements[menuIndex]; for(size_t i = 0; i < list->size(); i++){ ControlElement* elem = list->at(i); elem->display(); } Graphics::deleteMemDc(); displayedAfterMove = true; }
BOOL CBitmapTabCtrl::OnEraseBkgnd(CDC* pDC) { if(m_bmp.GetSafeHandle() && m_nType) { CRect rect; GetClientRect(rect); CDC bgDC; bgDC.CreateCompatibleDC(NULL); bgDC.SelectObject(&m_bmp); BITMAP bmp; m_bmp.GetBitmap(&bmp); int nWidth = bmp.bmWidth; int nHeight = bmp.bmHeight; switch(m_nType) { case BITMAP_CENTER: CTabCtrl::OnEraseBkgnd(pDC); BITMAP bmp; m_bmp.GetBitmap (&bmp); pDC->BitBlt ((rect.Width() - bmp.bmWidth) / 2, (rect.Height() - bmp.bmHeight) / 2, bmp.bmWidth, bmp.bmHeight, &bgDC, 0, 0, SRCCOPY); return TRUE; case BITMAP_STRETCH: pDC->SetStretchBltMode(HALFTONE); pDC->StretchBlt(0, 0, rect.Width(), rect.Height(), &bgDC, 0, 0, nWidth, nHeight, SRCCOPY); return TRUE; default: CBrush bgBrush(&m_bmp); pDC->FillRect(rect,&bgBrush); return TRUE; } } else CTabCtrl::OnEraseBkgnd(pDC); return TRUE; //Let's get rid of flickering }
EditorBase::EditorBase( QWidget* parent, const char* name, Qt::WFlags f ) : QMainWindow( parent, f ), mMainView(0), mWorldManager(0), mTime(0), mLastTime(0) { mInstance = this; setObjectName(name); setWindowTitle("Gamedesk Editor"); statusBar()->showMessage(tr("Ready")); InitActions(); InitMenu(); QBrush bgBrush( QColor( 0, 0, 0 ) ); mWorldManager = GD_NEW(WorldManager, this, "EditorLib::EditorBase"); LoadTools(); }
// Linux does not reliably generate EraseBackground // events here, so use Paint events void CSimplePanelBase::OnPaint(wxPaintEvent& /*event*/) { wxPaintDC dc(this); if (!m_GotBGBitMap) { MakeBGBitMap(); } dc.DrawBitmap(m_TaskPanelBGBitMap, 0, 0); wxPen oldPen= dc.GetPen(); wxBrush oldBrush = dc.GetBrush(); int oldMode = dc.GetBackgroundMode(); wxCoord w, h; wxPen bgPen(*wxLIGHT_GREY, 3); wxBrush bgBrush(*wxLIGHT_GREY, wxTRANSPARENT); dc.SetBackgroundMode(wxSOLID); dc.SetPen(bgPen); dc.SetBrush(bgBrush); dc.GetSize(&w, &h); dc.DrawRoundedRectangle(0, 0, w, h, RECTANGLERADIUS); #ifdef __WXMAC__ // Mac progress bar can be hard to see on a colored // background, so put it on a white background wxRect* progressRect = GetProgressRect(); if (progressRect) { dc.SetPen(*wxBLACK_PEN); dc.SetBrush(*wxWHITE_BRUSH); dc.DrawRoundedRectangle(progressRect->x, progressRect->y, progressRect->width, progressRect->height, 2); } #endif // Restore Mode, Pen and Brush dc.SetBackgroundMode(oldMode); dc.SetPen(oldPen); dc.SetBrush(oldBrush); }
void CStartupView::DrawBackground(Gdiplus::Graphics &graphics) { CSize siTotal = GetTotalSize(); CRect rcClient(0, 0, siTotal.cx, siTotal.cy); CRect rc; GetClientRect(&rc); /* int iLeft = 6; int iRight = 13; int iMiddle = rcClient.Width() - iLeft - iRight;*/ Gdiplus::Rect gdipRcClient(rcClient.left, rcClient.top, rcClient.Width(), rcClient.Height()); Gdiplus::SolidBrush bgBrush(Gdiplus::Color(255, 238, 238, 238)); graphics.FillRectangle(&bgBrush, gdipRcClient); Gdiplus::REAL offsetY = (Gdiplus::REAL)OFFSET_Y; Gdiplus::REAL y = offsetY; float fHeight = (Gdiplus::REAL)TOP_HEIGHT; Gdiplus::RectF gdipRcLeft; Gdiplus::RectF gdipRcMiddle; Gdiplus::RectF gdipRcRight; CalculateBkgRects(gdipRcLeft, gdipRcMiddle, gdipRcRight, y, fHeight); graphics.DrawImage(m_pBmpTopLeft, gdipRcLeft); graphics.DrawImage(m_pBmpTopMiddle, gdipRcMiddle, 0.0, 0.0, 1.0, (Gdiplus::REAL)fHeight, Gdiplus::UnitPixel); graphics.DrawImage(m_pBmpTopRight, gdipRcRight); fHeight = (Gdiplus::REAL)BLUE_HEIGHT; CalculateBkgRects(gdipRcLeft, gdipRcMiddle, gdipRcRight, y, fHeight); graphics.DrawImage(m_pBmpBlueLeft, gdipRcLeft); graphics.DrawImage(m_pBmpBlueMiddle, gdipRcMiddle, 0.0, 0.0, 1.0, (Gdiplus::REAL)fHeight, Gdiplus::UnitPixel); graphics.DrawImage(m_pBmpBlueRight, gdipRcRight); fHeight =(Gdiplus::REAL)( rcClient.Height() - OFFSET_Y - TOP_HEIGHT - BLUE_HEIGHT - LIGHT_BLUE_HEIGHT - FOOT_HEIGHT); CalculateBkgRects(gdipRcLeft, gdipRcMiddle, gdipRcRight, y, fHeight); graphics.DrawImage(m_pBmpWhiteLeft, gdipRcLeft/*, 0.0, 0.0, 1.0, (Gdiplus::REAL)296, Gdiplus::UnitPixel*/); graphics.DrawImage(m_pBmpWhiteMiddle, gdipRcMiddle, 0.0, 0.0, 1.0, (Gdiplus::REAL)296, Gdiplus::UnitPixel); graphics.DrawImage(m_pBmpWhiteRight, gdipRcRight/*, 0.0, 0.0, 1.0, (Gdiplus::REAL)296, Gdiplus::UnitPixel*/); fHeight = (Gdiplus::REAL)LIGHT_BLUE_HEIGHT; y--; CalculateBkgRects(gdipRcLeft, gdipRcMiddle, gdipRcRight, y , fHeight); graphics.DrawImage(m_pBmpLightBlueLeft, gdipRcLeft); graphics.DrawImage(m_pBmpLightBlueMiddle, gdipRcMiddle, 0.0, 0.0, 1.0, (Gdiplus::REAL)fHeight, Gdiplus::UnitPixel); graphics.DrawImage(m_pBmpLightBlueRight, gdipRcRight); fHeight = (Gdiplus::REAL)FOOT_HEIGHT; CalculateBkgRects(gdipRcLeft, gdipRcMiddle, gdipRcRight, y, fHeight); graphics.DrawImage(m_pBmpFootLeft, gdipRcLeft); graphics.DrawImage(m_pBmpFootMiddle, gdipRcMiddle, 0.0, 0.0, 1.0, (Gdiplus::REAL)fHeight, Gdiplus::UnitPixel); graphics.DrawImage(m_pBmpFootRight, gdipRcRight); Gdiplus::Color colorFrom[] = {Gdiplus::Color(255, 220, 223, 224), Gdiplus::Color(255, 215, 215, 215), Gdiplus::Color(255, 216, 216, 216), Gdiplus::Color(255, 219, 219, 219), Gdiplus::Color(255, 223, 223, 223), Gdiplus::Color(255, 226, 226, 226), Gdiplus::Color(255, 229, 229, 229), Gdiplus::Color(255, 231, 231, 231), }; Gdiplus::Color colorTo[] = {Gdiplus::Color(255, 198, 199, 201), Gdiplus::Color(255, 185, 185, 185), Gdiplus::Color(255, 190, 190, 190), Gdiplus::Color(255, 197, 197, 197), Gdiplus::Color(255, 203, 203, 203), Gdiplus::Color(255, 213, 213, 213), Gdiplus::Color(255, 218, 218, 218), Gdiplus::Color(255, 226, 226, 226), }; Gdiplus::RectF gdipRcM2; for(int i = 0; i < 8; i++) { gdipRcM2.X = gdipRcMiddle.X + gdipRcMiddle.Width - 30.0; gdipRcM2.Y = gdipRcMiddle.Y + gdipRcMiddle.Height - 8 + i; gdipRcM2.Width = 30.0; gdipRcM2.Height = 1.0; Gdiplus::LinearGradientBrush gradientBrush(gdipRcM2, colorFrom[i], colorTo[i], Gdiplus::LinearGradientModeHorizontal); graphics.FillRectangle(&gradientBrush, gdipRcM2); } }
// Create a background bitmap simulating partial transparency void CSimplePanelBase::MakeBGBitMap() { wxRect r; wxBitmap rawBmp; wxBitmap whiteBmp; wxImage bgImage; wxImage whiteImage; register unsigned char *bgImagePixels; register unsigned char *whitePixels; register int i, j, k; CSimpleGUIPanel* backgroundPanel = (CSimpleGUIPanel*)GetParent(); wxPen bgPen(*wxWHITE, 1, wxTRANSPARENT); wxBrush bgBrush(*wxWHITE); CSkinSimple* pSkinSimple = wxGetApp().GetSkinManager()->GetSimple(); wxASSERT(pSkinSimple); wxASSERT(wxDynamicCast(pSkinSimple, CSkinSimple)); int white_weight = pSkinSimple->GetPanelOpacity(); int image_weight = MAX_OPACITY - white_weight; // Workaround for CSimpleGUIPanel not reliably getting // Paint or EraseBackground events under Linux #if (!(defined(__WXMSW_) || defined(__WXMAC__))) backgroundPanel->SetBackgroundBitmap(); #endif GetPosition(&r.x, &r.y); GetSize(&r.width, &r.height); wxBitmap *bgBmp(backgroundPanel->GetBackgroundBitMap()); wxRect bgRect(0, 0, bgBmp->GetWidth(), bgBmp->GetHeight()); if (bgRect.Contains(r)) { rawBmp = bgBmp->GetSubBitmap(r); } else { fprintf(stderr, "SimpleGUI background image is too small\n"); rawBmp = wxBitmap(r.width, r.height); wxMemoryDC dc(rawBmp); wxPen rawPen(*wxBLACK, 1, wxTRANSPARENT); wxBrush rawBrush(*wxBLACK); dc.SetBackgroundMode(wxSOLID); dc.SetPen(rawPen); dc.SetBrush(rawBrush); dc.DrawRectangle(0, 0, r.width, r.height); } whiteBmp = wxBitmap(r.width, r.height); wxMemoryDC dc(whiteBmp); dc.SetBackgroundMode(wxSOLID); dc.SetPen(bgPen); dc.SetBrush(bgBrush); dc.DrawRoundedRectangle(0, 0, r.width, r.height, RECTANGLERADIUS); bgImage = rawBmp.ConvertToImage(); bgImagePixels = bgImage.GetData(); // RGBRGBRGB... whiteImage = whiteBmp.ConvertToImage(); whitePixels = whiteImage.GetData(); // RGBRGBRGB... for (i=0; i<r.width; ++i) { for (j=0; j<r.height; ++j) { if (*whitePixels) { k = (((unsigned int)*bgImagePixels * image_weight) + ((unsigned int)*whitePixels++ * white_weight)); *bgImagePixels++ = k / MAX_OPACITY; k = (((unsigned int)*bgImagePixels * image_weight) + ((unsigned int)*whitePixels++ * white_weight)); *bgImagePixels++ = k / MAX_OPACITY; k = (((unsigned int)*bgImagePixels * image_weight) + ((unsigned int)*whitePixels++ * white_weight)); *bgImagePixels++ = k / MAX_OPACITY; } else { bgImagePixels += 3; whitePixels += 3; } } } m_TaskPanelBGBitMap = wxBitmap(bgImage); m_GotBGBitMap = true; }
void CMemoryView::OnPaint(wxPaintEvent& event) { wxPaintDC dc(this); wxRect rc = GetClientRect(); wxFont hFont("Courier"); hFont.SetFamily(wxFONTFAMILY_TELETYPE); wxCoord w,h; dc.GetTextExtent("0WJyq", &w, &h, nullptr, nullptr, &hFont); if (h > rowHeight) rowHeight = h; dc.GetTextExtent("0WJyq", &w, &h, nullptr, nullptr, &DebuggerFont); if (h > rowHeight) rowHeight = h; if (viewAsType==VIEWAS_HEX) dc.SetFont(hFont); else dc.SetFont(DebuggerFont); dc.GetTextExtent("W", &w, &h); int fontSize = w; int textPlacement = 17 + 9 * fontSize; // TODO: Add any drawing code here... int width = rc.width; int numRows = (rc.height / rowHeight) / 2 + 2; dc.SetBackgroundMode(wxTRANSPARENT); const wxColour bgColor = *wxWHITE; wxPen nullPen(bgColor); wxPen currentPen(*wxBLACK_PEN); wxPen selPen(*wxGREY_PEN); nullPen.SetStyle(wxTRANSPARENT); wxBrush currentBrush(*wxLIGHT_GREY_BRUSH); wxBrush pcBrush(*wxGREEN_BRUSH); wxBrush mcBrush(*wxBLUE_BRUSH); wxBrush bgBrush(bgColor); wxBrush nullBrush(bgColor); nullBrush.SetStyle(wxTRANSPARENT); dc.SetPen(nullPen); dc.SetBrush(bgBrush); dc.DrawRectangle(0, 0, 16, rc.height); dc.DrawRectangle(0, 0, rc.width, 5+8); // TODO - clean up this freaking mess!!!!! for (int row = -numRows; row <= numRows; row++) { unsigned int address = curAddress + row * align; int rowY1 = rc.height / 2 + rowHeight * row - rowHeight / 2; int rowY2 = rc.height / 2 + rowHeight * row + rowHeight / 2; wxString temp = wxString::Format("%08x", address); u32 col = debugger->GetColor(address); wxBrush rowBrush(wxColour(col >> 16, col >> 8, col)); dc.SetBrush(nullBrush); dc.SetPen(nullPen); dc.DrawRectangle(0, rowY1, 16, rowY2); if (selecting && (address == selection)) dc.SetPen(selPen); else dc.SetPen(row == 0 ? currentPen : nullPen); if (address == debugger->GetPC()) dc.SetBrush(pcBrush); else dc.SetBrush(rowBrush); dc.DrawRectangle(16, rowY1, width, rowY2 - 1); dc.SetBrush(currentBrush); dc.SetTextForeground("#600000"); // Dark red dc.DrawText(temp, 17, rowY1); if (viewAsType != VIEWAS_HEX) { char mem[256]; debugger->GetRawMemoryString(memory, address, mem, 256); dc.SetTextForeground(wxTheColourDatabase->Find("NAVY")); dc.DrawText(StrToWxStr(mem), 17+fontSize*(8), rowY1); dc.SetTextForeground(*wxBLACK); } if (!PowerPC::HostIsRAMAddress(address)) continue; if (debugger->IsAlive()) { std::string dis; u32 mem_data = debugger->ReadExtraMemory(memory, address); if (viewAsType == VIEWAS_FP) { float flt = *(float *)(&mem_data); dis = StringFromFormat("f: %f", flt); } else if (viewAsType == VIEWAS_ASCII) { u32 a[4] = { (mem_data & 0xff000000) >> 24, (mem_data & 0xff0000) >> 16, (mem_data & 0xff00) >> 8, (mem_data & 0xff) }; for (auto& word : a) { if (word == '\0') word = ' '; } dis = StringFromFormat("%c%c%c%c", a[0], a[1], a[2], a[3]); } else if (viewAsType == VIEWAS_HEX)
void CCodeView::OnPaint(wxPaintEvent& event) { // -------------------------------------------------------------------- // General settings // ------------------------- wxPaintDC dc(this); wxRect rc = GetClientRect(); dc.SetFont(DebuggerFont); wxCoord w,h; dc.GetTextExtent(_T("0WJyq"),&w,&h); if (h > rowHeight) rowHeight = h; dc.GetTextExtent(_T("W"),&w,&h); int charWidth = w; struct branch { int src, dst, srcAddr; }; branch branches[256]; int numBranches = 0; // TODO: Add any drawing code here... int width = rc.width; int numRows = (rc.height / rowHeight) / 2 + 2; // ------------ // -------------------------------------------------------------------- // Colors and brushes // ------------------------- dc.SetBackgroundMode(wxTRANSPARENT); // the text background const wxChar* bgColor = _T("#ffffff"); wxPen nullPen(bgColor); wxPen currentPen(_T("#000000")); wxPen selPen(_T("#808080")); // gray nullPen.SetStyle(wxTRANSPARENT); currentPen.SetStyle(wxSOLID); wxBrush currentBrush(_T("#FFEfE8")); // light gray wxBrush pcBrush(_T("#70FF70")); // green wxBrush bpBrush(_T("#FF3311")); // red wxBrush bgBrush(bgColor); wxBrush nullBrush(bgColor); nullBrush.SetStyle(wxTRANSPARENT); dc.SetPen(nullPen); dc.SetBrush(bgBrush); dc.DrawRectangle(0, 0, 16, rc.height); dc.DrawRectangle(0, 0, rc.width, 5); // ------------ // -------------------------------------------------------------------- // Walk through all visible rows // ------------------------- for (int i = -numRows; i <= numRows; i++) { unsigned int address = curAddress + i * align; int rowY1 = rc.height / 2 + rowHeight * i - rowHeight / 2; int rowY2 = rc.height / 2 + rowHeight * i + rowHeight / 2; wxString temp = wxString::Format(_T("%08x"), address); u32 col = debugger->GetColor(address); wxBrush rowBrush(wxColor(col >> 16, col >> 8, col)); dc.SetBrush(nullBrush); dc.SetPen(nullPen); dc.DrawRectangle(0, rowY1, 16, rowY2 - rowY1 + 2); if (selecting && (address == selection)) dc.SetPen(selPen); else dc.SetPen(i == 0 ? currentPen : nullPen); if (address == debugger->GetPC()) dc.SetBrush(pcBrush); else dc.SetBrush(rowBrush); dc.DrawRectangle(16, rowY1, width, rowY2 - rowY1 + 1); dc.SetBrush(currentBrush); if (!plain) { dc.SetTextForeground(_T("#600000")); // the address text is dark red dc.DrawText(temp, 17, rowY1); dc.SetTextForeground(_T("#000000")); } // If running if (debugger->IsAlive()) { char dis[256]; debugger->Disassemble(address, dis, 256); char* dis2 = strchr(dis, '\t'); char desc[256] = ""; // If we have a code if (dis2) { *dis2 = 0; dis2++; // look for hex strings to decode branches const char* mojs = strstr(dis2, "0x8"); if (mojs) { for (int k = 0; k < 8; k++) { bool found = false; for (int j = 0; j < 22; j++) { if (mojs[k + 2] == "0123456789ABCDEFabcdef"[j]) found = true; } if (!found) { mojs = nullptr; break; } } } if (mojs) { int offs; sscanf(mojs + 2, "%08x", &offs); branches[numBranches].src = rowY1 + rowHeight / 2; branches[numBranches].srcAddr = address / align; branches[numBranches++].dst = (int)(rowY1 + ((s64)(u32)offs - (s64)(u32)address) * rowHeight / align + rowHeight / 2); sprintf(desc, "-->%s", debugger->GetDescription(offs).c_str()); dc.SetTextForeground(_T("#600060")); // the -> arrow illustrations are purple } else { dc.SetTextForeground(_T("#000000")); } dc.DrawText(StrToWxStr(dis2), 17 + 17*charWidth, rowY1); // ------------ } // Show blr as its' own color if (strcmp(dis, "blr")) dc.SetTextForeground(_T("#007000")); // dark green else dc.SetTextForeground(_T("#8000FF")); // purple dc.DrawText(StrToWxStr(dis), 17 + (plain ? 1*charWidth : 9*charWidth), rowY1); if (desc[0] == 0) { strcpy(desc, debugger->GetDescription(address).c_str()); } if (!plain) { dc.SetTextForeground(_T("#0000FF")); // blue //char temp[256]; //UnDecorateSymbolName(desc,temp,255,UNDNAME_COMPLETE); if (strlen(desc)) { dc.DrawText(StrToWxStr(desc), 17 + 35 * charWidth, rowY1); } } // Show red breakpoint dot if (debugger->IsBreakpoint(address)) { dc.SetBrush(bpBrush); dc.DrawRectangle(2, rowY1 + 1, 11, 11); } } } // end of for // ------------ // -------------------------------------------------------------------- // Colors and brushes // ------------------------- dc.SetPen(currentPen); for (int i = 0; i < numBranches; i++) { int x = 17 + 49 * charWidth + (branches[i].srcAddr % 9) * 8; _MoveTo(x-2, branches[i].src); if (branches[i].dst < rc.height + 400 && branches[i].dst > -400) { _LineTo(dc, x+2, branches[i].src); _LineTo(dc, x+2, branches[i].dst); _LineTo(dc, x-4, branches[i].dst); _MoveTo(x, branches[i].dst - 4); _LineTo(dc, x-4, branches[i].dst); _LineTo(dc, x+1, branches[i].dst+5); } //else //{ // This can be re-enabled when there is a scrollbar or // something on the codeview (the lines are too long) //_LineTo(dc, x+4, branches[i].src); //_MoveTo(x+2, branches[i].dst-4); //_LineTo(dc, x+6, branches[i].dst); //_LineTo(dc, x+1, branches[i].dst+5); //} //_LineTo(dc, x, branches[i].dst+4); //_LineTo(dc, x-2, branches[i].dst); } // ------------ }
void CLab08View::OnDraw(CDC* _pDC) { CLab08Doc* pDoc = GetDocument(); ASSERT_VALID(pDoc); if (!pDoc) return; CRect size; _pDC->GetWindow()->GetClientRect(&size); // Супер костыли CMemDC dc(*_pDC, _pDC->GetWindow()); CDC * pDC = &dc.GetDC(); // Крутая штука, почему я раньше её не юзал // Чистим фон CBrush bgBrush(_pDC->GetBkColor()); pDC->FillRect(size, &bgBrush); if (size.Width() < 150 || size.Height() < 150 ) { LONG x = size.left + (size.right - size.left) / 2; LONG y = size.top + (size.bottom - size.top) / 2; HICON m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); pDC->DrawIcon(x - 16, y - 16, m_hIcon); return; } auto & props = pDoc->properties; auto & funcs = pDoc->properties.functions; // Начало координат в пикселях. Может не попадать в область видимости LONG center_x = t_dim_to_pixel_x(size, 0.0); LONG center_y = t_dim_to_pixel_y(size, 0.0); pDC->SetBkMode(TRANSPARENT); // Рисуем вспомогательную сетку CPen penGird(PS_DOT, 1, COLORREF(0x7f7f7f)); pDC->SelectObject(&penGird); pDC->SetTextColor(COLORREF(0x7f7f7f)); double gird_lx = ceil(t_pixel_to_dim_x(size, size.left) / props.x_grid) * props.x_grid; double gird_rx = floor(t_pixel_to_dim_x(size, size.right) / props.x_grid) * props.x_grid; for(double i = gird_lx; i <= gird_rx; i += props.x_grid) { LONG ix = t_dim_to_pixel_x(size, i); if ( ix != center_x && size.left + 1 < ix && ix < size.right - 1) { pDC->MoveTo(ix, size.bottom - 5); pDC->LineTo(ix, size.top + 5); } } double gird_ly = ceil(t_pixel_to_dim_y(size, size.bottom) / props.y_grid) * props.y_grid; double gird_ry = floor(t_pixel_to_dim_y(size, size.top) / props.y_grid) * props.y_grid; for(double i = gird_ly; i <= gird_ry; i += props.y_grid) { LONG iy = t_dim_to_pixel_y(size, i); if ( iy != center_y && size.top + 1 < iy && iy < size.bottom - 1) { pDC->MoveTo(size.left + 5, iy); pDC->LineTo(size.right - 5, iy); } } // Рисуем оси, если это имеет смысл CPen penAxis(PS_SOLID, 2, COLORREF(0x000000)); pDC->SelectObject(&penAxis); pDC->SetTextColor(0); if ( size.left <= center_x && center_x <= size.right ) { pDC->MoveTo(center_x, size.bottom - 5); pDC->LineTo(center_x, size.top + 5); // стрелочка pDC->MoveTo(center_x - 5, size.top + 10); pDC->LineTo(center_x, size.top + 5); pDC->LineTo(center_x + 5, size.top + 10); // Буковка pDC->TextOut(center_x + 5, size.top + 10, _T("Y")); } if ( size.top <= center_y && center_y <= size.bottom ) { pDC->MoveTo(size.left + 5, center_y); pDC->LineTo(size.right - 5, center_y); // стрелочка pDC->MoveTo(size.right - 10, center_y - 5); pDC->LineTo(size.right - 5, center_y); pDC->LineTo(size.right - 10, center_y + 5); // Буковка pDC->TextOut(size.right - 15, center_y + 5, _T("X")); } if ( size.left <= center_x && center_x <= size.right && size.top <= center_y && center_y <= size.bottom ) { pDC->TextOut(center_x + 1, center_y + 1, _T("(0;0)")); } // координаты в углах { CString tmp; tmp.Format(_T("(%g;%g)"), gird_lx, gird_ly); drawPoint(pDC, size, t_dim_to_pixel_x(size, gird_lx), t_dim_to_pixel_y(size, gird_ly), tmp); tmp.Format(_T("(%g;%g)"), gird_lx, gird_ry); drawPoint(pDC, size, t_dim_to_pixel_x(size, gird_lx), t_dim_to_pixel_y(size, gird_ry), tmp); tmp.Format(_T("(%g;%g)"), gird_rx, gird_ly); drawPoint(pDC, size, t_dim_to_pixel_x(size, gird_rx), t_dim_to_pixel_y(size, gird_ly), tmp); tmp.Format(_T("(%g;%g)"), gird_rx, gird_ry); drawPoint(pDC, size, t_dim_to_pixel_x(size, gird_rx), t_dim_to_pixel_y(size, gird_ry), tmp); } // Рисование графиков for(int ii = 0; ii < funcs.size(); ++ii) { CPen penFunc(PS_SOLID, 1, funcs[ii].second); pDC->SelectObject(&penFunc); for(int pixel_x = size.left; pixel_x < size.right; pixel_x += props.accuracy) { //Sleep(1); // TEST ONLY double dim_x = t_pixel_to_dim_x(size, pixel_x); double dim_y = funcs[ii].first.f(dim_x); int pixel_y = t_dim_to_pixel_y(size, dim_y); if (pixel_x == size.left) pDC->MoveTo(pixel_x, pixel_y); else pDC->LineTo(pixel_x, pixel_y); } } }
void CSimpleGUIPanel::SetBackgroundBitmap() { wxLogTrace(wxT("Function Start/End"), wxT("CSimpleGUIPanel::SetBackgroundBitmap - Function Start")); CSkinSimple* pSkinSimple = wxGetApp().GetSkinManager()->GetSimple(); wxASSERT(pSkinSimple); wxASSERT(wxDynamicCast(pSkinSimple, CSkinSimple)); wxColour bgColor(*pSkinSimple->GetBackgroundImage()->GetBackgroundColor()); SetBackgroundColour(bgColor); wxRect panelRect = GetRect(); m_bmpBg = wxBitmap(panelRect.width, panelRect.height); wxMemoryDC dc(m_bmpBg); wxBrush bgBrush(bgColor); dc.SetBackground(bgBrush); dc.Clear(); #ifdef __WXMAC__ // Work around an apparent bug in wxMemoryDC::Clear() in wxCarbon 2.9.4 // TODO: remove this when the wxCarbon bug is fixed dc.SetBrush(bgBrush); wxPen bgPen(bgColor); dc.SetPen(bgPen); dc.DrawRectangle(panelRect); #endif int srcX, srcY, destX, destY, h, w; wxBitmap* srcBmp = pSkinSimple->GetBackgroundImage()->GetBitmap(); wxSize srcSize = srcBmp->GetSize(); switch(pSkinSimple->GetBackgroundImage()->GetHorizontalAnchor()) { case BKGD_ANCHOR_HORIZ_LEFT: default: srcX = 0; destX = 0; break; case BKGD_ANCHOR_HORIZ_CENTER: if (panelRect.width < srcSize.GetWidth()) { srcX = (srcSize.GetWidth() - panelRect.width) / 2; destX = 0; } else { srcX = 0; destX = (panelRect.width - srcSize.GetWidth()) / 2; } break; case BKGD_ANCHOR_HORIZ_RIGHT: if (panelRect.width < srcSize.GetWidth()) { srcX = (srcSize.GetWidth() - panelRect.width); destX = 0; } else { srcX = 0; destX = (panelRect.width - srcSize.GetWidth()); } break; } w = wxMin(panelRect.width, srcSize.GetWidth()); switch(pSkinSimple->GetBackgroundImage()->GetVerticalAnchor()) { case BKGD_ANCHOR_VERT_TOP: default: srcY = 0; destY = 0; break; case BKGD_ANCHOR_VERT_CENTER: if (panelRect.height < srcSize.GetHeight()) { srcY = (srcSize.GetHeight() - panelRect.height) / 2; destY = 0; } else { srcY = 0; destY = (panelRect.height - srcSize.GetHeight()) / 2; } break; case BKGD_ANCHOR_VERT_BOTTOM: if (panelRect.height < srcSize.GetHeight()) { srcY = (srcSize.GetHeight() - panelRect.height); destY = 0; } else { srcY = 0; destY = (panelRect.height - srcSize.GetHeight()); } break; } h = wxMin(panelRect.height, srcSize.GetHeight()); wxMemoryDC srcDC(*srcBmp); dc.Blit(destX, destY, w, h, &srcDC, srcX, srcY, wxCOPY); // dc.DrawBitmap(*pSkinSimple->GetBackgroundImage()->GetBitmap(), 0, 0, false); wxLogTrace(wxT("Function Start/End"), wxT("CSimpleGUIPanel::SetBackgroundBitmap - Function End")); }
void CCodeView::OnPaint(wxPaintEvent& event) { // ------------------------- // General settings // ------------------------- std::unique_ptr<wxGraphicsContext> ctx(wxGraphicsContext::Create(wxPaintDC(this))); wxRect rc = GetClientRect(); ctx->SetFont(DebuggerFont, *wxBLACK); wxDouble w, h; ctx->GetTextExtent("0WJyq", &w, &h); if (h > m_rowHeight) m_rowHeight = h; ctx->GetTextExtent("W", &w, &h); int charWidth = w; struct branch { int src, dst, srcAddr; }; branch branches[256]; int numBranches = 0; // TODO: Add any drawing code here... int width = rc.width; int numRows = ((rc.height / m_rowHeight) / 2) + 2; // ------------ // ------------------------- // Colors and brushes // ------------------------- const wxColour bgColor = *wxWHITE; wxPen nullPen(bgColor); wxPen currentPen(*wxBLACK_PEN); wxPen selPen(*wxGREY_PEN); nullPen.SetStyle(wxPENSTYLE_TRANSPARENT); currentPen.SetStyle(wxPENSTYLE_SOLID); wxBrush currentBrush(*wxLIGHT_GREY_BRUSH); wxBrush pcBrush(*wxGREEN_BRUSH); wxBrush bpBrush(*wxRED_BRUSH); wxBrush bgBrush(bgColor); wxBrush nullBrush(bgColor); nullBrush.SetStyle(wxBRUSHSTYLE_TRANSPARENT); ctx->SetPen(nullPen); ctx->SetBrush(bgBrush); ctx->DrawRectangle(0, 0, 16, rc.height); ctx->DrawRectangle(0, 0, rc.width, 5); // ------------ // ----------------------------- // Walk through all visible rows // ----------------------------- for (int i = -numRows; i <= numRows; i++) { unsigned int address = m_curAddress + (i * m_align); int rowY1 = (rc.height / 2) + (m_rowHeight * i) - (m_rowHeight / 2); int rowY2 = (rc.height / 2) + (m_rowHeight * i) + (m_rowHeight / 2); wxString temp = wxString::Format("%08x", address); u32 color = m_debugger->GetColor(address); wxBrush rowBrush(wxColour(color >> 16, color >> 8, color)); ctx->SetBrush(nullBrush); ctx->SetPen(nullPen); ctx->DrawRectangle(0, rowY1, 16, rowY2 - rowY1 + 2); if (m_selecting && (address == m_selection)) ctx->SetPen(selPen); else ctx->SetPen(i == 0 ? currentPen : nullPen); if (address == m_debugger->GetPC()) ctx->SetBrush(pcBrush); else ctx->SetBrush(rowBrush); ctx->DrawRectangle(16, rowY1, width, rowY2 - rowY1 + 1); ctx->SetBrush(currentBrush); if (!m_plain) { // the address text is dark red ctx->SetFont(DebuggerFont, wxColour("#600000")); ctx->DrawText(temp, 17, rowY1); ctx->SetFont(DebuggerFont, *wxBLACK); } // If running if (m_debugger->IsAlive()) { std::vector<std::string> dis; SplitString(m_debugger->Disassemble(address), '\t', dis); dis.resize(2); static const size_t VALID_BRANCH_LENGTH = 10; const std::string& opcode = dis[0]; const std::string& operands = dis[1]; std::string desc; // look for hex strings to decode branches std::string hex_str; size_t pos = operands.find("0x8"); if (pos != std::string::npos) { hex_str = operands.substr(pos); } if (hex_str.length() == VALID_BRANCH_LENGTH) { u32 offs = std::stoul(hex_str, nullptr, 16); branches[numBranches].src = rowY1 + (m_rowHeight / 2); branches[numBranches].srcAddr = (address / m_align); branches[numBranches++].dst = (int)(rowY1 + ((s64)(u32)offs - (s64)(u32)address) * m_rowHeight / m_align + m_rowHeight / 2); desc = StringFromFormat("-->%s", m_debugger->GetDescription(offs).c_str()); // the -> arrow illustrations are purple ctx->SetFont(DebuggerFont, wxTheColourDatabase->Find("PURPLE")); } else { ctx->SetFont(DebuggerFont, *wxBLACK); } ctx->DrawText(StrToWxStr(operands), 17 + 17 * charWidth, rowY1); // ------------ // Show blr as its' own color if (opcode == "blr") ctx->SetFont(DebuggerFont, wxTheColourDatabase->Find("DARK GREEN")); else ctx->SetFont(DebuggerFont, wxTheColourDatabase->Find("VIOLET")); ctx->DrawText(StrToWxStr(opcode), 17 + (m_plain ? 1 * charWidth : 9 * charWidth), rowY1); if (desc.empty()) { desc = m_debugger->GetDescription(address); } if (!m_plain) { ctx->SetFont(DebuggerFont, *wxBLUE); // char temp[256]; // UnDecorateSymbolName(desc,temp,255,UNDNAME_COMPLETE); if (!desc.empty()) { ctx->DrawText(StrToWxStr(desc), 17 + 35 * charWidth, rowY1); } } // Show red breakpoint dot if (m_debugger->IsBreakpoint(address)) { ctx->SetBrush(bpBrush); ctx->DrawRectangle(2, rowY1 + 1, 11, 11); } } } // end of for // ------------ // ------------------------- // Colors and brushes // ------------------------- ctx->SetPen(currentPen); for (int i = 0; i < numBranches; i++) { int x = 17 + 49 * charWidth + (branches[i].srcAddr % 9) * 8; MoveTo(x - 2, branches[i].src); if (branches[i].dst < rc.height + 400 && branches[i].dst > -400) { LineTo(ctx, x + 2, branches[i].src); LineTo(ctx, x + 2, branches[i].dst); LineTo(ctx, x - 4, branches[i].dst); MoveTo(x, branches[i].dst - 4); LineTo(ctx, x - 4, branches[i].dst); LineTo(ctx, x + 1, branches[i].dst + 5); } // else //{ // This can be re-enabled when there is a scrollbar or // something on the codeview (the lines are too long) // LineTo(ctx, x+4, branches[i].src); // MoveTo(x+2, branches[i].dst-4); // LineTo(ctx, x+6, branches[i].dst); // LineTo(ctx, x+1, branches[i].dst+5); //} // LineTo(ctx, x, branches[i].dst+4); // LineTo(ctx, x-2, branches[i].dst); } // ------------ }
void CMemoryView::OnPaint(wxPaintEvent& event) { wxPaintDC dc(this); wxRect rc = GetClientRect(); wxFont hFont(_T("Courier")); hFont.SetFamily(wxFONTFAMILY_TELETYPE); wxCoord w,h; dc.GetTextExtent(_T("0WJyq"),&w,&h,nullptr,nullptr,&hFont); if (h > rowHeight) rowHeight = h; dc.GetTextExtent(_T("0WJyq"),&w,&h,nullptr,nullptr,&DebuggerFont); if (h > rowHeight) rowHeight = h; if (viewAsType==VIEWAS_HEX) dc.SetFont(hFont); else dc.SetFont(DebuggerFont); dc.GetTextExtent(_T("W"),&w,&h); int fontSize = w; int textPlacement = 17 + 9 * fontSize; // TODO: Add any drawing code here... int width = rc.width; int numRows = (rc.height / rowHeight) / 2 + 2; dc.SetBackgroundMode(wxTRANSPARENT); const wxChar* bgColor = _T("#ffffff"); wxPen nullPen(bgColor); wxPen currentPen(_T("#000000")); wxPen selPen(_T("#808080")); // gray nullPen.SetStyle(wxTRANSPARENT); wxBrush currentBrush(_T("#FFEfE8")); // light gray wxBrush pcBrush(_T("#70FF70")); // green wxBrush mcBrush(_T("#1133FF")); // blue wxBrush bgBrush(bgColor); wxBrush nullBrush(bgColor); nullBrush.SetStyle(wxTRANSPARENT); dc.SetPen(nullPen); dc.SetBrush(bgBrush); dc.DrawRectangle(0, 0, 16, rc.height); dc.DrawRectangle(0, 0, rc.width, 5+8); // TODO - clean up this freaking mess!!!!! for (int row = -numRows; row <= numRows; row++) { unsigned int address = curAddress + row * align; int rowY1 = rc.height / 2 + rowHeight * row - rowHeight / 2; int rowY2 = rc.height / 2 + rowHeight * row + rowHeight / 2; wxString temp = wxString::Format(_T("%08x"), address); u32 col = debugger->GetColor(address); wxBrush rowBrush(wxColor(col >> 16, col >> 8, col)); dc.SetBrush(nullBrush); dc.SetPen(nullPen); dc.DrawRectangle(0, rowY1, 16, rowY2); if (selecting && (address == selection)) dc.SetPen(selPen); else dc.SetPen(row == 0 ? currentPen : nullPen); if (address == debugger->GetPC()) dc.SetBrush(pcBrush); else dc.SetBrush(rowBrush); dc.DrawRectangle(16, rowY1, width, rowY2 - 1); dc.SetBrush(currentBrush); dc.SetTextForeground(_T("#600000")); dc.DrawText(temp, 17, rowY1); if (viewAsType != VIEWAS_HEX) { char mem[256]; debugger->GetRawMemoryString(memory, address, mem, 256); dc.SetTextForeground(_T("#000080")); dc.DrawText(StrToWxStr(mem), 17+fontSize*(8), rowY1); dc.SetTextForeground(_T("#000000")); } if (debugger->IsAlive()) { char dis[256] = {0}; u32 mem_data = debugger->ReadExtraMemory(memory, address); if (viewAsType == VIEWAS_FP) { float flt = *(float *)(&mem_data); sprintf(dis, "f: %f", flt); } else if (viewAsType == VIEWAS_ASCII) { u32 a[4] = {(mem_data&0xff000000)>>24, (mem_data&0xff0000)>>16, (mem_data&0xff00)>>8, mem_data&0xff}; for (auto& word : a) if (word == '\0') word = ' '; sprintf(dis, "%c%c%c%c", a[0], a[1], a[2], a[3]); } else if (viewAsType == VIEWAS_HEX)