本文整理汇总了C++中BView::StrokeRect方法的典型用法代码示例。如果您正苦于以下问题:C++ BView::StrokeRect方法的具体用法?C++ BView::StrokeRect怎么用?C++ BView::StrokeRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BView
的用法示例。
在下文中一共展示了BView::StrokeRect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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
示例4: 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;
}
示例5: string
bool
ClipView::InitiateDrag(BPoint point, int32 index, bool wasSelected)
{
ClipItem* sItem = dynamic_cast<ClipItem *> (ItemAt(index));
if (sItem == NULL)
return false;
BString string(sItem->GetClip());
BMessage message(FAV_ADD);
message.AddData("text/plain", B_MIME_TYPE, string, string.Length());
message.AddPointer("clip", sItem);
BRect dragRect(0.0f, 0.0f, Bounds().Width(), sItem->Height());
BBitmap* dragBitmap = new BBitmap(dragRect, B_RGB32, true);
if (dragBitmap->IsValid()) {
BView* view = new BView(dragBitmap->Bounds(), "helper", B_FOLLOW_NONE,
B_WILL_DRAW);
dragBitmap->AddChild(view);
dragBitmap->Lock();
sItem->DrawItem(view, dragRect);
view->SetHighColor(0, 0, 0, 255);
view->StrokeRect(view->Bounds());
view->Sync();
dragBitmap->Unlock();
} else {
delete dragBitmap;
dragBitmap = NULL;
}
if (dragBitmap != NULL)
DragMessage(&message, dragBitmap, B_OP_ALPHA, BPoint(0.0, 0.0));
else
DragMessage(&message, dragRect.OffsetToCopy(point), this);
return true;
}
示例6: ceilf
/*! \function CategoryMenuItem::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 color,
BBitmap* toChange )
{
BBitmap* toReturn = NULL; //!< This is the value to be returned.
BRect tempRect;
float width, height, squareSide;
// Get size of the square
this->GetContentSize( &width, &height );
squareSide = ceilf( height ) - 2;
// Compare submitted bitmap to calculated size
if ( toChange )
{
tempRect = toChange->Bounds();
if ( ( tempRect.Width() != squareSide ) ||
( tempRect.Height() != squareSide ) )
{
// Dimensions don't match - need to delete the bitmap and reallocate it
delete toChange;
tempRect.Set( 0, 0, squareSide, squareSide );
toChange = new BBitmap( tempRect, B_RGB32, true );
if ( !toChange )
{
/* Panic! */
exit(1);
}
toReturn = toChange;
}
else
{
/*! \note Note about color spaces
* Actually, even if the dimensions are correct, the existing
* BBitmap may be not suitable due to incorrect color space.
* However, BBitmap may change the color space on its own, (and
* probably will, since there's no much sense in having 32 bits
* per pixel for bitmap with only 2 colors - black for the frame
* and Category's color for the inside). Therefore, color space is
* not checked. It's assumed that existing color space is good enough.
*/
// Dimensions match, color space is not checked - continuing
toReturn = toChange;
}
}
else // No bitmap is submitted
{
toReturn = new BBitmap( tempRect, B_RGB32, true );
if ( !toReturn )
{
/* Panic! */
exit(1);
}
}
/* Here toReturn is already set. */
// Add the drawing view to the bitmap
tempRect.Set( 0, 0, squareSide, squareSide );
BView* drawing = new BView (tempRect,
"Drawer",
B_FOLLOW_LEFT | B_FOLLOW_TOP,
B_WILL_DRAW);
if (!drawing || !toReturn) {
/* Panic! */
return NULL;
}
toReturn->AddChild(drawing);
if (toReturn->Lock()) {
// Clean the area
drawing->SetHighColor( ui_color( B_MENU_BACKGROUND_COLOR ) );
drawing->FillRect( tempRect );
// Draw the black square
drawing->SetHighColor( ui_color( B_MENU_ITEM_TEXT_COLOR ) );
drawing->SetPenSize( 1 );
drawing->StrokeRect( tempRect );
// Fill the inside of the square
drawing->SetHighColor( color );
drawing->FillRect( tempRect.InsetBySelf( 1, 1 ) );
// Flush the actions to BBitmap
drawing->Sync();
toReturn->Unlock();
}
toReturn->RemoveChild( drawing );
//.........这里部分代码省略.........
示例7: AttribView
AttribRect::AttribRect ()
: AttribView (BRect (0, 0, 148, 90), lstring (31, "Rectangles"))
{
SetViewColor (LightGrey);
lSlid = new Slider (BRect (8, 8, 140, 26), 60, lstring (310, "Pen Size"), 1, 50, 1, new BMessage ('ALpc'));
AddChild (lSlid);
fType = RECT_OUTFILL;
fPenSize = 1;
BBox *type = new BBox (BRect (18, 32, 130, 82), "type");
type->SetLabel (lstring (311, "Type"));
AddChild (type);
BRect shape = BRect (3, 5, 27, 25);
BWindow *picWindow = new BWindow (BRect (0, 0, 100, 100), "Temp Pic Window", B_BORDERED_WINDOW, uint32 (NULL), uint32 (NULL));
BView *bg = new BView (BRect (0, 0, 100, 100), "Temp Pic View", uint32 (NULL), uint32 (NULL));
picWindow->AddChild (bg);
BPicture *p10;
bg->BeginPicture (new BPicture);
bg->SetLowColor (LightGrey);
bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW);
bg->SetLowColor (White);
bg->FillRect (shape, B_SOLID_LOW);
bg->StrokeRect (shape);
p10 = bg->EndPicture();
BPicture *p20;
bg->BeginPicture (new BPicture);
bg->SetLowColor (LightGrey);
bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW);
bg->SetHighColor (Black);
bg->SetLowColor (White);
bg->FillRect (shape, B_SOLID_LOW);
p20 = bg->EndPicture();
BPicture *p30;
bg->BeginPicture (new BPicture);
bg->SetLowColor (LightGrey);
bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW);
bg->SetHighColor (Black);
bg->SetLowColor (White);
bg->StrokeRect (shape);
p30 = bg->EndPicture();
BPicture *p11;
bg->BeginPicture (new BPicture);
bg->SetLowColor (DarkGrey);
bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW);
bg->SetHighColor (Black);
bg->SetLowColor (White);
bg->FillRect (shape, B_SOLID_LOW);
bg->StrokeRect (shape);
p11 = bg->EndPicture();
BPicture *p21;
bg->BeginPicture (new BPicture);
bg->SetLowColor (DarkGrey);
bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW);
bg->SetHighColor (Black);
bg->SetLowColor (White);
bg->FillRect (shape, B_SOLID_LOW);
p21 = bg->EndPicture();
BPicture *p31;
bg->BeginPicture (new BPicture);
bg->SetLowColor (DarkGrey);
bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW);
bg->SetHighColor (Black);
bg->SetLowColor (White);
bg->StrokeRect (shape);
p31 = bg->EndPicture();
SetViewColor (LightGrey);
delete picWindow;
pT1 = new BPictureButton (BRect (4, 15, 34, 45), "APVt1", p10, p11, new BMessage ('pvT1'), B_TWO_STATE_BUTTON);
pT2 = new BPictureButton (BRect (40, 15, 70, 45), "APVt2", p20, p21, new BMessage ('pvT2'), B_TWO_STATE_BUTTON);
pT3 = new BPictureButton (BRect (76, 15, 106, 45), "APVt3", p30, p31, new BMessage ('pvT3'), B_TWO_STATE_BUTTON);
type->AddChild (pT1);
type->AddChild (pT2);
type->AddChild (pT3);
pT1->SetValue (B_CONTROL_ON);
fCurrentProperty = 0;
}
示例8: cursor
// MouseMoved
void
ObjectView::MouseMoved(BPoint where, uint32 transit,
const BMessage* dragMessage)
{
// BRect dirty(where, where);
// dirty.InsetBy(-10, -10);
// Invalidate(dirty);
if (dragMessage) {
//printf("ObjectView::MouseMoved(BPoint(%.1f, %.1f)) - DRAG MESSAGE\n", where.x, where.y);
//Window()->CurrentMessage()->PrintToStream();
} else {
//printf("ObjectView::MouseMoved(BPoint(%.1f, %.1f))\n", where.x, where.y);
}
if (fScrolling) {
BCursor cursor(kGrabCursor);
SetViewCursor(&cursor);
BPoint offset = fLastMousePos - where;
ScrollBy(offset.x, offset.y);
fLastMousePos = where + offset;
} else if (fInitiatingDrag) {
BPoint offset = fLastMousePos - where;
if (sqrtf(offset.x * offset.x + offset.y * offset.y) > 5.0) {
BMessage newDragMessage('drag');
BBitmap* dragBitmap = new BBitmap(BRect(0, 0, 40, 40), B_RGBA32,
true);
if (dragBitmap->Lock()) {
BView* helper = new BView(dragBitmap->Bounds(),
"offscreen view", B_FOLLOW_ALL, B_WILL_DRAW);
dragBitmap->AddChild(helper);
helper->SetDrawingMode(B_OP_ALPHA);
helper->SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_COMPOSITE);
BRect r(helper->Bounds());
helper->SetHighColor(0, 0, 0, 128);
helper->StrokeRect(r);
helper->SetHighColor(200, 200, 200, 100);
r.InsetBy(1, 1);
helper->FillRect(r);
helper->SetHighColor(0, 0, 0, 255);
const char* text = B_TRANSLATE("Test");
float pos = (r.Width() - helper->StringWidth(text)) / 2;
helper->DrawString(text, BPoint(pos, 25));
helper->Sync();
}
DragMessage(&newDragMessage, dragBitmap, B_OP_ALPHA, B_ORIGIN,
this);
fInitiatingDrag = false;
}
} else {
BCursor cursor(kMoveCursor);
SetViewCursor(&cursor);
if (fState && fState->IsTracking()) {
BRect before = fState->Bounds();
fState->MouseMoved(where);
BRect after = fState->Bounds();
BRect invalid(before | after);
Invalidate(invalid);
}
}
// SetViewCursor();
}
示例9: reply
//.........这里部分代码省略.........
BPoint points[numPoints];
for (int32 i = 0; i < numPoints; i++)
message.Read(points[i]);
if (code == RP_STROKE_POLYGON) {
offscreen->StrokePolygon(points, numPoints, bounds, closed,
pattern);
bounds.InsetBy(-penSize, -penSize);
} else if (code == RP_FILL_POLYGON)
offscreen->FillPolygon(points, numPoints, bounds, pattern);
else {
BGradient *gradient;
if (message.ReadGradient(&gradient) != B_OK)
continue;
offscreen->FillPolygon(points, numPoints, bounds,
*gradient);
delete gradient;
}
invalidRegion.Include(bounds);
break;
}
case RP_STROKE_RECT:
case RP_FILL_RECT:
case RP_FILL_RECT_GRADIENT:
{
BRect rect;
if (message.Read(rect) != B_OK)
continue;
if (code == RP_STROKE_RECT) {
offscreen->StrokeRect(rect, pattern);
rect.InsetBy(-penSize, -penSize);
} else if (code == RP_FILL_RECT)
offscreen->FillRect(rect, pattern);
else {
BGradient *gradient;
if (message.ReadGradient(&gradient) != B_OK)
continue;
offscreen->FillRect(rect, *gradient);
delete gradient;
}
invalidRegion.Include(rect);
break;
}
case RP_STROKE_ROUND_RECT:
case RP_FILL_ROUND_RECT:
case RP_FILL_ROUND_RECT_GRADIENT:
{
BRect rect;
float xRadius, yRadius;
message.Read(rect);
message.Read(xRadius);
if (message.Read(yRadius) != B_OK)
continue;
if (code == RP_STROKE_ROUND_RECT) {
offscreen->StrokeRoundRect(rect, xRadius, yRadius,
pattern);
rect.InsetBy(-penSize, -penSize);
示例10: KeyDown
void MonthWindowView::KeyDown(const char *bytes, int32 numBytes)
{
switch(bytes[0])
{
case B_TAB:
{
Bmp->Lock();
switch(which_focused)
{
case 0: // months
{
BmpView->SetHighColor(VIEW_COLOR);
BmpView->StrokeLine(BPoint(monthMStringView[0]->Frame().left,
monthMStringView[0]->Frame().bottom+1),
BPoint(monthMStringView[1]->Frame().right,
monthMStringView[1]->Frame().bottom+1));
BmpView->SetHighColor(0,0,0);
break;
}
case 1: // years
{
BmpView->SetHighColor(VIEW_COLOR);
BmpView->StrokeLine(BPoint(yearMStringView[0]->Frame().left,
yearMStringView[0]->Frame().bottom+1),
BPoint(yearMStringView[1]->Frame().right,
yearMStringView[1]->Frame().bottom+1));
BmpView->SetHighColor(0,0,0);
break;
}
case 2: // days of month
{
BmpView->SetHighColor(NOACTIVE_COLOR);
BmpView->StrokeRect(cursor);
BmpView->SetHighColor(0,0,0);
break;
}
case 3: // today
{
BmpView->SetHighColor(VIEW_COLOR);
BmpView->StrokeLine(BPoint(todayStringView->Frame().left,
todayStringView->Frame().bottom+1),
BPoint(todayStringView->Frame().right,
todayStringView->Frame().bottom+1));
BmpView->SetHighColor(0,0,0);
break;
}
}
// changing which_focused
if(modifiers() & B_SHIFT_KEY)
{
if(which_focused==0)
which_focused=3;
else which_focused--;
}
else // simply Tab
{
if(which_focused==3)
which_focused=0;
else which_focused++;
}
// drawing with new which_focused
switch(which_focused)
{
case 0: // months
{
BmpView->SetHighColor(ACTIVE_COLOR);
BmpView->StrokeLine(BPoint(monthMStringView[0]->Frame().left,
monthMStringView[0]->Frame().bottom+1),
BPoint(monthMStringView[1]->Frame().right,
monthMStringView[1]->Frame().bottom+1));
BmpView->SetHighColor(0,0,0);
break;
}
case 1: // years
{
BmpView->SetHighColor(ACTIVE_COLOR);
BmpView->StrokeLine(BPoint(yearMStringView[0]->Frame().left,
yearMStringView[0]->Frame().bottom+1),
BPoint(yearMStringView[1]->Frame().right,
yearMStringView[1]->Frame().bottom+1));
BmpView->SetHighColor(0,0,0);
break;
}
case 2: // days of month
{
BmpView->SetHighColor(ACTIVE_COLOR);
BmpView->StrokeRect(cursor);
BmpView->SetHighColor(0,0,0);
break;
}
case 3: // today
{
BmpView->SetHighColor(ACTIVE_COLOR);
BmpView->StrokeLine(BPoint(todayStringView->Frame().left,
todayStringView->Frame().bottom+1),
BPoint(todayStringView->Frame().right,
todayStringView->Frame().bottom+1));
BmpView->SetHighColor(0,0,0);
//.........这里部分代码省略.........
示例11: DrawMonth
void MonthWindowView::DrawMonth()
{
Bmp->Lock();
float y=yearStringView->Frame().bottom+h_cell;
float x=0;
if(NewMonth)
{
BmpView->SetHighColor(VIEW_COLOR);
BmpView->FillRect(BRect(0,y+1,
BmpView->Bounds().right,todayStringView->Frame().top-6));
BmpView->SetHighColor(0,0,0,0);
NewMonth=false;
}
int byear=cyear; // base year
if(tyear<byear) byear=tyear;
int day1=0, m=0, k=byear;
while(k<cyear)
{
day1++;
if(k%4==0) // leap year?
if((k%100!=0) || (k%400==0)) day1++; // yes
k++;
}
while(++m<cmonth)
{
day1+=(monthDays[m-1]-28);
if(m==2) if((cyear%4)==0) if((cyear%100!=0) || (cyear%400==0)) day1++;
}
day1++; // day1 is number of 1st day of chosen month in chosen year
day1=day1%7;
int day2=0;
m=0;
k=byear;
while(k<tyear)
{
day2++;
if((k%4)==0) if((k%100!=0) || (k%400==0)) day2++;
k++;
}
while(++m<tmonth)
{
day2+=(monthDays[m-1]-28);
if(m==2) if((tyear%4)==0) if((tyear%100!=0) || (tyear%400==0)) day2++;
}
day2+=tday; // day2 - number of today's day in today's year
day2=day2%7;
k=(twday==0) ? 6 : twday-1;
k=k-day2+day1;
while(k<0) k+=7;
k=k%7;
cwday1=k;
x=w_cell*k+1;
y+=h_cell;
int qu_days=monthDays[cmonth-1]; // quantity of days in month
if(cmonth==2) if(cyear%4==0) if((cyear%100!=0) || (cyear%400==0)) qu_days=29;
BString s;
int t=0;
while(t<qu_days)
{
t++;
s<<t;
if(cyear==tyear) if(cmonth==tmonth) if(t==tday) BmpView->SetHighColor(200,0,0,0);
BmpView->DrawString(s.String(),BPoint(x+(w_cell-StringWidth(s.String()))/2,y));
if(cyear==tyear) if(cmonth==tmonth) if(t==tday) BmpView->SetHighColor(0,0,0,0);
if(t==cday)
{
cwday=k;
if(which_focused==2) BmpView->SetHighColor(ACTIVE_COLOR);
else BmpView->SetHighColor(NOACTIVE_COLOR);
cursor.Set(x,y-h_cell+5,x+w_cell-1,y+4);
BmpView->StrokeRect(cursor);
BmpView->SetHighColor(0,0,0,0);
}
x+=w_cell;
k++;
s.SetTo("");
if(k==7)
{
k=0;
y+=h_cell;
x=1;
//.........这里部分代码省略.........
示例12: message
bool
AudioListView::InitiateDrag(BPoint point, int32 dragIndex, bool)
{
BListItem* item = ItemAt(CurrentSelection(0));
if (item == NULL) {
// workaround for a timing problem (see Locale prefs)
Select(dragIndex);
item = ItemAt(dragIndex);
}
if (item == NULL)
return false;
// create drag message
BMessage message(kDraggedItem);
for (int32 i = 0;; i++) {
int32 index = CurrentSelection(i);
if (index < 0)
break;
message.AddPointer("trackitem", ItemAt(CurrentSelection(i)));
}
// figure out drag rect
BRect dragRect(0.0, 0.0, Bounds().Width(), -1.0);
// figure out, how many items fit into our bitmap
bool fade = false;
for (int32 i = 0; message.FindPointer("trackitem", i,
reinterpret_cast<void**>(&item)) == B_OK; i++) {
dragRect.bottom += ceilf(item->Height()) + 1.0;
if (dragRect.Height() > MAX_DRAG_HEIGHT) {
dragRect.bottom = MAX_DRAG_HEIGHT;
fade = true;
break;
}
}
BBitmap* dragBitmap = new BBitmap(dragRect, B_RGB32, true);
if (dragBitmap->IsValid()) {
BView* view = new BView(dragBitmap->Bounds(), "helper", B_FOLLOW_NONE,
B_WILL_DRAW);
dragBitmap->AddChild(view);
dragBitmap->Lock();
BRect itemBounds(dragRect) ;
itemBounds.bottom = 0.0;
// let all selected items, that fit into our drag_bitmap, draw
for (int32 i = 0; message.FindPointer("trackitem", i,
reinterpret_cast<void**>(&item)) == B_OK; i++) {
AudioListItem* item;
message.FindPointer("trackitem", i,
reinterpret_cast<void**>(&item));
itemBounds.bottom = itemBounds.top + ceilf(item->Height());
if (itemBounds.bottom > dragRect.bottom)
itemBounds.bottom = dragRect.bottom;
item->DrawItem(view, itemBounds);
itemBounds.top = itemBounds.bottom + 1.0;
}
// make a black frame around the edge
view->SetHighColor(0, 0, 0, 255);
view->StrokeRect(view->Bounds());
view->Sync();
uint8* bits = (uint8*)dragBitmap->Bits();
int32 height = (int32)dragBitmap->Bounds().Height() + 1;
int32 width = (int32)dragBitmap->Bounds().Width() + 1;
int32 bpr = dragBitmap->BytesPerRow();
if (fade) {
for (int32 y = 0; y < height - ALPHA / 2; y++, bits += bpr) {
uint8* line = bits + 3;
for (uint8* end = line + 4 * width; line < end; line += 4)
*line = ALPHA;
}
for (int32 y = height - ALPHA / 2; y < height;
y++, bits += bpr) {
uint8* line = bits + 3;
for (uint8* end = line + 4 * width; line < end; line += 4)
*line = (height - y) << 1;
}
} else {
for (int32 y = 0; y < height; y++, bits += bpr) {
uint8* line = bits + 3;
for (uint8* end = line + 4 * width; line < end; line += 4)
*line = ALPHA;
}
}
dragBitmap->Unlock();
} else {
delete dragBitmap;
dragBitmap = NULL;
}
if (dragBitmap != NULL)
DragMessage(&message, dragBitmap, B_OP_ALPHA, BPoint(0.0, 0.0));
else
DragMessage(&message, dragRect.OffsetToCopy(point), this);
return true;
//.........这里部分代码省略.........
示例13: if
//.........这里部分代码省略.........
MyButton * pholdDemoMyButton = new MyButton( "demoButton",
myPrefs->DemoButtonLabel,
DEMOBUTTONMSG,
pholdDemoLayoutMatrix);
kindDemo = KIND_MYBUTTON;
pholdDemo = (void *)pholdDemoMyButton;
}
break;
case SPECIFIC_COLOR_PICTURE:
{
BPicture * pOnPicture;
BPicture * pOnDisabledPicture;
BPicture * pOffPicture;
BPicture * pOffDisabledPicture;
BWindow * bWindow = new BWindow( BRect(0, 0, 32, 32), //manditory for BPicture
NULL,
B_DOCUMENT_WINDOW,
0);
BView * bView = new BView( BRect(0, 0, 32, 32),
NULL,
B_FOLLOW_NONE,
0);
// BWindow bWindow( BRect(0, 0, 32, 32), //manditory for BPicture
// NULL,
// B_DOCUMENT_WINDOW,
// 0);
// BView bView( BRect(0, 0, 32, 32),
// NULL,
// B_FOLLOW_NONE,
// 0);
bWindow->AddChild(bView);
bView->BeginPicture(new BPicture);
bView->MoveTo(5, 5);
bView->StrokeRect(BRect(0,0,8,8));
pOffPicture = bView->EndPicture();
bView->BeginPicture(new BPicture);
bView->MoveTo(10, 5);
bView->StrokeRect(BRect(0,0,10,15));
pOnPicture = bView->EndPicture();
bView->BeginPicture(new BPicture);
bView->MoveTo(2, 5);
bView->FillRect(BRect(0,0,22,20));
pOffDisabledPicture = bView->EndPicture();
bView->BeginPicture(new BPicture);
bView->MoveTo(1, 5);
bView->FillRect(BRect(0,0,6,15));
pOnDisabledPicture = bView->EndPicture();
//bView.RemoveSelf();
bWindow->Run();
bWindow->PostMessage(B_QUIT_REQUESTED);
MyPictureButton * pholdDemoMyPictureButton = new MyPictureButton( BRect(0, 0, 32, 32),
"DemoPictureButton",
pOffPicture,
pOnPicture,
pOffDisabledPicture,
pOnDisabledPicture,
DEMOPICTUREBUTTONMSG,
B_TWO_STATE_BUTTON,//B_ONE_STATE_BUTTON
pholdDemoLayoutMatrix);
kindDemo = KIND_MYPICTUREBUTTON;
pholdDemo = (void *)pholdDemoMyPictureButton;
}
break;
示例14: MouseMoved
void ColorMenu::MouseMoved (BPoint point, uint32 transit, const BMessage *msg)
{
msg = msg;
uint32 buttons;
if (!Parent())
return;
// printf ("("); fflush (stdout);
GetMouse (&point, &buttons);
// printf (")"); fflush (stdout);
if (transit == B_EXITED_VIEW && buttons) // Do the tear off thing!
{
#if defined (EASTER_EGG_SFX)
extern bool EasterEgg;
if (modifiers() & B_SHIFT_KEY && EasterEgg)
{
extern EffectsPlayer *easterEgg;
easterEgg->StartEffect();
}
#endif
BMessage *tearmsg = new BMessage ('tear');
BBitmap *dragmap = new BBitmap (Bounds(), B_RGBA32, true);
dragmap->Lock();
BView *dragview = new BView (Bounds(), "temp dragmap view", B_FOLLOW_ALL, B_WILL_DRAW);
dragmap->AddChild (dragview);
//dragview->SetLowColor (LightGrey);
//dragview->FillRect (Bounds(), B_SOLID_LOW);
for (int i = 0; i < MAX_COLORS; i++)
{
dragview->SetHighColor (items[i]->getColor());
dragview->FillRect (items[i]->Frame());
dragview->Sync();
}
dragview->SetHighColor (DarkGrey);
dragview->StrokeRect (Bounds());
dragmap->RemoveChild (dragview);
bgra_pixel *bits = (bgra_pixel *) dragmap->Bits();
for (bgra_pixel p = 0; p < dragmap->BitsLength()/4; p++)
{
bgra_pixel pixel = *bits;
*bits++ = (pixel & COLOR_MASK) | (127 << ALPHA_BPOS);
}
dragmap->Unlock();
delete dragview;
DragMessage (tearmsg, dragmap, B_OP_ALPHA, B_ORIGIN);
delete tearmsg;
BRect place = Bounds();
// Send a fake Esc keydown to the popup
char kbuf[2];
BMessage kmsg (B_KEY_DOWN);
kmsg.AddInt64 ("when", system_time());
kmsg.AddInt32 ("modifiers", 0);
kmsg.AddInt32 ("key", B_ESCAPE);
kmsg.AddInt8 ("byte", B_ESCAPE);
kbuf[0] = B_ESCAPE;
kbuf[1] = '\0';
kmsg.AddString ("bytes", kbuf);
Window()->PostMessage (&kmsg, this);
// This makes the original popup go away.
// We can't use Hide() since that crashes.
colorTearInfo *tearInfo = new colorTearInfo (place, this, parent);
resume_thread (spawn_thread (color_tear_drag, "Menu Tear Thread", B_NORMAL_PRIORITY, tearInfo));
}
}
示例15: dragRect
bool
LanguageListView::InitiateDrag(BPoint point, int32 dragIndex,
bool /*wasSelected*/)
{
if (fDragMessage == NULL)
return false;
BListItem* item = ItemAt(CurrentSelection(0));
if (item == NULL) {
// workaround for a timing problem
// TODO: this should support extending the selection
item = ItemAt(dragIndex);
Select(dragIndex);
}
if (item == NULL)
return false;
// create drag message
BMessage message = *fDragMessage;
message.AddPointer("listview", this);
for (int32 i = 0;; i++) {
int32 index = CurrentSelection(i);
if (index < 0)
break;
message.AddInt32("index", index);
}
// figure out drag rect
BRect dragRect(0.0, 0.0, Bounds().Width(), -1.0);
int32 numItems = 0;
bool fade = false;
// figure out, how many items fit into our bitmap
for (int32 i = 0, index; message.FindInt32("index", i, &index) == B_OK;
i++) {
BListItem* item = ItemAt(index);
if (item == NULL)
break;
dragRect.bottom += ceilf(item->Height()) + 1.0;
numItems++;
if (dragRect.Height() > MAX_DRAG_HEIGHT) {
dragRect.bottom = MAX_DRAG_HEIGHT;
fade = true;
break;
}
}
BBitmap* dragBitmap = new BBitmap(dragRect, B_RGB32, true);
if (dragBitmap->IsValid()) {
BView* view = new BView(dragBitmap->Bounds(), "helper", B_FOLLOW_NONE,
B_WILL_DRAW);
dragBitmap->AddChild(view);
dragBitmap->Lock();
BRect itemBounds(dragRect) ;
itemBounds.bottom = 0.0;
// let all selected items, that fit into our drag_bitmap, draw
for (int32 i = 0; i < numItems; i++) {
int32 index = message.FindInt32("index", i);
LanguageListItem* item
= static_cast<LanguageListItem*>(ItemAt(index));
itemBounds.bottom = itemBounds.top + ceilf(item->Height());
if (itemBounds.bottom > dragRect.bottom)
itemBounds.bottom = dragRect.bottom;
item->DrawItem(view, itemBounds);
itemBounds.top = itemBounds.bottom + 1.0;
}
// make a black frame arround the edge
view->SetHighColor(0, 0, 0, 255);
view->StrokeRect(view->Bounds());
view->Sync();
uint8* bits = (uint8*)dragBitmap->Bits();
int32 height = (int32)dragBitmap->Bounds().Height() + 1;
int32 width = (int32)dragBitmap->Bounds().Width() + 1;
int32 bpr = dragBitmap->BytesPerRow();
if (fade) {
for (int32 y = 0; y < height - ALPHA / 2; y++, bits += bpr) {
uint8* line = bits + 3;
for (uint8* end = line + 4 * width; line < end; line += 4)
*line = ALPHA;
}
for (int32 y = height - ALPHA / 2; y < height;
y++, bits += bpr) {
uint8* line = bits + 3;
for (uint8* end = line + 4 * width; line < end; line += 4)
*line = (height - y) << 1;
}
} else {
for (int32 y = 0; y < height; y++, bits += bpr) {
uint8* line = bits + 3;
for (uint8* end = line + 4 * width; line < end; line += 4)
*line = ALPHA;
}
}
//.........这里部分代码省略.........