Exemplo n.º 1
0
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();
}
Exemplo n.º 2
0
SIZE mew::theme::MenuMeasureItem(PCWSTR wcsText, IImageList* pImageList, int nImage)
{
	if(!theMenuFont)
	{
		HandleSystemSettingChange();
	}

	if(str::empty(wcsText))
	{
		SIZE sz = { 0, ::GetSystemMetrics(SM_CYMENU) / 2 };
		return sz;
	}
	else
	{
		DC dc;
		dc.CreateCompatibleDC();
		SIZE sz = dc.GetTextExtent(theMenuFont, wcsText);
		SIZE ret;
		SIZE iconSize = ImageList_GetIconSize(pImageList);
		ret.cx = sz.cx + iconSize.cx + MENU_ICON_SPACE_W * 2 + MENU_TEXT_INDENT + MENU_TEXT_SPACE;
		ret.cy = math::max<int>(sz.cy + MENU_ITEM_PADDING, iconSize.cy + MENU_ICON_SPACE_H * 2);
		return ret;
	}
}