void CRectangle::DrawTag(CClientDC* pDC) { CPoint t_point1; CPoint t_point2; // create and select a solid blue brush CBrush brushBlue(RGB(0, 255, 0)); CBrush* pOldBrush = pDC->SelectObject(&brushBlue); t_point1.x=(point1.x+point2.x)/2-5; t_point1.y=point1.y; t_point2.x=t_point1.x+10; t_point2.y=t_point1.y-10; pDC->Rectangle(CRect(t_point1,t_point2)); t_point1.y=(point1.y+point2.y)/2-5; t_point1.x=point1.x; t_point2.x=t_point1.x-10; t_point2.y=t_point1.y+10; pDC->Rectangle(CRect(t_point1,t_point2)); t_point1.y=(point1.y+point2.y)/2-5; t_point1.x=point2.x; t_point2.x=t_point1.x+10; t_point2.y=t_point1.y+10; pDC->Rectangle(CRect(t_point1,t_point2)); t_point1.x=(point1.x+point2.x)/2-5; t_point1.y=point2.y; t_point2.x=t_point1.x+10; t_point2.y=t_point1.y+10; pDC->Rectangle(CRect(t_point1,t_point2)); pDC->SelectObject(pOldBrush); }
void CDCView::DrawRoundRect(CDC* pDC) { // create and select a solid blue brush CBrush brushBlue(RGB(0, 0, 255)); CBrush* pOldBrush = pDC->SelectObject(&brushBlue); // create and select a thick, black pen CPen penBlack; penBlack.CreatePen(PS_SOLID, 3, RGB(0, 0, 0)); CPen* pOldPen = pDC->SelectObject(&penBlack); // get our client rectangle CRect rect; GetClientRect(rect); // shrink our rect 20 pixels in each direction rect.DeflateRect(20, 20); // Draw a thick black rectangle filled with blue // corners rounded at a 17-unit radius. Note that // a radius of three or less is not noticable because // the pen is three units wide. pDC->RoundRect(rect, CPoint(17, 17)); // put back the old objects pDC->SelectObject(pOldBrush); pDC->SelectObject(pOldPen); }
Win_Start::Win_Start(QWidget *parent,Qt::WindowFlags flags) :QWidget(parent,flags|Qt::FramelessWindowHint) { QPalette palette; QBrush brushBlue(QColor(0,0,255,255)); palette.setBrush(QPalette::Active,QPalette::Window,brushBlue); palette.setBrush(QPalette::Inactive,QPalette::Window,brushBlue); palette.setBrush(QPalette::Disabled,QPalette::Window,brushBlue); setPalette(palette); setFixedSize(800,480); QFont font; font.setFamily("simsun"); QTextCodec::setCodecForTr(QTextCodec::codecForName("utf-8")); pb = new QProgressBar(this); font.setPointSize(45); pb->setFont(font); pb->setStyleSheet("QProgressBar::chunk:horizontal{background:qlineargradient(x1:0,y1:0.5,x2:1,y2:0.5,stop: 0 green,stop: 1 white);}"); pb->setGeometry(200,300,400,16); pb->setRange(0,100); label1 = new QLabel(this); label1->setGeometry(200,340,400,50); label1->setText(QObject::tr("正在启动...")); label1->setAlignment(Qt::AlignHCenter); label2 = new QLabel(this); label2->setMovie(new QMovie("a.gif")); label2->show(); label2->movie()->start(); this->show(); }
void CLine::DrawTag(CClientDC* pDC) { CPoint t_point1; CPoint t_point2; CBrush brushBlue(RGB(0, 255, 0)); CBrush* pOldBrush = pDC->SelectObject(&brushBlue); t_point1.x=point1.x-5; t_point1.y=point1.y-5; t_point2.x=t_point1.x+10; t_point2.y=t_point1.y+10; pDC->Rectangle(CRect(t_point1,t_point2)); t_point1.x=+point2.x-5; t_point1.y=point2.y-5; t_point2.x=t_point1.x+10; t_point2.y=t_point1.y+10; pDC->Rectangle(CRect(t_point1,t_point2)); pDC->SelectObject(pOldBrush); }
void CLine::In_Draw_Point(CClientDC* pDC) { CPoint t_point1; CPoint t_point2; CPen pen(PS_SOLID,1,pDC->GetBkColor()); CPen *pOldPen=pDC->SelectObject(&pen);// CBrush brushBlue(pDC->GetBkColor()); CBrush* pOldBrush = pDC->SelectObject(&brushBlue); t_point1.x=point1.x-5; t_point1.y=point1.y-5; t_point2.x=t_point1.x+10; t_point2.y=t_point1.y+10; pDC->Rectangle(CRect(t_point1,t_point2)); t_point1.x=point2.x-5; t_point1.y=point2.y-5; t_point2.x=t_point1.x+10; t_point2.y=t_point1.y+10; pDC->Rectangle(CRect(t_point1,t_point2)); pDC->SelectObject(pOldPen); pDC->SelectObject(pOldBrush); }
void KDateTable::paintCell(QPainter *painter, int row, int col) { QRect rect; QString text; QPen pen; int w=cellWidth(); int h=cellHeight(); int pos; QBrush brushBlue(blue); QBrush brushLightblue(lightGray); QFont font=KGlobalSettings::generalFont(); // ----- font.setPointSize(fontsize); if(row==0) { // we are drawing the headline font.setBold(true); painter->setFont(font); bool normalday = true; QString daystr; if (KGlobal::locale()->weekStartsMonday()) { daystr = KGlobal::locale()->weekDayName(col+1, true); if (col == 5 || col == 6) normalday = false; } else { daystr = KGlobal::locale()->weekDayName(col==0? 7 : col, true); if (col == 0 || col == 6) normalday = false; } if (!normalday) { painter->setPen(lightGray); painter->setBrush(brushLightblue); painter->drawRect(0, 0, w, h); painter->setPen(blue); } else { painter->setPen(blue); painter->setBrush(brushBlue); painter->drawRect(0, 0, w, h); painter->setPen(white); } painter->drawText(0, 0, w, h-1, AlignCenter, daystr, -1, &rect); painter->setPen(black); painter->moveTo(0, h-1); painter->lineTo(w-1, h-1); // ----- draw the weekday: } else { painter->setFont(font); pos=7*(row-1)+col; if (KGlobal::locale()->weekStartsMonday()) pos++; if(pos<firstday || (firstday+numdays<=pos)) { // we are either // ° painting a day of the previous month or // ° painting a day of the following month if(pos<firstday) { // previous month text.setNum(numDaysPrevMonth+pos-firstday+1); } else { // following month text.setNum(pos-firstday-numdays+1); } painter->setPen(gray); } else { // paint a day of the current month text.setNum(pos-firstday+1); painter->setPen(black); } pen=painter->pen(); if(firstday+date.day()-1==pos) { if(hasFocus()) { // draw the currently selected date painter->setPen(red); painter->setBrush(darkRed); pen=white; } else { painter->setPen(darkGray); painter->setBrush(darkGray); pen=white; } } else { painter->setBrush(lightGray); painter->setPen(lightGray); } painter->drawRect(0, 0, w, h); painter->setPen(pen); painter->drawText(0, 0, w, h, AlignCenter, text, -1, &rect); } if(rect.width()>maxCell.width()) maxCell.setWidth(rect.width()); if(rect.height()>maxCell.height()) maxCell.setHeight(rect.height()); }
void kMyMoneyDateTbl::paintCell(QPainter *painter, int row, int col) { QRect rect; QString text; QPen pen; int w=cellWidth(); int h=cellHeight(); QBrush brushBlue(KGlobalSettings::activeTitleColor()); QBrush brushLightblue(KGlobalSettings::baseColor()); QFont font=KGlobalSettings::generalFont(); // ----- font.setPointSize(fontsize); #if KDE_VERSION < 310 int firstWeekDay = KGlobal::locale()->weekStartsMonday() ? 1 : 0; #else int firstWeekDay = KGlobal::locale()->weekStartDay(); #endif if (row==0) { // we are drawing the headline if (m_type == MONTHLY) { font.setBold(true); painter->setFont(font); bool normalday = true; QString daystr; if ( col+firstWeekDay < 8 ) daystr = WEEK_DAY_NAME(col+firstWeekDay, true); else daystr = WEEK_DAY_NAME(col+firstWeekDay-7, true); if ( daystr==i18n("Sunday", "Sun") || daystr==i18n("Saturday", "Sat") ) normalday=false; if (!normalday) { painter->setPen(KGlobalSettings::baseColor()); painter->setBrush(brushLightblue); painter->drawRect(0, 0, w, h); painter->setPen(KGlobalSettings::activeTitleColor()); } else { painter->setPen(KGlobalSettings::activeTitleColor()); painter->setBrush(brushBlue); painter->drawRect(0, 0, w, h); painter->setPen(KGlobalSettings::activeTextColor()); } painter->drawText(0, 0, w, h-1, AlignCenter, daystr, -1, &rect); painter->setPen(KGlobalSettings::textColor()); painter->moveTo(0, h-1); painter->lineTo(w-1, h-1); if(rect.width()>maxCell.width()) maxCell.setWidth(rect.width()); if(rect.height()>maxCell.height()) maxCell.setHeight(rect.height()); } else if (m_type == WEEKLY) { painter->setPen(KGlobalSettings::activeTitleColor()); painter->setBrush(brushBlue); painter->drawRect(0, 0, w, h); painter->setPen(KGlobalSettings::activeTextColor()); int year=date.year(); QString headerText; #if QT_VERSION > 0x030005 // FIXME: Shouldn't that be i18n()'ed as well QString weekStr = QString::number(date.weekNumber(&year)); QString yearStr = QString::number(year); headerText = i18n("Week %1 for year %2.") .arg(weekStr) .arg(yearStr); #else // FIXME: include code to display the same as for KDE >= 3.0.5 QString weekStr = QString::number(weekNumber(date, &year)); QString yearStr = QString::number(year); headerText = i18n("Week %1 for year %2.") .arg(weekStr) .arg(yearStr); #endif painter->drawText(0, 0, w, h-1, AlignCenter, headerText, -1, &rect); maxCell.setWidth(width()); if(rect.height()>maxCell.height()) maxCell.setHeight(rect.height()); } else if (m_type == QUARTERLY) { int athird = width()/3; painter->setPen(KGlobalSettings::activeTitleColor()); painter->setBrush(brushBlue); painter->setPen(/*KGlobalSettings::activeTextColor()*/black); if (col == 0) { painter->drawRect(0, 0, athird, h); painter->drawText(0, 0, athird, h-1, AlignCenter, "Month 1", -1, &rect); painter->drawRect(athird, 0, athird, h); painter->drawText(athird, 0, athird, h-1, AlignCenter, "Month 2", -1, &rect); painter->drawRect(athird*2, 0, athird, h); painter->drawText(athird*2, 0, athird, h-1, AlignCenter, "Month 3", -1, &rect); } } } else { int pos; QDate drawDate(date); if (m_type == MONTHLY) { pos=7*(row-1)+col; if ( firstWeekDay < 4 ) pos += firstWeekDay; else pos += firstWeekDay - 7; if (pos<firstday || (firstday+numdays<=pos)) { // we are either // painting a day of the previous month or // painting a day of the following month if (pos<firstday) { // previous month drawDate = drawDate.addMonths(-1); text.setNum(numDaysPrevMonth+pos-firstday+1); drawDate.setYMD(drawDate.year(), drawDate.month(), text.toInt()); } else { // following month drawDate = drawDate.addMonths(1); text.setNum(pos-firstday-numdays+1); drawDate.setYMD(drawDate.year(), drawDate.month(), text.toInt()); } } else { // paint a day of the current month text.setNum(pos-firstday+1); drawDate.setYMD(drawDate.year(), drawDate.month(), text.toInt()); } } else if (m_type == WEEKLY) { // TODO: Handle other start weekdays than Monday text = QDate::shortDayName(row); text += " "; int dayOfWeek = date.dayOfWeek(); int diff; if (row < dayOfWeek) { diff = -(dayOfWeek - row); } else { diff = row - dayOfWeek; } drawDate = date.addDays(diff); } else if (m_type == QUARTERLY) { } drawCellContents(painter, row, col, drawDate); } }