本文整理汇总了C++中BView::StrokeLine方法的典型用法代码示例。如果您正苦于以下问题:C++ BView::StrokeLine方法的具体用法?C++ BView::StrokeLine怎么用?C++ BView::StrokeLine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BView
的用法示例。
在下文中一共展示了BView::StrokeLine方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawStatusBar
void wxStatusBarBeOS::DrawStatusBar()
{
int i=0;
int leftPos=0;
wxArrayInt widthsAbs;
wxString text;
m_view->Clear();
BRect bounds(m_view->bounds());
BView * drawview = m_view->GetBack();
if(drawview->LockLooper())
{
rgb_color clr;
drawview->PushState();
clr = drawview->ViewColor();
clr.red-=50; clr.green-=50; clr.blue-=50;
drawview->SetHighColor(clr);
drawview->StrokeLine(BPoint(bounds.left, bounds.top), BPoint(bounds.right, bounds.top));
clr.red+=100; clr.green+=100; clr.blue+=100;
drawview->SetHighColor(clr);
drawview->StrokeLine(BPoint(bounds.left, bounds.top+1), BPoint(bounds.right, bounds.top+1));
drawview->PopState();
if(m_nFields>0)
widthsAbs = CalculateAbsWidths(bounds.IntegerWidth() - 2*(m_nFields - 1));
drawview->SetDrawingMode(B_OP_OVER);
for(i=0;i<m_nFields;i++)
{
text = GetStatusBufferText(i);
drawview->DrawString(text, BPoint(leftPos, bounds.bottom-2));
leftPos+=widthsAbs[i]+2;
}
drawview->UnlockLooper();
}
m_view->flush();
}
示例2: bounds
void
BTitleView::Draw(BRect /*updateRect*/, bool useOffscreen, bool updateOnly,
const BColumnTitle *pressedColumn,
void (*trackRectBlitter)(BView *, BRect), BRect passThru)
{
BRect bounds(Bounds());
BView *view;
if (useOffscreen) {
ASSERT(sOffscreen);
BRect frame(bounds);
frame.right += frame.left;
// this is kind of messy way of avoiding being clipped by the ammount the
// title is scrolled to the left
// ToDo: fix this
view = sOffscreen->BeginUsing(frame);
view->SetOrigin(-bounds.left, 0);
view->SetLowColor(LowColor());
view->SetHighColor(HighColor());
BFont font(be_plain_font);
font.SetSize(9);
view->SetFont(&font);
} else
view = this;
if (be_control_look != NULL) {
rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
view->SetHighColor(tint_color(base, B_DARKEN_2_TINT));
view->StrokeLine(bounds.LeftBottom(), bounds.RightBottom());
bounds.bottom--;
be_control_look->DrawButtonBackground(view, bounds, bounds, base, 0,
BControlLook::B_TOP_BORDER | BControlLook::B_BOTTOM_BORDER);
} else {
// fill background with light gray background
if (!updateOnly)
view->FillRect(bounds, B_SOLID_LOW);
view->BeginLineArray(4);
view->AddLine(bounds.LeftTop(), bounds.RightTop(), sShadowColor);
view->AddLine(bounds.LeftBottom(), bounds.RightBottom(), sShadowColor);
// draw lighter gray and white inset lines
bounds.InsetBy(0, 1);
view->AddLine(bounds.LeftBottom(), bounds.RightBottom(), sLightShadowColor);
view->AddLine(bounds.LeftTop(), bounds.RightTop(), sShineColor);
view->EndLineArray();
}
int32 count = fTitleList.CountItems();
float minx = bounds.right;
float maxx = bounds.left;
for (int32 index = 0; index < count; index++) {
BColumnTitle *title = fTitleList.ItemAt(index);
title->Draw(view, title == pressedColumn);
BRect titleBounds(title->Bounds());
if (titleBounds.left < minx)
minx = titleBounds.left;
if (titleBounds.right > maxx)
maxx = titleBounds.right;
}
if (be_control_look != NULL) {
bounds = Bounds();
minx--;
view->SetHighColor(sLightShadowColor);
view->StrokeLine(BPoint(minx, bounds.top), BPoint(minx, bounds.bottom - 1));
} else {
// first and last shades before and after first column
maxx++;
minx--;
view->BeginLineArray(2);
view->AddLine(BPoint(minx, bounds.top),
BPoint(minx, bounds.bottom), sShadowColor);
view->AddLine(BPoint(maxx, bounds.top),
BPoint(maxx, bounds.bottom), sShineColor);
view->EndLineArray();
}
#if !(APP_SERVER_CLEARS_BACKGROUND)
FillRect(BRect(bounds.left, bounds.top + 1, minx - 1, bounds.bottom - 1), B_SOLID_LOW);
FillRect(BRect(maxx + 1, bounds.top + 1, bounds.right, bounds.bottom - 1), B_SOLID_LOW);
#endif
if (useOffscreen) {
if (trackRectBlitter)
(trackRectBlitter)(view, passThru);
view->Sync();
DrawBitmap(sOffscreen->Bitmap());
sOffscreen->DoneUsing();
} else if (trackRectBlitter)
(trackRectBlitter)(view, passThru);
}
示例3: bounds
void
BTitleView::Draw(BRect /*updateRect*/, bool useOffscreen, bool updateOnly,
const BColumnTitle* pressedColumn,
void (*trackRectBlitter)(BView*, BRect), BRect passThru)
{
BRect bounds(Bounds());
BView* view;
if (useOffscreen) {
ASSERT(sOffscreen);
BRect frame(bounds);
frame.right += frame.left;
// ToDo: this is kind of messy way of avoiding being clipped
// by the amount the title is scrolled to the left
view = sOffscreen->BeginUsing(frame);
view->SetOrigin(-bounds.left, 0);
view->SetLowColor(LowColor());
view->SetHighColor(HighColor());
BFont font;
GetFont(&font);
view->SetFont(&font);
} else
view = this;
view->SetHighUIColor(B_PANEL_BACKGROUND_COLOR, B_DARKEN_2_TINT);
view->StrokeLine(bounds.LeftBottom(), bounds.RightBottom());
bounds.bottom--;
rgb_color baseColor = ui_color(B_PANEL_BACKGROUND_COLOR);
be_control_look->DrawButtonBackground(view, bounds, bounds, baseColor, 0,
BControlLook::B_TOP_BORDER | BControlLook::B_BOTTOM_BORDER);
int32 count = fTitleList.CountItems();
float minx = bounds.right;
float maxx = bounds.left;
for (int32 index = 0; index < count; index++) {
BColumnTitle* title = fTitleList.ItemAt(index);
title->Draw(view, title == pressedColumn);
BRect titleBounds(title->Bounds());
if (titleBounds.left < minx)
minx = titleBounds.left;
if (titleBounds.right > maxx)
maxx = titleBounds.right;
}
bounds = Bounds();
minx--;
view->SetHighUIColor(B_PANEL_BACKGROUND_COLOR, B_DARKEN_1_TINT);
view->StrokeLine(BPoint(minx, bounds.top),
BPoint(minx, bounds.bottom - 1));
#if !(APP_SERVER_CLEARS_BACKGROUND)
FillRect(BRect(bounds.left, bounds.top + 1, minx - 1, bounds.bottom - 1),
B_SOLID_LOW);
FillRect(BRect(maxx + 1, bounds.top + 1, bounds.right, bounds.bottom - 1),
B_SOLID_LOW);
#endif
if (useOffscreen) {
if (trackRectBlitter)
(trackRectBlitter)(view, passThru);
view->Sync();
DrawBitmap(sOffscreen->Bitmap());
sOffscreen->DoneUsing();
} else if (trackRectBlitter)
(trackRectBlitter)(view, passThru);
}
示例4: reply
//.........这里部分代码省略.........
BPoint points[3];
message.ReadList(points, 3);
if (message.Read(bounds) != B_OK)
continue;
if (code == RP_STROKE_TRIANGLE) {
offscreen->StrokeTriangle(points[0], points[1], points[2],
bounds, pattern);
bounds.InsetBy(-penSize, -penSize);
} else if (code == RP_FILL_TRIANGLE) {
offscreen->FillTriangle(points[0], points[1], points[2],
bounds, pattern);
} else {
BGradient *gradient;
if (message.ReadGradient(&gradient) != B_OK)
continue;
offscreen->FillTriangle(points[0], points[1], points[2],
bounds, *gradient);
delete gradient;
}
invalidRegion.Include(bounds);
break;
}
case RP_STROKE_LINE:
{
BPoint points[2];
if (message.ReadList(points, 2) != B_OK)
continue;
offscreen->StrokeLine(points[0], points[1], pattern);
BRect bounds = _BuildInvalidateRect(points, 2);
invalidRegion.Include(bounds.InsetBySelf(-penSize, -penSize));
break;
}
case RP_STROKE_LINE_ARRAY:
{
int32 numLines;
if (message.Read(numLines) != B_OK)
continue;
BRect bounds;
offscreen->BeginLineArray(numLines);
for (int32 i = 0; i < numLines; i++) {
rgb_color color;
BPoint start, end;
message.ReadArrayLine(start, end, color);
offscreen->AddLine(start, end, color);
bounds.left = min_c(bounds.left, min_c(start.x, end.x));
bounds.top = min_c(bounds.top, min_c(start.y, end.y));
bounds.right = max_c(bounds.right, max_c(start.x, end.x));
bounds.bottom = max_c(bounds.bottom, max_c(start.y, end.y));
}
offscreen->EndLineArray();
invalidRegion.Include(bounds);
break;
}
case RP_FILL_REGION:
示例5: AttachedToWindow
//.........这里部分代码省略.........
monthStringView=new BStringView(BRect(10,10,100,100),"monthStringViewAViX",
monthNames[8]);
monthStringView->SetAlignment(B_ALIGN_CENTER);
AddChild(monthStringView);
monthStringView->ResizeToPreferred();
monthStringView->SetText(monthNames[cmonth-1]);
monthStringView->SetViewColor(VIEW_COLOR);
s.SetTo("");
if(cyear<10) s.Append("000");
else if(cyear<100) s.Append("00");
else if(cyear<1000) s.Append("0");
s<<cyear;
yearStringView=new BStringView(BRect(10,10,100,100),"yearStringViewAViX",
"0000");
AddChild(yearStringView);
yearStringView->ResizeToPreferred();
yearStringView->SetText(s.String());
yearStringView->SetViewColor(VIEW_COLOR);
ResizeTo(w_cell*7+1,h_cell*7+3+16+yearStringView->Bounds().bottom+todayStringView->Bounds().bottom);
Window()->ResizeTo(Bounds().right, Bounds().bottom);
yearMStringView[0]=new MouseSenseStringView(new BMessage('YEA0'),msng,
BRect(10,10,100,100),
"yearMStringViewAViX0",
"<<");
AddChild(yearMStringView[0]);
yearMStringView[0]->ResizeToPreferred();
yearMStringView[0]->SetViewColor(VIEW_COLOR);
yearMStringView[1]=new MouseSenseStringView(new BMessage('YEA1'),msng,
BRect(10,10,100,100),
"yearMStringViewAViX1",
">>");
AddChild(yearMStringView[1]);
yearMStringView[1]->ResizeToPreferred();
yearMStringView[1]->SetViewColor(VIEW_COLOR);
monthMStringView[0]=new MouseSenseStringView(new BMessage('MON0'),msng,
BRect(10,10,100,100),
"monthMStringViewAViX0",
"<<");
AddChild(monthMStringView[0]);
monthMStringView[0]->ResizeToPreferred();
monthMStringView[0]->SetViewColor(VIEW_COLOR);
monthMStringView[1]=new MouseSenseStringView(new BMessage('MON1'),msng,
BRect(10,10,100,100),
"monthMStringViewAViX1",
">>");
AddChild(monthMStringView[1]);
monthMStringView[1]->ResizeToPreferred();
monthMStringView[1]->SetViewColor(VIEW_COLOR);
todayStringView->MoveTo((Bounds().right-todayStringView->Bounds().right)/2,
Bounds().bottom-todayStringView->Bounds().bottom-2);
if(tyear<first_year || tyear>last_year) todayStringView->SetHighColor(NOACTIVE_COLOR);
yearMStringView[1]->MoveTo(Bounds().right-yearMStringView[1]->Bounds().right,5);
yearStringView->MoveTo(yearMStringView[1]->Frame().left-yearStringView->Bounds().right,5);
yearMStringView[0]->MoveTo(yearStringView->Frame().left-yearMStringView[0]->Bounds().right,5);
monthStringView->MoveTo((yearMStringView[0]->Frame().left-monthStringView->Bounds().right)/2,5);
monthMStringView[0]->MoveTo(monthStringView->Frame().left-monthMStringView[0]->Bounds().right,5);
monthMStringView[1]->MoveTo(monthStringView->Frame().right,5);
which_focused=2; // days of month
Bmp=new BBitmap(BRect(Frame()),B_RGB32,true);
BmpView=new BView(Bmp->Bounds(),"BV",0,B_WILL_DRAW);
Bmp->AddChild(BmpView);
Bmp->Lock();
BmpView->SetHighColor(VIEW_COLOR);
BmpView->FillRect(BmpView->Frame());
BmpView->SetHighColor(LINE_COLOR);
BmpView->StrokeLine(BPoint(3,todayStringView->Frame().top-5),
BPoint(Bounds().right-3,todayStringView->Frame().top-5));
BmpView->StrokeLine(BPoint(3,yearStringView->Frame().bottom+2),
BPoint(Bounds().right-3,yearStringView->Frame().bottom+2));
BmpView->SetHighColor(0,0,0,0);
float y=yearStringView->Frame().bottom+h_cell;
float x=0;
for(int i=0;i<7;i++)
{
BmpView->DrawString(weekdayNames[i],BPoint(x+(w_cell-StringWidth(weekdayNames[i]))/2,y));
x+=w_cell;
}
BmpView->Sync();
Bmp->Unlock();
DrawMonth();
}
示例6: KeyDown
void MonthWindowView::KeyDown(const char *bytes, int32 numBytes)
{
switch(bytes[0])
{
case B_TAB:
{
Bmp->Lock();
switch(which_focused)
{
case 0: // months
{
BmpView->SetHighColor(VIEW_COLOR);
BmpView->StrokeLine(BPoint(monthMStringView[0]->Frame().left,
monthMStringView[0]->Frame().bottom+1),
BPoint(monthMStringView[1]->Frame().right,
monthMStringView[1]->Frame().bottom+1));
BmpView->SetHighColor(0,0,0);
break;
}
case 1: // years
{
BmpView->SetHighColor(VIEW_COLOR);
BmpView->StrokeLine(BPoint(yearMStringView[0]->Frame().left,
yearMStringView[0]->Frame().bottom+1),
BPoint(yearMStringView[1]->Frame().right,
yearMStringView[1]->Frame().bottom+1));
BmpView->SetHighColor(0,0,0);
break;
}
case 2: // days of month
{
BmpView->SetHighColor(NOACTIVE_COLOR);
BmpView->StrokeRect(cursor);
BmpView->SetHighColor(0,0,0);
break;
}
case 3: // today
{
BmpView->SetHighColor(VIEW_COLOR);
BmpView->StrokeLine(BPoint(todayStringView->Frame().left,
todayStringView->Frame().bottom+1),
BPoint(todayStringView->Frame().right,
todayStringView->Frame().bottom+1));
BmpView->SetHighColor(0,0,0);
break;
}
}
// changing which_focused
if(modifiers() & B_SHIFT_KEY)
{
if(which_focused==0)
which_focused=3;
else which_focused--;
}
else // simply Tab
{
if(which_focused==3)
which_focused=0;
else which_focused++;
}
// drawing with new which_focused
switch(which_focused)
{
case 0: // months
{
BmpView->SetHighColor(ACTIVE_COLOR);
BmpView->StrokeLine(BPoint(monthMStringView[0]->Frame().left,
monthMStringView[0]->Frame().bottom+1),
BPoint(monthMStringView[1]->Frame().right,
monthMStringView[1]->Frame().bottom+1));
BmpView->SetHighColor(0,0,0);
break;
}
case 1: // years
{
BmpView->SetHighColor(ACTIVE_COLOR);
BmpView->StrokeLine(BPoint(yearMStringView[0]->Frame().left,
yearMStringView[0]->Frame().bottom+1),
BPoint(yearMStringView[1]->Frame().right,
yearMStringView[1]->Frame().bottom+1));
BmpView->SetHighColor(0,0,0);
break;
}
case 2: // days of month
{
BmpView->SetHighColor(ACTIVE_COLOR);
BmpView->StrokeRect(cursor);
BmpView->SetHighColor(0,0,0);
break;
}
case 3: // today
{
BmpView->SetHighColor(ACTIVE_COLOR);
BmpView->StrokeLine(BPoint(todayStringView->Frame().left,
todayStringView->Frame().bottom+1),
BPoint(todayStringView->Frame().right,
todayStringView->Frame().bottom+1));
BmpView->SetHighColor(0,0,0);
//.........这里部分代码省略.........
示例7: Calculate
//.........这里部分代码省略.........
a = a1 + b1 * (D_d / log(D_d)) + c1 * (log(D_d) / D_d);
}
a1 = -0.287595623;
b1 = -0.021137436;
c1 = 0.001099864;
b = a1 + b1 * D_d + c1 / log(D_d);
if (D_d <= 1.05)
{
a1 = -1.585648431;
b1 = 0.003195393;
c = a1 + b1 * (D_d / log(D_d));
}
else
{
a1 = 37.11501602;
b1 = 14.59448006;
c1 = -51.84367334;
c = D_d / (a1 + b1 * D_d + c1 * sqrt(D_d));
}
Kt = a * pow(x, b) * pow((1-x), c);
kt_text << "Kt : ";
kt_text << (float)Kt;
lbl1->SetText(kt_text.String());
/*
kt_text.SetTo("");
kt_text << "D_d : ";
kt_text << (float)D_d;
kt_text << "a : ";
kt_text << (float)a;
kt_text << "; b : ";
kt_text << (float)b;
kt_text << "; c : ";
kt_text << (float)c;
txt2->SetText(kt_text.String());
*/
BView *drawView;
drawView = (BView *)FindView("drawView");
drawView->SetHighColor(0, 200, 50);
/*
.:: Asse x (30, 200) - (310, 200) ::.
.:: Asse y (30, 0) - ( 30, 200)::.
*/
BPoint p1, p2;
p1.x = (310 - 30) * x / 0.28 + 30;
p1.y = 200 - 200 * Kt / 4;
p2.x = (310 - 30) * x / 0.28 + 30;
p2.y = 200;
drawView->StrokeLine(p1, p2, B_SOLID_HIGH);
p1.x = (310 - 30) * x / 0.28 + 30;
p1.y = 200 - 200 * Kt / 4;
p2.x = 30;
p2.y = 200 - 200 * Kt / 4;
drawView->StrokeLine(p1, p2, B_SOLID_HIGH);
drawView->SetHighColor(0, 0, 0);
float xres;
xres = 0.28 / (310 - 30 + 1);
x = 1 * xres;
p1.x = 1 + 30;
p1.y = 200 - 200 * ( a * pow(x, b) * pow((1-x), c)) / 4;
drawView->MovePenTo(p1);
for (int i = 2; i <= 280; i++)
{
x = i * xres;
p1.x = i + 30;
p1.y = 200 - 200 * ( a * pow(x, b) * pow((1-x), c)) / 4;
drawView->StrokeLine(p1, B_SOLID_HIGH);
}
}
示例8: Draw
void CalcoloKtView::Draw(BRect)
{
BView *iconView;
iconView = (BView *)FindView("iconView");
iconView->SetHighColor(0, 0, 0);
BPoint p1, p2;
// Dimensioni della BView iconView 130 x 60 pixels
float x_origin;
float y_origin;
float l_tot;
float h_tot;
// .:: Dimensioni principali dell'icona ::.
x_origin = 25;
y_origin = 5;
l_tot = 90;
h_tot = 52;
// .:: Sezione Sx ::.
p1.x = x_origin;
p1.y = y_origin;
p2.x = x_origin + l_tot * 5 / 9;
p2.y = y_origin;
iconView->StrokeLine(p1, p2, B_SOLID_HIGH);
p1.x = x_origin;
p1.y = y_origin + h_tot;
p2.x = x_origin + l_tot * 5 / 9;
p2.y = y_origin + h_tot;
iconView->StrokeLine(p1, p2, B_SOLID_HIGH);
p1.x = x_origin + l_tot * 5 / 9;
p1.y = y_origin;
p2.x = x_origin + l_tot * 5 / 9;
p2.y = y_origin + h_tot;
iconView->StrokeLine(p1, p2, B_SOLID_HIGH);
// .:: Quota Sx ::.
p1.x = x_origin + (l_tot * 5 / 9)/2;
p1.y = y_origin;
p2.x = x_origin + (l_tot * 5 / 9)/2;
p2.y = y_origin + h_tot;
iconView->StrokeLine(p1, p2, B_SOLID_HIGH);
// .:: Freccie quota Sx ::.
float largfreccie;
BPoint p3;
largfreccie = h_tot * 3 / 52;
p1.x = x_origin + (l_tot * 5 / 9)/2;
p1.y = y_origin;
p2.x = p1.x - largfreccie / 2;
p2.y = p1.y + largfreccie * 2;
p3.x = p1.x + largfreccie / 2;
p3.y = p1.y + largfreccie * 2;
iconView->FillTriangle(p1, p2, p3, B_SOLID_HIGH);
p1.x = x_origin + (l_tot * 5 / 9)/2;
p1.y = y_origin + h_tot;
p2.x = p1.x - largfreccie / 2;
p2.y = p1.y - largfreccie * 2;
p3.x = p1.x + largfreccie / 2;
p3.y = p1.y - largfreccie * 2;
iconView->FillTriangle(p1, p2, p3, B_SOLID_HIGH);
// .:: Testo quota Sx ::.
BPoint dimtext;
BFont font(be_plain_font);
float fontsize;
fontsize = h_tot * 7 / 52;
font.SetSize(fontsize);
iconView->SetFont(&font);
dimtext.x = x_origin + (l_tot * 5 / 9)/2 + l_tot * 5 / 90;
dimtext.y = y_origin + h_tot / 2 + fontsize / 2;
iconView->MovePenTo(dimtext);
iconView->DrawString("D");
// .:: Sezione Dx ::.
//.........这里部分代码省略.........
示例9: rightRect
void
TouchpadView::DrawSliders()
{
BView* view;
if (fOffScreenView != NULL)
view = fOffScreenView;
else
view = this;
if (!LockLooper())
return;
if (fOffScreenBitmap->Lock()) {
view->SetHighColor(ui_color(B_PANEL_BACKGROUND_COLOR));
view->FillRect(Bounds());
view->SetHighColor(100, 100, 100);
view->FillRoundRect(fPadRect, 4, 4);
int32 dragSize = 3; // half drag size
// scroll areas
view->SetHighColor(145, 100, 100);
BRect rightRect(fPadRect.left + fXScrollRange, fPadRect.top,
fPadRect.right, fPadRect.bottom);
view->FillRoundRect(rightRect, 4, 4);
BRect bottomRect(fPadRect.left, fPadRect.top + fYScrollRange,
fPadRect.right, fPadRect.bottom);
view->FillRoundRect(bottomRect, 4, 4);
// Stroke Rect
view->SetHighColor(100, 100, 100);
view->SetPenSize(2);
view->StrokeRoundRect(fPadRect, 4, 4);
// x scroll range line
view->SetHighColor(200, 0, 0);
view->StrokeLine(BPoint(fPadRect.left + fXScrollRange, fPadRect.top),
BPoint(fPadRect.left + fXScrollRange, fPadRect.bottom));
fXScrollDragZone = BRect(fPadRect.left + fXScrollRange - dragSize,
fPadRect.top - dragSize, fPadRect.left + fXScrollRange + dragSize,
fPadRect.bottom + dragSize);
fXScrollDragZone1 = BRect(fPadRect.left + fXScrollRange - dragSize,
fPadRect.top - dragSize, fPadRect.left + fXScrollRange + dragSize,
fPadRect.top + dragSize);
view->FillRect(fXScrollDragZone1);
fXScrollDragZone2 = BRect(fPadRect.left + fXScrollRange - dragSize,
fPadRect.bottom - dragSize,
fPadRect.left + fXScrollRange + dragSize,
fPadRect.bottom + dragSize);
view->FillRect(fXScrollDragZone2);
// y scroll range line
view->StrokeLine(BPoint(fPadRect.left, fPadRect.top + fYScrollRange),
BPoint(fPadRect.right, fPadRect.top + fYScrollRange));
fYScrollDragZone = BRect(fPadRect.left - dragSize,
fPadRect.top + fYScrollRange - dragSize,
fPadRect.right + dragSize,
fPadRect.top + fYScrollRange + dragSize);
fYScrollDragZone1 = BRect(fPadRect.left - dragSize,
fPadRect.top + fYScrollRange - dragSize, fPadRect.left + dragSize,
fPadRect.top + fYScrollRange + dragSize);
view->FillRect(fYScrollDragZone1);
fYScrollDragZone2 = BRect(fPadRect.right - dragSize,
fPadRect.top + fYScrollRange - dragSize, fPadRect.right + dragSize,
fPadRect.top + fYScrollRange + dragSize);
view->FillRect(fYScrollDragZone2);
fOffScreenView->Sync();
fOffScreenBitmap->Unlock();
DrawBitmap(fOffScreenBitmap, B_ORIGIN);
}
UnlockLooper();
}
示例10: _
void
ActivityView::_DrawHistory(bool drawBackground)
{
_UpdateOffscreenBitmap();
BView* view = this;
if (fOffscreen != NULL) {
fOffscreen->Lock();
view = _OffscreenView();
}
BRect frame = _HistoryFrame();
BRect outerFrame = frame.InsetByCopy(-2, -2);
// draw the outer frame
uint32 flags = 0;
if (!drawBackground)
flags |= BControlLook::B_BLEND_FRAME;
be_control_look->DrawTextControlBorder(this, outerFrame,
outerFrame, fLegendBackgroundColor, flags);
// convert to offscreen view if necessary
if (view != this)
frame.OffsetTo(B_ORIGIN);
view->SetLowColor(fHistoryBackgroundColor);
view->FillRect(frame, B_SOLID_LOW);
uint32 step = 2;
uint32 resolution = fDrawResolution;
if (fDrawResolution > 1) {
step = 1;
resolution--;
}
uint32 width = frame.IntegerWidth() - 10;
uint32 steps = width / step;
bigtime_t timeStep = RefreshInterval() * resolution;
bigtime_t now = system_time();
// Draw scale
// TODO: add second markers?
view->SetPenSize(1);
rgb_color scaleColor = view->LowColor();
uint32 average = (scaleColor.red + scaleColor.green + scaleColor.blue) / 3;
if (average < 96)
scaleColor = tint_color(scaleColor, B_LIGHTEN_2_TINT);
else
scaleColor = tint_color(scaleColor, B_DARKEN_2_TINT);
view->SetHighColor(scaleColor);
view->StrokeLine(BPoint(frame.left, frame.top + frame.Height() / 2),
BPoint(frame.right, frame.top + frame.Height() / 2));
// Draw values
view->SetPenSize(1.5);
BAutolock _(fSourcesLock);
for (uint32 i = fSources.CountItems(); i-- > 0;) {
ViewHistory* viewValues = fViewValues.ItemAt(i);
DataSource* source = fSources.ItemAt(i);
DataHistory* values = fValues.ItemAt(i);
viewValues->Update(values, steps, fDrawResolution, now, timeStep,
RefreshInterval());
uint32 x = viewValues->Start() * step;
BShape shape;
bool first = true;
for (uint32 i = viewValues->Start(); i < steps; x += step, i++) {
float y = _PositionForValue(source, values,
viewValues->ValueAt(i));
if (first) {
shape.MoveTo(BPoint(x, y));
first = false;
} else
shape.LineTo(BPoint(x, y));
}
view->SetHighColor(source->Color());
view->SetLineMode(B_BUTT_CAP, B_ROUND_JOIN);
view->MovePenTo(B_ORIGIN);
view->StrokeShape(&shape);
}
// TODO: add marks when an app started or quit
view->Sync();
if (fOffscreen != NULL) {
fOffscreen->Unlock();
DrawBitmap(fOffscreen, outerFrame.LeftTop());
}
}