当前位置: 首页>>代码示例>>C++>>正文


C++ BView::Sync方法代码示例

本文整理汇总了C++中BView::Sync方法的典型用法代码示例。如果您正苦于以下问题:C++ BView::Sync方法的具体用法?C++ BView::Sync怎么用?C++ BView::Sync使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BView的用法示例。


在下文中一共展示了BView::Sync方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CreateIcon

BBitmap* MainView::CreateIcon(const rgb_color colorIn)
{
	BRect rect(0, 0, 15, 15);
	BBitmap* toReturn = new BBitmap(rect, B_CMAP8, true);
	BView* drawing = new BView(rect, 
								"drawer", 
								B_FOLLOW_LEFT | B_FOLLOW_TOP,
								B_WILL_DRAW);
	if (!drawing || !toReturn) { return NULL; }	
	toReturn->AddChild(drawing);
	if (toReturn->Lock()) {
		drawing->SetHighColor(kWhite);
		drawing->FillRect(rect);
		drawing->SetHighColor(kBlack);
		drawing->SetPenSize(1);
		drawing->StrokeRect(rect);
		drawing->SetHighColor(colorIn);
		drawing->FillRect(rect.InsetBySelf(1, 1));
		drawing->Sync();
		toReturn->Unlock();			
	}
	toReturn->RemoveChild(drawing);
	delete drawing;
	return toReturn;
}
开发者ID:BackupTheBerlios,项目名称:haiku-pim-svn,代码行数:25,代码来源:clsMainWindow.cpp

示例2: make_bitmap

BBitmap* SwatchView::make_bitmap(void)
{
	BRect rect(0.0, 0.0, 12.0, 12.0);
	
	BBitmap *bitmap = new BBitmap(rect, B_RGB32, true);
	BView *view = new BView(rect, "", B_FOLLOW_NONE, B_WILL_DRAW);

	bitmap->Lock();

	bitmap->AddChild(view);

	view->SetDrawingMode(B_OP_ALPHA);
	view->SetHighColor(m_color);
	view->FillRect(rect);
	
	view->SetDrawingMode(B_OP_COPY);
	view->SetHighColor(0, 0, 0, 255);
	view->StrokeRect(rect);
	view->Sync();

	bitmap->RemoveChild(view);
	delete view;

	bitmap->Unlock();
	
	return bitmap;
}
开发者ID:HaikuArchives,项目名称:HyperStudio,代码行数:27,代码来源:SwatchView.cpp

示例3: 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);
  }
}
开发者ID:kallisti5,项目名称:VNCServer,代码行数:25,代码来源:UserAppMessageMonitor.cpp

示例4: _updateBitmap

void MediaJack::_updateBitmap()
{
	D_METHOD(("MediaJack::_updateBitmap()\n"));

	if (m_bitmap)
	{
		delete m_bitmap;
	}
	BBitmap *tempBitmap = new BBitmap(Frame().OffsetToCopy(0.0, 0.0), B_CMAP8, true);
	tempBitmap->Lock();
	{
		BView *tempView = new BView(tempBitmap->Bounds(), "", B_FOLLOW_NONE, 0);
		tempBitmap->AddChild(tempView);
		tempView->SetOrigin(0.0, 0.0);

		MediaRoutingView* mediaView = dynamic_cast<MediaRoutingView*>(view());
		int32 layout = mediaView ? mediaView->getLayout() : MediaRoutingView::M_ICON_VIEW;

		_drawInto(tempView, tempView->Bounds(), layout);

		tempView->Sync();
		tempBitmap->RemoveChild(tempView);
		delete tempView;
	}
	tempBitmap->Unlock();
	m_bitmap = new BBitmap(tempBitmap);
	delete tempBitmap;
}
开发者ID:mariuz,项目名称:haiku,代码行数:28,代码来源:MediaJack.cpp

示例5: new

