MCPcopy Create free account
hub / github.com/GeoDaCenter/geoda / OnDraw

Method OnDraw

TemplateLegend.cpp:453–532  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

451}
452
453void TemplateLegend::OnDraw(wxDC& dc)
454{
455 if (!template_canvas)
456 return;
457
458 dc.SetTextForeground(*wxBLACK);
459
460 wxPen bg_pen(legend_background_color);
461 dc.SetPen(bg_pen);
462 wxBrush bg_brush(legend_background_color);
463 dc.SetBrush(bg_brush);
464 wxSize sz = this->GetSize();
465 dc.DrawRectangle(0, 0, sz.GetWidth(), sz.GetHeight());
466
467 dc.SetFont(*GdaConst::small_font);
468 wxString title = template_canvas->GetCategoriesTitle();
469 dc.DrawText(title, px, 13);
470
471 wxString save_png_ttl = template_canvas->GetVariableNames();
472 wxSize title_sz = dc.GetTextExtent(save_png_ttl);
473
474 title_width = title_sz.GetWidth();
475 title_height = title_sz.GetHeight();
476
477 int time = template_canvas->cat_data.GetCurrentCanvasTmStep();
478 int cur_y = py;
479 int numRect = template_canvas->cat_data.GetNumCategories(time);
480
481 dc.SetPen(*wxBLACK_PEN);
482
483 // init labels
484 if (recreate_labels || labels.size() != numRect) {
485 for (int i=0; i<labels.size(); i++){
486 delete labels[i];
487 }
488 labels.clear();
489
490 new_order.clear();
491
492 int init_y = py;
493 for (int i=0; i<numRect; i++) {
494 wxString lbl = template_canvas->cat_data.GetCatLblWithCnt(time, i);
495 wxPoint pt( px + m_l + 10, init_y - (m_w / 2));
496 wxSize sz = dc.GetTextExtent(lbl);
497 labels.push_back(new GdaLegendLabel(i, lbl, pt, sz));
498 //init_y += d_rect;
499
500 new_order.push_back(i);
501 }
502
503 recreate_labels = false;
504 }
505
506 for (int i=0; i<numRect; i++) {
507 wxColour brush_clr = template_canvas->cat_data.GetCategoryBrushColor(time, i);
508 wxColour pen_clr = template_canvas->cat_data.GetCategoryPenColor(time, i);
509 if (brush_clr.IsOk())
510 dc.SetBrush(brush_clr);

Callers

nothing calls this directly

Calls 15

DrawTextMethod · 0.80
GetCatLblWithCntMethod · 0.80
GetCategoryBrushColorMethod · 0.80
GetCategoryPenColorMethod · 0.80
drawMoveMethod · 0.80
SetPenMethod · 0.45
SetBrushMethod · 0.45
GetSizeMethod · 0.45
DrawRectangleMethod · 0.45
GetWidthMethod · 0.45
GetHeightMethod · 0.45

Tested by

no test coverage detected