コード例 #1
0
ファイル: qed_led.cpp プロジェクト: Aconex/pcp
void QedRoundLED::paintEvent(QPaintEvent *event)
{
    qreal lowerInset, upperInset;
    (void)event;

    QPainterPath baseCirclePath;
    QRectF baseBox(0.0, 0.0, my.bound, my.bound);
    baseCirclePath.arcTo(baseBox, 0.0, 360.0);
    baseCirclePath.closeSubpath();
    QLinearGradient baseGradient(0, 0, 0, 1.33846 * my.bound);
    baseGradient.setColorAt(0.0, Qt::lightGray);
    baseGradient.setColorAt(1.0, Qt::white);

    QPainterPath seatCirclePath;
    lowerInset = 0.06666 * my.bound;
    upperInset = my.bound - (lowerInset * 2.0);
    QRectF seatBox(lowerInset, lowerInset, upperInset, upperInset);
    seatCirclePath.arcTo(seatBox, 0.0, 360.0);
    seatCirclePath.closeSubpath();
    QLinearGradient seatGradient(0, 0, 0, 0.7692 * my.bound);
    seatGradient.setColorAt(0.0, Qt::lightGray);
    seatGradient.setColorAt(1.0, Qt::darkGray);

    QPainterPath mainCirclePath;
    lowerInset = 0.1 * my.bound;
    upperInset = my.bound - (lowerInset * 2.0);
    QRectF mainBox(lowerInset, lowerInset, upperInset, upperInset);
    mainCirclePath.arcTo(mainBox, 0.0, 360.0);
    mainCirclePath.closeSubpath();
    QLinearGradient mainGradient(0, 0, 0, 1.23076 * my.bound);
    mainGradient.setColorAt(0.0, my.color);
    mainGradient.setColorAt(1.0, Qt::white);

    QPainterPath reflectCirclePath;
    QRectF reflectBox(0.18538 * my.bound, 0.12969 * my.bound,
		      0.61384 * my.bound, 0.48615 * my.bound);
    reflectCirclePath.arcTo(reflectBox, 0.0, 360.0);
    reflectCirclePath.closeSubpath();
    QLinearGradient reflectGradient(0, 0, 0, 1.22953 * my.bound);
    reflectGradient.setColorAt(0.0, Qt::white);
    reflectGradient.setColorAt(1.0, my.color);

    QPainter painter(this);
    painter.setRenderHint(QPainter::Antialiasing);
    painter.setPen(Qt::NoPen);

    painter.setBrush(baseGradient);
    painter.drawPath(baseCirclePath);
    painter.setBrush(seatGradient);
    painter.drawPath(seatCirclePath);
    painter.setBrush(mainGradient);
    painter.drawPath(mainCirclePath);
    painter.setBrush(reflectGradient);
    painter.drawPath(reflectCirclePath);
}
コード例 #2
0
NetPrefsServerView::NetPrefsServerView(BRect bounds, const char* name, BMessenger target)
	: BView(bounds, name, B_FOLLOW_ALL_SIDES, B_WILL_DRAW), fEntryWin(NULL), fNetWin(target)
{
	SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	BRect boundsRect(Bounds());
	BBox* mainBox(new BBox(bounds.InsetByCopy(-1, -1), NULL, B_FOLLOW_ALL_SIDES));
	AddChild(mainBox);
	fSelectTitleString = new BStringView(BRect(0, 0, 0, 0), NULL, "Select servers for");
	fSelectTitleString->ResizeToPreferred();
	mainBox->AddChild(fSelectTitleString);
	fSelectTitleString->MoveTo(11, 11);
	fServerList = new BColumnListView(BRect(0, 0, boundsRect.Width() - 10, boundsRect.Height() / 2),
									  "fServerList", B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW,
									  B_PLAIN_BORDER);
	fServerList->SetSelectionMessage(new BMessage(M_SERVER_ITEM_SELECTED));
	mainBox->AddChild(fServerList);
	fServerList->MoveTo(5, fSelectTitleString->Frame().bottom + 3);
	BStringColumn* status(new BStringColumn(S_PREFSERVER_STATUS_COLUMN,
											be_plain_font->StringWidth("Status") * 2, 0,
											bounds.Width(), 0, B_ALIGN_CENTER));
	fServerList->AddColumn(status, 0);
	BStringColumn* data(new BStringColumn(S_PREFSERVER_SERVER_COLUMN,
										  be_plain_font->StringWidth("Server") * 2, 0,
										  bounds.Width(), 0));
	fServerList->AddColumn(data, 1);
	BStringColumn* port(new BStringColumn(
		S_PREFSERVER_PORT_COLUMN, be_plain_font->StringWidth("Port") * 2, 0, bounds.Width(), 0));
	fServerList->AddColumn(port, 2);
	fAddButton = new BButton(BRect(0, 0, 0, 0), NULL, S_PREFSERVER_ADD_BUTTON B_UTF8_ELLIPSIS,
							 new BMessage(M_SERVER_ADD_ITEM));
	fRemoveButton = new BButton(BRect(0, 0, 0, 0), NULL, S_PREFSERVER_REMOVE_BUTTON,
								new BMessage(M_SERVER_REMOVE_ITEM));
	fEditButton = new BButton(BRect(0, 0, 0, 0), NULL, S_PREFSERVER_EDIT_BUTTON B_UTF8_ELLIPSIS,
							  new BMessage(M_SERVER_EDIT_ITEM));
	fAddButton->ResizeToPreferred();
	fRemoveButton->ResizeToPreferred();
	fEditButton->ResizeToPreferred();
	fRemoveButton->MoveTo(fServerList->Frame().right - fRemoveButton->Frame().Width(),
						  fServerList->Frame().bottom + 5);
	mainBox->AddChild(fRemoveButton);
	fAddButton->MoveTo(fRemoveButton->Frame().left - (fAddButton->Frame().Width() + 5),
					   fRemoveButton->Frame().top);
	mainBox->AddChild(fAddButton);
	fEditButton->MoveTo(fAddButton->Frame().left - (fEditButton->Frame().Width() + 15),
						fAddButton->Frame().top);
	mainBox->AddChild(fEditButton);
	BStringView* legend1 = new BStringView(BRect(0, 0, 0, 0), "str1", S_PREFSERVER_DESC1);
	legend1->ResizeToPreferred();
	mainBox->AddChild(legend1);
	legend1->MoveTo(fServerList->Frame().left + 5, fAddButton->Frame().bottom + 5);
	BStringView* legend2 = new BStringView(BRect(0, 0, 0, 0), "str1", S_PREFSERVER_DESC2);
	legend2->ResizeToPreferred();
	mainBox->AddChild(legend2);
	legend2->MoveTo(legend1->Frame().left, legend1->Frame().bottom);
	BStringView* legend3 = new BStringView(BRect(0, 0, 0, 0), "str1", S_PREFSERVER_DESC3);
	legend3->ResizeToPreferred();
	mainBox->AddChild(legend3);
	legend3->MoveTo(legend2->Frame().left, legend2->Frame().bottom);
	fLegend4 = new BStringView(BRect(0, 0, 0, 0), "str1", S_PREFSERVER_DESC4);
	fLegend4->ResizeToPreferred();
	mainBox->AddChild(fLegend4);
	fLegend4->MoveTo(legend3->Frame().left, legend3->Frame().bottom);
	fOkButton = new BButton(BRect(0, 0, 0, 0), NULL, S_PREFSERVER_OK_BUTTON,
							new BMessage(B_QUIT_REQUESTED));
	fOkButton->ResizeToPreferred();
	mainBox->AddChild(fOkButton);
	fOkButton->MoveTo(fServerList->Frame().right - fOkButton->Frame().Width(),
					  fLegend4->Frame().bottom + 5);
}