本文整理汇总了C++中BRect::OffsetTo方法的典型用法代码示例。如果您正苦于以下问题:C++ BRect::OffsetTo方法的具体用法?C++ BRect::OffsetTo怎么用?C++ BRect::OffsetTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BRect
的用法示例。
在下文中一共展示了BRect::OffsetTo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rintf
BRect
WorkspacesView::_WindowFrame(const BRect& workspaceFrame,
const BRect& screenFrame, const BRect& windowFrame,
BPoint windowPosition)
{
BRect frame = windowFrame;
frame.OffsetTo(windowPosition);
// scale down the rect
float factor = workspaceFrame.Width() / screenFrame.Width();
frame.left = frame.left * factor;
frame.right = frame.right * factor;
factor = workspaceFrame.Height() / screenFrame.Height();
frame.top = frame.top * factor;
frame.bottom = frame.bottom * factor;
// offset by the workspace fame position
// and snap to integer coordinates without distorting the size too much
frame.OffsetTo(rintf(frame.left + workspaceFrame.left),
rintf(frame.top + workspaceFrame.top));
frame.right = rintf(frame.right);
frame.bottom = rintf(frame.bottom);
return frame;
}
示例2: screen
bool
TOSMagnify::CopyScreenRect(BRect srcRect)
{
// constrain src rect to legal screen rect
BScreen screen(Window());
BRect scrnframe = screen.Frame();
if (srcRect.right > scrnframe.right)
srcRect.OffsetTo(scrnframe.right - srcRect.Width(), srcRect.top);
if (srcRect.top < 0)
srcRect.OffsetTo(srcRect.left, 0);
if (srcRect.bottom > scrnframe.bottom)
srcRect.OffsetTo(srcRect.left, scrnframe.bottom - srcRect.Height());
if (srcRect.left < 0)
srcRect.OffsetTo(0, srcRect.top);
// save a copy of the bits for comparison later
memcpy(fOldBits, fBitmap->Bits(), fBitmap->BitsLength());
screen.ReadBitmap(fBitmap, false, &srcRect);
// let caller know whether bits have actually changed
return memcmp(fBitmap->Bits(), fOldBits, fBitmap->BitsLength()) != 0;
}
示例3: StartTime
BBitmap *TWipeTopLeftToBottomRightIn::TransformBitmap(uint32 time, const BBitmap *source,
const TCuePosition ®istration, DisplayQuality quality)
{
// Only create offscreen at first pass
if (!m_Inited)
{
BRect offRect = registration.Enclosure();
offRect.OffsetTo(0, 0);
InitOffscreen(offRect);
}
// Calculate times
const uint32 taskTime = time - StartTime();
const uint32 endTime = StartTime() + Duration();
// percentDone is on a scale of 0 to 1000. Check for overflow...
int32 percentDone;
if ( time < endTime)
percentDone = taskTime * 1000L / Duration();
else
percentDone = 1001;
if (percentDone > 1000)
percentDone = 1000;
// Set up source rectangle
BRect srcRect = registration.Enclosure();
srcRect.OffsetTo(0, 0);
srcRect.right = srcRect.left + srcRect.Width() * percentDone / 1000;
srcRect.bottom = srcRect.top + srcRect.Height() * percentDone / 1000;
// Set up destination rectangle
BRect dstRect = registration.Enclosure();
dstRect.OffsetTo(0, 0);
dstRect.right = dstRect.left + srcRect.Width();
dstRect.bottom = dstRect.top + srcRect.Height();
// Draw bitmap
if (m_OffscreenView->LockLooper())
{
// Clear offscreen
m_OffscreenView->SetHighColor(B_TRANSPARENT_32_BIT);
m_OffscreenView->FillRect(m_OffscreenView->Bounds());
// Do transitioned data
m_OffscreenView->DrawBitmap(source, srcRect, dstRect);
m_OffscreenView->Sync();
m_OffscreenView->UnlockLooper();
}
// Clone offscreen
BBitmap *newBitmap = CloneBitmap(*m_OffscreenBitmap);
ASSERT(newBitmap);
return newBitmap;
}
示例4: GetTextRect
BRect URLView::GetTextRect() {
// This function will return a BRect that contains only the text
// and the underline, so the mouse can change and the link will
// be activated only when the mouse is over the text itself, not
// just within the view.
// Note: We'll use bounding boxes, because they are the most
// accurate, and since the user is interacting with the
// view, off-by-one-pixel errors look bad.
const char *textArray[1];
textArray[0] = Text();
escapement_delta delta;
delta.nonspace = 0;
delta.space = 0;
escapement_delta escapements[1];
escapements[0] = delta;
BRect returnMe;
BRect rectArray[1];
rectArray[0] = returnMe;
BFont font;
GetFont( &font );
font.GetBoundingBoxesForStrings( textArray, 1, B_SCREEN_METRIC, escapements, rectArray );
BRect frame = Frame();
frame.OffsetTo( B_ORIGIN );
returnMe = rectArray[0];
// Get the height of the current font.
font_height height;
GetFontHeight( &height );
float descent = height.descent;
// Account for rounding of the floats when drawn to avoid
// one-pixel-off errors.
float lowerBound = 0;
if( (((int) descent) * 2) != ((int) (descent * 2)) )
lowerBound = 1;
// Adjust the bounding box to reflect where the text is in the view.
returnMe.bottom += 1;
returnMe.OffsetTo( B_ORIGIN );
float rectHeight = returnMe.Height();
returnMe.bottom = frame.bottom - descent;
returnMe.top = returnMe.bottom - rectHeight;
returnMe.bottom += 1 + underlineThickness;
returnMe.OffsetBy( 0.0, -(1 + lowerBound) );
return returnMe;
}
示例5: Parent
void
ObjectView::Pulse()
{
Window()->Lock();
BRect parentBounds = Parent()->Bounds();
BRect bounds = Bounds();
parentBounds.OffsetTo(0, 0);
bounds.OffsetTo(0, 0);
if (bounds != parentBounds) {
ResizeTo(parentBounds.right - parentBounds.left,
parentBounds.bottom - parentBounds.top);
}
Window()->Unlock();
}
示例6: BView
AGGView::AGGView(BRect frame,
agg::platform_support* agg,
agg::pix_format_e format,
bool flipY)
: BView(frame, "AGG View", B_FOLLOW_ALL,
B_FRAME_EVENTS | B_WILL_DRAW),
fFormat(format),
fFlipY(flipY),
fAGG(agg),
fMouseButtons(0),
fMouseX(-1),
fMouseY(-1),
fLastKeyDown(0),
fRedraw(true),
fPulse(NULL),
fLastPulse(0),
fEnableTicks(true)
{
SetViewColor(B_TRANSPARENT_32_BIT);
frame.OffsetTo(0.0, 0.0);
fBitmap = new BBitmap(frame, 0, pix_format_to_color_space(fFormat));
if (fBitmap->IsValid()) {
attach_buffer_to_BBitmap(fAGG->rbuf_window(), fBitmap, fFlipY);
} else {
delete fBitmap;
fBitmap = NULL;
}
}
示例7: m
HDialog::HDialog(BRect frame, const char *name, window_type type,
int flags, BWindow *owner, BPositionIO* data)
: BWindow(frame, name, type, flags)
, fOwner(owner)
, fPlacement(H_PLACE_LAST_POS)
{
frame.OffsetTo(0, 0);
AddChild(fMainView = new HDlogView(frame, "main"));
if (data)
_BuildIt(*data);
AddCommonFilter(new BMessageFilter(B_KEY_DOWN,KeyDownFilter));
if (fOwner)
{
BMessage m(msg_AddDialog);
m.AddPointer("dialog", this);
fOwner->PostMessage(&m);
// [zooey]: let dialog float above owner:
SetFeel(B_FLOATING_SUBSET_WINDOW_FEEL);
AddToSubset(fOwner);
}
} /* HDialog::HDialog */
示例8: BApplication
BochsApplication::BochsApplication()
: BApplication("application/x-vnd.Be-Bochs")
{
BRect aRect;
int left, right, top, bottom;
left = 5;
top = 80;
dimension_x = 640;
dimension_y = 480 + bx_headerbar_y;
right = left + dimension_x - 1;
bottom = top + dimension_y - 1;
// set up a rectangle and instantiate a new window
aRect.Set(left, top, right, bottom);
aWindow = new BochsWindow(aRect);
// set up a rectangle and instantiate a new view
// view rect should be same size as window rect but with left top at (0, 0)
aRect.OffsetTo(B_ORIGIN);
aView = new BochsView(aRect, "BochsView");
aView->SetViewColor(0, 0, 0);
aView->set_text_colors();
// add view to window
aWindow->AddChild(aView);
// make window visible
aWindow->Show();
}
示例9: BMessage
MagnificationView::MagnificationView(BRect rect)
: BBox(rect, "magnificationView", B_FOLLOW_TOP | B_FOLLOW_LEFT,
B_WILL_DRAW | B_FRAME_EVENTS, B_PLAIN_BORDER)
{
char string[256];
sprintf(string,"%s: %.1f%%", StringServer::ReturnString(MAG_STRING), 1600.0);
float width, height;
rect.OffsetTo(4.0, 1.0);
fMagStringView = new MagStringView(rect, "magStringView", string);
fMagStringView->GetPreferredSize(&width, &height);
fMagStringView->ResizeTo(width, rect.Height() - 2.0);
AddChild(fMagStringView);
height = rect.Height() - 2.0;
fMinusButton = new BButton(rect, "minusButton", "-",
new BMessage(HS_ZOOM_IMAGE_OUT));
AddChild(fMinusButton);
fMinusButton->ResizeTo(height, height);
fPlusButton = new BButton(rect, "plusButton", "+",
new BMessage(HS_ZOOM_IMAGE_IN));
AddChild(fPlusButton);
fPlusButton->ResizeTo(height, height);
fMinusButton->MoveBy(width + 5.0, 0.0);
fPlusButton->MoveBy(width + 5.0 + height, 0.0);
ResizeTo(fPlusButton->Frame().right + 1.0, Bounds().Height());
}
示例10: screen
CalcWindow::CalcWindow(BRect frame, BMessage* settings)
: BWindow(frame, kWindowTitle, B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS)
{
// create calculator view with calculator description and
// desktop background color
BScreen screen(this);
rgb_color baseColor = screen.DesktopColor();
SetSizeLimits(100.0, 400.0, 100.0, 400.0);
frame.OffsetTo(B_ORIGIN);
fCalcView = new CalcView(frame, baseColor, settings);
// create replicant dragger
BRect replicantFrame(frame);
replicantFrame.top = replicantFrame.bottom - 7.0f;
replicantFrame.left = replicantFrame.right - 7.0f;
BDragger* dragger = new BDragger(replicantFrame, fCalcView,
B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
// attach views
AddChild(fCalcView);
fCalcView->AddChild(dragger);
BRect rect;
if (settings->FindRect("window frame", &rect) == B_OK)
SetFrame(rect);
else
SetFrame(frame, true);
}
示例11: listBounds
PPDConfigView::PPDConfigView(BRect bounds, const char *name, uint32 resizeMask, uint32 flags)
: BView(bounds, name, resizeMask, flags)
, fPPD(NULL)
{
// add category outline list view
bounds.OffsetTo(0, 0);
BRect listBounds(bounds.left + kLeftMargin, bounds.top + kTopMargin,
bounds.right - kHorizontalSpace, bounds.bottom - kBottomMargin);
listBounds.right -= B_V_SCROLL_BAR_WIDTH;
listBounds.bottom -= B_H_SCROLL_BAR_HEIGHT;
BStringView* label = new BStringView(listBounds, "printer-settings", "Printer Settings:");
AddChild(label);
label->ResizeToPreferred();
listBounds.top += label->Bounds().bottom + 5;
// add details view
fDetails = new BView(listBounds, "details", B_FOLLOW_ALL_SIDES, B_WILL_DRAW);
fDetails->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
BScrollView* scrollView = new BScrollView("details-scroll-view",
fDetails, B_FOLLOW_ALL_SIDES, 0, true, true);
AddChild(scrollView);
}
示例12: BView
MainView::MainView( BRect frame ) : BView (frame, "mainView", B_FOLLOW_ALL_SIDES, B_WILL_DRAW) {
SetViewColor(216, 216, 216);
// nutzbare Größe
frame.OffsetTo( 0.0, 0.0 );
frame.InsetBy( 5.0, 5.0 );
// Erstellen der beiden inneren Frames
TopView* topView = new TopView( BRect( frame.left, frame.top, frame.right, frame.bottom - 72.0 - be_plain_font->Size() - be_bold_font->Size() ) );
AddChild( topView );
BottomView* bottomView = new BottomView( BRect( frame.left, frame.bottom - 67.0 - be_plain_font->Size() - be_bold_font->Size(), frame.right, frame.bottom - 43.0 ) );
AddChild( bottomView );
// StatusBar
BStatusBar* statusBar = new BStatusBar( BRect(frame.left + 5.0, frame.bottom - be_plain_font->Size() - 23.0, frame.left + 400.0, frame.bottom), "statusBar", STATUS_STATUS, NULL);
statusBar->SetText(STATUS_SELECT_FILES);
statusBar->SetResizingMode(B_FOLLOW_BOTTOM);
rgb_color color = { 70, 100, 180, 255};
statusBar->SetBarColor(color);
statusBar->SetBarHeight(14.0);
AddChild(statusBar);
// Do it! - Button
BButton* DoItButton = new BButton( BRect ( frame.right - be_plain_font->StringWidth(STR_DO_IT) - 25.0, frame.bottom - 30.0, frame.right - 5.0 , frame.bottom - 5.0 ), "DoIt", STR_DO_IT, new BMessage(MSG_DO_IT), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM );
DoItButton->SetEnabled(false);
AddChild(DoItButton);
};
示例13: font
void
CalcView::FrameResized(float width, float height)
{
fWidth = width;
fHeight = height;
// layout expression text view
BRect frame = _ExpressionRect();
if (fOptions->keypad_mode == KEYPAD_MODE_COMPACT) {
frame.InsetBy(2, 2);
frame.right -= ceilf(fCalcIcon->Bounds().Width() * 1.5);
} else
frame.InsetBy(4, 4);
fExpressionTextView->MoveTo(frame.LeftTop());
fExpressionTextView->ResizeTo(frame.Width(), frame.Height());
// configure expression text view font size and color
float sizeDisp = fOptions->keypad_mode == KEYPAD_MODE_COMPACT
? fHeight : fHeight * kDisplayScaleY;
BFont font(be_bold_font);
font.SetSize(sizeDisp * kExpressionFontScaleY);
fExpressionTextView->SetFontAndColor(&font, B_FONT_ALL);
frame.OffsetTo(B_ORIGIN);
float inset = (frame.Height() - fExpressionTextView->LineHeight(0)) / 2;
frame.InsetBy(0, inset);
fExpressionTextView->SetTextRect(frame);
Invalidate();
}
示例14: BView
/*!
This is the BDirectWindow subclass that rendering occurs in.
A view is added to it so that BView based screensavers will work.
*/
ScreenSaverWindow::ScreenSaverWindow(BRect frame)
:
BDirectWindow(frame, "ScreenSaver Window",
B_NO_BORDER_WINDOW_LOOK, kWindowScreenFeel,
B_NOT_RESIZABLE | B_NOT_MOVABLE | B_NOT_MINIMIZABLE
| B_NOT_ZOOMABLE | B_NOT_CLOSABLE, B_ALL_WORKSPACES),
fTopView(NULL),
fSaverRunner(NULL),
fFilter(NULL)
{
frame.OffsetTo(0, 0);
fTopView = new BView(frame, "ScreenSaver View", B_FOLLOW_ALL,
B_WILL_DRAW);
fTopView->SetViewColor(B_TRANSPARENT_COLOR);
fFilter = new ScreenSaverFilter();
fTopView->AddFilter(fFilter);
AddChild(fTopView);
// Ensure that this view receives keyboard and mouse input
fTopView->MakeFocus(true);
fTopView->SetEventMask(B_KEYBOARD_EVENTS | B_POINTER_EVENTS,
B_NO_POINTER_HISTORY);
}
示例15: BWindow
BottomlineWindow::BottomlineWindow()
: BWindow(BRect(0, 0, 350, 16), "",
kLeftTitledWindowLook,
B_FLOATING_ALL_WINDOW_FEEL,
B_NOT_V_RESIZABLE | B_NOT_CLOSABLE | B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE
| B_AVOID_FOCUS | B_WILL_ACCEPT_FIRST_CLICK)
{
BRect textRect = Bounds();
textRect.OffsetTo(B_ORIGIN);
textRect.InsetBy(2,2);
fTextView = new BTextView(Bounds(), "", textRect, be_plain_font,
NULL, B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS);
AddChild(fTextView);
fTextView->SetText("");
BRect screenFrame = (BScreen(B_MAIN_SCREEN_ID).Frame());
BPoint pt;
pt.x = 100;
pt.y = screenFrame.Height()*2/3 - Bounds().Height()/2;
MoveTo(pt);
Show();
SERIAL_PRINT(("BottomlineWindow created\n"));
}