本文整理汇总了C++中BLayoutItem类的典型用法代码示例。如果您正苦于以下问题:C++ BLayoutItem类的具体用法?C++ BLayoutItem怎么用?C++ BLayoutItem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BLayoutItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BTextControl
void
BreakpointEditWindow::_Init()
{
fConditionInput = new BTextControl(NULL, NULL, NULL);
BLayoutItem* textLayoutItem = fConditionInput->CreateTextViewLayoutItem();
textLayoutItem->SetExplicitMinSize(BSize(200.0, B_SIZE_UNSET));
BLayoutBuilder::Group<>(this, B_VERTICAL)
.SetInsets(B_USE_DEFAULT_SPACING)
.Add((fAlwaysRadio = new BRadioButton("Break always",
new BMessage(MSG_SET_BREAK_ALWAYS))))
.AddGroup(B_HORIZONTAL)
.Add((fConditionRadio = new BRadioButton("Break on condition: ",
new BMessage(MSG_SET_BREAK_ON_CONDITION))))
.Add(textLayoutItem)
.End()
.AddGroup(B_HORIZONTAL)
.AddGlue()
.Add((fSaveButton = new BButton("Save",
new BMessage(MSG_SAVE_BREAKPOINT_SETTINGS))))
.Add((fCancelButton = new BButton("Cancel",
new BMessage(B_CANCEL))))
.End()
.End();
AutoLocker< ::Team> teamLocker(fTeam);
if (fTargetBreakpoint->HasCondition()) {
fConditionRadio->SetValue(B_CONTROL_ON);
fConditionInput->SetText(fTargetBreakpoint->Condition());
} else {
fAlwaysRadio->SetValue(B_CONTROL_ON);
fConditionInput->SetEnabled(false);
}
}
示例2:
LaunchButton*
PadView::ButtonAt(int32 index) const
{
BLayoutItem* item = fButtonLayout->ItemAt(index);
if (item == NULL)
return NULL;
return dynamic_cast<LaunchButton*>(item->View());
}
示例3:
BView*
TabManager::ViewForTab(int32 tabIndex) const
{
BLayoutItem* item = fCardLayout->ItemAt(tabIndex);
if (item != NULL)
return item->View();
return NULL;
}
示例4: Panel
NamePanel::NamePanel(const char* label, const char* text, BWindow* window,
BHandler* target, BMessage* message, const BSize& size)
:
Panel(BRect(B_ORIGIN, size), B_TRANSLATE("Name Panel"),
B_MODAL_WINDOW_LOOK, B_MODAL_SUBSET_WINDOW_FEEL,
B_ASYNCHRONOUS_CONTROLS | B_NOT_V_RESIZABLE
| B_AUTO_UPDATE_SIZE_LIMITS),
fWindow(window),
fTarget(target),
fMessage(message)
{
BButton* defaultButton = new BButton(B_TRANSLATE("OK"),
new BMessage(MSG_PANEL_OK));
BButton* cancelButton = new BButton(B_TRANSLATE("Cancel"),
new BMessage(MSG_PANEL_CANCEL));
fNameTC = new BTextControl(label, text, NULL);
BLayoutItem* inputItem = fNameTC->CreateTextViewLayoutItem();
inputItem->SetExplicitMinSize(
BSize(fNameTC->StringWidth("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"),
B_SIZE_UNSET));
BLayoutBuilder::Group<>(this, B_VERTICAL, 10)
.AddGlue()
// controls
.AddGroup(B_HORIZONTAL, 5)
.AddStrut(5)
// text control
.Add(fNameTC->CreateLabelLayoutItem())
.Add(inputItem)
.AddStrut(5)
.End()
.AddGlue()
// buttons
.AddGroup(B_HORIZONTAL, 5)
.AddGlue()
.Add(cancelButton)
.Add(defaultButton)
.AddStrut(5)
.End()
.AddGlue();
SetDefaultButton(defaultButton);
fNameTC->MakeFocus(true);
if (fWindow && fWindow->Lock()) {
fSavedTargetWindowFeel = fWindow->Feel();
if (fSavedTargetWindowFeel != B_NORMAL_WINDOW_FEEL)
fWindow->SetFeel(B_NORMAL_WINDOW_FEEL);
fWindow->Unlock();
}
AddToSubset(fWindow);
}
示例5:
int32
BLayout::IndexOfView(BView* child) const
{
int itemCount = fItems.CountItems();
for (int32 i = 0; i < itemCount; i++) {
BLayoutItem* item = (BLayoutItem*)fItems.ItemAt(i);
if (dynamic_cast<BViewLayoutItem*>(item) && item->View() == child)
return i;
}
return -1;
}
示例6: _ValidateMinMax
void
BTwoDimensionalLayout::LayoutView()
{
_ValidateMinMax();
// layout the horizontal/vertical elements
BSize size = SubtractInsets(View()->Frame().Size());
#ifdef DEBUG_LAYOUT
printf("BTwoDimensionalLayout::LayoutView(%p): size: (%.1f, %.1f)\n",
View(), size.width, size.height);
#endif
fLocalLayouter->Layout(size);
// layout the items
int itemCount = CountItems();
for (int i = 0; i < itemCount; i++) {
BLayoutItem* item = ItemAt(i);
if (item->IsVisible()) {
Dimensions itemDimensions;
GetItemDimensions(item, &itemDimensions);
BRect frame = fLocalLayouter->ItemFrame(itemDimensions);
frame.left += fLeftInset;
frame.top += fTopInset;
frame.right += fLeftInset;
frame.bottom += fTopInset;
{
#ifdef DEBUG_LAYOUT
printf(" frame for item %2d (view: %p): ", i, item->View());
frame.PrintToStream();
#endif
//BSize min(item->MinSize());
//BSize max(item->MaxSize());
//printf(" min: (%.1f, %.1f), max: (%.1f, %.1f)\n", min.width, min.height,
// max.width, max.height);
//if (item->HasHeightForWidth()) {
//float minHeight, maxHeight, preferredHeight;
//item->GetHeightForWidth(frame.Width(), &minHeight, &maxHeight,
// &preferredHeight);
//printf(" hfw: min: %.1f, max: %.1f, pref: %.1f\n", minHeight, maxHeight,
// preferredHeight);
//}
}
item->AlignInFrame(frame);
}
//else
//printf(" item %2d not visible", i);
}
}
示例7: BView
/*!
* \brief Default constructor
* \param[in] frame The rectangle enclosing the view
* \param[in] name Name of the view. Will be passed to BView's constructor.
*
*/
CalendarModulePreferencesView::CalendarModulePreferencesView( BRect frame )
:
BView( BRect( frame.left, frame.top, frame.right, frame.bottom-10 ),
"Calendar Module Preferences",
B_FOLLOW_LEFT | B_FOLLOW_TOP,
B_NAVIGABLE | B_WILL_DRAW | B_FRAME_EVENTS )
{
BRect tempFrame = this->Bounds(); // Got the boundaries
this->SetViewColor( ui_color( B_PANEL_BACKGROUND_COLOR ) );
tempFrame.InsetBySelf( 5, 5 );
tempFrame.bottom -= 10;
/* Add the chooser for the calendar modules */
BGroupLayout* groupLayout = new BGroupLayout( B_VERTICAL );
if ( !groupLayout ) {
/* Panic! */
exit( 1 );
}
groupLayout->SetSpacing( 2 );
this->SetLayout( groupLayout );
// Create the menu with all supported calendar modules
calendarModules = PopulateModulesMenu();
if ( ! calendarModules ) {
/* Panic! */
exit ( 1 );
}
calendarModuleSelector = new BMenuField( BRect( 0, 0, this->Bounds().Width() - 10, 1 ),
"Calendar Modules selector",
"Calendar module:",
calendarModules,
B_FOLLOW_H_CENTER | B_FOLLOW_TOP );
if ( !calendarModuleSelector ) {
/* Panic! */
exit ( 1 );
}
calendarModuleSelector->ResizeToPreferred();
// Add the menu with all calendar modules to the layout
BLayoutItem* layoutItem = groupLayout->AddView( 0, calendarModuleSelector, 1 );
if ( layoutItem ) {
layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_CENTER, B_ALIGN_TOP ) );
}
// Relayout
groupLayout->Relayout();
} // <-- end of constructor for CalendarModulePreferencesView
示例8:
void
MediaWindow::_ClearParamView()
{
BLayoutItem* item = fContentLayout->VisibleItem();
if (!item)
return;
BView* view = item->View();
if (view != fVideoView && view != fAudioView && view != fMidiView) {
fContentLayout->RemoveItem(item);
delete item;
delete view;
delete fParamWeb;
fParamWeb = NULL;
}
}
示例9: _FindInsertIndex
int32 _FindInsertIndex(PartitionView* view, BGroupLayout* layout) const
{
int32 insertIndex = 0;
int32 count = layout->CountItems();
for (int32 i = 0; i < count; i++) {
BLayoutItem* item = layout->ItemAt(i);
if (!item)
break;
PartitionView* sibling
= dynamic_cast<PartitionView*>(item->View());
if (sibling && sibling->Offset() > view->Offset())
break;
insertIndex++;
}
return insertIndex;
}
示例10: CountItems
// _ValidateMinMax
void
BCardLayout::_ValidateMinMax()
{
if (fMinMaxValid)
return;
fMin.width = 0;
fMin.height = 0;
fMax.width = B_SIZE_UNLIMITED;
fMax.height = B_SIZE_UNLIMITED;
fPreferred.width = 0;
fPreferred.height = 0;
int32 itemCount = CountItems();
for (int32 i = 0; i < itemCount; i++) {
BLayoutItem* item = ItemAt(i);
BSize min = item->MinSize();
BSize max = item->MaxSize();
BSize preferred = item->PreferredSize();
fMin.width = max_c(fMin.width, min.width);
fMin.height = max_c(fMin.height, min.height);
fMax.width = min_c(fMax.width, max.width);
fMax.height = min_c(fMax.height, max.height);
fPreferred.width = max_c(fPreferred.width, preferred.width);
fPreferred.height = max_c(fPreferred.height, preferred.height);
}
fMax.width = max_c(fMax.width, fMin.width);
fMax.height = max_c(fMax.height, fMin.height);
fPreferred.width = max_c(fPreferred.width, fMin.width);
fPreferred.height = max_c(fPreferred.height, fMin.height);
fPreferred.width = min_c(fPreferred.width, fMax.width);
fPreferred.height = min_c(fPreferred.height, fMax.height);
fMinMaxValid = true;
if (BView* view = View())
view->ResetLayoutInvalidation();
}
示例11: streamNodeSource
void
TFilePanel::RestoreState()
{
BNode defaultingNode;
if (DefaultStateSourceNode(kDefaultFilePanelTemplate, &defaultingNode,
false)) {
AttributeStreamFileNode streamNodeSource(&defaultingNode);
RestoreWindowState(&streamNodeSource);
PoseView()->Init(&streamNodeSource);
} else {
RestoreWindowState(NULL);
PoseView()->Init(NULL);
}
// Finish UI creation now that the PoseView is initialized
BLayoutItem* item
= fBorderedView->GroupLayout()->AddView(0, fPoseView->TitleView());
BSize minSize = item->MinSize();
BSize maxSize = item->MaxSize();
item->SetExplicitMinSize(BSize(minSize.Width(), kTitleViewHeight));
item->SetExplicitMaxSize(BSize(maxSize.Width(), kTitleViewHeight));
BRect rect(fBorderedView->Frame());
rect.right = rect.left + kCountViewWidth;
rect.top = rect.bottom + 1;
rect.bottom = rect.top + PoseView()->HScrollBar()->Bounds().Height() - 1;
PoseView()->CountView()->MoveTo(rect.LeftTop());
PoseView()->CountView()->ResizeTo(rect.Size());
PoseView()->CountView()->SetResizingMode(B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
fBackView->AddChild(PoseView()->CountView(), fBorderedView);
PoseView()->HScrollBar()->MoveBy(kCountViewWidth + 1, 0);
PoseView()->HScrollBar()->ResizeBy(-kCountViewWidth - 1, 0);
// The Be Book states that the BTitleView will have a name of "TitleView",
// and so some apps will try to grab it by that name and move it around.
// They don't need to, because resizing "PoseView" (really the BorderedView)
// will resize the BTitleView as well. So just create a dummy view here
// so that they don't get NULL when trying to find the view.
BView* dummyTitleView = new BView(BRect(), "TitleView", B_FOLLOW_NONE, 0);
fBackView->AddChild(dummyTitleView);
dummyTitleView->Hide();
}
示例12: ItemAt
bool
BLayout::RemoveView(BView* child)
{
bool removed = false;
// a view can have any number of layout items - we need to remove them all
for (int32 i = fItems.CountItems(); i-- > 0;) {
BLayoutItem* item = ItemAt(i);
if (item->View() != child)
continue;
RemoveItem(i);
removed = true;
delete item;
}
return removed;
}
示例13: _ValidateMinMax
// GetHeightForWidth
void
BCardLayout::GetHeightForWidth(float width, float* min, float* max,
float* preferred)
{
_ValidateMinMax();
// init with useful values
float minHeight = fMin.height;
float maxHeight = fMax.height;
float preferredHeight = fPreferred.height;
// apply the items' constraints
int32 count = CountItems();
for (int32 i = 0; i < count; i++) {
BLayoutItem* item = ItemAt(i);
if (item->HasHeightForWidth()) {
float itemMinHeight;
float itemMaxHeight;
float itemPreferredHeight;
item->GetHeightForWidth(width, &itemMinHeight, &itemMaxHeight,
&itemPreferredHeight);
minHeight = max_c(minHeight, itemMinHeight);
maxHeight = min_c(maxHeight, itemMaxHeight);
preferredHeight = min_c(preferredHeight, itemPreferredHeight);
}
}
// adjust max and preferred, if necessary
maxHeight = max_c(maxHeight, minHeight);
preferredHeight = max_c(preferredHeight, minHeight);
preferredHeight = min_c(preferredHeight, maxHeight);
if (min)
*min = minHeight;
if (max)
*max = maxHeight;
if (preferred)
*preferred = preferredHeight;
}
示例14:
bool
BTwoDimensionalLayout::LocalLayouter::AddHeightForWidthConstraints(
VerticalCompoundLayouter* compoundLayouter, Layouter* layouter,
BLayoutContext* context)
{
if (context != fHorizontalLayoutContext)
return false;
if (fHeightForWidthConstraintsAdded)
return false;
LayoutInfo* hLayoutInfo = fHLayouter->GetLayoutInfo();
// add the children's height for width constraints
int32 itemCount = fHeightForWidthItems.CountItems();
for (int32 i = 0; i < itemCount; i++) {
BLayoutItem* item = (BLayoutItem*)fHeightForWidthItems.ItemAt(i);
Dimensions itemDimensions;
fLayout->GetItemDimensions(item, &itemDimensions);
float minHeight, maxHeight, preferredHeight;
item->GetHeightForWidth(
hLayoutInfo->ElementRangeSize(itemDimensions.x,
itemDimensions.width),
&minHeight, &maxHeight, &preferredHeight);
layouter->AddConstraints(
itemDimensions.y,
itemDimensions.height,
minHeight,
maxHeight,
preferredHeight);
}
SetHeightForWidthConstraintsAdded(true);
return true;
}
示例15: CountElements
void
BTwoDimensionalLayout::LocalLayouter::AddConstraints(
CompoundLayouter* compoundLayouter, Layouter* layouter)
{
enum orientation orientation = compoundLayouter->Orientation();
int itemCount = fLayout->CountItems();
if (itemCount > 0) {
for (int i = 0; i < itemCount; i++) {
BLayoutItem* item = fLayout->ItemAt(i);
if (item->IsVisible()) {
Dimensions itemDimensions;
fLayout->GetItemDimensions(item, &itemDimensions);
BSize min = item->MinSize();
BSize max = item->MaxSize();
BSize preferred = item->PreferredSize();
if (orientation == B_HORIZONTAL) {
layouter->AddConstraints(
itemDimensions.x,
itemDimensions.width,
min.width,
max.width,
preferred.width);
if (item->HasHeightForWidth())
fHeightForWidthItems.AddItem(item);
} else {
layouter->AddConstraints(
itemDimensions.y,
itemDimensions.height,
min.height,
max.height,
preferred.height);
}
}
}
// add column/row constraints
ColumnRowConstraints constraints;
int elementCount = CountElements(compoundLayouter);
for (int element = 0; element < elementCount; element++) {
fLayout->GetColumnRowConstraints(orientation, element,
&constraints);
layouter->SetWeight(element, constraints.weight);
layouter->AddConstraints(element, 1, constraints.min,
constraints.max, constraints.min);
}
}
}