void wxGISMapView::OnPaint(wxPaintEvent & event) { //event.Skip(); wxPaintDC paint_dc(this); wxRect rect = GetClientRect(); if(rect.width == 0 || rect.height == 0) { return; } if(m_nDrawingState == enumGISMapZooming || m_nDrawingState == enumGISMapPanning || m_nDrawingState == enumGISMapRotating || m_nDrawingState == enumGISMapWheeling) //if operation - exit immediatly { return; } if(m_pGISDisplay) { if(!GetThread() && m_pGISDisplay->IsDerty())//m_nDrawingState = enumGISMapDrawing { return; } else { //draw contents of m_pGISDisplay m_pGISDisplay->Output(&paint_dc, m_ClipGeometry); } } }
void DendrogramPanel::OnPaint( wxPaintEvent& event ) { wxSize sz = GetClientSize(); if (layer_bm && isLayerValid) { wxMemoryDC dc; dc.SelectObject(*layer_bm); wxPaintDC paint_dc(this); paint_dc.Blit(0, 0, sz.x, sz.y, &dc, 0, 0); if (split_line) { split_line->draw(paint_dc); } dc.SelectObject(wxNullBitmap); } else { wxAutoBufferedPaintDC dc(this); dc.Clear(); dc.SetPen(*wxTRANSPARENT_PEN); wxBrush Brush; Brush.SetColour(GdaConst::canvas_background_color); dc.SetBrush(Brush); dc.DrawRectangle(wxRect(0, 0, sz.x, sz.y)); } event.Skip(); }
void cbSplashScreen::OnPaint(wxPaintEvent &) { // an obscure statement in the wxWidgets book says to // allocate the DC even if you don't paint to avoid // a paint loop. //pecan 2006/04/3 wxPaintDC paint_dc(this); DoPaint(paint_dc); }
void CCodeView::OnPaint(wxPaintEvent& event) { // ------------------------- // General settings // ------------------------- wxPaintDC paint_dc(this); wxRect rc = GetClientRect(); int char_width; paint_dc.SetFont(DebuggerFont); { wxFontMetrics metrics = paint_dc.GetFontMetrics(); char_width = metrics.averageWidth; m_rowHeight = std::max(metrics.height, m_rowHeight); if (!DebuggerFont.IsFixedWidth()) char_width = paint_dc.GetTextExtent("mxx").GetWidth() / 3; // (1em + 2ex) / 3 } std::unique_ptr<wxGraphicsContext> ctx(wxGraphicsContext::Create(paint_dc)); ctx->DisableOffset(); // Incompatible with matrix transforms ctx->SetFont(DebuggerFont, *wxBLACK); struct Branch { int src, dst, srcAddr; }; Branch branches[256]; int num_branches = 0; const int num_rows = ((rc.height / m_rowHeight) / 2) + 2; const double scale = FromDIP(1024) / 1024.0; const int pen_width = static_cast<int>(std::ceil(scale)); const int col_width = rc.width - m_left_col_width; const int text_col = m_left_col_width + pen_width / 2 + 1; // 1 unscaled pixel const int bp_offset_x = FromDIP(LEFT_COL_WIDTH / 8); const wxSize bp_size = FromDIP(wxSize(LEFT_COL_WIDTH * 3 / 4, LEFT_COL_WIDTH * 3 / 4)); const int bp_offset_y = (m_rowHeight - bp_size.GetHeight()) / 2; // ------------ // ------------------------- // Colors and brushes // ------------------------- wxColour branch_color = wxTheColourDatabase->Find("PURPLE"); wxColour blr_color = wxTheColourDatabase->Find("DARK GREEN"); wxColour instr_color = wxTheColourDatabase->Find("VIOLET"); wxGraphicsPen null_pen = ctx->CreatePen(*wxTRANSPARENT_PEN); wxGraphicsPen focus_pen = ctx->CreatePen(wxPen(*wxBLACK, pen_width)); wxGraphicsPen selection_pen = ctx->CreatePen(wxPen("GREY", pen_width)); wxGraphicsBrush pc_brush = ctx->CreateBrush(*wxGREEN_BRUSH); wxGraphicsBrush bp_brush = ctx->CreateBrush(*wxRED_BRUSH); wxGraphicsBrush back_brush = ctx->CreateBrush(*wxWHITE_BRUSH); wxGraphicsBrush null_brush = ctx->CreateBrush(*wxTRANSPARENT_BRUSH); // ------------ // ----------------------------- // Walk through all visible rows // ----------------------------- for (int i = -num_rows; i <= num_rows; i++) { unsigned int address = m_curAddress + (i * m_align); int row_y = (rc.height / 2) + (m_rowHeight * i) - (m_rowHeight / 2); wxString temp = wxString::Format("%08x", address); u32 color = m_debugger->GetColor(address); wxBrush row_brush(wxColour(color >> 16, color >> 8, color)); ctx->SetBrush(back_brush); ctx->SetPen(null_pen); ctx->DrawRectangle(0, row_y, m_left_col_width, m_rowHeight); if (address == m_debugger->GetPC()) ctx->SetBrush(pc_brush); else ctx->SetBrush(row_brush); ctx->SetPen(null_pen); ctx->DrawRectangle(m_left_col_width, row_y, col_width, m_rowHeight); if (i == 0 || (m_selecting && address == m_selection)) { if (m_selecting && address == m_selection) ctx->SetPen(selection_pen); else ctx->SetPen(focus_pen); ctx->SetBrush(null_brush); // In a graphics context, the border of a rectangle is drawn along the edge, // it does not count towards the width of the rectangle (i.e. drawn right on // the pixel boundary of the fill area, half inside, half outside. For example // a rect with a 1px pen at (5,5)->(10,10) will have an actual screen size of // (4.5,4.5)->(10.5,10.5) with the line being aliased on the half-pixels) double offset = pen_width / 2.0; ctx->DrawRectangle(m_left_col_width + offset, row_y + offset, col_width - pen_width, m_rowHeight - pen_width); } if (!m_plain) { // the address text is dark red ctx->SetFont(DebuggerFont, wxColour(0x60, 0x00, 0x00)); ctx->DrawText(temp, text_col, row_y); ctx->SetFont(DebuggerFont, *wxBLACK); } // If running if (m_debugger->IsAlive()) { std::vector<std::string> dis = SplitString(m_debugger->Disassemble(address), '\t'); 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("0x"); 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[num_branches].src = row_y + (m_rowHeight / 2); branches[num_branches].srcAddr = (address / m_align); branches[num_branches++].dst = (int)(row_y + ((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, branch_color); } else { ctx->SetFont(DebuggerFont, *wxBLACK); } ctx->DrawText(StrToWxStr(operands), text_col + 17 * char_width, row_y); // ------------ // Show blr as its' own color if (opcode == "blr") ctx->SetFont(DebuggerFont, blr_color); else ctx->SetFont(DebuggerFont, instr_color); ctx->DrawText(StrToWxStr(opcode), text_col + (m_plain ? 1 * char_width : 9 * char_width), row_y); 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), text_col + 44 * char_width, row_y); } } // Show red breakpoint dot if (m_debugger->IsBreakpoint(address)) { ctx->SetPen(null_pen); ctx->SetBrush(bp_brush); ctx->DrawEllipse(bp_offset_x, row_y + bp_offset_y, bp_size.GetWidth(), bp_size.GetHeight()); } } } // end of for // ------------ // ------------------------- // Colors and brushes // ------------------------- ctx->SetPen(focus_pen); wxGraphicsPath branch_path = ctx->CreatePath(); for (int i = 0; i < num_branches; ++i) { int x = text_col + 60 * char_width + (branches[i].srcAddr % 9) * 8; branch_path.MoveToPoint(x - 2 * scale, branches[i].src); if (branches[i].dst < rc.height + 400 && branches[i].dst > -400) { branch_path.AddLineToPoint(x + 2 * scale, branches[i].src); branch_path.AddLineToPoint(x + 2 * scale, branches[i].dst); branch_path.AddLineToPoint(x - 4 * scale, branches[i].dst); branch_path.MoveToPoint(x, branches[i].dst - 4 * scale); branch_path.AddLineToPoint(x - 4 * scale, branches[i].dst); branch_path.AddLineToPoint(x + 1 * scale, branches[i].dst + 5 * scale); } // 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); } // If the pen width is odd then we need to offset the path so that lines are drawn in // the middle of pixels instead of the edge so we don't get aliasing. if (pen_width & 1) { wxGraphicsMatrix matrix = ctx->CreateMatrix(); matrix.Translate(0.5, 0.5); branch_path.Transform(matrix); } ctx->StrokePath(branch_path); // ------------ }