本文整理汇总了C++中BBitmap::AddChild方法的典型用法代码示例。如果您正苦于以下问题:C++ BBitmap::AddChild方法的具体用法?C++ BBitmap::AddChild怎么用?C++ BBitmap::AddChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BBitmap
的用法示例。
在下文中一共展示了BBitmap::AddChild方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Window
void
SLoadingModulesViewLight::ReGetBitmap()
{
BWindow *window = Window();
if(!window) return;
bool is_hidden = window->IsHidden();
if(!is_hidden) window->Hide();
if(red_bitmap) delete red_bitmap;
red_bitmap = new BBitmap(Bounds(), B_BITMAP_ACCEPTS_VIEWS, B_RGB32);
if(red_bitmap)
{
SAutolock<BBitmap> autolock(red_bitmap);
BView *bitmap_view = new BView(red_bitmap->Bounds(), NULL, B_FOLLOW_NONE, B_WILL_DRAW);
red_bitmap->AddChild(bitmap_view);
bitmap_view->PushState();
bitmap_view->SetDrawingMode(B_OP_ALPHA);
bitmap_view->SetHighColor(ViewColor());
bitmap_view->FillRect(Bounds());
bitmap_view->SetHighColor(203, 0, 51, 255);
bitmap_view->FillArc(Bounds(), 0, 360);
bitmap_view->SetHighColor(20, 20, 20, 150);
bitmap_view->StrokeArc(Bounds(), 45, 180);
bitmap_view->SetHighColor(220, 220, 220, 150);
bitmap_view->StrokeArc(Bounds(), 225, 180);
bitmap_view->PopState();
bitmap_view->Sync();
}
if(green_bitmap) delete green_bitmap;
green_bitmap = new BBitmap(Bounds(), B_BITMAP_ACCEPTS_VIEWS, B_RGB32);
if(green_bitmap)
{
SAutolock<BBitmap> autolock(green_bitmap);
BView *bitmap_view = new BView(green_bitmap->Bounds(), NULL, B_FOLLOW_NONE, B_WILL_DRAW);
green_bitmap->AddChild(bitmap_view);
bitmap_view->PushState();
bitmap_view->SetDrawingMode(B_OP_ALPHA);
bitmap_view->SetHighColor(ViewColor());
bitmap_view->FillRect(Bounds());
bitmap_view->SetHighColor(0, 169, 12, 255);
bitmap_view->FillArc(Bounds(), 0, 360);
bitmap_view->SetHighColor(20, 20, 20, 150);
bitmap_view->StrokeArc(Bounds(), 45, 180);
bitmap_view->SetHighColor(220, 220, 220, 150);
bitmap_view->StrokeArc(Bounds(), 225, 180);
bitmap_view->PopState();
bitmap_view->Sync();
}
if(!is_hidden) window->Show();
}
示例2: fFrame
OffscreenBitmap::OffscreenBitmap(BRect frame, color_space colorSpace)
: fFrame(frame)
, fColorSpace(colorSpace)
, fStatus(B_ERROR)
, fBitmap(NULL)
, fView(NULL)
{
BBitmap *bitmap = new BBitmap(frame, fColorSpace, true);
AutoDelete<BBitmap> _bitmap(bitmap);
if (bitmap == NULL || bitmap->IsValid() == false || bitmap->InitCheck() != B_OK)
return;
BView *view = new BView(frame, "offscreen", B_FOLLOW_ALL, B_WILL_DRAW);
AutoDelete<BView> _view(view);
if (view == NULL)
return;
bitmap->Lock();
bitmap->AddChild(view);
// bitmap is locked during the life time of this object
fBitmap = _bitmap.Release();
fView = _view.Release();
fStatus = B_OK;
}
示例3: 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;
}
示例4: BView
/***********************************************************
* Make disable state picture.
***********************************************************/
BPicture*
HToolbarButton::MakeDisablePicture(BBitmap *in)
{
HToolbar *toolbar = cast_as(Parent(),HToolbar);
BRect buttonRect = toolbar->ButtonRect();
BView *view = new BView(BRect(0,0,buttonRect.Width(),buttonRect.Height())
,"offview",0,0);
BBitmap *bitmap = new BBitmap(view->Bounds(), in->ColorSpace(), true);
BPicture *pict;
bitmap->AddChild(view);
bitmap->Lock();
view->BeginPicture(new BPicture);
view->SetHighColor(bgcolor);
view->FillRect(view->Bounds());
DrawString(view,fName.String(),false,false);
view->SetDrawingMode(B_OP_BLEND);
DrawBitmap(view,in);
pict = view->EndPicture();
bitmap->Unlock();
delete bitmap;
return pict;
}
示例5: view
BBitmap*
PictureView::_CopyPicture(uint8 alpha)
{
bool hasAlpha = alpha != 255;
if (!fPicture)
return NULL;
BRect rect = fPictureRect.OffsetToCopy(B_ORIGIN);
BView view(rect, NULL, B_FOLLOW_NONE, B_WILL_DRAW);
BBitmap* bitmap = new(nothrow) BBitmap(rect, hasAlpha ? B_RGBA32
: fPicture->ColorSpace(), true);
if (bitmap == NULL || !bitmap->IsValid()) {
delete bitmap;
return NULL;
}
if (bitmap->Lock()) {
bitmap->AddChild(&view);
if (hasAlpha) {
view.SetHighColor(0, 0, 0, 0);
view.FillRect(rect);
view.SetDrawingMode(B_OP_ALPHA);
view.SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_COMPOSITE);
view.SetHighColor(0, 0, 0, alpha);
}
view.DrawBitmap(fPicture, fPicture->Bounds().OffsetToCopy(B_ORIGIN),
rect, B_FILTER_BITMAP_BILINEAR);
view.Sync();
bitmap->RemoveChild(&view);
bitmap->Unlock();
}
return bitmap;
}
示例6: _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;
}
示例7: 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;
}
示例8: BBitmap
static BBitmap*
MakeActuatorBitmap(bool lit)
{
BBitmap* map = new BBitmap(ICON_BITMAP_RECT, ICON_BITMAP_SPACE, true);
const rgb_color yellow = {255, 255, 0};
const rgb_color red = {200, 200, 200};
const rgb_color black = {0, 0, 0};
const BPoint points[10] = {
BPoint(8, 0), BPoint(9.8, 5.8), BPoint(16, 5.8),
BPoint(11, 9.0), BPoint(13, 16), BPoint(8, 11),
BPoint(3, 16), BPoint(5, 9.0), BPoint(0, 5.8),
BPoint(6.2, 5.8) };
BView* view = new BView(BRect(0, 0, 16, 16), NULL, B_FOLLOW_ALL_SIDES, 0L);
map->AddChild(view);
map->Lock();
view->SetHighColor(B_TRANSPARENT_32_BIT);
view->FillRect(ICON_BITMAP_RECT);
view->SetHighColor(lit ? yellow : red);
view->FillPolygon(points, 10);
view->SetHighColor(black);
view->StrokePolygon(points, 10);
map->Unlock();
map->RemoveChild(view);
delete view;
return map;
}
示例9: rect
HSPictureButton::HSPictureButton(BRect frame, BBitmap* off, BBitmap* on,
BMessage* message, const char* helpMessage, const char* longHelpMessage,
uint32 behavior, uint32 mode, uint32 flags)
: BPictureButton(frame, "?", NULL, NULL, message, behavior, mode, flags)
, fLongHelpMessage(longHelpMessage)
{
if (helpMessage)
SetToolTip(helpMessage);
BRect rect(0, 0, 0, 0);
BBitmap* offScreen = new BBitmap(rect, B_RGB_32_BIT, true);
BView* offView = new BView(rect, "", B_FOLLOW_ALL, 0);
offScreen->AddChild(offView);
offScreen->Lock();
offView->SetHighColor(255, 0, 0);
offView->SetLowColor(0, 0, 120);
offView->SetDrawingMode(B_OP_COPY);
offView->BeginPicture(new BPicture());
offView->DrawBitmap(on, BPoint(0, 0));
SetEnabledOn(offView->EndPicture());
offView->BeginPicture(new BPicture());
offView->DrawBitmap(off, BPoint(0, 0));
SetEnabledOff(offView->EndPicture());
offScreen->Unlock();
delete offScreen;
}
示例10: 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;
}
示例11: 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
示例12: 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();
}
}
示例13: 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;
}
示例14: rect
static cairo_surface_t *
_cairo_beos_surface_create_similar (void *abstract_surface,
cairo_content_t content,
int width,
int height)
{
fprintf(stderr, "Creating similar\n");
cairo_beos_surface_t *surface = reinterpret_cast<cairo_beos_surface_t*>(
abstract_surface);
if (width <= 0)
width = 1;
if (height <= 0)
height = 1;
BRect rect(0.0, 0.0, width - 1, height - 1);
BBitmap* bmp;
switch (content) {
case CAIRO_CONTENT_ALPHA:
// Can't support this natively
return _cairo_image_surface_create_with_content(content, width,
height);
case CAIRO_CONTENT_COLOR_ALPHA:
bmp = new BBitmap(rect, B_RGBA32, true);
break;
case CAIRO_CONTENT_COLOR:
// Match the color depth
if (surface->bitmap) {
color_space space = surface->bitmap->ColorSpace();
// No alpha was requested -> make sure not to return
// a surface with alpha
if (space == B_RGBA32)
space = B_RGB32;
if (space == B_RGBA15)
space = B_RGB15;
bmp = new BBitmap(rect, space, true);
} else {
BScreen scr(surface->view->Window());
color_space space = B_RGB32;
if (scr.IsValid())
space = scr.ColorSpace();
bmp = new BBitmap(rect, space, true);
}
break;
default:
assert(0);
return NULL;
};
BView* view = new BView(rect, "Cairo bitmap view", B_FOLLOW_ALL_SIDES, 0);
bmp->AddChild(view);
return _cairo_beos_surface_create_internal(view, bmp, true);
}
示例15: 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;
}