本文整理汇总了C++中BRect::OffsetBy方法的典型用法代码示例。如果您正苦于以下问题:C++ BRect::OffsetBy方法的具体用法?C++ BRect::OffsetBy怎么用?C++ BRect::OffsetBy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BRect
的用法示例。
在下文中一共展示了BRect::OffsetBy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testPattern
static void testPattern(BView *view, BRect frame)
{
frame.InsetBy(2, 2);
int x = frame.IntegerWidth() / 3;
frame.right = frame.left + x - 2;
// -2 for an empty pixel row between
// filled rectangles
view->SetLowColor(kGreen);
view->SetHighColor(kRed);
view->FillRect(frame, B_SOLID_HIGH);
frame.OffsetBy(x, 0);
view->FillRect(frame, B_MIXED_COLORS);
frame.OffsetBy(x, 0);
view->FillRect(frame, B_SOLID_LOW);
}
示例2: LeftVar
void
WindowArea::DoGroupLayout()
{
SATWindow* parentWindow = fWindowLayerOrder.ItemAt(0);
if (parentWindow == NULL)
return;
BRect frame = parentWindow->CompleteWindowFrame();
// Make it also work for solver which don't support negative variables
frame.OffsetBy(kMakePositiveOffset, kMakePositiveOffset);
// adjust window size soft constraints
fWidthConstraint->SetRightSide(frame.Width());
fHeightConstraint->SetRightSide(frame.Height());
LinearSpec* linearSpec = fGroup->GetLinearSpec();
Constraint* leftConstraint = linearSpec->AddConstraint(1.0, LeftVar(),
kEQ, frame.left);
Constraint* topConstraint = linearSpec->AddConstraint(1.0, TopVar(), kEQ,
frame.top);
// give soft constraints a high penalty
fWidthConstraint->SetPenaltyNeg(kHighPenalty);
fWidthConstraint->SetPenaltyPos(kHighPenalty);
fHeightConstraint->SetPenaltyNeg(kHighPenalty);
fHeightConstraint->SetPenaltyPos(kHighPenalty);
// After we set the new parameter solve and apply the new layout.
ResultType result;
for (int32 tries = 0; tries < 15; tries++) {
result = fGroup->GetLinearSpec()->Solve();
if (result == kInfeasible) {
debug_printf("can't solve constraints!\n");
break;
}
if (result == kOptimal) {
const WindowAreaList& areas = fGroup->GetAreaList();
for (int32 i = 0; i < areas.CountItems(); i++) {
WindowArea* area = areas.ItemAt(i);
area->_MoveToSAT(parentWindow);
}
break;
}
}
// set penalties back to normal
fWidthConstraint->SetPenaltyNeg(kExtentPenalty);
fWidthConstraint->SetPenaltyPos(kExtentPenalty);
fHeightConstraint->SetPenaltyNeg(kExtentPenalty);
fHeightConstraint->SetPenaltyPos(kExtentPenalty);
linearSpec->RemoveConstraint(leftConstraint);
linearSpec->RemoveConstraint(topConstraint);
}
示例3: DrawMods
void KeyItem::DrawMods(BView *view, BRect r, int32 mod)
{
float w = -(r.Width()+2);
if (mod & B_SHIFT_KEY){
DrawKey(view, r, "S");
r.OffsetBy(w,0);
}
if (mod & B_CONTROL_KEY){
DrawKey(view, r, "C");
r.OffsetBy(w,0);
}
if (mod & B_OPTION_KEY){
DrawKey(view, r, "O");
r.OffsetBy(w,0);
}
if ((mod & B_COMMAND_KEY)){
DrawKey(view, r, "A");
r.OffsetBy(w,0);
}
}
示例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: BMessage
void
TTimeWindow::_InitWindow()
{
SetPulseRate(500000);
fDateTimeView = new DateTimeView(Bounds());
BRect bounds = fDateTimeView->Bounds();
fTimeZoneView = new TimeZoneView(bounds);
fBaseView = new TTimeBaseView(bounds, "baseView");
AddChild(fBaseView);
fBaseView->StartWatchingAll(fDateTimeView);
fBaseView->StartWatchingAll(fTimeZoneView);
bounds.OffsetBy(10.0, 10.0);
BTabView *tabView = new BTabView(bounds.InsetByCopy(-5.0, -5.0),
"tabView" , B_WIDTH_AS_USUAL, B_FOLLOW_NONE);
BTab *tab = new BTab();
tabView->AddTab(fDateTimeView, tab);
tab->SetLabel("Date & Time");
tab = new BTab();
tabView->AddTab(fTimeZoneView, tab);
tab->SetLabel("Time zone");
fBaseView->AddChild(tabView);
tabView->ResizeBy(0.0, tabView->TabHeight());
BRect rect = Bounds();
rect.left = 10;
rect.top = rect.bottom - 10;
fRevertButton = new BButton(rect, "revert", "Revert",
new BMessage(kMsgRevert), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM, B_WILL_DRAW);
fRevertButton->ResizeToPreferred();
fRevertButton->SetEnabled(false);
float buttonHeight = fRevertButton->Bounds().Height();
fRevertButton->MoveBy(0, -buttonHeight);
fBaseView->AddChild(fRevertButton);
fRevertButton->SetTarget(this);
fBaseView->ResizeTo(tabView->Bounds().Width() + 10.0,
tabView->Bounds().Height() + buttonHeight + 30.0);
ResizeTo(fBaseView->Bounds().Width(), fBaseView->Bounds().Height());
}
示例6: DraggingRectFor
BRect SeqToolBarView::DraggingRectFor(BPoint pt, int32* lIndex, int32* rIndex)
{
if (mCachedData.size() < 1) {
if (lIndex) *lIndex = -1;
if (rIndex) *rIndex = 0;
return Bounds();
}
BRect bounds(Bounds() );
float x = 0;
float IN_BETWEEN = 0.20;
for (uint32 k = 0; k < mCachedData.size(); k++) {
BRect b = mCachedData[k].Bounds();
float inBetween = b.Width() * IN_BETWEEN;
float pad = 0;
b.OffsetBy(BPoint(x, 0) );
/* Special case: If we're on the last tool, the drag bounds
* extend to the end of the view.
*/
if (k >= mCachedData.size() - 1) {
b.right = bounds.right;
pad = LAST_BUTTON_PAD;
}
if (b.Contains(pt)) {
if (lIndex && rIndex) *lIndex = *rIndex = (int32)k;
BRect ans(b);
if (pt.x <= b.left + inBetween) {
if (lIndex) *lIndex = *lIndex -1;
ans.right = ans.left + inBetween;
if (k > 0) {
float f = (mCachedData[k-1].Bounds().Width()) * IN_BETWEEN;
ans.left -= (mSpace + f);
}
} else if (pt.x >= b.right - inBetween - pad) {
if (rIndex) *rIndex = *rIndex + 1;
ans.left = ans.right - inBetween - pad;
if (k != mCachedData.size() - 1) {
float f = (mCachedData[k+1].Bounds().Width()) * IN_BETWEEN;
ans.right += mSpace + f;
}
}
return ans;
}
x = b.right + 1;
x += mSpace;
if (x > pt.x) return BRect(-1, -1, -1, -1);
}
return BRect(-1, -1, -1, -1);
}
示例7: AddView
void DetailsBuilder::AddView(BView* view)
{
if (view != NULL) {
fDetails->AddChild(view);
view->ResizeToPreferred();
fBounds.OffsetBy(0, view->Bounds().Height()+1);
BControl* control = dynamic_cast<BControl*>(view);
if (control != NULL) {
control->SetTarget(fParent);
}
}
}
示例8: line
void
ResizerWindow::AddSeparatorLine(BView* view, BRect& rect)
{
const float lineWidth = 3;
BRect line(Bounds());
line.left += 3;
line.right -= 3;
line.top = rect.top;
line.bottom = line.top + lineWidth - 1;
BBox* separatorLine = new BBox(line, "", B_FOLLOW_LEFT_RIGHT,
B_WILL_DRAW | B_FRAME_EVENTS, B_PLAIN_BORDER);
view->AddChild(separatorLine);
rect.OffsetBy(0, kLineDistance + lineWidth);
}
示例9: BPoint
static void testSetPenSize2(BView *view, BRect frame)
{
// test if pen size is scaled too
frame.InsetBy(2, 2);
frame.OffsetBy(0, 5);
view->SetPenSize(4);
view->StrokeLine(BPoint(frame.left, frame.top), BPoint(frame.right, frame.top));
view->SetScale(0.5);
view->StrokeLine(BPoint(frame.left + 2, frame.bottom), BPoint(frame.right + 2, frame.bottom));
// black line from left to right, 4 pixel size
// below black line with half the length of the first one
// and 2 pixel size
}
示例10: font
//===========================PrefsWindow======================================
PrefsWindow::PrefsWindow(BRect frame, BMessenger *messenger)
: BWindow(frame, "Preferences", B_FLOATING_WINDOW, B_NOT_ZOOMABLE|B_NOT_RESIZABLE|B_NOT_CLOSABLE|B_ASYNCHRONOUS_CONTROLS),
m_msgr(messenger),
m_colourPrefsChanged(false),
m_fontSizeChanged(false),
m_toolbarChanged(false)
{
SetFeel(B_NORMAL_WINDOW_FEEL);
m_parent = new BView(Bounds(), "parent", B_FOLLOW_ALL_SIDES, B_WILL_DRAW);
m_parent->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
AddChild(m_parent);
prefsLock.Lock();
BFont font(be_fixed_font);
float fontSize = 10.0f;
if (preferences.FindFloat(K_FONT_SIZE, &fontSize) == B_OK)
font.SetSize(fontSize);
prefsLock.Unlock();
float prefsListWidth = 80.0f;
BRect prefsListFrame(10.0f, 10.0f, 10.0f + prefsListWidth, Bounds().bottom - 10.0f);
PrefsListView *prefsListView = new PrefsListView(prefsListFrame, m_parent);
BScrollView *prefsListScroll = new BScrollView("ScrollView", prefsListView, B_FOLLOW_LEFT | B_FOLLOW_TOP,B_WILL_DRAW,false,false);
m_parent->AddChild(prefsListScroll);
float bwidth = 80.0f,
bheight = 30.0f,
bspacing = 10.0f
;
BRect okButtonFrame(Bounds().right - bspacing - bwidth, Bounds().bottom - bspacing - bheight, Bounds().right - bspacing,Bounds().bottom - bspacing);
BButton *okButton = new BButton(okButtonFrame, "okButton", "Ok", new BMessage(PrefsConstants::K_PREFS_VIEW_OK));
m_parent->AddChild(okButton);
okButton->MakeDefault(true);
BRect cancelButtonFrame = okButtonFrame;
cancelButtonFrame.OffsetBy(-(bwidth + 2.0f * bspacing), 0.0f);
BButton *cancelButton = new BButton(cancelButtonFrame,"cancelButton","Cancel",new BMessage(PrefsConstants::K_PREFS_VIEW_CANCEL));
m_parent->AddChild(cancelButton);
float respiteWidth = 41.0f;
BRect boxRect(10.0f + prefsListWidth + 10.0f , 2.0f, Bounds().right - 7.0f , Bounds().bottom - 10.0f - respiteWidth);
prefsListView->AddItem(new PrefsListItem(constructGeneralBox(boxRect), m_parent, "General"));
prefsListView->AddItem(new PrefsListItem(constructCommandBox(boxRect), m_parent, "Commands"));
prefsListView->AddItem(new PrefsListItem(constructColourBox(boxRect), m_parent, "TexView"));
prefsListView->AddItem(new PrefsListItem(constructToolbarBox(boxRect), m_parent, "Toolbars"));
prefsListView->Select(0);
prefsListView->MakeFocus(true);
}
示例11: font
pbView::pbView(BRect r) : mobileView(r, "pbView") {
caption->SetText(_("Phonebooks summary"));
BFont font(be_plain_font);
float maxw, totalw = 0;
BRect r = this->MyBounds();
r.InsetBy(10,15);
r.right -= B_V_SCROLL_BAR_WIDTH;
r.bottom -= 100;
// add column list
CLVContainerView *containerView;
list = new ColumnListView(r, &containerView, NULL, B_FOLLOW_TOP_BOTTOM|B_FOLLOW_LEFT,
B_WILL_DRAW|B_FRAME_EVENTS|B_NAVIGABLE, B_SINGLE_SELECTION_LIST, false, true, true, true,
B_FANCY_BORDER);
maxw = font.StringWidth(_("Folder"))*5+20; totalw += maxw;
list->AddColumn(new CLVColumn(_("Folder"), maxw, CLV_TELL_ITEMS_WIDTH|CLV_HEADER_TRUNCATE|CLV_SORT_KEYABLE));
maxw = font.StringWidth(_("Unique"))*2+20; totalw += maxw;
list->AddColumn(new CLVColumn(_("Unique"), maxw, CLV_TELL_ITEMS_WIDTH|CLV_HEADER_TRUNCATE|CLV_SORT_KEYABLE));
maxw = font.StringWidth(_("Used"))*2+20; totalw += maxw;
list->AddColumn(new CLVColumn(_("Used"), maxw, CLV_TELL_ITEMS_WIDTH|CLV_HEADER_TRUNCATE|CLV_SORT_KEYABLE));
maxw = font.StringWidth(_("Total"))*2+20; totalw += maxw;
list->AddColumn(new CLVColumn(_("Total"), maxw, CLV_TELL_ITEMS_WIDTH|CLV_HEADER_TRUNCATE|CLV_SORT_KEYABLE));
maxw = font.StringWidth(_("Used (%)"))+20;
list->AddColumn(new CLVColumn(_("Used (%)"), r.right-B_V_SCROLL_BAR_WIDTH-4-totalw, CLV_TELL_ITEMS_WIDTH|CLV_HEADER_TRUNCATE|CLV_SORT_KEYABLE));
list->SetSortFunction(CLVEasyItem::CompareItems);
this->AddChild(containerView);
list->SetInvocationMessage(new BMessage(PBLIST_INV));
list->SetSelectionMessage(new BMessage(PBLIST_SEL));
r = this->MyBounds();
r.InsetBy(10,15);
r.top = r.bottom - font.Size()*4 - 30;
r.bottom = r.top + font.Size()*2;
this->AddChild(progress = new BStatusBar(r, "pbStatusBar"));
progress->SetResizingMode(B_FOLLOW_LEFT_RIGHT|B_FOLLOW_BOTTOM);
progress->SetMaxValue(100);
progress->Hide();
r = this->MyBounds();
r.InsetBy(20,20);
BRect s;
s = r; s.top = s.bottom - font.Size()*2;
float len = s.Width()/5;
s.right = s.left + len - 10;
this->AddChild(refresh = new BButton(s, "pbRefresh", _("Refresh"), new BMessage(PBREFRESH), B_FOLLOW_LEFT|B_FOLLOW_BOTTOM));
s.OffsetBy(len*4,0);
this->AddChild(refresh = new BButton(s, "pbExport", _("Export"), new BMessage(PBEXPORT), B_FOLLOW_RIGHT|B_FOLLOW_BOTTOM));
}
示例12: BMessage
DesktopSettingsView::DesktopSettingsView(BRect rect)
: SettingsView(rect, "DesktopSettingsView")
{
rect.OffsetTo(B_ORIGIN);
fShowDisksIconRadioButton = new BRadioButton(rect, "", "Show Disks icon",
new BMessage(kShowDisksIconChanged));
fShowDisksIconRadioButton->ResizeToPreferred();
AddChild(fShowDisksIconRadioButton);
const float itemSpacing = fShowDisksIconRadioButton->Bounds().Height() + kItemExtraSpacing;
rect.OffsetBy(0, itemSpacing);
fMountVolumesOntoDesktopRadioButton = new BRadioButton(rect, "",
"Show volumes on Desktop", new BMessage(kVolumesOnDesktopChanged));
AddChild(fMountVolumesOntoDesktopRadioButton);
fMountVolumesOntoDesktopRadioButton->ResizeToPreferred();
rect.OffsetBy(20, itemSpacing);
fMountSharedVolumesOntoDesktopCheckBox = new BCheckBox(rect, "",
"Show shared volumes on Desktop", new BMessage(kVolumesOnDesktopChanged));
AddChild(fMountSharedVolumesOntoDesktopCheckBox);
fMountSharedVolumesOntoDesktopCheckBox->ResizeToPreferred();
rect.OffsetBy(-20, itemSpacing);
rect = Bounds();
rect.top = rect.bottom;
fMountButton = new BButton(rect, "", "Mount settings" B_UTF8_ELLIPSIS,
new BMessage(kRunAutomounterSettings), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
fMountButton->ResizeToPreferred();
fMountButton->MoveBy(0, -fMountButton->Bounds().Height());
AddChild(fMountButton);
fMountButton->SetTarget(be_app);
}
示例13:
void
_MediaSlider_::UpdateThumb(
bool force)
{
fBitmap->Lock();
BRect bounds = fOffscreenView->Bounds();
bounds.left += 2.0;
bounds.right -= kThumbWidth + 3.0;
BRect thumbRect = fThumbRect;
thumbRect.OffsetTo(bounds.left + (bounds.right * ((float)fCurTime / (float)fTotalTime)), thumbRect.top);
if ((!force) && (thumbRect == fThumbRect)) {
fBitmap->Unlock();
return;
}
fOffscreenView->SetLowColor(kSliderBackgroundColor);
fOffscreenView->FillRect(fThumbRect, B_SOLID_LOW);
BRect drawRect = fThumbRect | thumbRect;
fThumbRect = thumbRect;
fOffscreenView->SetHighColor(kBlack);
fOffscreenView->StrokeRect(thumbRect, B_SOLID_HIGH);
thumbRect.InsetBy(1.0, 1.0);
fOffscreenView->BeginLineArray(4);
fOffscreenView->AddLine(thumbRect.RightTop(), thumbRect.RightBottom(), kThumbDarkColor);
fOffscreenView->AddLine(thumbRect.RightBottom(), thumbRect.LeftBottom(), kThumbDarkColor);
fOffscreenView->AddLine(thumbRect.LeftBottom(), thumbRect.LeftTop(), kThumbLightColor);
fOffscreenView->AddLine(thumbRect.LeftTop(), thumbRect.RightTop(), kThumbLightColor);
fOffscreenView->EndLineArray();
thumbRect.InsetBy(1.0, 1.0);
fOffscreenView->SetHighColor(kThumbBackgroundColor);
fOffscreenView->FillRect(thumbRect, B_SOLID_HIGH);
fOffscreenView->Sync();
fBitmap->Unlock();
BPoint drawLoc(0.0, (Bounds().Height() - kSliderHeight) / 2);
BRect dstRect = drawRect;
dstRect.OffsetBy(drawLoc);
DrawBitmap(fBitmap, drawRect, dstRect);
}
示例14: BDragger
AnalogView::AnalogView(BRect r, int cpu)
: _inherited(r, "", B_FOLLOW_NONE, B_WILL_DRAW | B_PULSE_NEEDED)
{
BDragger* dragger;
BRect rt = r;
InitObject(r, cpu);
rt.OffsetTo(B_ORIGIN);
rt.left = rt.right - 7;
rt.top = rt.bottom - 7;
rt.OffsetBy(-1, -1);
dragger = new BDragger(rt, (BView *)this );
AddChild(dragger);
}
示例15: DrawContent
void TIconMenu::DrawContent()
{
if (iconLabel) {
Menu()->SetDrawingMode(B_OP_OVER);
float width, height;
Menu()->GetPreferredSize(&width, &height);
BRect destBounds = bounds;
destBounds.OffsetBy(8.0, ((height - bounds.Height()) * 0.5) - 1);
// Scaling the icon is left as an exercise for the reader :)
Menu()->DrawBitmap(iconLabel, bounds, destBounds);
} else
BMenuItem::DrawContent();
}