//----------------------------------------------------------------------- // r e n d e r //----------------------------------------------------------------------- void TGListBoxItem::render() { if(isRenderCached()) return; int x1, y1, x2, y2; getBounds(x1, y1, x2, y2); TGSBrush brush; if (box->m_selectedItem == this) { brush = m_theme.getCaptionBrush(); fillRect(x1, y1, x2, y2, brush); brush = m_theme.getTextFocusedBrush(); } else { if (m_mouseOverControl) brush = m_theme.getTextFocusedBrush(); else brush = m_theme.getTextBrush(); } drawString(x1 + 8, (y2-y1 + 1)/2 + y1 - stringHeight()/2, text, brush); m_redraw = false; }
//----------------------------------------------------------------------- // T G L i s t B o x I t e m //----------------------------------------------------------------------- TGListBoxItem::TGListBoxItem(TGControl *parent) : TGControl(parent) { box = (TGListBox*)parent; text = ""; minimumWidth = 16; itemHeight = stringHeight() + 5; data = NULL; }
void QPaintContext::drawString(int x, int y, const char *str, int len) { QString qStr = QString::fromUtf8(str, len); for (unsigned int i=0; i<qStr.length(); i++) { if (qStr[i] == QChar(0x14,0x20) || qStr[i] == QChar(0x13,0x20)) qStr[i] = QChar('-', 0); } // myPainter->drawText(x + leftMargin(), y + topMargin(),0,-1,-1, qStr); myPainter->drawText(x + leftMargin(), y + topMargin(),stringWidth(str,len),stringHeight()+3,0, qStr); // myPainter->drawText(x + leftMargin(), y + topMargin(), qStr); }
void ZLWin32PaintContext::drawString(int x, int y, const char *str, int len) { if (myDisplayContext == 0) { return; } y -= stringHeight(); y += myTextMetric.tmDescent; int utf8len = ZLUnicodeUtil::utf8Length(str, len); if (utf8len == len) { TextOutA(myDisplayContext, x, y, str, len); } else { static ZLUnicodeUtil::Ucs2String ucs2Str; ucs2Str.clear(); ZLUnicodeUtil::utf8ToUcs2(ucs2Str, str, len, utf8len); TextOutW(myDisplayContext, x, y, ::wchar(ucs2Str), utf8len); } }
//----------------------------------------------------------------------- // r e n d e r //----------------------------------------------------------------------- void TGButton::render() { if(isRenderCached()) return; int x1, y1, x2, y2; TGFrameStyle fs = FS_FLAT; getBounds(x1, y1, x2, y2); if (getMouseOverControl()) fs = m_pushed?FS_LOWERED:FS_RAISED; else fs = FS_FLAT; drawFrame(x1, y1, x2, y2, fs); if (focused()) { drawOwnFocus(); } TGSBrush brush; if (m_pushed) brush = m_theme.getTextInvertedBrush(); else { if(getMouseOverControl()) brush = m_theme.getTextFocusedBrush(); else brush = m_theme.getTextBrush(); } x1 = (x2 - x1 + 1)/2 + x1; x1 -= stringWidth(m_caption)/2; x2 = 0; openClip(); drawString(x1 + x2, (y2-y1 + 1)/2 + y1 - stringHeight()/2, m_caption, brush); closeClip(); }
//----------------------------------------------------------------------- // r e n d e r //----------------------------------------------------------------------- void TGCheckBox::render() { if(isRenderCached()) return; int x1, y1, x2, y2, bsize; TGFrameStyle fs = FS_FLAT; getBounds(x1, y1, x2, y2); bsize = y2 - y1; if (m_hover) fs = m_pushed?FS_LOWERED:FS_RAISED; else fs = FS_FLAT; drawFrame(x1, y1, x1 + bsize, y2, fs); TGSBrush brush; if (m_checked.get()) { if (m_hover) brush = m_theme.getFrameFocusedBrush(); else brush = m_theme.getBaseBright(); drawLine(x1, y1, x1 + bsize, y2, brush); drawLine(x1 + bsize, y1, x1, y2, brush); } if (m_hover) brush = m_theme.getTextFocusedBrush(); else brush = m_theme.getTextBrush(); drawString(x1 + bsize + 4, (y2-y1 + 1)/2 + y1 - (int)stringHeight()/2, m_caption,brush); }