// SetIcon
status_t
IconButton::SetIcon(const unsigned char* bitsFromQuickRes,
                    uint32 width, uint32 height, color_space format, bool convertToBW)
{
    status_t status = B_BAD_VALUE;
    if (bitsFromQuickRes && width > 0 && height > 0) {
        BBitmap* quickResBitmap = new(nothrow) BBitmap(BRect(0.0, 0.0, width - 1.0, height - 1.0), format);
        status = quickResBitmap ? quickResBitmap->InitCheck() : B_ERROR;
        if (status >= B_OK) {
            // It doesn't look right to copy BitsLength() bytes, but bitmaps
            // exported from QuickRes still contain their padding, so it is alright.
            memcpy(quickResBitmap->Bits(), bitsFromQuickRes, quickResBitmap->BitsLength());
            if (format != B_RGB32 && format != B_RGBA32 && format != B_RGB32_BIG && format != B_RGBA32_BIG) {
                // colorspace needs conversion
                BBitmap* bitmap = new(nothrow) BBitmap(quickResBitmap->Bounds(), B_RGB32, true);
                if (bitmap && bitmap->IsValid()) {
                    BView* helper = new BView(bitmap->Bounds(), "helper",
                                              B_FOLLOW_NONE, B_WILL_DRAW);
                    if (bitmap->Lock()) {
                        bitmap->AddChild(helper);
                        helper->SetHighColor(ui_color(B_PANEL_BACKGROUND_COLOR));
                        helper->FillRect(helper->Bounds());
                        helper->SetDrawingMode(B_OP_OVER);
                        helper->DrawBitmap(quickResBitmap, BPoint(0.0, 0.0));
                        helper->Sync();
                        bitmap->Unlock();
                    }
                    status = _MakeBitmaps(bitmap);
                } else
                    printf("IconButton::SetIcon() - B_RGB32 bitmap is not valid\n");
                delete bitmap;
            } else {
                // native colorspace (32 bits)
                if (convertToBW) {
                    // convert to gray scale icon
                    uint8* bits = (uint8*)quickResBitmap->Bits();
                    uint32 bpr = quickResBitmap->BytesPerRow();
                    for (uint32 y = 0; y < height; y++) {
                        uint8* handle = bits;
                        uint8 gray;
                        for (uint32 x = 0; x < width; x++) {
                            gray = uint8((116 * handle[0] + 600 * handle[1] + 308 * handle[2]) / 1024);
                            handle[0] = gray;
                            handle[1] = gray;
                            handle[2] = gray;
                            handle += 4;
                        }
                        bits += bpr;
                    }
                }
                status = _MakeBitmaps(quickResBitmap);
            }
        } else
            printf("IconButton::SetIcon() - error allocating bitmap: %s\n", strerror(status));
        delete quickResBitmap;
    }
    return status;
}
开发者ID:mmanley,项目名称:Antares,代码行数:59,代码来源:IconButton.cpp

示例6: CreateIcon

/*!
 *	\brief		Create the square icon filled with submitted color.
 *	\param[in]	color		The color of the requested icon.
 *	\param[in]	toChange	If there is an allocated item, it may be changed.
 *							If the submitted pointer is not NULL (which is default),
 *							this BBitmap is tested for dimensions match, and if dimensions
 *							allow, its contents are replaced with new icon. Else, old icon
 *							is deleted, and a new is created. In this case, both the
 *							"toChange" pointer and returned pointer point to the same
 *							BBitmap. 
 */
BBitmap* CategoryMenuItem::CreateIcon(const rgb_color colorIn, BBitmap* toChange )
{
	font_height fh;
	BFont plainFont( be_plain_font );
	plainFont.GetHeight( &fh );
	
	int squareSize = ceilf( fh.ascent + fh.descent + fh.leading - 2 );	//!< Side of the square.
	BRect rect(0, 0, squareSize, squareSize );
	BBitmap* toReturn = NULL;
	if ( !toChange )	// Checking availability of the input
	{
		toReturn = new BBitmap(rect, B_RGB32, true);
	} else {
		// It would be a good idea to check also the color space,
		// but it may be changed by the BBitmap itself, so...
		if ( ceilf ( ( toChange->Bounds() ).Width() ) != squareSize )
		{
			delete toChange;
			toChange = new BBitmap(rect, B_RGB32, true);
			if ( !toChange )
			{
				/* Panic! */
				exit(1);
			}			
		}
		toReturn = toChange;
	}
	
	BView* drawing = new BView( rect, 
								"Drawer", 
								B_FOLLOW_LEFT | B_FOLLOW_TOP,
								B_WILL_DRAW);
	if (!drawing || !toReturn) { return NULL; }	
	toReturn->AddChild(drawing);
	if (toReturn->Lock()) {
		
		// Clean the area
		drawing->SetHighColor( ui_color( B_DOCUMENT_BACKGROUND_COLOR ) );
		drawing->FillRect(rect);
		
		// Draw the black square
		drawing->SetHighColor( ui_color( B_DOCUMENT_TEXT_COLOR ) );
		drawing->SetPenSize(1);
		drawing->StrokeRect(rect);
		
		// Fill the inside of the square
		drawing->SetHighColor( colorIn );
		drawing->FillRect(rect.InsetBySelf(1, 1));
		
		// Flush the actions to BBitmap
		drawing->Sync();
		toReturn->Unlock();
	}
	toReturn->RemoveChild(drawing);			// Cleanup
	delete drawing;
	return toReturn;
}	// <-- end of function CategoryMenuItem::CreateIcon
开发者ID:HaikuArchives,项目名称:Eventual,代码行数:68,代码来源:CategoryItem.cpp

