コード例 #1
2
ファイル: qztools.cpp プロジェクト: Shinobi-San/qupzilla
QPixmap QzTools::createPixmapForSite(const QIcon &icon, const QString &title, const QString &url)
{
    const QFontMetrics fontMetrics = QApplication::fontMetrics();
    const int padding = 4;
    const int maxWidth = fontMetrics.width(title.length() > url.length() ? title : url) + 3 * padding + 16;

    const int width = qMin(maxWidth, 150);
    const int height = fontMetrics.height() * 2 + fontMetrics.leading() + 2 * padding;

    QPixmap pixmap(width, height);
    QPainter painter(&pixmap);

    // Draw background
    QPen pen(Qt::black);
    pen.setWidth(1);
    painter.setPen(pen);

    painter.fillRect(QRect(0, 0, width, height), Qt::white);
    painter.drawRect(0, 0, width - 1, height - 1);

    // Draw icon
    QRect iconRect(0, 0, 16 + 2 * padding, height);
    icon.paint(&painter, iconRect);

    // Draw title
    QRect titleRect(iconRect.width(), padding, width - padding - iconRect.width(), fontMetrics.height());
    painter.drawText(titleRect, fontMetrics.elidedText(title, Qt::ElideRight, titleRect.width()));

    // Draw url
    QRect urlRect(titleRect.x(), titleRect.bottom() + fontMetrics.leading(), titleRect.width(), titleRect.height());
    painter.setPen(QApplication::palette().color(QPalette::Link));
    painter.drawText(urlRect, fontMetrics.elidedText(url, Qt::ElideRight, urlRect.width()));

    return pixmap;
}
コード例 #2
0
ファイル: HeaderDock.cpp プロジェクト: Omgan/RealFTP.net
void CHeaderDockPane::OnInitialUpdate() 
{
	CFont * fntTitle1 = new CFont;
	fntTitle1->CreateFont(15 /*height*/, 8 /*width*/, 0, 0,
			      FW_BOLD, FALSE, FALSE, FALSE, ANSI_CHARSET,
				OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
				ANTIALIASED_QUALITY, DEFAULT_PITCH, // | FF_ROMAN,
				_T("Arial"));    // Arial

	// dynamically create an edit control on the view
	CRect urlRect(145, 12, 500 /*end x*/, 33);
	//url.Create( WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER, urlRect, this, 1234); // CEdit
	url.Create( CBS_DROPDOWN  | WS_VSCROLL | WS_CHILD | WS_VISIBLE  , urlRect, this, 1234);
	url.SetFont(fntTitle1);
	url.ModifyStyle( 0, CBS_SORT );
	//RecreateComboBox(&url, 0);
	url.SetWindowText(CString(_T("ftp://")));
	// doesnt respond to WM_CUT, WM_COPY

	CRect searchRect(520, 12, 700 /*end x*/, 33);
	//search.Create( WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER, searchRect, this, IDC_SEARCH); // CEdit
	search.Create( CBS_DROPDOWN  | WS_VSCROLL | WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER , searchRect, this, IDC_SEARCH);
	// CBS_DROPDOWNLIST CBS_SIMPLE
	//search.SetCurSel(0);
	search.SetDroppedWidth(300);
	search.SetFont(fntTitle1);
	
	m_backBButton.Create(NULL, WS_CHILD | WS_VISIBLE | BS_OWNERDRAW, CRect(14,5,32 + 14,32 + 5), this, IDC_BACK_BUTTON_ID);
	m_backBButton.EnableWindow(TRUE);
	m_backBButton.LoadBitmaps(IDB_BACK, IDB_BACK /*sel*/, IDB_BACK /*foc*/, IDB_BACK /*dis*/);
	//m_backBButton.SizeToContent();

	m_nextBButton.Create(NULL, WS_CHILD | WS_VISIBLE | BS_OWNERDRAW, CRect(14 + 41,5,32 + 14 + 41,32 + 5), this, IDC_NEXT_BUTTON_ID);
	m_nextBButton.EnableWindow(TRUE);
	m_nextBButton.LoadBitmaps(IDB_NEXT, IDB_NEXT /*sel*/, IDB_NEXT /*foc*/, IDB_NEXT /*dis*/);
	//m_backBButton.SizeToContent();

	m_queueBButton.Create(NULL, WS_CHILD | WS_VISIBLE | BS_OWNERDRAW, CRect(14 + (41*2),5,32 + 14 + (41*2),32 + 5), this, IDC_QUEUE_BUTTON_ID);
	m_queueBButton.EnableWindow(TRUE);
	m_queueBButton.LoadBitmaps(IDB_QUEUE, IDB_QUEUE /*sel*/, IDB_QUEUE /*foc*/, IDB_QUEUE /*dis*/);
	//m_queueBButton.SizeToContent();

	//TRACE1("", m_backBButton.En);
}