本文整理汇总了C++中BStringView::MoveTo方法的典型用法代码示例。如果您正苦于以下问题:C++ BStringView::MoveTo方法的具体用法?C++ BStringView::MoveTo怎么用?C++ BStringView::MoveTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BStringView
的用法示例。
在下文中一共展示了BStringView::MoveTo方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Bounds
void
TSignatureView::AttachedToWindow()
{
BRect rect = Bounds();
float name_text_length = StringWidth(kNameText);
float sig_text_length = StringWidth(kSigText);
float divide_length;
if (name_text_length > sig_text_length)
divide_length = name_text_length;
else
divide_length = sig_text_length;
rect.InsetBy(8,0);
rect.top+= 8;
fName = new TNameControl(rect, kNameText, new BMessage(NAME_FIELD));
AddChild(fName);
fName->SetDivider(divide_length + 10);
fName->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);
rect.OffsetBy(0,fName->Bounds().Height()+5);
rect.bottom = rect.top + kSigHeight;
rect.left = fName->TextView()->Frame().left;
BRect text = rect;
text.OffsetTo(10,0);
fTextView = new TSigTextView(rect, text);
BScrollView *scroller = new BScrollView("SigScroller", fTextView, B_FOLLOW_ALL, 0, false, true);
AddChild(scroller);
scroller->ResizeBy(-1 * scroller->ScrollBar(B_VERTICAL)->Frame().Width() - 9, 0);
scroller->MoveBy(7,0);
/* back up a bit to make room for the label */
rect = scroller->Frame();
BStringView *stringView = new BStringView(rect, "SigLabel", kSigText);
AddChild(stringView);
float tWidth, tHeight;
stringView->GetPreferredSize(&tWidth, &tHeight);
/* the 5 is for the spacer in the TextView */
rect.OffsetBy(-1 *(tWidth) - 5, 0);
rect.right = rect.left + tWidth;
rect.bottom = rect.top + tHeight;
stringView->MoveTo(rect.LeftTop());
stringView->ResizeTo(rect.Width(), rect.Height());
/* Resize the View to the correct height */
scroller->SetResizingMode(B_FOLLOW_NONE);
ResizeTo(Frame().Width(), scroller->Frame().bottom + 8);
scroller->SetResizingMode(B_FOLLOW_ALL);
}
示例2: AttachedToWindow
void AttachedToWindow()
{
if (Parent()) {
SetViewColor(Parent()->ViewColor());
SetHighColor(Parent()->HighColor());
SetLowColor (Parent()->LowColor() );
}
BRect rect;
rect = Bounds();
rect.bottom = rect.top + B_H_SCROLL_BAR_HEIGHT - 1;
mTotalCount_->ResizeTo(rect.Width(), rect.Height());
mTotalCount_->MoveTo(rect.left, rect.top);
rect = Bounds();
rect.top = rect.top + B_H_SCROLL_BAR_HEIGHT;
mMarkedCount_->ResizeTo(rect.Width(), rect.Height());
mMarkedCount_->MoveTo(rect.left, rect.top);
}
示例3: AttachedToWindow
//.........这里部分代码省略.........
monthStringView=new BStringView(BRect(10,10,100,100),"monthStringViewAViX",
monthNames[8]);
monthStringView->SetAlignment(B_ALIGN_CENTER);
AddChild(monthStringView);
monthStringView->ResizeToPreferred();
monthStringView->SetText(monthNames[cmonth-1]);
monthStringView->SetViewColor(VIEW_COLOR);
s.SetTo("");
if(cyear<10) s.Append("000");
else if(cyear<100) s.Append("00");
else if(cyear<1000) s.Append("0");
s<<cyear;
yearStringView=new BStringView(BRect(10,10,100,100),"yearStringViewAViX",
"0000");
AddChild(yearStringView);
yearStringView->ResizeToPreferred();
yearStringView->SetText(s.String());
yearStringView->SetViewColor(VIEW_COLOR);
ResizeTo(w_cell*7+1,h_cell*7+3+16+yearStringView->Bounds().bottom+todayStringView->Bounds().bottom);
Window()->ResizeTo(Bounds().right, Bounds().bottom);
yearMStringView[0]=new MouseSenseStringView(new BMessage('YEA0'),msng,
BRect(10,10,100,100),
"yearMStringViewAViX0",
"<<");
AddChild(yearMStringView[0]);
yearMStringView[0]->ResizeToPreferred();
yearMStringView[0]->SetViewColor(VIEW_COLOR);
yearMStringView[1]=new MouseSenseStringView(new BMessage('YEA1'),msng,
BRect(10,10,100,100),
"yearMStringViewAViX1",
">>");
AddChild(yearMStringView[1]);
yearMStringView[1]->ResizeToPreferred();
yearMStringView[1]->SetViewColor(VIEW_COLOR);
monthMStringView[0]=new MouseSenseStringView(new BMessage('MON0'),msng,
BRect(10,10,100,100),
"monthMStringViewAViX0",
"<<");
AddChild(monthMStringView[0]);
monthMStringView[0]->ResizeToPreferred();
monthMStringView[0]->SetViewColor(VIEW_COLOR);
monthMStringView[1]=new MouseSenseStringView(new BMessage('MON1'),msng,
BRect(10,10,100,100),
"monthMStringViewAViX1",
">>");
AddChild(monthMStringView[1]);
monthMStringView[1]->ResizeToPreferred();
monthMStringView[1]->SetViewColor(VIEW_COLOR);
todayStringView->MoveTo((Bounds().right-todayStringView->Bounds().right)/2,
Bounds().bottom-todayStringView->Bounds().bottom-2);
if(tyear<first_year || tyear>last_year) todayStringView->SetHighColor(NOACTIVE_COLOR);
yearMStringView[1]->MoveTo(Bounds().right-yearMStringView[1]->Bounds().right,5);
yearStringView->MoveTo(yearMStringView[1]->Frame().left-yearStringView->Bounds().right,5);
yearMStringView[0]->MoveTo(yearStringView->Frame().left-yearMStringView[0]->Bounds().right,5);
monthStringView->MoveTo((yearMStringView[0]->Frame().left-monthStringView->Bounds().right)/2,5);
monthMStringView[0]->MoveTo(monthStringView->Frame().left-monthMStringView[0]->Bounds().right,5);
monthMStringView[1]->MoveTo(monthStringView->Frame().right,5);
which_focused=2; // days of month
Bmp=new BBitmap(BRect(Frame()),B_RGB32,true);
BmpView=new BView(Bmp->Bounds(),"BV",0,B_WILL_DRAW);
Bmp->AddChild(BmpView);
Bmp->Lock();
BmpView->SetHighColor(VIEW_COLOR);
BmpView->FillRect(BmpView->Frame());
BmpView->SetHighColor(LINE_COLOR);
BmpView->StrokeLine(BPoint(3,todayStringView->Frame().top-5),
BPoint(Bounds().right-3,todayStringView->Frame().top-5));
BmpView->StrokeLine(BPoint(3,yearStringView->Frame().bottom+2),
BPoint(Bounds().right-3,yearStringView->Frame().bottom+2));
BmpView->SetHighColor(0,0,0,0);
float y=yearStringView->Frame().bottom+h_cell;
float x=0;
for(int i=0;i<7;i++)
{
BmpView->DrawString(weekdayNames[i],BPoint(x+(w_cell-StringWidth(weekdayNames[i]))/2,y));
x+=w_cell;
}
BmpView->Sync();
Bmp->Unlock();
DrawMonth();
}
示例4: BuildGUI
//.........这里部分代码省略.........
name, _T(desc), enabling);
if (active) ((BCheckBox*)control)->SetValue(B_CONTROL_ON);
} break;
default: {
continue;
};
};
if (!value) value = "";
if (!control) {
if (freeText) {
if (multiLine == false) {
control = new BTextControl(
BRect(0, 0, kControlWidth, fFontHeight), name,
_T(desc), value, NULL);
if (secret) {
((BTextControl *)control)->TextView()->HideTyping(true);
((BTextControl *)control)->SetText(_T(value));
};
((BTextControl *)control)->SetDivider(kDividerWidth);
} else
{
BRect rect;
BRect textRect;
if (desc) //andrea: add description only if available.
{
BRect labelRect(0, 0, kDividerWidth, fFontHeight);
BStringView *label = new BStringView(labelRect, "NA", _T(desc),
B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW);
view->AddChild(label);
label->MoveTo(kEdgeOffset, yOffset);
rect = BRect(0, 0, kControlWidth - kDividerWidth, fFontHeight * 4);
rect.right -= B_V_SCROLL_BAR_WIDTH + kEdgeOffset + kControlOffset;
xOffset = kEdgeOffset + kDividerWidth;
}
else
{
rect = BRect(0, 0, kControlWidth, fFontHeight * 4);
rect.right -= B_V_SCROLL_BAR_WIDTH + kControlOffset;
xOffset = 0;
}
textRect = rect;
textRect.InsetBy(kEdgeOffset, kEdgeOffset);
textRect.OffsetTo(1.0, 1.0);
BTextView *textView = new BTextView(rect, name, textRect,
B_FOLLOW_ALL_SIDES, B_WILL_DRAW);
control = new BScrollView("NA", textView, B_FOLLOW_ALL_SIDES,
B_WILL_DRAW | B_NAVIGABLE, false, true);
textView->SetText(_T(value));
};
} else {
control = new BMenuField(BRect(0, 0, kControlWidth, fFontHeight),
name, _T(desc), menu);
float size=kDividerWidth;
if(control->StringWidth(_T(desc)) > kDividerWidth)
size=control->StringWidth(_T(desc)) + 20;
((BMenuField *)control)->SetDivider(size);
示例5:
//.........这里部分代码省略.........
{
localLeft = paramMatrixLeft + hpad;
float columnRight = 0;
excessBottom = 0;
for ( uint32 jj = 0;
jj < mui32Columns;
jj++)
{
excessRight = 0;
LayoutMatrixItem * lmi = (LayoutMatrixItem *)mpItemsList->ItemAt(index++);
switch (lmi->mui32Kind)
{
case KIND_MYPOPUPMENU:
{
hasPopUpMenu = true;
MyPopUpMenu * scratchPopUpMenu = (MyPopUpMenu *)lmi->mpItem;
scratchPopUpMenu->mfLabelLeft = localLeft;
excessRightHold = lmi->mfWidthPref + scratchPopUpMenu->mfLabelWidth;
scratchPopUpMenu->SetLeft(localLeft);
scratchPopUpMenu->mfLabelTop = localTop;
if ((scratchPopUpMenu->mfHeight + 9) > scratchPopUpMenu->mfLabelHeight)
{
excessBottomHold = scratchPopUpMenu->mfHeight + 10;
}
else
{
excessBottomHold = scratchPopUpMenu->mfLabelHeight + 1;
}
}
break;
case KIND_MYTEXTVIEW:
{
BTextView * scratchTextView = (BTextView *)lmi->mpItem;
scratchTextView->MoveTo(localLeft, localTop);
excessRightHold = ((MyTextView *)scratchTextView)->mfWidth;
excessBottomHold = ((MyTextView *)scratchTextView)->mfHeight;
}
break;
case KIND_MYLISTVIEW:
{
BListView * scratchListView = (BListView *)lmi->mpItem;
scratchListView->MoveTo(localLeft, localTop);
((BListView *)(lmi->mpItem))->GetPreferredSize(&excessRightHold, &excessBottomHold);
}
break;
case KIND_MYBUTTON:
{
BButton * scratchMyButton = (BButton *)lmi->mpItem;
scratchMyButton->MoveTo(localLeft, localTop);
excessRightHold = lmi->mfWidthPref;
excessBottomHold = lmi->mfHeightPref;
}
break;
case KIND_MYSLIDER:
{
BSlider * scratchMySlider = (BSlider *)lmi->mpItem;
scratchMySlider->MoveTo(localLeft, localTop);
excessRightHold = lmi->mfWidthPref;
excessBottomHold = lmi->mfHeightPref;
}
break;
case KIND_MYSPACER:
{
MySpacer * scratchMySpacer = (MySpacer *)lmi->mpItem;
if ( (mui32Flags & SAMESIZE)
&&
示例6: locker
//.........这里部分代码省略.........
const char *type = B_TRANSLATE("Unknown type");
switch (fEditor.Type()) {
case B_MINI_ICON_TYPE:
case B_LARGE_ICON_TYPE:
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
case B_VECTOR_ICON_TYPE:
#endif
type = B_TRANSLATE("Icon");
break;
case B_PNG_FORMAT:
type = B_TRANSLATE("PNG format");
break;
case B_MESSAGE_TYPE:
type = B_TRANSLATE("Flattened bitmap");
break;
default:
break;
}
const char *colorSpace;
switch (fBitmap->ColorSpace()) {
case B_GRAY1:
case B_GRAY8:
colorSpace = B_TRANSLATE("Grayscale");
break;
case B_CMAP8:
colorSpace = B_TRANSLATE("8 bit palette");
break;
case B_RGB32:
case B_RGBA32:
case B_RGB32_BIG:
case B_RGBA32_BIG:
colorSpace = B_TRANSLATE("32 bit");
break;
case B_RGB15:
case B_RGBA15:
case B_RGB15_BIG:
case B_RGBA15_BIG:
colorSpace = B_TRANSLATE("15 bit");
break;
case B_RGB16:
case B_RGB16_BIG:
colorSpace = B_TRANSLATE("16 bit");
break;
default:
colorSpace = B_TRANSLATE("Unknown format");
break;
}
snprintf(buffer, sizeof(buffer), "%s, %g x %g, %s", type,
fBitmap->Bounds().Width() + 1, fBitmap->Bounds().Height() + 1,
colorSpace);
fDescriptionView->SetText(buffer);
} else
fDescriptionView->SetText(B_TRANSLATE_COMMENT("Could not read image",
"Image means here a picture file, not a disk image."));
// Update the view size to match the image and its description
float width, height;
fDescriptionView->GetPreferredSize(&width, &height);
fDescriptionView->ResizeTo(width, height);
BRect rect = fDescriptionView->Bounds();
if (fBitmap != NULL) {
BRect bounds = fBitmap->Bounds();
rect.bottom += bounds.Height() + 5;
if (fScaleSlider != NULL && rect.Width() < fScaleSlider->Bounds().Width())
rect.right = fScaleSlider->Bounds().right;
if (bounds.Width() > rect.Width())
rect.right = bounds.right;
// center description below the bitmap
fDescriptionView->MoveTo((rect.Width() - fDescriptionView->Bounds().Width()) / 2,
bounds.Height() + 5);
if (fScaleSlider != NULL) {
// center slider below description
rect.bottom += fScaleSlider->Bounds().Height() + 5;
fScaleSlider->MoveTo((rect.Width() - fScaleSlider->Bounds().Width()) / 2,
fDescriptionView->Frame().bottom + 5);
if (fScaleSlider->IsHidden())
fScaleSlider->Show();
}
} else if (fScaleSlider != NULL && !fScaleSlider->IsHidden())
fScaleSlider->Hide();
ResizeTo(rect.Width(), rect.Height());
if (Parent()) {
// center within parent view
BRect parentBounds = Parent()->Bounds();
MoveTo((parentBounds.Width() - rect.Width()) / 2,
(parentBounds.Height() - rect.Height()) / 2);
}
Invalidate();
// restore old view size
fEditor.SetViewSize(viewSize);
}
示例7: cat
RecipeEditor::RecipeEditor(const BRect &frame, const BMessenger &msgr,
const int32 &number, const char *category)
: BWindow(frame,"Add Recipe",B_FLOATING_WINDOW_LOOK, B_MODAL_SUBSET_WINDOW_FEEL,
B_ASYNCHRONOUS_CONTROLS),
fMessenger(msgr),
fNumber(number),
fCategory(category)
{
AddShortcut('W', B_COMMAND_KEY, new BMessage(B_QUIT_REQUESTED));
AddShortcut('Q', B_COMMAND_KEY, new BMessage(M_QUIT_APP));
BView *back = new BView(Bounds(),"back",B_FOLLOW_ALL, B_WILL_DRAW);
back->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
AddChild(back);
fCategories = new BMenu("Categories");
CppSQLite3Query query = DBQuery("select category from categories order by category;",
"RecipeEditor:get categories");
while(!query.eof())
{
BString cat(DeescapeIllegalCharacters(query.getStringField(0)));
BMessage *menumsg = new BMessage(M_CATEGORY_CHANGED);
menumsg->AddString("name",cat);
fCategories->AddItem(new BMenuItem(cat.String(),menumsg));
query.nextRow();
}
fCategories->SetRadioMode(true);
fCategories->SetLabelFromMarked(true);
if(fCategories->CountItems()>0)
fCategories->ItemAt(0)->SetMarked(true);
BRect r(10,10,10 + fCategories->MaxContentWidth(),11);
BMenuField *field = new BMenuField(r,"field","Category",fCategories,
B_FOLLOW_LEFT | B_FOLLOW_TOP,
B_WILL_DRAW | B_NAVIGABLE | B_NAVIGABLE_JUMP);
back->AddChild(field);
field->ResizeToPreferred();
r = field->Frame();
if(category)
{
BMenuItem *marked = fCategories->FindItem(category);
if(marked)
marked->SetMarked(true);
}
else
{
BMenuItem *marked = fCategories->ItemAt(0L);
if(marked)
marked->SetMarked(true);
}
r.OffsetBy(0,r.Height() + 10);
fNameBox = new AutoTextControl(r,"namebox","Name: ",NULL,NULL,
B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP,
B_WILL_DRAW | B_PULSE_NEEDED | B_NAVIGABLE |
B_NAVIGABLE_JUMP);
fNameBox->SetEscapeCancel(true);
fNameBox->SetDivider(be_plain_font->StringWidth("Name ") + 5);
back->AddChild(fNameBox);
fNameBox->ResizeToPreferred();
r = fNameBox->Frame();
r.right = Bounds().right - 10;
fNameBox->ResizeTo(r.Width(), r.Height());
r.OffsetBy(0,r.Height() + 10);
BStringView *label = new BStringView(r,"inglabel","Ingredients:");
back->AddChild(label);
r.OffsetBy(0,r.Height() + 10);
r.bottom = r.top + 100;
r.right -= B_V_SCROLL_BAR_WIDTH;
BRect textrect = r.OffsetToCopy(0,0);
textrect.InsetBy(10,10);
fIngredientBox = new BTextView(r, "ingredients", textrect, B_FOLLOW_ALL,
B_WILL_DRAW | B_PULSE_NEEDED | B_NAVIGABLE |
B_NAVIGABLE_JUMP);
fIngredientBox->SetDoesUndo(true);
BScrollView *ingredscroll = new BScrollView("ingredients_scroller",fIngredientBox,
B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP,0,false, true);
back->AddChild(ingredscroll);
r = ingredscroll->Frame();
label = new BStringView(BRect(10,10,11,11),"dirlabel","Directions:");
label->ResizeToPreferred();
label->MoveTo(10, r.bottom + 10);
back->AddChild(label);
r.OffsetBy(0,r.Height() + 20 + label->Frame().Height());
r.right -= B_V_SCROLL_BAR_WIDTH;
textrect = r.OffsetToCopy(0,0);
textrect.InsetBy(10,10);
fDirectionsBox = new BTextView(r, "directions", textrect, B_FOLLOW_ALL,
B_WILL_DRAW | B_PULSE_NEEDED | B_NAVIGABLE |
B_NAVIGABLE_JUMP);
fDirectionsBox->SetDoesUndo(true);
//.........这里部分代码省略.........