本文整理汇总了C++中BView::MovePenTo方法的典型用法代码示例。如果您正苦于以下问题:C++ BView::MovePenTo方法的具体用法?C++ BView::MovePenTo怎么用?C++ BView::MovePenTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BView
的用法示例。
在下文中一共展示了BView::MovePenTo方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Draw
void CounterView::Draw (BRect updateRect)
{
BRect MovingRect (
m_MovingDotPoint.x,
m_MovingDotPoint.y,
m_MovingDotPoint.x + m_MovingDotSize,
m_MovingDotPoint.y + m_MovingDotSize);
char TempString [40];
if (m_BackingBitmap != NULL)
{
m_BackingBitmap->Lock ();
m_BackingView.SetHighColor (60, 60, 255, 8);
m_BackingView.FillRect (m_BndRect);
m_BackingView.SetHighColor (255, 255, 0, 255);
m_BackingView.MovePenTo (m_TextStartPoint);
sprintf (TempString, "%d", m_CurrentCount);
m_BackingView.DrawString (TempString);
m_BackingView.FillRect (MovingRect);
m_BackingView.Sync ();
m_BackingBitmap->Unlock ();
MovePenTo (0, 0);
DrawBitmap (m_BackingBitmap);
}
}
示例2: BBitmap
// GetClipping -- this will return NULL if the user hasn't selected any region of
// the screen. If she has, it will return a BBitmap representing that
// selection. You MUST delete it. It's not mine.
// Anything else, it returns NULL.
BBitmap * PictureViewer::GetClipping() {
if (thePic == NULL) return NULL;
if (clipping == false) return NULL;
BBitmap *dragImage = new BBitmap(BRect(0,0,clippingRegion.Width(),clippingRegion.Height()), thePic->ColorSpace(),true,false);
BView *tempView = new BView(dragImage->Bounds(),"yo",0,0);
dragImage->AddChild(tempView);
dragImage->Lock();
tempView->SetViewColor(0,0,0);
float left = -clippingRegion.left;
float top = -clippingRegion.top;
tempView->MovePenTo( left, top);
tempView->DrawBitmap(thePic);
dragImage->Unlock();
dragImage->RemoveChild(tempView);
delete tempView;
return dragImage;
}
示例3: BBitmap
BBitmap *DragonView::_MakeNoneImage( void )
{
// Draw an "empty" bitmap to represent "no image"; we'll use one
// that tells the user what to do.
BBitmap *bitmap = new BBitmap( BRect( 0, 0, 319, 199 ),
BScreen().ColorSpace(),
true );
BView *view = new BView( bitmap->Bounds(),
"not a bitmap",
B_FOLLOW_ALL_SIDES, 0 );
bitmap->AddChild( view );
DragonApp *app = dynamic_cast<DragonApp *>( be_app );
rgb_color White = { 255, 255, 255, 0 };
rgb_color Black = { 0, 0, 0, 0 };
bitmap->Lock();
view->SetLowColor( White );
view->SetViewColor( White );
view->SetHighColor( Black );
view->SetDrawingMode( B_OP_OVER );
view->FillRect( view->Bounds(), B_SOLID_LOW );
// Excercise for the reader here: Read the old newsletter articles
// about how to use the font metrics to find out how large a font is,
// then center to font in the window dynamically no matter what font
// settings the user has.
view->SetFont( be_plain_font );
view->MovePenTo( 5, 100 );
view->DrawString( app->rsrc_strings->FindString( RSRC_Drop_an_image ) );
view->Sync();
bitmap->Unlock();
return bitmap;
}
示例4: reply
//.........这里部分代码省略.........
engine_state *state = _FindState(token);
if (state == NULL) {
TRACE_ERROR("didn't find state for token %lu\n", token);
continue;
}
BView *offscreen = state->view;
::pattern &pattern = state->pattern;
BRegion &clippingRegion = state->clipping_region;
float &penSize = state->pen_size;
bool &syncDrawing = state->sync_drawing;
BRegion invalidRegion;
BAutolock offscreenLocker(offscreen->Looper());
if (!offscreenLocker.IsLocked())
break;
switch (code) {
case RP_ENABLE_SYNC_DRAWING:
syncDrawing = true;
continue;
case RP_DISABLE_SYNC_DRAWING:
syncDrawing = false;
continue;
case RP_SET_OFFSETS:
{
int32 xOffset, yOffset;
message.Read(xOffset);
if (message.Read(yOffset) != B_OK)
continue;
offscreen->MovePenTo(xOffset, yOffset);
break;
}
case RP_SET_HIGH_COLOR:
case RP_SET_LOW_COLOR:
{
rgb_color color;
if (message.Read(color) != B_OK)
continue;
if (code == RP_SET_HIGH_COLOR)
offscreen->SetHighColor(color);
else
offscreen->SetLowColor(color);
break;
}
case RP_SET_PEN_SIZE:
{
float newPenSize;
if (message.Read(newPenSize) != B_OK)
continue;
offscreen->SetPenSize(newPenSize);
penSize = newPenSize / 2;
break;
}
case RP_SET_STROKE_MODE:
{
cap_mode capMode;
示例5: 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);
}
}
示例6: 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 ::.
//.........这里部分代码省略.........
示例7: clipRect
// This function returns the number of pixels of the text that
// were clipped if the text does not fit into the clipping rect.
// If the text all fit, it returns 0.
int
BeOSCanvas::RenderText( int iFontHeight, Rect& oClipRect,
string& oText, AlignEnum eAlign,
Font* pFont, const Color& oColor,
bool bBold, bool bItalic, bool bUnderline )
{
Erase( oClipRect );
BView* v = m_pBufferBitmap->OffscreenView();
if ( !v ) return 0;
BBitmap* bitmap = m_pBufferBitmap->GetBBitmap();
assert( bitmap );
BFont font;
font_height fontHeight;
BRect clipRect( float(oClipRect.x1), float(oClipRect.y1),
float(oClipRect.x2-1), float(oClipRect.y2-1) );
BRegion clipRegion;
clipRegion.Set( clipRect );
if ( !bitmap->Lock() )
{
puts( "lock failed" );
return 0;
}
v->ConstrainClippingRegion( &clipRegion );
v->SetDrawingMode( B_OP_OVER );
if ( bBold )
{
v->SetFont( be_bold_font );
}
else
{
v->SetFont( be_plain_font );
}
v->SetFontSize( (float)iFontHeight - 1 );
v->GetFont( &font );
font.GetHeight( &fontHeight );
float width = v->StringWidth(oText.c_str(), oText.size());
if(eAlign == eCenter)
v->MovePenTo( float(oClipRect.x1) +
(float(oClipRect.x2 - oClipRect.x1) - width)/2,
float(oClipRect.y2-fontHeight.descent) );
else if (eAlign == eRight)
v->MovePenTo( float(oClipRect.x2) - width,
float(oClipRect.y2-fontHeight.descent) );
else
v->MovePenTo( float(oClipRect.x1),
float(oClipRect.y2-fontHeight.descent) );
v->DrawString( oText.c_str() );
v->Sync();
bitmap->Unlock();
Invalidate( oClipRect );
return (width < oClipRect.Width()) ? 0 : int(width - oClipRect.Width());
}
示例8: DoPersonDrag
void URLView::DoPersonDrag() {
// Handle all of the bookmark dragging. This includes setting up
// the drag message and drawing the dragged bitmap.
// Set up the drag message to support both BTextView dragging (using
// the e-mail address) and file dropping (to Tracker).
BMessage *dragMessage = new BMessage( B_MIME_DATA );
dragMessage->AddInt32( "be:actions", B_COPY_TARGET );
dragMessage->AddString( "be:types", "application/octet-stream" );
dragMessage->AddString( "be:filetypes", "application/x-person" );
dragMessage->AddString( "be:type_descriptions", "person" );
dragMessage->AddString( "be:clip_name", Text() );
// This allows the user to drag the e-mail address into a
// standard BTextView.
BString email = GetImportantURL();
dragMessage->AddData( "text/plain", B_MIME_DATA, email.String(),
email.Length() + 1 );
// Query for the system's icon for bookmarks.
BBitmap *personIcon = new BBitmap( BRect( 0, 0, iconSize - 1,
iconSize - 1 ), B_CMAP8 );
#ifdef ZETA
BMimeType mime( "application/x-vnd.Be-PEPL" );
#else
BMimeType mime( "application/x-person" );
#endif
if( iconSize == 16 ) mime.GetIcon( personIcon, B_MINI_ICON );
else mime.GetIcon( personIcon, B_LARGE_ICON );
// Find the size of the bitmap to drag. If the text is bigger than the
// icon, use that size. Otherwise, use the icon's. Center the icon
// vertically in the bitmap.
BRect rect = GetTextRect();
rect.right += iconSize + 4;
if( (rect.bottom - rect.top) < iconSize ) {
int adjustment = (int) ((iconSize - (rect.bottom - rect.top)) / 2) + 1;
rect.top -= adjustment;
rect.bottom += adjustment;
}
// Make sure the rectangle starts at 0,0.
rect.bottom += 0 - rect.top;
rect.top = 0;
// Create the bitmap to draw the dragged image in.
BBitmap *dragBitmap = new BBitmap( rect, B_RGBA32, true );
BView *dragView = new BView( rect, "Drag View", 0, 0 );
dragBitmap->Lock();
dragBitmap->AddChild( dragView );
BRect frameRect = dragView->Frame();
// Make the background of the dragged image transparent.
dragView->SetHighColor( B_TRANSPARENT_COLOR );
dragView->FillRect( frameRect );
// We want 'g's, etc. to go below the underline. When the BeOS can
// do underlining of any font, this code can be removed.
font_height height;
GetFontHeight( &height );
float descent = height.descent;
// Find the vertical center of the view so we can vertically
// center everything.
int centerPixel = (int) ((frameRect.bottom - frameRect.top) / 2);
int textCenter = (int) (descent + underlineThickness) + centerPixel;
// We want to draw everything only half opaque.
dragView->SetDrawingMode( B_OP_ALPHA );
dragView->SetHighColor( 0.0, 0.0, 0.0, 128.0 );
dragView->SetBlendingMode( B_CONSTANT_ALPHA, B_ALPHA_COMPOSITE );
// Center the icon in the view.
dragView->MovePenTo( BPoint( frameRect.left,
centerPixel - (iconSize / 2) ) );
dragView->DrawBitmap( personIcon );
// Draw the text in the same font (size, etc.) as the link view.
// Note: DrawString() draws the text at one pixel above the pen's
// current y coordinate.
BFont font;
GetFont( &font );
dragView->SetFont( &font );
dragView->MovePenTo( BPoint( frameRect.left + iconSize + 4, textCenter ) );
dragView->DrawString( Text() );
// Be sure to flush the view buffer so everything is drawn.
dragView->Flush();
dragBitmap->Unlock();
// The Person icon adds some width to the bitmap that we are
// going to draw. So horizontally offset the bitmap proportionally
// to where the user clicked on the link.
float horiz = dragOffset.x / GetTextRect().Width();
dragOffset.x = horiz * frameRect.right;
DragMessage( dragMessage, dragBitmap, B_OP_ALPHA,
BPoint( dragOffset.x,
(rect.Height() + underlineThickness) / 2 + 2), this );
//.........这里部分代码省略.........
示例9: _
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());
}
}