本文整理汇总了C++中BRect::OffsetBySelf方法的典型用法代码示例。如果您正苦于以下问题:C++ BRect::OffsetBySelf方法的具体用法?C++ BRect::OffsetBySelf怎么用?C++ BRect::OffsetBySelf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BRect
的用法示例。
在下文中一共展示了BRect::OffsetBySelf方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CopyPixelsIn
status_t MesaDriver::CopyPixelsIn(BBitmap *bitmap, BPoint location)
{
color_space scs = bitmap->ColorSpace();
color_space dcs = m_bitmap->ColorSpace();
if (scs != dcs && (dcs != B_RGBA32 || scs != B_RGB32)) {
printf("CopyPixelsIn(): incompatible color space: %s != %s\n",
color_space_name(scs),
color_space_name(dcs));
return B_BAD_TYPE;
}
// debugger("CopyPixelsIn()");
BRect sr = bitmap->Bounds();
BRect dr = m_bitmap->Bounds();
sr = sr & dr.OffsetBySelf(location);
dr = sr.OffsetByCopy(-location.x, -location.y);
uint8 *ps = (uint8 *) bitmap->Bits();
uint8 *pd = (uint8 *) m_bitmap->Bits();
uint32 *s, *d;
uint32 y;
for (y = (uint32) sr.top; y <= (uint32) sr.bottom; y++) {
s = (uint32 *) (ps + y * bitmap->BytesPerRow());
s += (uint32) sr.left;
d = (uint32 *) (pd + (y + (uint32) (dr.top - sr.top)) * m_bitmap->BytesPerRow());
d += (uint32) dr.left;
memcpy(d, s, dr.IntegerWidth() * 4);
}
return B_OK;
}
示例2: message
BRect
RemoteDrawingEngine::CopyRect(BRect rect, int32 xOffset, int32 yOffset) const
{
RemoteMessage message(NULL, fHWInterface->SendBuffer());
message.Start(RP_COPY_RECT_NO_CLIPPING);
message.Add(xOffset);
message.Add(yOffset);
message.Add(rect);
return rect.OffsetBySelf(xOffset, yOffset);
}
示例3: BWindow
PromotionWindow::PromotionWindow(ChessBoardView* target)
:
BWindow(target->Frame(), "Please Choose", B_TITLED_WINDOW_LOOK,
B_MODAL_APP_WINDOW_FEEL, B_ASYNCHRONOUS_CONTROLS
| B_NOT_CLOSABLE
| B_AUTO_UPDATE_SIZE_LIMITS | B_OUTLINE_RESIZE
| B_NOT_RESIZABLE | B_NOT_MINIMIZABLE | B_NOT_ZOOMABLE ),
fTarget(target)
{
BRect frame = BRect(0, 0, fTarget->fIR.Width()*8, fTarget->fIR.Width()*8);
frame.OffsetBySelf(fTarget->Window()->Frame().LeftTop());
frame.OffsetBySelf(fTarget->Frame().LeftTop());
frame.OffsetBySelf(fTarget->fBoard2dOffset);
ImageButton* (button)[4];
BString nameW[4] = {"wQ", "wR", "wB", "wN"};
BString nameB[4] = {"bQ", "bR", "bB", "bN"};
int valW[4] = {Q_W, R_W, B_W, N_W};
int valB[4] = {Q_B, R_B, B_B, N_B};
for (int i = 0; i < 4; ++i) {
if (fTarget->IsWhiteTurn() == false)
button[i] = new ImageButton(nameW[i], new BMessage(valW[i]), 0.1);
else
button[i] = new ImageButton(nameB[i], new BMessage(valB[i]), 0.1);
button[i]->SetExplicitMinSize(BSize(frame.Width()/5, frame.Width()/5));
button[i]->SetExplicitMaxSize(BSize(frame.Width()/5, frame.Width()/5));
}
//if (isWhite) name = ;
BLayoutBuilder::Group<>(this, B_HORIZONTAL, 0)
.Add(button[0]).Add(button[1]).Add(button[2]).Add(button[3])
;
CenterIn(frame);
Show();
}
示例4:
status_t
IntelRenderer::CopyPixelsIn(BBitmap *bitmap, BPoint location)
{
CALLED();
color_space sourceCS = bitmap->ColorSpace();
color_space destinationCS = fBitmap->ColorSpace();
if (sourceCS != destinationCS
&& (sourceCS != B_RGB32 || destinationCS != B_RGBA32)) {
ERROR("%s::CopyPixelsIn(): incompatible color space: %s != %s\n",
__PRETTY_FUNCTION__, color_space_name(sourceCS),
color_space_name(destinationCS));
return B_BAD_TYPE;
}
BRect sr = bitmap->Bounds();
BRect dr = fBitmap->Bounds();
sr = sr & dr.OffsetBySelf(location);
dr = sr.OffsetByCopy(-location.x, -location.y);
uint8 *ps = (uint8 *) bitmap->Bits();
uint8 *pd = (uint8 *) fBitmap->Bits();
uint32 *s, *d;
uint32 y;
for (y = (uint32) sr.top; y <= (uint32) sr.bottom; y++) {
s = (uint32 *)(ps + y * bitmap->BytesPerRow());
s += (uint32) sr.left;
d = (uint32 *)(pd + (y + (uint32)(dr.top - sr.top))
* fBitmap->BytesPerRow());
d += (uint32) dr.left;
memcpy(d, s, dr.IntegerWidth() * 4);
}
return B_OK;
}
示例5:
status_t
SoftwareRenderer::CopyPixelsOut(BPoint location, BBitmap *bitmap)
{
CALLED();
color_space scs = fBitmap->ColorSpace();
color_space dcs = bitmap->ColorSpace();
if (scs != dcs && (scs != B_RGBA32 || dcs != B_RGB32)) {
ERROR("%s::CopyPixelsOut(): incompatible color space: %s != %s\n",
__PRETTY_FUNCTION__, color_space_name(scs), color_space_name(dcs));
return B_BAD_TYPE;
}
BRect sr = fBitmap->Bounds();
BRect dr = bitmap->Bounds();
// int32 w1 = sr.IntegerWidth();
// int32 h1 = sr.IntegerHeight();
// int32 w2 = dr.IntegerWidth();
// int32 h2 = dr.IntegerHeight();
sr = sr & dr.OffsetBySelf(location);
dr = sr.OffsetByCopy(-location.x, -location.y);
uint8 *ps = (uint8 *) fBitmap->Bits();
uint8 *pd = (uint8 *) bitmap->Bits();
uint32 *s, *d;
uint32 y;
for (y = (uint32) sr.top; y <= (uint32) sr.bottom; y++) {
s = (uint32 *)(ps + y * fBitmap->BytesPerRow());
s += (uint32) sr.left;
d = (uint32 *)(pd + (y + (uint32)(dr.top - sr.top))
* bitmap->BytesPerRow());
d += (uint32) dr.left;
memcpy(d, s, dr.IntegerWidth() * 4);
}
return B_OK;
}
示例6: KeyDown
//.........这里部分代码省略.........
BPoint(todayStringView->Frame().right,
todayStringView->Frame().bottom+1));
BmpView->SetHighColor(0,0,0);
break;
}
}
BmpView->Sync();
Bmp->Unlock();
Draw(Bounds());
break;
} // B_TAB
case B_DOWN_ARROW:
{
if(which_focused==0) // month
{
BMessage msg('MON0');
MessageReceived(&msg);
}
else if(which_focused==1) // year
{
BMessage msg('YEA0');
MessageReceived(&msg);
}
else if(which_focused==2) // days of month
{
int qu_days=monthDays[cmonth-1];
if(cmonth==2) if(cyear%4==0) if((cyear%100!=0) || (cyear%400==0)) qu_days=29;
if((cday+7)<=qu_days)
{
Bmp->Lock();
BmpView->SetHighColor(VIEW_COLOR);
BmpView->StrokeRect(cursor);
cursor.OffsetBySelf(0, h_cell);
cday+=7;
BmpView->SetHighColor(ACTIVE_COLOR);
BmpView->StrokeRect(cursor);
BmpView->SetHighColor(0,0,0);
BmpView->Sync();
Bmp->Unlock();
Draw(Bounds());
}
}
break;
}
case B_UP_ARROW:
{
// Test whether Ctrl+UpArrow is pressed
if(modifiers() & B_CONTROL_KEY)
Window()->PostMessage(B_QUIT_REQUESTED);
else
{
if(which_focused==0) // month
{
BMessage msg('MON1');
MessageReceived(&msg);
}
else if(which_focused==1) // year
{
BMessage msg('YEA1');
MessageReceived(&msg);
}
else if(which_focused==2) // days of month
{
if((cday-7)>=1)
示例7: mbRect
ActivityWindow::ActivityWindow()
:
BWindow(BRect(100, 100, 500, 350), B_TRANSLATE_SYSTEM_NAME("ActivityMonitor"),
B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_QUIT_ON_WINDOW_CLOSE)
{
BMessage settings;
_LoadSettings(settings);
BRect frame;
if (settings.FindRect("window frame", &frame) == B_OK) {
MoveTo(frame.LeftTop());
ResizeTo(frame.Width(), frame.Height());
}
#ifdef __HAIKU__
BGroupLayout* layout = new BGroupLayout(B_VERTICAL, 0);
SetLayout(layout);
// create GUI
BMenuBar* menuBar = new BMenuBar("menu");
layout->AddView(menuBar);
fLayout = new BGroupLayout(B_VERTICAL);
float inset = ceilf(be_plain_font->Size() * 0.7);
fLayout->SetInsets(inset, inset, inset, inset);
fLayout->SetSpacing(inset);
BView* top = new BView("top", 0, fLayout);
top->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
layout->AddView(top);
BMessage viewState;
int32 count = 0;
for (int32 i = 0; settings.FindMessage("activity view", i, &viewState)
== B_OK; i++) {
ActivityView* view = new ActivityView("ActivityMonitor", &viewState);
fLayout->AddItem(view->CreateHistoryLayoutItem());
fLayout->AddItem(view->CreateLegendLayoutItem());
count++;
}
if (count == 0) {
// Add default views (memory & CPU usage)
_AddDefaultView();
_AddDefaultView();
}
#else // !__HAIKU__
BView *layout = new BView(Bounds(), "topmost", B_FOLLOW_NONE, 0);
AddChild(layout);
// create GUI
BRect mbRect(Bounds());
mbRect.bottom = 10;
BMenuBar* menuBar = new BMenuBar(mbRect, "menu");
layout->AddChild(menuBar);
BRect topRect(Bounds());
topRect.top = menuBar->Bounds().bottom + 1;
BView* top = new BView(topRect, "top", B_FOLLOW_ALL, 0);
top->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
layout->AddChild(top);
BMessage viewState;
int32 count = 0;
ActivityView *aview;
BRect rect;
for (int32 i = 0; settings.FindMessage("activity view", i, &viewState)
== B_OK; i++) {
aview = new ActivityView("ActivityMonitor", &viewState);
if (!rect.IsValid())
rect = aview->Bounds();
else
rect.OffsetBySelf(0.0, aview->Bounds().Height());
top->AddChild(aview);
count++;
}
if (count == 0)
top->AddChild(new ActivityView("ActivityMonitor", NULL));
#endif
// add menu
// "File" menu
BMenu* menu = new BMenu(B_TRANSLATE("File"));
menu->AddItem(new BMenuItem(B_TRANSLATE("Add graph"),
new BMessage(kMsgAddView)));
menu->AddSeparatorItem();
menu->AddItem(new BMenuItem(B_TRANSLATE("Quit"),
new BMessage(B_QUIT_REQUESTED), 'Q'));
menu->SetTargetForItems(this);
menuBar->AddItem(menu);
// "Settings" menu
menu = new BMenu(B_TRANSLATE("Settings"));
menu->AddItem(new BMenuItem(B_TRANSLATE("Settings" B_UTF8_ELLIPSIS),
new BMessage(kMsgShowSettings)));
menu->SetTargetForItems(this);
menuBar->AddItem(menu);
//.........这里部分代码省略.........
示例8: BCheckBox
PackageCheckBox::PackageCheckBox(BRect rect, Package *item)
:
BCheckBox(rect.OffsetBySelf(7, 0), "pack_cb", item->Name(), NULL),
fPackage(item)
{
}
示例9: where
void
BasicPreviewView::Draw(BRect updateRect)
{
BRect bounds = Bounds();
if (fEngine == nullptr) {
BView::Draw(updateRect);
return;
}
SetHighColor(0, 0, 0, 255);
BPoint where(0, 0);
if (fColumnWidth > 0 && fColumnWidth < bounds.Width()) {
fRows = ceil(static_cast<float>(_Pages()) / fColumns);
_SetColumns((Bounds().Width() - 2*fHMargin + fHSpace) / (fColumnWidth + fHSpace));
fPageHeight = _PageHeight();
int lowerbound = fCurrentPageNumber;
int upperbound = 2 + (bounds.Height() -fVSpace) / (fPageHeight + fVSpace);
upperbound *= fColumns;
upperbound += fCurrentPageNumber;
if (upperbound > _Pages())
upperbound = _Pages();
BRect rect;
int i = lowerbound;
where.y = fVMargin + fCurrentRow * (fPageHeight + fVSpace);
for ( ; i < upperbound;) {
where.x = fHMargin;
for (int j = 0; j < fColumns && i < upperbound; ++j, ++i) {
rect.left = 0;
rect.top = 0;
rect.right = fColumnWidth;
rect.bottom = fPageHeight = _PageHeight(i);
rect.OffsetBySelf(where);
if (rect.Intersects(updateRect)) {
DrawBitmapAsync(_Page(i), rect);
if (i == fHighlightPageNumber) {
SetHighColor(0, 0, 255, 255);
SetPenSize(2);
StrokeRect(rect);
SetHighColor(0, 0, 0, 255);
SetPenSize(1);
} else {
StrokeRect(rect);
}
}
where.x += fColumnWidth + fHSpace;
}
where.y += rect.Height() + fVSpace;
}
fZoom = fColumnWidth / fEngine->Page(upperbound - 1)->Bounds().Width();
} else {
where.x = fHMargin;
fRows = fEngine->PageCount();
fPageHeight = _PageHeight();
float width = bounds.Width() - 2*fHMargin;
int upperbound = bounds.Height() / fPageHeight;
upperbound = upperbound + fCurrentPageNumber + 2;
if (upperbound > fEngine->PageCount())
upperbound = fEngine->PageCount();
where.y = fVMargin + fCurrentRow * (fPageHeight + fVSpace);
bool hasDrawn = false;
for (int i = fCurrentPageNumber; i < upperbound; ++i) {
fPageHeight = _PageHeight(i);
BRect rect(0, 0, width, fPageHeight);
rect.OffsetBySelf(where);
if (rect.Intersects(updateRect)){
hasDrawn = true;
DrawBitmapAsync(_Page(i), rect);
if (i == fHighlightPageNumber) {
SetHighColor(0, 0, 255, 255);
SetPenSize(2);
} else {
SetHighColor(0, 0, 0, 255);
SetPenSize(1);
}
StrokeRect(rect);
} else if (hasDrawn) {
break;
}
where.y += (fPageHeight + fVSpace);
}
fZoom = width / (fZoom * fEngine->Page(upperbound - 1)->Bounds().Width());
}
}