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

Method DrawLegend

Explore/MapLayerTree.cpp:910–967  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

908}
909
910void MapTree::DrawLegend(wxDC& dc, int x, int y, wxString text)
911{
912 int x_org = x;
913
914 wxPen pen(*wxBLACK, 1, wxPENSTYLE_DOT);
915 dc.SetPen(pen);
916 dc.DrawLine(10, y+2, x, y+2);
917
918 BackgroundMapLayer* ml = GetMapLayer(text);
919
920 x = x + 45; // switch width
921 dc.SetPen(*wxBLACK_PEN);
922 if (text == current_map_title) {
923 dc.SetPen(*wxLIGHT_GREY);
924 dc.SetBrush(*wxTRANSPARENT_BRUSH);
925 } else {
926 if (ml == NULL)
927 return; // in case of removed layer
928 wxPen pen(ml->GetPenColour(), ml->GetPenSize());
929 wxBrush brush(ml->GetBrushColour());
930 dc.SetPen(pen);
931 dc.SetBrush(brush);
932 dc.DrawRectangle(x, y, leg_w, leg_h);
933 }
934
935 x = x + leg_w + leg_pad_x;
936
937 // add highlight/all
938 AssociateLayerInt* ml_int;
939 if (ml) {
940 ml_int = ml;
941 } else {
942 ml_int = canvas;
943 }
944 int hl_cnt = ml_int->GetHighlightRecords();
945 int all_cnt = ml_int->GetNumRecords();
946 wxString hl_str = wxString::Format(" (%d/%d selected)", hl_cnt, all_cnt);
947 text = text + hl_str;
948 dc.DrawText(text, x, y);
949
950 // draw switch button
951 wxString ds_thumb = "switch-on.png";
952 if (ml_int->IsHide()) ds_thumb = "switch-off.png";
953 wxString file_path_str = GenUtils::GetSamplesDir() + ds_thumb;
954
955 wxImage img;
956 if (!wxFileExists(file_path_str)) {
957 return;
958 }
959
960 img.LoadFile(file_path_str);
961 if (!img.IsOk()) {
962 return;
963 }
964
965 wxBitmap bmp(img);
966 dc.DrawBitmap(bmp, x_org, y);
967}

Callers

nothing calls this directly

Calls 13

GetPenColourMethod · 0.80
GetPenSizeMethod · 0.80
GetBrushColourMethod · 0.80
DrawTextMethod · 0.80
IsHideMethod · 0.80
SetPenMethod · 0.45
DrawLineMethod · 0.45
SetBrushMethod · 0.45
DrawRectangleMethod · 0.45
GetHighlightRecordsMethod · 0.45
GetNumRecordsMethod · 0.45
LoadFileMethod · 0.45

Tested by

no test coverage detected