本文整理汇总了C++中BTextControl::GetPreferredSize方法的典型用法代码示例。如果您正苦于以下问题:C++ BTextControl::GetPreferredSize方法的具体用法?C++ BTextControl::GetPreferredSize怎么用?C++ BTextControl::GetPreferredSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BTextControl
的用法示例。
在下文中一共展示了BTextControl::GetPreferredSize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BTextControl
BTextControl*
DocInfoWindow::_AddFieldToTable(BRect rect, const char* name, const char* value)
{
BTextControl *textControl = new BTextControl(rect, name, name, value, NULL,
B_FOLLOW_LEFT_RIGHT, B_WILL_DRAW | B_NAVIGABLE);
fTable->AddChild(textControl);
float width, height;
textControl->GetPreferredSize(&width, &height);
textControl->ResizeTo(rect.Width(), height);
textControl->SetDivider(rect.Width() / 2.0);
fKeyList->AddItem(new BMenuItem(name, new BMessage(REMOVE_KEY_MSG)));
return textControl;
}
示例2:
void
DocInfoWindow::FrameResized(float newWidth, float newHeight)
{
BTextControl *textControl = dynamic_cast<BTextControl*> (fTable->ChildAt(0));
if (textControl) {
float width, height;
textControl->GetPreferredSize(&width, &height);
int32 count = fKeyList->CountItems();
float fieldsHeight = (height * count) + (2 * count);
_AdjustScrollBar(height, fieldsHeight);
while (textControl) {
textControl->SetDivider(textControl->Bounds().Width() / 2.0);
textControl = dynamic_cast<BTextControl*> (textControl->NextSibling());
}
}
}
示例3: bounds
void
DocInfoWindow::_SetupDocInfoView(BBox* panel)
{
BRect bounds(panel->Bounds());
#if HAVE_FULLVERSION_PDF_LIB
bounds.InsetBy(10.0, 10.0);
#endif
// add list of keys
fKeyList = new BMenu("Delete Key");
BMenuField *menu = new BMenuField(bounds, "delete", "", fKeyList,
B_FOLLOW_BOTTOM);
panel->AddChild(menu);
menu->SetDivider(0);
#ifdef __HAIKU__
menu->ResizeToPreferred();
menu->MoveTo(bounds.left, bounds.bottom - menu->Bounds().Height());
#else
menu->ResizeTo(menu->StringWidth("Delete Key") + 15.0, 25.0);
menu->MoveTo(bounds.left, bounds.bottom - 25.0);
#endif
const char* title[6] = { "Title", "Author", "Subject", "Keywords", "Creator",
NULL }; // PDFlib sets these: "Producer", "CreationDate", not "ModDate"
BMenu* defaultKeys = new BMenu("Default Keys");
for (int32 i = 0; title[i] != NULL; ++i)
defaultKeys->AddItem(new BMenuItem(title[i], new BMessage(DEFAULT_KEY_MSG)));
BRect frame(menu->Frame());
menu = new BMenuField(frame, "add", "", defaultKeys, B_FOLLOW_BOTTOM);
panel->AddChild(menu);
menu->SetDivider(0);
#ifdef __HAIKU__
menu->ResizeToPreferred();
menu->MoveBy(frame.Width() + 10.0, 0.0);
#else
menu->ResizeTo(menu->StringWidth("Default Keys") + 15.0, 25.0);
menu->MoveBy(menu->Bounds().Width() + 10.0, 0.0);
#endif
frame = menu->Frame();
frame.left = frame.right + 10.0;
frame.right = bounds.right;
BTextControl *add = new BTextControl(frame, "add", "Add Key:", "",
new BMessage(ADD_KEY_MSG), B_FOLLOW_LEFT_RIGHT | B_FOLLOW_BOTTOM);
panel->AddChild(add);
float width, height;
add->GetPreferredSize(&width, &height);
add->ResizeTo(bounds.right - frame.left, height);
add->SetDivider(be_plain_font->StringWidth("Add Key: "));
bounds.bottom = frame.top - 10.0;
bounds.right -= B_V_SCROLL_BAR_WIDTH;
bounds.InsetBy(2.0, 2.0);
fTable = new BView(bounds, "table", B_FOLLOW_ALL, B_WILL_DRAW);
fTable->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
fTableScrollView = new BScrollView("scroll_table", fTable, B_FOLLOW_ALL, 0,
false, true);
panel->AddChild(fTableScrollView);
BMessage docInfo;
fDocInfo->FindMessage("doc_info", &docInfo);
// fill table
_BuildTable(docInfo);
}