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


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

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


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

示例1: DrawThumb

void APPosSlider::DrawThumb(void)
{
	BRect rect;
	BView *view;

	// Get the frame rectangle of the thumb
	// and the offscreen view
	rect = ThumbFrame();
	view = OffscreenView();

	// Draw the black shadow
	view->SetDrawingMode(B_OP_ALPHA);
	rgb_color c = BeDarkShadow;
	c.alpha = 128;
	view->SetHighColor(c);
	rect.top++;
	rect.left++;
	view->FillEllipse(rect);
	
	// Fill the inside of the thumb
	view->SetDrawingMode(B_OP_COPY);
	view->SetHighColor(BeButtonGrey);
	rect.OffsetBy(-1, -1);
	view->FillEllipse(rect);

	// Draw the dark grey edge
	view->SetHighColor(86, 86, 86, 255); // TODO : use an Haiku define to get that ?
	view->SetPenSize(1.2);
	view->StrokeEllipse(rect);


}
开发者ID:pulkomandy,项目名称:APlayer,代码行数:32,代码来源:APPosSlider.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: BView

/***********************************************************
 * Make down state picture.
 ***********************************************************/
BPicture*
HToolbarButton::MakeDownPicture(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->SetHighColor(BeLightShadow);
	view->FillRect(view->Bounds());
	
	view->BeginPicture(new BPicture); 
	
	DrawString(view,fName.String(),true);
	view->SetDrawingMode(B_OP_MIN); 
	DrawBitmap(view,in,true);
	
	const float height = view->Bounds().Height();
	view->SetDrawingMode(B_OP_OVER);
	view->SetHighColor(BeShadow);
	view->FillRect(BRect(0,0,0,height));
	view->FillRect(BRect(0,0,height,0));
	view->SetHighColor(White);
	view->FillRect(BRect(height-1,0,height-1,height-1));
	view->FillRect(BRect(0,height-1,height-1,height-1));
	
	pict = view->EndPicture();
	bitmap->Unlock();
	delete bitmap;
	return pict;
}
开发者ID:kallisti5,项目名称:libtoolbar,代码行数:38,代码来源:HToolbarButton.cpp

示例4: _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

示例5: rect

/*
 * Make inside state picture.
 */
BPicture*
HToolbarButton::MakeInsidePicture(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->SetDrawingMode(B_OP_ALPHA); 
	view->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);
	view->BeginPicture(new BPicture); 
	
	DrawBitmap(view,in);
	DrawString(view,fName.String());
	
	//view->SetHighColor(White);
	//view->FillRect(BRect(0,0,0,22));
	//view->FillRect(BRect(0,0,22,0));
	//view->SetHighColor(BeShadow);
	//view->FillRect(BRect(21,0,21,21));
	//view->FillRect(BRect(0,21,21,21));
	BRect rect(Bounds());
	view->SetDrawingMode(B_OP_OVER); 
	rect.InsetBy(1,1);
	view->BeginLineArray(5);
	view->AddLine(rect.LeftTop(), rect.LeftBottom(),
			tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_LIGHTEN_MAX_TINT));
	view->AddLine(rect.LeftTop(), rect.RightTop(),
			tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_LIGHTEN_MAX_TINT));
	view->AddLine(rect.LeftBottom(), rect.RightBottom(),
			tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_3_TINT));
	rect.bottom--;
	view->AddLine(rect.LeftBottom(), rect.RightBottom(),
			tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_1_TINT));
	view->AddLine(rect.RightTop(), rect.RightBottom(),
			tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_3_TINT));
	view->EndLineArray();
	
	view->SetHighColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_3_TINT));
	view->StrokeRect(Bounds());
	pict = view->EndPicture();
	bitmap->Unlock();
	delete bitmap;
	return pict;
}
开发者ID:kallisti5,项目名称:libtoolbar,代码行数:51,代码来源:HToolbarButton.cpp

示例6: 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;
}
开发者ID:HaikuArchives,项目名称:ArtPaint,代码行数:32,代码来源:HSPictureButton.cpp

示例7: 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

示例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: 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

示例10: pos

void
EntryMenuItem::DrawContent()
{
	BView* view = Menu();
	BPoint pos(view->PenLocation());

	if (fSmallIcon == NULL) {
		fSmallIcon = LoadIcon(); // load on demand
	}

	view->MovePenBy(kTextIndent, 0);
	BMenuItem::DrawContent();
	
	if (fSmallIcon) {
		view->SetDrawingMode(B_OP_OVER);
		view->DrawBitmap(fSmallIcon, pos);
	}
}
开发者ID:Akujiism,项目名称:BePDF,代码行数:18,代码来源:EntryMenuItem.cpp

示例11: FrameResized

