void MainView::getSelBounds(BRect& bounds) { BPoint upper_left, lower_right; upper_left.x = upper_left.y = 999999; lower_right.x = lower_right.y = 0; for(int i = 0; i < selected_fields.CountItems(); i++) { BView *field = (BView *)selected_fields.ItemAt(i); BRect frame = field->Frame(); BPoint tl = frame.LeftTop(); BPoint br = frame.RightBottom(); if(tl.x < upper_left.x) { upper_left.x = tl.x; } if(br.x > lower_right.x) { lower_right.x = br.x; } if(tl.y < upper_left.y) { upper_left.y = tl.y; } if(br.y > lower_right.y) { lower_right.y = br.y; } } bounds.SetLeftTop(upper_left); bounds.SetRightBottom(lower_right); }
void AnalogView::UpdateNeedle(short cpuTime) { BRect updateRect; BRect rt; if(cpuTime != oldCPUTime) { rt.SetRightBottom(param.meterCenter); rt.SetLeftTop(angle[oldCPUTime].arry); if(rt.left > rt.right) { double tmp = rt.left; rt.left = rt.right; rt.right = tmp; } DrawBitmap(panel, rt, rt); const rgb_color kNeedleColor = {0,0,0,0}; //const rgb_color kNeedleColor = {0,255,0,0}; this->SetHighColor(kNeedleColor); StrokeLine(param.meterCenter, angle[cpuTime].arry); } Sync(); oldCPUTime = cpuTime; }
_MediaBar_::_MediaBar_( BRect frame, MediaView *owner) : BView(frame, B_EMPTY_STRING, B_FOLLOW_BOTTOM | B_FOLLOW_LEFT_RIGHT, B_WILL_DRAW) { fOwner = owner; BRect buttonRect; buttonRect.SetLeftTop(BPoint(kMediaBarInset, kMediaBarInset + 1.0)); buttonRect.SetRightBottom(buttonRect.LeftTop() + kPlayButtonSize); fPlayPauseButton = new PlayPauseButton(buttonRect, B_EMPTY_STRING, kPlayButtonBitmapBits, kPressedPlayButtonBitmapBits, kDisabledPlayButtonBitmapBits, kPlayingPlayButtonBitmapBits, kPressedPlayingPlayButtonBitmapBits, kPausedPlayButtonBitmapBits, kPressedPausedPlayButtonBitmapBits, new BMessage(msg_PlayPause), ' ', 0, B_FOLLOW_LEFT | B_FOLLOW_BOTTOM); AddChild(fPlayPauseButton); fPlayPauseButton->SetPaused(); BRect sliderRect = Bounds(); sliderRect.left = buttonRect.right; sliderRect.InsetBy(kMediaBarInset * 4, kMediaBarInset); fMediaSlider = new _MediaSlider_(sliderRect, fOwner); AddChild(fMediaSlider); SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); }
void BSCMenuItem::DrawContent() { Menu()->SetFontSize(10); switch (fAction) { case BSC_START: { BPoint drawPoint(ContentLocation()); drawPoint.x += 20; drawPoint.y += 2; Menu()->MovePenTo(drawPoint); BMenuItem::DrawContent(); BRect imageRect; imageRect.SetLeftTop(ContentLocation()); imageRect.top += 2; imageRect.right = imageRect.left + 10; imageRect.bottom = Frame().bottom - 2; Menu()->SetHighColor(248, 0, 0); Menu()->FillEllipse(imageRect); break; } case BSC_STOP: { BPoint drawPoint(ContentLocation()); drawPoint.x += 20; drawPoint.y += 2; Menu()->MovePenTo(drawPoint); BMenuItem::DrawContent(); BRect imageRect; imageRect.SetLeftTop(ContentLocation()); imageRect.top += 2; imageRect.right = imageRect.left + 10; imageRect.bottom = Frame().bottom - 2; Menu()->SetHighColor(248, 0, 0); Menu()->FillRect(imageRect); break; } case BSC_PAUSE: { BPoint drawPoint(ContentLocation()); drawPoint.x += 20; drawPoint.y += 2; Menu()->MovePenTo(drawPoint); BMenuItem::DrawContent(); BRect imageRect; imageRect.SetLeftTop(ContentLocation()); imageRect.top += 2; imageRect.right = imageRect.left + 4; imageRect.bottom = Frame().bottom - 2; Menu()->SetHighColor(0, 250, 0); Menu()->FillRect(imageRect); imageRect.OffsetBy(6, 0); Menu()->FillRect(imageRect); break; } case BSC_RESUME: { BPoint drawPoint(ContentLocation()); drawPoint.x += 20; drawPoint.y += 2; Menu()->MovePenTo(drawPoint); BMenuItem::DrawContent(); BPoint ptOne = ContentLocation(); BPoint ptTwo = ptOne; ptTwo.y = Frame().bottom - 2; BPoint ptThree = ptOne; ptThree.x += 10; ptThree.y += (ptTwo.y - ptOne.y) / 2; Menu()->SetHighColor(0, 250, 0); Menu()->FillTriangle(ptOne, ptTwo, ptThree); break; } default: BMenuItem::DrawContent(); break; } }