示例7: scaledBounds

status_t
MakeScreenshot(BBitmap **here)
{
	status_t err;
	BScreen bs;
	BWindow *win;
	BBitmap *shot;
	BBitmap *scaledBmp = NULL;
	be_app->Lock();
	win = be_app->WindowAt(0);
	if (win) {
		win->Lock();
		win->Hide();
		win->Unlock();
	}
	snooze(500000);
	err = bs.GetBitmap(&shot);
	if (!err) {
		BRect scaledBounds(0,0,640-1,480-1);
		scaledBmp = new BBitmap(scaledBounds, B_BITMAP_ACCEPTS_VIEWS, B_RGB32/*shot->ColorSpace()*/);
		err = scaledBmp->InitCheck();
		if (!err) {
			err = ENOSYS;
#ifdef B_ZETA_VERSION
			err = ScaleBitmap(*shot, *scaledBmp);
#endif
			if (err) {
				// filtered scaling didn't work, do it manually
				BView *v = new BView(scaledBounds, "scaleview", B_FOLLOW_NONE, 0);
				scaledBmp->AddChild(v);
				v->LockLooper();
				v->DrawBitmap(shot);
				v->Sync();
				v->UnlockLooper();
				scaledBmp->RemoveChild(v);
				delete v;
				err = B_OK;
			}
		}
		delete shot;
	}

	if (win) {
		win->Lock();
		win->Show();
		win->Unlock();
	}
	be_app->Unlock();
	
	if (err)
		return err;
	
	*here = scaledBmp;

	return B_OK;
}
开发者ID:HaikuArchives,项目名称:HaikuThemeManager,代码行数:56,代码来源:MakeScreenshot.cpp

示例8: message

void
IconView::MouseMoved(BPoint where, uint32 transit, const BMessage* dragMessage)
{
	if (fTracking && !fDragging && fIcon != NULL
		&& (abs((int32)(where.x - fDragPoint.x)) > 3
			|| abs((int32)(where.y - fDragPoint.y)) > 3)) {
		// Start drag
		BMessage message(B_SIMPLE_DATA);

		::Icon* icon = fIconData;
		if (fHasRef || fHasType) {
			icon = new ::Icon;
			if (fHasRef)
				icon->SetTo(fRef, fType.Type());
			else if (fHasType)
				icon->SetTo(fType);
		}

		icon->CopyTo(message);

		if (icon != fIconData)
			delete icon;

		BBitmap *dragBitmap = new BBitmap(fIcon->Bounds(), B_RGBA32, true);
		dragBitmap->Lock();
		BView *view
			= new BView(dragBitmap->Bounds(), B_EMPTY_STRING, B_FOLLOW_NONE, 0);
		dragBitmap->AddChild(view);

		view->SetHighColor(B_TRANSPARENT_COLOR);
		view->FillRect(dragBitmap->Bounds());
		view->SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_COMPOSITE);
		view->SetDrawingMode(B_OP_ALPHA);
		view->SetHighColor(0, 0, 0, 160);
		view->DrawBitmap(fIcon);

		view->Sync();
		dragBitmap->Unlock();

		DragMessage(&message, dragBitmap, B_OP_ALPHA,
			fDragPoint - BitmapRect().LeftTop(), this);
		fDragging = true;
		SetMouseEventMask(B_POINTER_EVENTS, B_NO_POINTER_HISTORY);
	}

	if (dragMessage != NULL && !fDragging && AcceptsDrag(dragMessage)) {
		bool dropTarget = transit == B_ENTERED_VIEW || transit == B_INSIDE_VIEW;
		if (dropTarget != fDropTarget) {
			fDropTarget = dropTarget;
			Invalidate();
		}
	} else if (fDropTarget) {
		fDropTarget = false;
		Invalidate();
	}
}
开发者ID:veer77,项目名称:Haiku-services-branch,代码行数:56,代码来源:IconView.cpp

