void UserViewItemBase::drawSeparator(QPainter *p, int x, int width, const QColorGroup &cg) { if (x < width - 6){ #if QT_VERSION > 300 QRect rcSep(x, height()/2, width - 6 - x, 1); listView()->style().drawPrimitive(QStyle::PE_Separator, p, rcSep, cg); #else listView()->style().drawSeparator(p, x, height() / 2, width - 6, height() / 2, cg); #endif } }
CSeparator::CSeparator(HWND hParent, CPoint pt, int cx, const TCHAR *p) { static int height; if (height == 0) { CDCHandle dc = ::GetDC(NULL); HFONT hOldFont = dc.SelectFont(Globals::Instance().sep.font); CSize textSize; dc.GetTextExtent(L"ABC", 3, &textSize); dc.SelectFont(hOldFont); height = textSize.cy; ::ReleaseDC(NULL, dc); } CRect rcSep(pt.x, pt.y, pt.x+cx, pt.y + (p && *p ? height : 5)); Create(hParent, rcSep, nullptr, SS_GRAYFRAME | WS_CHILD | WS_VISIBLE); SetWindowText(p); ShowWindow(SW_SHOW); }