// event handlers void LifeCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) { wxPaintDC dc(this); wxRect rect = GetUpdateRegion().GetBox(); wxCoord x, y, w, h; wxInt32 i0, j0, i1, j1; // find damaged area x = rect.GetX(); y = rect.GetY(); w = rect.GetWidth(); h = rect.GetHeight(); i0 = XToCell(x); j0 = YToCell(y); i1 = XToCell(x + w - 1); j1 = YToCell(y + h - 1); size_t ncells; LifeCell *cells; m_life->BeginFind(i0, j0, i1, j1, false); bool done = m_life->FindMore(&cells, &ncells); // erase all damaged cells and draw the grid dc.SetBrush(*wxWHITE_BRUSH); if (m_cellsize <= 2) { // no grid dc.SetPen(*wxWHITE_PEN); dc.DrawRectangle(x, y, w, h); } else { x = CellToX(i0); y = CellToY(j0); w = CellToX(i1 + 1) - x + 1; h = CellToY(j1 + 1) - y + 1; dc.SetPen(*wxLIGHT_GREY_PEN); for (wxInt32 yy = y; yy <= (y + h - m_cellsize); yy += m_cellsize) dc.DrawRectangle(x, yy, w, m_cellsize + 1); for (wxInt32 xx = x; xx <= (x + w - m_cellsize); xx += m_cellsize) dc.DrawLine(xx, y, xx, y + h); } // draw all alive cells dc.SetPen(*wxBLACK_PEN); dc.SetBrush(*wxBLACK_BRUSH); while (!done) { for (size_t m = 0; m < ncells; m++) DrawCell(cells[m].i, cells[m].j, dc); done = m_life->FindMore(&cells, &ncells); } // last set for (size_t m = 0; m < ncells; m++) DrawCell(cells[m].i, cells[m].j, dc); }
void wxRibbonBar::OnPaint(wxPaintEvent& WXUNUSED(evt)) { wxAutoBufferedPaintDC dc(this); if(GetUpdateRegion().Contains(0, 0, GetClientSize().GetWidth(), m_tab_height) == wxOutRegion) { // Nothing to do in the tab area, and the page area is handled by the active page return; } DoEraseBackground(dc); size_t numtabs = m_pages.GetCount(); double sep_visibility = 0.0; bool draw_sep = false; wxRect tabs_rect(m_tab_margin_left, 0, GetClientSize().GetWidth() - m_tab_margin_left - m_tab_margin_right, m_tab_height); if(m_tab_scroll_buttons_shown) { tabs_rect.x += m_tab_scroll_left_button_rect.GetWidth(); tabs_rect.width -= m_tab_scroll_left_button_rect.GetWidth() + m_tab_scroll_right_button_rect.GetWidth(); } size_t i; for(i = 0; i < numtabs; ++i) { wxRibbonPageTabInfo& info = m_pages.Item(i); dc.DestroyClippingRegion(); if(m_tab_scroll_buttons_shown) { if(!tabs_rect.Intersects(info.rect)) continue; dc.SetClippingRegion(tabs_rect); } dc.SetClippingRegion(info.rect); m_art->DrawTab(dc, this, info); if(info.rect.width < info.small_begin_need_separator_width) { draw_sep = true; if(info.rect.width < info.small_must_have_separator_width) { sep_visibility += 1.0; } else { sep_visibility += (double)(info.small_begin_need_separator_width - info.rect.width) / (double)(info.small_begin_need_separator_width - info.small_must_have_separator_width); } } } if(draw_sep) { wxRect rect = m_pages.Item(0).rect; rect.width = m_art->GetMetric(wxRIBBON_ART_TAB_SEPARATION_SIZE); sep_visibility /= (double)numtabs; for(i = 0; i < numtabs - 1; ++i) { wxRibbonPageTabInfo& info = m_pages.Item(i); rect.x = info.rect.x + info.rect.width; if(m_tab_scroll_buttons_shown && !tabs_rect.Intersects(rect)) { continue; } dc.DestroyClippingRegion(); dc.SetClippingRegion(rect); m_art->DrawTabSeparator(dc, this, rect, sep_visibility); } } if(m_tab_scroll_buttons_shown) { dc.DestroyClippingRegion(); if(m_tab_scroll_left_button_rect.GetWidth() != 0) { m_art->DrawScrollButton(dc, this, m_tab_scroll_left_button_rect, wxRIBBON_SCROLL_BTN_LEFT | m_tab_scroll_left_button_state | wxRIBBON_SCROLL_BTN_FOR_TABS); } if(m_tab_scroll_right_button_rect.GetWidth() != 0) { m_art->DrawScrollButton(dc, this, m_tab_scroll_right_button_rect, wxRIBBON_SCROLL_BTN_RIGHT | m_tab_scroll_right_button_state | wxRIBBON_SCROLL_BTN_FOR_TABS); } } }
void WxGraphs::OnPaint(wxPaintEvent & WXUNUSED(event)) { wxBufferedPaintDC dc(this); dc.SetMapMode(wxMM_TEXT); dc.SetBackground(*wxBLACK); dc.SetFont(GetFont()); int selected_draw = m_draws_wdg->GetSelectedDrawIndex(); if (selected_draw == -1) { dc.Clear(); return; } wxRegion region = GetUpdateRegion(); wxRegionIterator i(region); wxDC *pdc = m_bg_view->GetDC(); if (m_draws_wdg->GetNoData() == false) { #ifndef NO_GSTREAMER if (!m_dancing) #endif while (i) { int x = i.GetX(); int y = i.GetY(); int w = i.GetW(); int h = i.GetH(); wxLogInfo(_T("Repainting - x:%d y:%d, w:%d h:%d"), x, y, w, h); if (pdc->Ok()) dc.Blit(x, y, w, h, pdc, x, y, wxCOPY); for (size_t j = 0; j <= m_draws.size(); ++j) { size_t i; if ((int)j == selected_draw) continue; if (j == m_draws.size()) i = selected_draw; else i = j; Draw *d = m_draws[i]; if (d->GetEnable() == false) continue; wxDC *pdc = m_graphs.at(i)->GetDC(); if (pdc->Ok()) dc.Blit(x, y, w, h, pdc, x, y, wxCOPY, true); } ++i; } #ifndef NO_GSTREAMER else DrawDance(&dc); #endif } else { int w, h, tw, th; GetClientSize(&w, &h); if (pdc->Ok()) dc.Blit(0, 0, w, h, pdc, 0, 0, wxCOPY); wxString no_data = _("No data"); dc.SetFont(GetFont()); dc.SetTextForeground(*wxWHITE); dc.GetTextExtent(no_data, &tw, &th); dc.DrawText(no_data, (w - tw) / 2, (h - th) / 2); } DrawWindowInfo(&dc, region); if (m_draw_current_draw_name) DrawCurrentParamName(&dc); }
void wxLayoutWindow::OnPaint( wxPaintEvent &WXUNUSED(event)) { wxRect region = GetUpdateRegion().GetBox(); InternalPaint(®ion); }