void CounterView::FrameResized (float width, float height)
{
  BRect BitmapRect (0, 0, width, height);
  char  TempString [40];

  m_BndRect = Bounds ();

  m_MovingDotSize = (int) (height / 20);
  if (m_MovingDotSize < 1)
    m_MovingDotSize = 1;
  m_MoveSpeed = m_MovingDotSize / 2.0;
  
  // Resize the offscreen bitmap and its view.

  if (m_BackingBitmap != NULL)
  {
    m_BackingBitmap->RemoveChild (&m_BackingView);
    delete m_BackingBitmap;
    m_BackingBitmap = NULL;
  }

  m_BackingView.ResizeTo (width, height);

  m_BackingBitmap = new BBitmap (BitmapRect, B_RGBA32, true /* Accepts subviews */);
  if (!m_BackingBitmap->IsValid ())
  {
    delete m_BackingBitmap;
    m_BackingBitmap = NULL;
  }
  else
  {
    m_BackingBitmap->AddChild (&m_BackingView);
    m_BackingBitmap->Lock ();
    m_BackingView.SetDrawingMode (B_OP_ALPHA);
    m_BackingView.SetFontSize (height * 0.8);
    sprintf (TempString, "%d", m_CurrentCount);
    m_TextStartPoint.x = width / 2 - m_BackingView.StringWidth (TempString) / 2;
    m_TextStartPoint.y = height / 2 + height * 0.25;
    m_BackingBitmap->Unlock ();
  }
}
开发者ID:kallisti5,项目名称:VNCServer,代码行数:41,代码来源:UserAppMessageMonitor.cpp

示例12: 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

示例13: 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();
}
开发者ID:BackupTheBerlios,项目名称:wxbeos-svn,代码行数:39,代码来源:statbrbeos.cpp

示例14: Read

status_t
CanvasMessage::ReadViewState(BView& view, ::pattern& pattern)
{
	bool subPixelPrecise;
	float penSize, miterLimit;
	drawing_mode drawingMode;
	source_alpha sourceAlpha;
	alpha_function alphaFunction;
	cap_mode capMode;
	join_mode joinMode;
	rgb_color highColor, lowColor;

	Read(penSize);
	Read(subPixelPrecise);
	Read(drawingMode);
	Read(sourceAlpha);
	Read(alphaFunction);
	Read(pattern);
	Read(capMode);
	Read(joinMode);
	Read(miterLimit);
	Read(highColor);
	status_t result = Read(lowColor);
	if (result != B_OK)
		return result;

	uint32 flags = view.Flags() & ~B_SUBPIXEL_PRECISE;
	view.SetFlags(flags | (subPixelPrecise ? B_SUBPIXEL_PRECISE : 0));
	view.SetPenSize(penSize);
	view.SetDrawingMode(drawingMode);
	view.SetBlendingMode(sourceAlpha, alphaFunction);
	view.SetLineMode(capMode, joinMode, miterLimit);
	view.SetHighColor(highColor);
	view.SetLowColor(lowColor);
	return B_OK;
}
开发者ID:SummerSnail2014,项目名称:haiku,代码行数:36,代码来源:CanvasMessage.cpp

示例15: drag

void
KeyboardLayoutView::MouseMoved(BPoint point, uint32 transit,
                               const BMessage* dragMessage)
{
    if (fKeymap == NULL)
        return;

    // prevent dragging for tertiary mouse button
    if ((fButtons & B_TERTIARY_MOUSE_BUTTON) != 0)
        return;

    if (dragMessage != NULL) {
        if (fEditable) {
            _InvalidateKey(fDropTarget);
            fDropPoint = point;

            _EvaluateDropTarget(point);
        }

        return;
    }

    int32 buttons;
    if (Window()->CurrentMessage() == NULL
            || Window()->CurrentMessage()->FindInt32("buttons", &buttons) != B_OK
            || buttons == 0)
        return;

    if (fDragKey == NULL && (fabs(point.x - fClickPoint.x) > 4
                             || fabs(point.y - fClickPoint.y) > 4)) {
        // start dragging
        Key* key = _KeyAt(fClickPoint);
        if (key == NULL)
            return;

        BRect frame = _FrameFor(key);
        BPoint offset = fClickPoint - frame.LeftTop();
        frame.OffsetTo(B_ORIGIN);

        BRect rect = frame;
        rect.right--;
        rect.bottom--;
        BBitmap* bitmap = new BBitmap(rect, B_RGBA32, true);
        bitmap->Lock();

        BView* view = new BView(rect, "drag", B_FOLLOW_NONE, 0);
        bitmap->AddChild(view);

        view->SetHighColor(0, 0, 0, 0);
        view->FillRect(view->Bounds());
        view->SetDrawingMode(B_OP_ALPHA);
        view->SetHighColor(0, 0, 0, 128);
        // set the level of transparency by value
        view->SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_COMPOSITE);
        _DrawKey(view, frame, key, frame, false);

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

        BMessage drag(B_MIME_DATA);
        drag.AddInt32("key", key->code);

        char* string;
        int32 numBytes;
        fKeymap->GetChars(key->code, fModifiers, fDeadKey, &string,
                          &numBytes);
        if (string != NULL) {
            drag.AddData("text/plain", B_MIME_DATA, string, numBytes);
            delete[] string;
        }

        DragMessage(&drag, bitmap, B_OP_ALPHA, offset);
        fDragKey = key;
        fDragModifiers = fModifiers;

        fKeyState[key->code / 8] &= ~(1 << (7 - (key->code & 7)));
        _InvalidateKey(key);
    }
}
开发者ID:naveedasmat,项目名称:haiku,代码行数:79,代码来源:KeyboardLayoutView.cpp


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