示例9: _LoadBitmaps

void KlondikeView::_LoadBitmaps()
{
	BString suits[] = {
		"spade",
		"heart",
		"club",
		"diamond"
	};

	// load images
	BString filename;
	for (short i = 0; i < CARDS_IN_SUIT; i++) {
		for (short j = 0; j < 4; j++) {
			filename = "";
			filename << "Artwork/" << i + 1 << "_" << suits[j] << ".png";
			fCards[j * CARDS_IN_SUIT + i]
				= BTranslationUtils::GetBitmap('rGFX', filename);
		}
	}
	fBack[0] = BTranslationUtils::GetBitmap('rGFX', "Artwork/back.png");
	fEmpty = BTranslationUtils::GetBitmap('rGFX', "Artwork/empty.png");

	// load audio
	fResources = be_app->AppResources();
	fShuffle = _LoadSound("Artwork/shuffle.wav");
	fFanfare = _LoadSound("Artwork/fanfare.wav");
	
	// cache multiple backs in a row
	for (short i = 1; i < CACHED_BACKS; i++) {
		fBack[i] = new BBitmap(BRect(0, 0, CARD_WIDTH - 1,
			CARD_HEIGHT + i * 18), fBack[0]->ColorSpace(), true);
		
		BView* fBackView = new BView(fBack[i]->Bounds(), NULL, 0, 0);
		BRect destRect = fBack[0]->Bounds();
		fBack[i]->AddChild(fBackView);
		fBack[i]->Lock();
		
		fBackView->SetDrawingMode(B_OP_COPY);
		fBackView->DrawBitmap(fBack[0], destRect);
		destRect.top = i * 18;
		destRect.bottom = destRect.top + CARD_HEIGHT;
		fBackView->DrawBitmap(fBack[0], destRect);
		
		fBackView->SetDrawingMode(B_OP_ALPHA);
		for (short j = 0; j < i + 1; j++) {
			destRect.top = j * 18;
			destRect.bottom = destRect.top + CARD_HEIGHT;
			fBackView->DrawBitmap(fBack[0], destRect);
		}
		fBackView->Sync();
		fBack[i]->Unlock();
	}

	Invalidate();
}
开发者ID:hannahyp,项目名称:BeKlondike,代码行数:55,代码来源:KlondikeView.cpp

示例10: bitmap

BBitmap *
PictureTest::CreateBitmap(BPicture *picture, BRect frame)
{
	OffscreenBitmap bitmap(frame, fColorSpace);
	TEST_AND_RETURN(bitmap.InitCheck() != B_OK, "Offscreen bitmap for picture drawing could not be created!" , NULL);

	BView *view = bitmap.View();		
	view->DrawPicture(picture);
	view->Sync();
	
	return bitmap.Copy();
}
开发者ID:SummerSnail2014,项目名称:haiku,代码行数:12,代码来源:PictureTest.cpp

示例11: rect

