本文整理汇总了C++中BView::SetHighColor方法的典型用法代码示例。如果您正苦于以下问题:C++ BView::SetHighColor方法的具体用法?C++ BView::SetHighColor怎么用?C++ BView::SetHighColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BView
的用法示例。
在下文中一共展示了BView::SetHighColor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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);
}
示例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 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;
}
示例5: 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;
}
示例6: 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);
}
}
示例7: 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
示例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();
}
}
示例9: bounds
void
IconSpewer::DrawSomeOld()
{
#if 0
if (!oldIconCacheInited)
BIconCache::InitIconCaches();
target->Lock();
target->SetTitle("old cache");
BView* view = target->FindView("iconView");
ASSERT(view);
BRect bounds(target->Bounds());
view->SetHighColor(Color(255, 255, 255));
view->FillRect(bounds);
view->SetHighColor(Color(0, 0, 0));
char buffer[256];
if (cycleTime) {
sprintf(buffer, "last cycle time %Ld ms", cycleTime/1000);
view->DrawString(buffer, BPoint(20, bounds.bottom - 20));
}
if (numDrawn) {
sprintf(buffer, "average draw time %Ld us per icon",
watch.ElapsedTime() / numDrawn);
view->DrawString(buffer, BPoint(20, bounds.bottom - 30));
}
sprintf(buffer, "directory: %s", currentPath.Path());
view->DrawString(buffer, BPoint(20, bounds.bottom - 40));
target->Unlock();
for (int32 row = 0; row < kRowCount; row++) {
for (int32 column = 0; column < kColumnCount; column++) {
BEntry entry(NextRef());
BModel model(&entry, true);
if (!target->Lock())
return;
if (model.IsDirectory())
entry.GetPath(¤tPath);
BIconCache::LockIconCache();
BIconCache* iconCache
= BIconCache::GetIconCache(&model, kIconSize);
iconCache->Draw(view, BPoint(column * (kIconSize + 2),
row * (kIconSize + 2)), B_NORMAL_ICON, kIconSize, true);
BIconCache::UnlockIconCache();
target->Unlock();
numDrawn++;
}
}
#endif
}
示例10: 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;
}
示例11: 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;
}
示例12: BOutlineListView
TestWindow::TestWindow(BApplication* myApp)
: BWindow(BRect(20,20,100,100),
"Code Profile", B_TITLED_WINDOW, 0)
{
BRect frm = Bounds();
BView* myview = new BView(BRect(),"testView",0,0);
BOutlineListView* olist =
new BOutlineListView(BRect(),"MyList",
B_SINGLE_SELECTION_LIST,B_FOLLOW_NONE);
if( myview && olist ) {
myview->AddChild(olist);
BView* vw = olist;
vw->SetViewColor(0xc0,0xc0,0xc0);
vw->Invalidate();
vw->SetLowColor(0xc0,0xc0,0xc0);
vw->Invalidate();
vw->SetHighColor(0x00,0x00,0x00);
vw->Invalidate();
vw->SetFont(be_bold_font);
this->AddChild(myview);
BRect frm = vw->Frame();
vw->ResizeTo(1,1);
vw->Draw(vw->Bounds());
vw->ResizeToPreferred();
float w=0,h=0;
vw->GetPreferredSize(&w,&h);
printf("Preferred size = %f x %f\n",w,h);
}
string = new BStringView(BRect(0,0,100,20),"String",
"Ready to profile...");
if( string ) {
string->SetViewColor(0xc0,0xc0,0xc0);
this->AddChild(string);
float w=0, h=0;
string->GetPreferredSize(&w,&h);
MoveTo(30,30);
ResizeTo(w,h);
}
BMenuBar* menu = new BMenuBar(BRect(),"MainMenu",B_FOLLOW_NONE);
if( menu ) {
this->AddChild(menu);
float w=0, h=0;
menu->GetPreferredSize(&w,&h);
printf("Preferred Size = (%f,%f)\n",w,h);
menu->SetFont(be_plain_font);
menu->GetPreferredSize(&w,&h);
printf("Preferred Size = (%f,%f)\n",w,h);
menu->SetFont(be_bold_font);
menu->GetPreferredSize(&w,&h);
printf("Preferred Size = (%f,%f)\n",w,h);
menu->SetFont(be_fixed_font);
menu->GetPreferredSize(&w,&h);
printf("Preferred Size = (%f,%f)\n",w,h);
}
}
示例13: 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;
}
示例14: BView
BView *ViewFactory::Create<BView>(BRect rect, const char *name, uint32 resize, uint32 flags) {
BView *view = NULL;
#ifdef __HAIKU__
view = new BView(name, flags & B_SUPPORTS_LAYOUT);
#else
view = new BView(rect, name, resize, flags);
#endif
#if B_BEOS_VERSION > B_BEOS_VERSION_5
view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
view->SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));
view->SetHighColor(ui_color(B_PANEL_TEXT_COLOR));
#else
view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
view->SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));
view->SetHighColor(0, 0, 0, 0);
#endif
return view;
};
示例15: 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();
}