void PackageList::drawItem(DC& dc, int x, int y, size_t item) { dc.SetClippingRegion(x+1, y+2, item_size.x-2, item_size.y-2); PackageData& d = packages.at(item); RealRect rect(RealPoint(x,y),item_size); RealPoint pos; int w, h; // draw image if (d.image.Ok()) { dc.DrawBitmap(d.image, x + int(align_delta_x(ALIGN_CENTER, item_size.x, d.image.GetWidth())), y + 3, true); } // draw short name dc.SetFont(wxFont(12,wxSWISS,wxNORMAL,wxBOLD,false,_("Arial"))); dc.GetTextExtent(capitalize(d.package->short_name), &w, &h); pos = align_in_rect(ALIGN_CENTER, RealSize(w,h), rect); dc.DrawText(capitalize(d.package->short_name), max(x+1,(int)pos.x), (int)pos.y + 110); // draw name dc.SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)); dc.GetTextExtent(d.package->full_name, &w, &h); RealPoint text_pos = align_in_rect(ALIGN_CENTER, RealSize(w,h), rect); dc.DrawText(d.package->full_name, max(x+1,(int)text_pos.x), (int)text_pos.y + 130); dc.DestroyClippingRegion(); }
void DropDownList::draw(DC& dc) { // Size wxSize cs = dc.GetSize(); // Draw background & frame dc.SetPen (*wxTRANSPARENT_PEN); dc.SetBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); dc.DrawRectangle(0, 0, cs.x, cs.y); dc.SetFont(*wxNORMAL_FONT); // Draw items int y = marginH - visible_start; size_t count = itemCount(); for (size_t i = 0 ; i < count ; ++i) { drawItem(dc, y, i); y += (int)item_size.height + lineBelow(i); } }