BBitmap *DragonView::_MakeDragBitmap( void )
{
	// If the currently displayed bitmap is too large to drag around,
	// we'll just drag around a rectangle.

	BRect drag_rect = _bits->Bounds();

	if( drag_rect.Width() > _drag_max_size.x ||
		drag_rect.Height() > _drag_max_size.y ) return NULL;

	// If we've got a PNG image, we'll assume that it's got
	// "interesting" alpha information.  The ones that are built
	// into DragonDrop's resources all have "interesting" alpha
	// channels.
			
	if( _image_is_png ) {
		BBitmap *drag_me = new BBitmap( _bits );
		memcpy( drag_me->Bits(), _bits->Bits(), _bits->BitsLength() );
		
		return drag_me;
	}

	// If you've made it here, we'll need to build a semi-transparent image
	// to drag around.  This magic is from Pavel Cisler, and it ensures that
	// you've got a drag bitmap that's translucent.
	
	BRect rect( _bits->Bounds() );
	BBitmap *bitmap = new BBitmap( rect, B_RGBA32, true );
	BView *view = new BView( rect, "drag view", B_FOLLOW_NONE, 0 );

	bitmap->Lock();
	bitmap->AddChild( view );
	
	BRegion new_clip;
	new_clip.Set( rect );
	view->ConstrainClippingRegion( &new_clip );
	
	view->SetHighColor( 0, 0, 0, 0 );
	view->FillRect( rect );
	view->SetDrawingMode( B_OP_ALPHA );
	
	view->SetHighColor( 0, 0, 0, 128 );
	view->SetBlendingMode( B_CONSTANT_ALPHA, B_ALPHA_COMPOSITE );
	
	view->DrawBitmap( _bits );
	
	view->Sync();
	
	bitmap->Unlock();

	return bitmap;
}
开发者ID:Taffer,项目名称:BeOS,代码行数:52,代码来源:DragonView.cpp

示例12: BPoint

void
KeyboardLayoutView::Draw(BRect updateRect)
{
	if (fOldSize != BSize(Bounds().Width(), Bounds().Height())) {
		_InitOffscreen();
		_LayoutKeyboard();
	}

	BView* view;
	if (fOffscreenBitmap != NULL) {
		view = fOffscreenView;
		view->LockLooper();
	} else
		view = this;

	// Draw background

	if (Parent())
		view->SetLowColor(Parent()->ViewColor());
	else
		view->SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));

	view->FillRect(updateRect, B_SOLID_LOW);

	// Draw keys

	for (int32 i = 0; i < fLayout->CountKeys(); i++) {
		Key* key = fLayout->KeyAt(i);

		_DrawKey(view, updateRect, key, _FrameFor(key),
			_IsKeyPressed(key->code));
	}

	// Draw LED indicators

	for (int32 i = 0; i < fLayout->CountIndicators(); i++) {
		Indicator* indicator = fLayout->IndicatorAt(i);

		_DrawIndicator(view, updateRect, indicator, _FrameFor(indicator->frame),
			(fModifiers & indicator->modifier) != 0);
	}

	if (fOffscreenBitmap != NULL) {
		view->Sync();
		view->UnlockLooper();

		DrawBitmapAsync(fOffscreenBitmap, BPoint(0, 0));
	}
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:49,代码来源:KeyboardLayoutView.cpp

示例13: BBitmap

BBitmap*
OffscreenBitmap::Copy()
{
	// the result bitmap that does not accept views	
	// to save resources in the application server
	BBitmap *copy = new BBitmap(fFrame, fColorSpace, false);
	AutoDelete<BBitmap> _copy(copy);
	if (copy == NULL || copy->IsValid() == false || copy->InitCheck() != B_OK)
		return NULL;

	fView->Sync();
	fBitmap->Unlock();
	
	memcpy(copy->Bits(), fBitmap->Bits(), fBitmap->BitsLength());	
	
	fBitmap->Lock();

	return _copy.Release();
}
开发者ID:SummerSnail2014,项目名称:haiku,代码行数:19,代码来源:PictureTest.cpp

示例14: BBitmap

BBitmap *bitmap (char *title)
{
	strcpy (title, "Grabbed");
	BBitmap *b = new BBitmap (BRect (0, 0, 127, 127), B_RGB_32_BIT, true);
	BView *v = new BView (BRect (0, 0, 127, 127), "bg", 0, 0);
	b->Lock();
	b->AddChild (v);
	rgb_color fg, bg;
	fg.red = 255; fg.green = 255; fg.blue = 255; fg.alpha = 255;
	bg.red = 0;   bg.green = 0;   bg.blue = 0;   bg.alpha = 127;
	v->SetHighColor (fg);
	v->SetLowColor (bg);
	v->FillRect (BRect (0, 0, 127, 127), B_MIXED_COLORS);
	v->Sync();
	b->RemoveChild (v);
	b->Unlock();
	delete v;
	return (b);
}
开发者ID:gedrin,项目名称:Becasso,代码行数:19,代码来源:CaptureTest.cpp

示例15: 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;
}
开发者ID:Taffer,项目名称:BeOS,代码行数:39,代码来源:DragonView.cpp


注:本文中的BView::Sync方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。