本文整理汇总了C++中BRegion类的典型用法代码示例。如果您正苦于以下问题:C++ BRegion类的具体用法?C++ BRegion怎么用?C++ BRegion使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BRegion类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawItemColumn
void APListItemDescription::DrawItemColumn(BView *owner, BRect itemColumnRect, int32 columnIndex, bool complete)
{
BRegion region;
char *strPtr;
// Initialize drawing
owner->SetLowColor(White);
owner->SetDrawingMode(B_OP_COPY);
// Draw the background color
if (complete)
{
owner->SetHighColor(White);
owner->FillRect(itemColumnRect);
}
// Draw the item
region.Include(itemColumnRect);
owner->ConstrainClippingRegion(®ion);
owner->SetHighColor(Black);
owner->DrawString((strPtr = columnText.GetString()), BPoint(itemColumnRect.left + 2.0f, itemColumnRect.top + textOffset));
columnText.FreeBuffer(strPtr);
owner->ConstrainClippingRegion(NULL);
}
示例2: while
BView *BubbleHelper::FindView(BPoint where)
{
BView *winview=NULL;
BWindow *win;
long windex=0;
while((winview==NULL)&&((win=be_app->WindowAt(windex++))!=NULL))
{
if(win!=textwin)
{
// lock with timeout, in case somebody has a non-running window around
// in their app.
if(win->LockWithTimeout(1E6)==B_OK)
{
BRect frame=win->Frame();
if(frame.Contains(where))
{
BPoint winpoint;
winpoint=where-frame.LeftTop();
winview=win->FindView(winpoint);
if(winview)
{
BRegion region;
BPoint newpoint=where;
winview->ConvertFromScreen(&newpoint);
winview->GetClippingRegion(®ion);
if(!region.Contains(newpoint))
winview=0;
}
}
win->Unlock();
}
}
}
return winview;
}
示例3: Draw
virtual void Draw(BRect updateRect)
{
BRegion region;
region.Include(BRect(20, 20, 40, 40));
region.Include(BRect(30, 30, 80, 80));
ConstrainClippingRegion(®ion);
SetHighColor(55, 255, 128, 255);
FillRect(BRect(0, 0, 100, 100));
PushState();
SetOrigin(15, 15);
ConstrainClippingRegion(®ion);
SetHighColor(155, 255, 128, 255);
FillRect(BRect(0, 0, 100, 100));
// ConstrainClippingRegion(NULL);
SetHighColor(0, 0, 0, 255);
StrokeLine(BPoint(2, 2), BPoint(80, 80));
SetHighColor(255, 0, 0, 255);
StrokeLine(BPoint(2, 2), BPoint(4, 2));
PopState();
SetHighColor(0, 0, 0, 255);
StrokeLine(BPoint(4, 2), BPoint(82, 80));
}
示例4: Bounds
void ObjectView::Draw(BRect region)
{
BRect bnd = Bounds();
BRegion regi; regi.Include(region);
ConstrainClippingRegion(®i);
if (isSelected) {
SetDrawingMode(B_OP_OVER);
SetHighColor(black);
FillRect(bnd, B_SOLID_HIGH);
SetViewColor(black);
SetHighColor(color);
} else {
SetDrawingMode(B_OP_OVER);
SetHighColor(color);
FillRect(bnd, B_SOLID_HIGH);
SetViewColor(color);
SetHighColor(black);
}
StrokeRect(bnd, B_SOLID_HIGH);
if (label) {
DrawString(label, labelPoint);
if (container) {
BRect cb = container->Bounds();
int d = (cb.right-cb.left-30);
int llbl;
for ( llbl = labelPoint.x + (1+(((int32)region.left) / d)) * d;
llbl < region.right;
llbl += d) {
DrawString(label, BPoint(llbl,labelPoint.y));
}
}
}
}
示例5: CPPUNIT_ASSERT
void
SimpleTransformTest::TransformRegion()
{
BRegion region;
region.Include(BRect( 5.0, 5.0, 20.0, 20.0));
region.Include(BRect(10.0, 10.0, 30.0, 30.0));
region.Exclude(BRect(10.0, 20.0, 20.0, 25.0));
BRegion reference1 = region;
reference1.OffsetBy(10, 20);
SimpleTransform specimen;
specimen.AddOffset(10.0, 20.0);
specimen.Apply(®ion);
CPPUNIT_ASSERT(region == reference1);
specimen.SetScale(2.5);
BRegion reference2;
reference2.Include(BRect(47.0, 82.0, 87.0, 122.0));
reference2.Include(BRect(60.0, 95.0, 112.0, 147.0));
reference2.Exclude(BRect(60.0, 120.0, 86.0, 134.0));
specimen.Apply(®ion);
CPPUNIT_ASSERT(region == reference2);
}
示例6: DrawItem
void CLVListItem::DrawItem(BView* owner, BRect itemRect, bool complete)
{
BList* DisplayList = &((ColumnListView*)owner)->fColumnDisplayList;
int32 NumberOfColumns = DisplayList->CountItems();
//float PushMax = itemRect.right;
CLVColumn* ThisColumn;
BRect ThisColumnRect = itemRect;
BRegion ClippingRegion;
if(!complete)
owner->GetClippingRegion(&ClippingRegion);
else
ClippingRegion.Set(itemRect);
float LastColumnEnd = -1.0;
//Draw the columns
for(int32 Counter = 0; Counter < NumberOfColumns; Counter++)
{
ThisColumn = (CLVColumn*)DisplayList->ItemAt(Counter);
if(!ThisColumn->IsShown())
continue;
ThisColumnRect.left = ThisColumn->fColumnBegin;
ThisColumnRect.right = LastColumnEnd = ThisColumn->fColumnEnd;
if(ThisColumnRect.right >= ThisColumnRect.left && ClippingRegion.Intersects(ThisColumnRect))
DrawItemColumn(owner, ThisColumnRect, ((ColumnListView*)owner)->fColumnList.IndexOf(ThisColumn),complete);
}
//Fill the area after all the columns (so the select highlight goes all the way across)
ThisColumnRect.left = LastColumnEnd + 1.0;
ThisColumnRect.right = owner->Bounds().right;
if(ThisColumnRect.left <= ThisColumnRect.right && ClippingRegion.Intersects(ThisColumnRect))
DrawItemColumn(owner, ThisColumnRect,-1,complete);
}
示例7: lt
void
DrawState::Transform(BRegion* region) const
{
if (fCombinedScale == 1.0) {
region->OffsetBy(fCombinedOrigin.x, fCombinedOrigin.y);
} else {
// TODO: optimize some more
BRegion converted;
int32 count = region->CountRects();
for (int32 i = 0; i < count; i++) {
BRect r = region->RectAt(i);
BPoint lt(r.LeftTop());
BPoint rb(r.RightBottom());
// offset to bottom right corner of pixel before transformation
rb.x++;
rb.y++;
// apply transformation
Transform(<.x, <.y);
Transform(&rb.x, &rb.y);
// reset bottom right to pixel "index"
rb.x--;
rb.y--;
// add rect to converted region
// NOTE/TODO: the rect would not have to go
// through the whole intersection test process,
// it is guaranteed not to overlap with any rect
// already contained in the region
converted.Include(BRect(lt, rb));
}
*region = converted;
}
}
示例8: MakeFocus
void
MemoryView::MouseDown(BPoint point)
{
if (!IsFocus())
MakeFocus(true);
if (fTargetBlock == NULL)
return;
int32 buttons;
if (Looper()->CurrentMessage()->FindInt32("buttons", &buttons) != B_OK)
buttons = B_PRIMARY_MOUSE_BUTTON;
if (buttons == B_SECONDARY_MOUSE_BUTTON) {
_HandleContextMenu(point);
return;
}
int32 offset = _GetOffsetAt(point);
if (offset < fSelectionStart || offset > fSelectionEnd) {
BRegion oldSelectionRegion;
_GetSelectionRegion(oldSelectionRegion);
fSelectionBase = offset;
fSelectionStart = fSelectionBase;
fSelectionEnd = fSelectionBase;
Invalidate(oldSelectionRegion.Frame());
}
SetMouseEventMask(B_POINTER_EVENTS, B_NO_POINTER_HISTORY);
fTrackingMouse = true;
}
示例9: UpdateVisibleDeep
void
View::SetHidden(bool hidden)
{
if (fHidden != hidden) {
fHidden = hidden;
// recurse into children and update their visible flag
bool oldVisible = fVisible;
UpdateVisibleDeep(fParent ? fParent->IsVisible() : !fHidden);
if (oldVisible != fVisible) {
// Include or exclude us from the parent area, and update the
// children's clipping as well when the view will be visible
if (fParent)
fParent->RebuildClipping(fVisible);
else
RebuildClipping(fVisible);
if (fWindow) {
// trigger a redraw
IntRect clippedBounds = Bounds();
ConvertToVisibleInTopView(&clippedBounds);
BRegion* dirty = fWindow->GetRegion();
if (!dirty)
return;
dirty->Set((clipping_rect)clippedBounds);
fWindow->MarkContentDirty(*dirty);
fWindow->RecycleRegion(dirty);
}
}
}
}
示例10: screenBounds
void
View::AddTokensForViewsInRegion(BPrivate::PortLink& link, BRegion& region,
BRegion* windowContentClipping)
{
if (!fVisible)
return;
{
// NOTE: use scope in order to reduce stack space requirements
// This check will prevent descending the view hierarchy
// any further than necessary
IntRect screenBounds(Bounds());
ConvertToScreen(&screenBounds);
if (!region.Intersects((clipping_rect)screenBounds))
return;
// Unfortunately, we intersecting another region, but otherwise
// we couldn't provide the exact update rect to the client
BRegion localDirty = _ScreenClipping(windowContentClipping);
localDirty.IntersectWith(®ion);
if (localDirty.CountRects() > 0) {
link.Attach<int32>(fToken);
link.Attach<BRect>(localDirty.Frame());
}
}
for (View* child = FirstChild(); child; child = child->NextSibling())
child->AddTokensForViewsInRegion(link, region, windowContentClipping);
}
示例11: IsSelected
void
RemoteFileItem::DrawItemColumn(BView * clv, BRect itemRect, int32 colIdx, bool complete)
{
bool selected = IsSelected();
rgb_color color = (selected) ? ((ColumnListView*)clv)->ItemSelectColor()
: _owner->GetShareWindow()->GetColor(COLOR_BG);
clv->SetLowColor(color);
if ((selected) || (complete)) {
clv->SetHighColor(color);
clv->FillRect(itemRect);
}
if (colIdx > 0) {
BRegion Region;
Region.Include(itemRect);
clv->ConstrainClippingRegion(&Region);
clv->SetHighColor(_owner->GetShareWindow()->GetColor(COLOR_TEXT));
const char* text = _owner->GetShareWindow()->GetFileCellText(this, colIdx);
if (text)
clv->DrawString(text, BPoint(itemRect.left+2.0,itemRect.top+_textOffset));
clv->ConstrainClippingRegion(NULL);
} else if (colIdx == 0) {
const BBitmap* bmp = _owner->GetShareWindow()->GetBitmap(this, colIdx);
if (bmp) {
clv->SetDrawingMode(B_OP_OVER);
clv->DrawBitmap(bmp, BPoint(itemRect.left + ((itemRect.Width()-bmp->Bounds().Width())/2.0f), itemRect.top+((itemRect.Height()-bmp->Bounds().Height())/2.0f)));
}
}
}
示例12: UpdatePictureCueRegion
void TStageMovieCue::UpdatePictureCueRegion(double theTime)
{
// Determine channelID
int32 cueChannelID = m_ChannelCue->GetChannelID();
// Get total channels
int32 totalChannels = static_cast<MuseumApp *>(be_app)->GetCueSheet()->GetCueSheetView()->GetTotalChannels();
// Determine cue layer. Iterate through all higher layers and determine
// the area to be invalidated. Construct a region to do this. Exlude all
// other area rects in higher channels than us. We wil then break
// the region down into rects and invalidate them.
BRegion invalRegion;
invalRegion.Include(m_ChannelCue->GetArea());
for(int32 index = cueChannelID+1; index <= totalChannels; index++)
{
TStageCue *stageCue = ((TStageView *)Parent())->GetStageCueAtTimeandChannel(theTime, index);
if (stageCue)
invalRegion.Exclude( stageCue->GetChannelCue()->GetArea());
}
// Now call our custom invalidation routine
for(int32 index = 0; index < invalRegion.CountRects(); index++)
{
Parent()->Invalidate( invalRegion.RectAt(index));
//((TStageView *)Parent())->StageDraw( invalRegion.RectAt(index), theTime);
}
}
示例13: ClearAnts
void CCellView::StartDrag(BPoint where, bool copy)
{
ClearAnts();
BMessage msg(B_SIMPLE_DATA);
msg.AddPointer("container", fContainer);
msg.AddPointer("cellview", this);
msg.AddData("range", 'rang', &fSelection, sizeof(range));
msg.AddBool("dragacopy", copy);
BRegion rgn;
SelectionToRegion(rgn);
cell c;
GetCellHitBy(where, c);
BRect dragRect = rgn.Frame();
dragRect.OffsetBy(fCellWidths[c.h] - fCellWidths[fSelection.left],
fCellHeights[c.v] - fCellHeights[fSelection.top]);
BMallocIO buf;
CTextConverter conv(buf, fContainer);
conv.ConvertToText(&fSelection);
msg.AddData("text/plain", B_MIME_DATA,
buf.Buffer(), buf.BufferLength());
// and add a nice picture
BPicture pic;
BRect r;
GetPictureOfSelection(&pic, r);
pic.Archive(&msg);
// msg.AddData("picture", 'PICT', pic.Data(), pic.DataSize());
msg.AddData("rect of pict", 'RECT', &r, sizeof(BRect));
fDragIsAcceptable = true;
DragMessage(&msg, dragRect, this);
} /* CCellView::StartDrag */
示例14: _cairo_beos_surface_set_clip_region
static cairo_int_status_t
_cairo_beos_surface_set_clip_region (void *abstract_surface,
pixman_region16_t *region)
{
fprintf(stderr, "Setting clip region\n");
cairo_beos_surface_t *surface = reinterpret_cast<cairo_beos_surface_t*>(
abstract_surface);
AutoLockView locker(surface->view);
if (!locker)
return CAIRO_INT_STATUS_SUCCESS;
if (region == NULL) {
// No clipping
surface->view->ConstrainClippingRegion(NULL);
return CAIRO_INT_STATUS_SUCCESS;
}
int count = pixman_region_num_rects(region);
pixman_box16_t* rects = pixman_region_rects(region);
BRegion bregion;
for (int i = 0; i < count; ++i) {
// Have to substract one, because for pixman, the second coordinate
// lies outside the rectangle.
bregion.Include(BRect(rects[i].x1, rects[i].y1, rects[i].x2 - 1, rects[i].y2 - 1));
}
surface->view->ConstrainClippingRegion(&bregion);
return CAIRO_INT_STATUS_SUCCESS;
}
示例15: ConvertToScreen
BRegion&
View::_ScreenClipping(BRegion* windowContentClipping, bool force) const
{
if (!fScreenClippingValid || force) {
fScreenClipping = fLocalClipping;
ConvertToScreen(&fScreenClipping);
// see if parts of our bounds are hidden underneath
// the parent, the local clipping does not account for this
IntRect clippedBounds = Bounds();
ConvertToVisibleInTopView(&clippedBounds);
if (clippedBounds.Width() < fScreenClipping.Frame().Width()
|| clippedBounds.Height() < fScreenClipping.Frame().Height()) {
BRegion* temp = fWindow->GetRegion();
if (temp) {
temp->Set((clipping_rect)clippedBounds);
fScreenClipping.IntersectWith(temp);
fWindow->RecycleRegion(temp);
}
}
fScreenClipping.IntersectWith(windowContentClipping);
fScreenClippingValid = true;
}
return fScreenClipping;
}