本文整理汇总了C++中BGridLayout类的典型用法代码示例。如果您正苦于以下问题:C++ BGridLayout类的具体用法?C++ BGridLayout怎么用?C++ BGridLayout使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BGridLayout类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BGridView
PersonView::PersonView(const char* name, const char* categoryAttribute,
const entry_ref *ref)
:
BGridView(),
fLastModificationTime(0),
fGroups(NULL),
fControls(20, false),
fCategoryAttribute(categoryAttribute),
fPictureView(NULL),
fSaving(false)
{
SetName(name);
SetFlags(Flags() | B_WILL_DRAW);
fRef = ref;
BFile* file = NULL;
if (fRef != NULL)
file = new BFile(fRef, B_READ_ONLY);
// Add picture "field", using ID photo 35mm x 45mm ratio
fPictureView = new PictureView(70, 90, ref);
BGridLayout* layout = GridLayout();
float spacing = be_control_look->DefaultItemSpacing();
layout->SetInsets(spacing, spacing, spacing, spacing);
layout->AddView(fPictureView, 0, 0, 1, 5);
layout->ItemAt(0, 0)->SetExplicitAlignment(
BAlignment(B_ALIGN_CENTER, B_ALIGN_TOP));
if (file != NULL)
file->GetModificationTime(&fLastModificationTime);
delete file;
}
示例2: DrawingToolConfigView
TransparencyToolConfigView::TransparencyToolConfigView(DrawingTool* tool)
: DrawingToolConfigView(tool)
{
if (BLayout* layout = GetLayout()) {
BMessage* message = new BMessage(OPTION_CHANGED);
message->AddInt32("option", SIZE_OPTION);
message->AddInt32("value", tool->GetCurrentValue(SIZE_OPTION));
fSizeSlider =
new NumberSliderControl(StringServer::ReturnString(SIZE_STRING),
"1", message, 1, 100, false);
layout->AddView(fSizeSlider);
message = new BMessage(OPTION_CHANGED);
message->AddInt32("option", PRESSURE_OPTION);
message->AddInt32("value", tool->GetCurrentValue(PRESSURE_OPTION));
fSpeedSlider =
new NumberSliderControl(StringServer::ReturnString(SPEED_STRING),
"1", message, 1, 100, false);
layout->AddView(fSpeedSlider);
BGridLayout* gridLayout = BGridLayoutBuilder(5.0, 5.0)
.Add(fSizeSlider->LabelLayoutItem(), 0, 0)
.Add(fSizeSlider->TextViewLayoutItem(), 1, 0)
.Add(fSizeSlider->Slider(), 2, 0)
.Add(fSpeedSlider->LabelLayoutItem(), 0, 1)
.Add(fSpeedSlider->TextViewLayoutItem(), 1, 1)
.Add(fSpeedSlider->Slider(), 2, 1);
gridLayout->SetMaxColumnWidth(1, StringWidth("1000"));
gridLayout->SetMinColumnWidth(2, StringWidth("SLIDERSLIDERSLIDER"));
layout->AddView(gridLayout->View());
}
}
示例3: DrawingToolConfigView
HairyBrushToolConfigView::HairyBrushToolConfigView(DrawingTool* tool)
: DrawingToolConfigView(tool)
{
if (BLayout* layout = GetLayout()) {
BMessage* message = new BMessage(OPTION_CHANGED);
message->AddInt32("option", PRESSURE_OPTION);
message->AddInt32("value", tool->GetCurrentValue(PRESSURE_OPTION));
fBrushSize =
new NumberSliderControl(StringServer::ReturnString(SIZE_STRING),
"0", message, 2, 50, false);
layout->AddView(fBrushSize);
message = new BMessage(OPTION_CHANGED);
message->AddInt32("option", SIZE_OPTION);
message->AddInt32("value", tool->GetCurrentValue(SIZE_OPTION));
fBrushHairs =
new NumberSliderControl(StringServer::ReturnString(HAIRS_STRING),
"0", message, 5, 100, false);
layout->AddView(fBrushHairs);
fColorAmount =
new BSlider("", StringServer::ReturnString(COLOR_AMOUNT_STRING),
new BMessage(COLOR_AMOUNT_CHANGED), 1, 500, B_HORIZONTAL,
B_TRIANGLE_THUMB);
fColorAmount->SetLimitLabels(StringServer::ReturnString(LITTLE_STRING),
StringServer::ReturnString(MUCH_STRING));
fColorAmount->SetValue(tool->GetCurrentValue(CONTINUITY_OPTION));
fColorVariance =
new BSlider("", StringServer::ReturnString(COLOR_VARIANCE_STRING),
new BMessage(COLOR_VARIANCE_CHANGED), 0, 128, B_HORIZONTAL,
B_TRIANGLE_THUMB);
fColorVariance->SetLimitLabels(StringServer::ReturnString(NONE_STRING),
StringServer::ReturnString(RANDOM_STRING));
fColorVariance->SetValue(tool->GetCurrentValue(TOLERANCE_OPTION));
BGridLayout* gridLayout = BGridLayoutBuilder(5.0, 5.0)
.Add(fBrushSize->LabelLayoutItem(), 0, 0)
.Add(fBrushSize->TextViewLayoutItem(), 1, 0)
.Add(fBrushSize->Slider(), 2, 0)
.Add(fBrushHairs->LabelLayoutItem(), 0, 1)
.Add(fBrushHairs->TextViewLayoutItem(), 1, 1)
.Add(fBrushHairs->Slider(), 2, 1)
.SetInsets(5.0, 0.0, 0.0, 0.0);
gridLayout->SetMaxColumnWidth(1, StringWidth("1000"));
gridLayout->SetMinColumnWidth(2, StringWidth("SLIDERSLIDERSLIDER"));
layout->AddItem(BGroupLayoutBuilder(B_VERTICAL)
.Add(gridLayout)
.Add(fColorAmount)
.Add(fColorVariance)
);
}
}
示例4: BView
FontView::FontView()
: BView("Fonts", B_WILL_DRAW )
{
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
fPlainView = new FontSelectionView("plain", B_TRANSLATE("Plain font:"));
fBoldView = new FontSelectionView("bold", B_TRANSLATE("Bold font:"));
fFixedView = new FontSelectionView("fixed", B_TRANSLATE("Fixed font:"));
fMenuView = new FontSelectionView("menu", B_TRANSLATE("Menu font:"));
BGridLayout* layout = new BGridLayout(5, 5);
layout->SetInsets(10, 10, 10, 10);
SetLayout(layout);
int32 row = 0;
add_font_selection_view(layout, fPlainView, row, true);
add_font_selection_view(layout, fBoldView, row, true);
add_font_selection_view(layout, fFixedView, row, true);
add_font_selection_view(layout, fMenuView, row, false);
}
示例5: Visit
virtual void Visit(BStringContactField* field)
{
int count = fOwner->fControls.CountItems();
BGridLayout* layout = fOwner->GridLayout();
if (field->FieldType() != B_CONTACT_SIMPLE_GROUP) {
ContactFieldTextControl* control = new ContactFieldTextControl(field);
layout->AddItem(control->CreateLabelLayoutItem(), 1, count);
layout->AddItem(control->CreateTextViewLayoutItem(), 2, count);
fOwner->fControls.AddItem(control);
} else {
const char* label =
BContactField::ExtendedLabel(field);
fOwner->fGroups = new BPopUpMenu(label);
fOwner->fGroups->SetRadioMode(false);
fOwner->BuildGroupMenu(field);
BMenuField* field = new BMenuField("", "", fOwner->fGroups);
BTextControl* control = new BTextControl("simpleGroup",
NULL, NULL, NULL);
field->SetEnabled(true);
layout->AddItem(field->CreateLabelLayoutItem(), 1, 0, count);
layout->AddItem(field->CreateMenuBarLayoutItem(), 1, 1, count);
layout->AddItem(control->CreateLabelLayoutItem(), 2, 0, count);
layout->AddItem(control->CreateTextViewLayoutItem(), 2, 1, count);
}
}
示例6: AttributeTextControl
void
PersonView::AddAttribute(const char* label, const char* attribute)
{
// Check if this attribute has already been added.
AttributeTextControl* control = NULL;
for (int32 i = fControls.CountItems() - 1; i >= 0; i--) {
if (fControls.ItemAt(i)->Attribute() == attribute) {
return;
}
}
control = new AttributeTextControl(label, attribute);
fControls.AddItem(control);
BGridLayout* layout = GridLayout();
int32 row = fControls.CountItems();
if (fCategoryAttribute == attribute) {
// Special case the category attribute. The Group popup field will
// be added as the label instead.
fGroups = new BPopUpMenu(label);
fGroups->SetRadioMode(false);
BuildGroupMenu();
BMenuField* field = new BMenuField("", "", fGroups);
field->SetEnabled(true);
layout->AddView(field, 1, row);
control->SetLabel("");
layout->AddView(control, 2, row);
} else {
layout->AddItem(control->CreateLabelLayoutItem(), 1, row);
layout->AddItem(control->CreateTextViewLayoutItem(), 2, row);
}
SetAttribute(attribute, true);
}
示例7:
void
PartitionsPage::PageCompleted()
{
BGridLayout* layout = (BGridLayout*)fPartitions->GetLayout();
int32 index = 0;
for (int32 row = 0; row < layout->CountRows(); row += 3, index++) {
BCheckBox* showBox
= dynamic_cast<BCheckBox*>(layout->ItemAt(0, row)->View());
BTextControl* nameControl
= dynamic_cast<BTextControl*>(layout->ItemAt(1, row)->View());
if (nameControl == NULL || showBox == NULL)
debugger("partitions page is broken");
BMessage partition;
if (fSettings->FindMessage("partition", index, &partition) != B_OK)
continue;
partition.ReplaceBool("show", showBox->Value() != 0);
partition.ReplaceString("name", nameControl->Text());
fSettings->ReplaceMessage("partition", index, &partition);
}
}
示例8: utl_FindCalendarModule
/*!
* \brief Create box for selection of the weekend days
* \note Additionally, select the color for weekends and weekdays
* \param[in] frame Enclosing rectangle.
* \param[in] id Reference to name of the selected Calendar module.
* \returns Pointer to all-set-up BBox. Or NULL in case of error.
*/
BBox* CalendarModulePreferencesView::CreateWeekendSelectionBox( BRect frame,
const BString &id )
{
/*! \par Notes on implementation:
* It's not all that straightforward - to create this selection box.
* The problem is that number of days in week is dependent on the
* Calendar Module, therefore the frame rectangle must be divided
* properly. We should take into account the possibility that there's
* not enough place for all days in the submitted frame.
*
* \par
* The solution will be as follows:
* Let number of days in week be N. I create two columns and
* several rows (the number depends on N). Days in week will be
* proceeded in the order <em>as Calendar Module supplies them</em>.
* The days occupy both columns, and are located in rows
* [0, (ceiling of (N/2)) ). Days returned from CalendarModule are
* placed as follows: days from 0 to (ceiling of (N/2)-1) in the left
* column, days from (ceiling of (N/2)-1) to (N-1) in right column.
*
* \par
* There will be an empty cell in the right column, if number
* of days in week is odd, (which is usually the case).
*/
frame.InsetBySelf( 5, 0 );
BMessage* toSend = NULL;
BCheckBox* dayCheckBox = NULL;
BString tempString;
BLayoutItem* layoutItem = NULL;
CalendarModulePreferences* prefs = NULL;
CalendarModule* calModule = NULL;
int height = 0; //!< this is used to resize the BBox to proper size
calModule = utl_FindCalendarModule( id );
if ( calModule == NULL ) {
/* Error */
utl_Deb = new DebuggerPrintout( "Did not succeed to find the calendar module." );
return NULL;
}
// Get the data on days of week
uint32 daysInWeek = ( uint32 )( calModule->GetDaysInWeek() );
map<uint32, DoubleNames> weekdayNames = calModule->GetWeekdayNames();
/* Obtain the current Calendar Module preferences */
prefs = pref_GetPreferencesForCalendarModule( id );
if ( !prefs ) {
utl_Deb = new DebuggerPrintout( "Did not succeed to find the preferences for the calendar module." );
return NULL;
}
// At this point, "pref" points to current preferences of this calendar module.
BList* weekends = prefs->GetWeekends(); // Get info on currently selected weekends
// Prepare the item to be returned
BBox* enclosingBox = new BBox( frame, "Weekend selector" );
if ( !enclosingBox )
{
/* Panic! */
exit(1);
}
enclosingBox->SetLabel( "Select the non-working days (weekends)" );
// Prepare the layout to be used
BGridLayout* layout = new BGridLayout();
if ( !layout)
{
/* Panic! */
exit(1);
}
enclosingBox->SetLayout( layout );
layout->SetInsets( 10, 15, 10, 5 );
layout->SetVerticalSpacing( 1 );
/* indexX is 0 for left column or 1 for right column.
* indexY is 0 for topmost row, 1 for second from top row, etc.
* Max value for indexY = (ceiling of (N/2)).
*/
int indexX = 0, indexY = 0;
for (uint32 day = prefs->GetFirstDayOfWeek(), i = 0; i < ( uint32 )daysInWeek; ++i )
{
/* Creating the message to be sent */
toSend = new BMessage( kCalendarModuleWeekendDaySelected );
if ( !toSend )
{
/* Panic! */
exit(1);
}
toSend->AddInt32( "Weekday const", day );
toSend->AddString( "Calendar module", id );
//.........这里部分代码省略.........
示例9: main
int
main(int argc, char** argv)
{
BApplication app("application/x-vnd.antares-look");
BWindow* window = new Window(BRect(50, 50, 100, 100),
"Look at these pretty controls!", B_TITLED_WINDOW,
B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS
| B_QUIT_ON_WINDOW_CLOSE);
window->SetLayout(new BGroupLayout(B_HORIZONTAL));
// create some controls
// BListView
BListView* listView = new BListView();
for (int32 i = 0; i < 20; i++) {
BString itemLabel("List item ");
itemLabel << i + 1;
listView->AddItem(new BStringItem(itemLabel.String()));
}
BScrollView* scrollView = new BScrollView("scroller", listView, 0,
true, true);
scrollView->SetExplicitMinSize(BSize(300, 140));
// BColumnListView
BColumnListView* columnListView = new BColumnListView("clv", 0,
B_FANCY_BORDER);
// for (int32 i = 0; i < 20; i++) {
// BString itemLabel("List Item ");
// itemLabel << i + 1;
// columnListView->AddItem(new BStringItem(itemLabel.String()));
// }
BGridView* controls = new BGridView(kInset, kInset);
BGridLayout* layout = controls->GridLayout();
controls->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED));
int32 row = 0;
add_controls<BButton>(layout, row);
add_controls<BCheckBox>(layout, row);
add_controls<BRadioButton>(layout, row);
add_menu_fields(layout, row);
add_text_controls(layout, row);
add_sliders(layout, row);
add_status_bars(layout, row);
BColorControl* colorControl = new BColorControl(B_ORIGIN, B_CELLS_32x8,
8.0f, "color control");
layout->AddView(colorControl, 0, row, 4);
BTabView* tabView = new BTabView("tab view", B_WIDTH_FROM_WIDEST);
BView* content = BGroupLayoutBuilder(B_VERTICAL, kInset)
.Add(scrollView)
.Add(columnListView)
.Add(controls)
.SetInsets(kInset, kInset, kInset, kInset);
content->SetName("Tab 1");
tabView->AddTab(content);
BView* tab2 = new BView("Tab 2", 0);
tab2->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
tabView->AddTab(tab2);
tabView->AddTab(new BView("Tab 3", 0));
BMenuBar* menuBar = new BMenuBar("menu bar");
BMenu* menu = new BMenu("File");
menu->AddItem(new BMenuItem("Test Open BFilePanel",
new BMessage(MSG_TEST_OPEN_FILE_PANEL)));
menu->AddItem(new BMenuItem("Test Save BFilePanel",
new BMessage(MSG_TEST_SAVE_FILE_PANEL)));
menu->AddItem(new BMenuItem("Click me!", NULL));
menu->AddItem(new BMenuItem("Another option", NULL));
menu->AddSeparatorItem();
menu->AddItem(new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED)));
menuBar->AddItem(menu);
menu = new BMenu("Edit");
menu->SetEnabled(false);
menu->AddItem(new BMenuItem("Cut", NULL));
menu->AddItem(new BMenuItem("Copy", NULL));
menu->AddSeparatorItem();
menu->AddItem(new BMenuItem("Past", NULL));
menuBar->AddItem(menu);
menu = new BMenu("One Item");
menu->AddItem(new BMenuItem("Only", NULL));
menuBar->AddItem(menu);
menu = new BMenu("Sub Menu");
BMenu* subMenu = new BMenu("Click me");
subMenu->AddItem(new BMenuItem("Either", NULL));
subMenu->AddItem(new BMenuItem("Or", NULL));
subMenu->SetRadioMode(true);
menu->AddItem(subMenu);
menuBar->AddItem(menu);
BButton* okButton = new BButton("OK", new BMessage(B_QUIT_REQUESTED));
window->AddChild(BGroupLayoutBuilder(B_VERTICAL)
.Add(menuBar)
//.........这里部分代码省略.........
示例10: BControl
//.........这里部分代码省略.........
/* Panic! */
fLastError = B_NO_MEMORY;
return;
}
fCalendarModuleLabel = new BStringView( BRect( 0, 0, 1, 1 ),
"label for the calendar module selector",
"Calendar:" );
if ( !fCalendarModuleLabel ) {
/* Panic! */
fLastError = B_NO_MEMORY;
return;
}
fCalendarModuleLabel->ResizeToPreferred();
fCalendarsMenu = CreateMenuOfCalendarModules();
if ( !fCalendarsMenu ) {
/* Panic! */
fLastError = B_NO_MEMORY;
return;
}
fCalendarModuleSelector = new BMenuField( BRect( 0, 0, 1, 1 ),
"calendar module selector",
NULL, // Label is created separately
fCalendarsMenu );
if ( !fCalendarModuleSelector ) {
/* Panic! */
fLastError = B_NO_MEMORY;
return;
}
fCalendarModuleSelector->ResizeToPreferred();
// Create the menu
CreateMenu();
BRect stringViewFrame = fLabel->Frame();
BPoint topLeftCorner = stringViewFrame.RightTop();
BSize size( BUTTON_WIDTH, stringViewFrame.Height() + SPACING );
fMenuBar = new BMenuBar( BRect(topLeftCorner, size),
"menuBar",
B_FOLLOW_RIGHT | B_FOLLOW_TOP,
B_ITEMS_IN_ROW,
false);
if (! fMenuBar) {
// Panic!
fLastError = B_NO_MEMORY;
return;
}
fMenuBar->SetBorder( B_BORDER_EACH_ITEM );
fMenuBar->AddItem( fDateSelector );
// Update the selected date label to currently selected moment of time
UpdateText();
// Initializing the layout
BGridLayout* lay = new BGridLayout( );
if (!lay) {
// Panic!
fLastError = B_NO_MEMORY;
return;
}
lay->SetInsets(0, 5, 0, 0);
lay->SetSpacing( 10, 5 );
lay->SetExplicitAlignment( BAlignment( B_ALIGN_USE_FULL_WIDTH, B_ALIGN_MIDDLE ) );
this->SetLayout(lay);
BLayoutItem* layoutItem;
layoutItem = lay->AddView( fLabel, 0, 0 );
layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_LEFT, B_ALIGN_TOP ) );
layoutItem = lay->AddView( fDateLabel, 1, 0 );
layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_USE_FULL_WIDTH, B_ALIGN_TOP ) );
layoutItem = lay->AddView( fMenuBar, 2, 0 );
layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_RIGHT, B_ALIGN_TOP ) );
layoutItem->SetExplicitMaxSize( size );
layoutItem = lay->AddView( fCalendarModuleLabel, 0, 1 );
layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_LEFT, B_ALIGN_MIDDLE ) );
layoutItem = lay->AddView( fCalendarModuleSelector, 1, 1 );
layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_USE_FULL_WIDTH, B_ALIGN_TOP ) );
lay->SetColumnWeight( 0, 0 );
lay->SetColumnWeight( 1, 1000 );
lay->SetColumnWeight( 2, 0 );
lay->SetMaxColumnWidth( 2, BUTTON_WIDTH );
this->InvalidateLayout();
this->Relayout();
this->Invalidate();
fLastError = B_OK;
}
示例11: BWindow
TPrefsWindow::TPrefsWindow(BRect rect, BFont* font, int32* level, bool* wrap,
bool* attachAttributes, bool* cquotes, int32* account, int32* replyTo,
char** preamble, char** sig, uint32* encoding, bool* warnUnencodable,
bool* spellCheckStartOn, bool* autoMarkRead, uint8* buttonBar)
:
BWindow(rect, B_TRANSLATE("Mail preferences"),
B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE
| B_AUTO_UPDATE_SIZE_LIMITS),
fNewWrap(wrap),
fWrap(*fNewWrap),
fNewAttachAttributes(attachAttributes),
fAttachAttributes(*fNewAttachAttributes),
fNewButtonBar(buttonBar),
fButtonBar(*fNewButtonBar),
fNewColoredQuotes(cquotes),
fColoredQuotes(*fNewColoredQuotes),
fNewAccount(account),
fAccount(*fNewAccount),
fNewReplyTo(replyTo),
fReplyTo(*fNewReplyTo),
fNewPreamble(preamble),
fNewSignature(sig),
fSignature((char*)malloc(strlen(*fNewSignature) + 1)),
fNewFont(font),
fFont(*fNewFont),
fNewEncoding(encoding),
fEncoding(*fNewEncoding),
fNewWarnUnencodable(warnUnencodable),
fWarnUnencodable(*fNewWarnUnencodable),
fNewSpellCheckStartOn(spellCheckStartOn),
fSpellCheckStartOn(*fNewSpellCheckStartOn),
fNewAutoMarkRead(autoMarkRead),
fAutoMarkRead(*autoMarkRead)
{
strcpy(fSignature, *fNewSignature);
BMenuField* menu;
// group boxes
const float kSpacing = 8;
BGridView* interfaceView = new BGridView(kSpacing, kSpacing);
BGridLayout* interfaceLayout = interfaceView->GridLayout();
interfaceLayout->SetInsets(kSpacing, kSpacing, kSpacing, kSpacing);
BGridView* mailView = new BGridView(kSpacing, kSpacing);
BGridLayout* mailLayout = mailView->GridLayout();
mailLayout->SetInsets(kSpacing, kSpacing, kSpacing, kSpacing);
interfaceLayout->AlignLayoutWith(mailLayout, B_HORIZONTAL);
BBox* interfaceBox = new BBox(B_FANCY_BORDER, interfaceView);
interfaceBox->SetLabel(B_TRANSLATE("User interface"));
BBox* mailBox = new BBox(B_FANCY_BORDER, mailView);
mailBox->SetLabel(B_TRANSLATE("Mailing"));
// revert, ok & cancel
BButton* okButton = new BButton("ok", B_TRANSLATE("OK"),
new BMessage(P_OK));
okButton->MakeDefault(true);
BButton* cancelButton = new BButton("cancel", B_TRANSLATE("Cancel"),
new BMessage(P_CANCEL));
fRevert = new BButton("revert", B_TRANSLATE("Revert"),
new BMessage(P_REVERT));
fRevert->SetEnabled(false);
// User Interface
int32 layoutRow = 0;
fButtonBarMenu = _BuildButtonBarMenu(*buttonBar);
menu = new BMenuField("bar", B_TRANSLATE("Button bar:"), fButtonBarMenu);
add_menu_to_layout(menu, interfaceLayout, layoutRow);
fFontMenu = _BuildFontMenu(font);
menu = new BMenuField("font", B_TRANSLATE("Font:"), fFontMenu);
add_menu_to_layout(menu, interfaceLayout, layoutRow);
fSizeMenu = _BuildSizeMenu(font);
menu = new BMenuField("size", B_TRANSLATE("Size:"), fSizeMenu);
add_menu_to_layout(menu, interfaceLayout, layoutRow);
fColoredQuotesMenu = _BuildColoredQuotesMenu(fColoredQuotes);
menu = new BMenuField("cquotes", B_TRANSLATE("Colored quotes:"),
fColoredQuotesMenu);
//.........这里部分代码省略.........
示例12: BBox
/*! \function CalendarModulePreferences::CreateWeekendSelectionBox
* \brief Create box for selection of the weekend days
* \note Additionally, select the color for weekends and weekdays
* \param[in] frame Enclosing rectangle.
* \param[in] label Reference to label of the enclosing BBox.
* \param[in] calModule The calendar module for which the preferences are set.
*/
void CalendarModulePreferences::CreateWeekendSelectionBox( BRect frame,
BString &label,
CalendarModule* calModule )
{
/*! \par Notes on implementation:
* It's not all that straightforward - to create this selection box.
* The problem is that number of days in week is dependent on the
* Calendar Module, therefore the frame rectangle must be divided
* properly. We should take into account the possibility that there's
* not enough place for all days in the submitted frame.
*
* \par
* The solution will be as follows:
* Let number of days in week be N. I create two columns and
* several rows (the number depends on N). Days in week will be
* proceeded in the order <em>as Calendar Module supplies them</em>.
* The days occupy both columns, and are located in rows
* [0, (ceiling of (N/2)) ). Days returned from CalendarModule are
* placed as follows: days from 0 to (ceiling of (N/2)-1) in the left
* column, days from (ceiling of (N/2)-1) to (N-1) in right column.
*
* \par
* Two controls for setting the colors of weekdays and weekends
* are located at the bottom row of the grid; weekdays on right,
* weekends on left.
*
* \par
* There will be an empty cell in the right column, if number
* of days in week is odd.
*/
BMessage* toSend = NULL;
BCheckBox* dayCheckBox = NULL;
BString tempString;
/* indexX is 0 for left column or 1 for right column.
* indexY is 0 for topmost row, 1 for second from top row, etc.
* Max value for indexY = (ceiling of (N/2)).
*/
int indexX, indexY;
// Prepare the item to be returned
BBox* enclosingBox = new BBox( frame, "Weekend selector" );
if ( !enclosingBox )
{
/* Panic! */
exit(1);
}
// Prepare the layout to be used
BGridLayout* layout = new BGridLayout();
if ( !layout)
{
/* Panic! */
exit(1);
}
enclosingBox->SetLayout( layout );
// Get the data on days of week
unsigned int daysInWeek = (unsigned int)( calModule->GetDaysInWeek() );
map<uint32, DoubleNames> weekdayNames = calModule->GetWeekdayNames();
indexX = indexY = 0;
for (unsigned char day = 0; day < daysInWeek; ++day )
{
/* Creating the message to be sent */
toSend = new BMessage( kCalendarModuleWeekendDaySelected );
if ( !toSend )
{
/* Panic! */
exit(1);
}
toSend->AddInt32( "Weekday no", day );
/* Obtain the name of the day. I use the long name. */
tempString = (DoubleNames)weekdayNames[ day ].longName;
/* Creating the checkbox */
dayCheckBox = new BCheckBox( BRect(0, 0, 1, 1),
"Weekday",
tempString.String(),
toSend );
if (!dayCheckBox)
{
// Panic!
exit(1);
}
dayCheckBox->ResizeToPreferred();
/* Adding the item to the BBox */
layout->AddView( dayCheckBox, indexX, indexY );
/* Advancing to the next cell in grid */
//.........这里部分代码省略.........
示例13: BView
/*! \brief Constructor of CategoryPreferencesView
* \details It's a descendant of BView.
* \param[in] frame The frame rectangle of the view.
*/
CategoryPreferencesView::CategoryPreferencesView( BRect frame )
:
BView( frame,
"Category Preferences",
B_FOLLOW_ALL_SIDES,
B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE )
{
BLayoutItem* layoutItem = NULL;
BMessage* toSend = NULL;
menuField = NULL;
this->SetViewColor( ui_color( B_PANEL_BACKGROUND_COLOR ) );
/*! \note Layout of the view
* The view has a grid layout. It's arranged in the following way:
* 1) Left column - list of Categories (CategoryList) that
* contains all categories currently available.
* 2) Right column - three buttons, from top to bottom:
* 2a) Edit currently selected category - guess what it's doing
* 2b) Add a new category
* 2c) Merge a current directory into another one + menu with
* all categories. The category selected in the list is disabled.
* \note Restrictions:
* a) The list of categories is scrolled.
* b) If no category is selected, then
* i) "Edit" button is disabled
* ii) "Merge to" field is disabled
*
*/
BGridLayout* gridLayout = new BGridLayout();
if ( !gridLayout )
{
/* Panic! */
exit( 1 );
}
// Margins from the sides of the view and spacing between the elements
gridLayout->SetInsets( 5, 5, 5, 5 );
gridLayout->SetHorizontalSpacing( 10 );
gridLayout->SetVerticalSpacing( 10 );
this->SetLayout( gridLayout );
gridLayout->SetExplicitAlignment( BAlignment( B_ALIGN_USE_FULL_WIDTH, B_ALIGN_USE_FULL_HEIGHT ) );
gridLayout->SetExplicitMinSize( BSize( (this->Bounds()).Width(), (this->Bounds()).Height() ) );
BRect rect = gridLayout->Frame();
printf ( "The frame is %d pixels wide and %d pixels high.\n",
(int )rect.Width(),
(int )rect.Height() );
/* Creating the CategoryListView with its scroller */
BRect r( this->Bounds() );
r.InsetBySelf( 5, 10 ); // Margins near the border of the view
r.right = (int)(r.right / 2) - B_V_SCROLL_BAR_WIDTH;
r.bottom -= 0;
listView = new CategoryListView( r, "List View" );
if ( ! listView ) {
/* Panic! */
exit( 1 );
}
BLooper* looper = this->Looper();
if ( looper && looper->LockLooper() )
{
looper->AddHandler( ( BHandler* )this );
looper->UnlockLooper();
}
scroller = new BScrollView( "Scroller",
listView,
B_FOLLOW_LEFT | B_FOLLOW_TOP,
0, // Flags
true,
true );
if ( !scroller )
{
/* Panic! */
exit( 1 );
}
layoutItem = gridLayout->AddView( scroller, 0, 0, 1, 3 );
if ( !layoutItem ) {
/* Panic! */
exit( 1 );
}
layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_LEFT,
B_ALIGN_USE_FULL_HEIGHT ) );
toSend = new BMessage( kCategoryInvoked );
if ( !toSend )
{
/* Panic! */
exit( 1 );
}
listView->SetInvocationMessage( toSend );
toSend = new BMessage( kCategorySelected );
if ( !toSend )
{
//.........这里部分代码省略.........
示例14: SetLayout
void
MainWindow::_CreateGUI()
{
SetLayout(new BGroupLayout(B_HORIZONTAL));
BGridLayout* layout = new BGridLayout();
layout->SetSpacing(0, 0);
BView* rootView = new BView("root view", 0, layout);
AddChild(rootView);
rootView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
BGroupView* leftTopView = new BGroupView(B_VERTICAL, 0);
layout->AddView(leftTopView, 0, 0);
// views along the left side
leftTopView->AddChild(_CreateMenuBar());
float splitWidth = 13 * be_plain_font->Size();
BSize minSize = leftTopView->MinSize();
splitWidth = std::max(splitWidth, minSize.width);
leftTopView->SetExplicitMaxSize(BSize(splitWidth, B_SIZE_UNSET));
leftTopView->SetExplicitMinSize(BSize(splitWidth, B_SIZE_UNSET));
BGroupView* iconPreviews = new BGroupView(B_HORIZONTAL);
iconPreviews->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
iconPreviews->GroupLayout()->SetSpacing(5);
// icon previews
fIconPreview16Folder = new IconView(BRect(0, 0, 15, 15),
"icon preview 16 folder");
fIconPreview16Menu = new IconView(BRect(0, 0, 15, 15),
"icon preview 16 menu");
fIconPreview16Menu->SetLowColor(ui_color(B_MENU_BACKGROUND_COLOR));
fIconPreview32Folder = new IconView(BRect(0, 0, 31, 31),
"icon preview 32 folder");
fIconPreview32Desktop = new IconView(BRect(0, 0, 31, 31),
"icon preview 32 desktop");
fIconPreview32Desktop->SetLowColor(ui_color(B_DESKTOP_COLOR));
fIconPreview64 = new IconView(BRect(0, 0, 63, 63), "icon preview 64");
fIconPreview64->SetLowColor(ui_color(B_DESKTOP_COLOR));
BGroupView* smallPreviews = new BGroupView(B_VERTICAL);
smallPreviews->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
smallPreviews->GroupLayout()->SetSpacing(5);
smallPreviews->AddChild(fIconPreview16Folder);
smallPreviews->AddChild(fIconPreview16Menu);
BGroupView* mediumPreviews = new BGroupView(B_VERTICAL);
mediumPreviews->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
mediumPreviews->GroupLayout()->SetSpacing(5);
mediumPreviews->AddChild(fIconPreview32Folder);
mediumPreviews->AddChild(fIconPreview32Desktop);
// iconPreviews->AddChild(fIconPreview48);
iconPreviews->AddChild(smallPreviews);
iconPreviews->AddChild(mediumPreviews);
iconPreviews->AddChild(fIconPreview64);
iconPreviews->SetExplicitMaxSize(BSize(B_SIZE_UNSET, B_SIZE_UNLIMITED));
leftTopView->AddChild(iconPreviews);
BGroupView* leftSideView = new BGroupView(B_VERTICAL, 0);
layout->AddView(leftSideView, 0, 1);
leftSideView->SetExplicitMaxSize(BSize(splitWidth, B_SIZE_UNSET));
// path menu and list view
BMenuBar* menuBar = new BMenuBar("path menu bar");
menuBar->AddItem(fPathMenu);
leftSideView->AddChild(menuBar);
fPathListView = new PathListView(BRect(0, 0, splitWidth, 100),
"path list view", new BMessage(MSG_PATH_SELECTED), this);
BView* scrollView = new BScrollView("path list scroll view",
fPathListView, B_FOLLOW_NONE, 0, false, true, B_NO_BORDER);
leftSideView->AddChild(scrollView);
// shape list view
menuBar = new BMenuBar("shape menu bar");
menuBar->AddItem(fShapeMenu);
leftSideView->AddChild(menuBar);
fShapeListView = new ShapeListView(BRect(0, 0, splitWidth, 100),
"shape list view", new BMessage(MSG_SHAPE_SELECTED), this);
scrollView = new BScrollView("shape list scroll view",
fShapeListView, B_FOLLOW_NONE, 0, false, true, B_NO_BORDER);
leftSideView->AddChild(scrollView);
// transformer list view
menuBar = new BMenuBar("transformer menu bar");
menuBar->AddItem(fTransformerMenu);
leftSideView->AddChild(menuBar);
//.........这里部分代码省略.........
示例15: BTextView
void
VideoWindow::_BuildCaptureControls()
{
// a view to hold the video image
fVideoView = new BTextView("");
fVideoView->SetExplicitMinSize(BSize(VIDEO_SIZE_X, VIDEO_SIZE_Y));
fVideoView->SetExplicitMaxSize(BSize(VIDEO_SIZE_X, VIDEO_SIZE_Y));
fVideoView->MakeEditable(false);
fVideoView->MakeResizable(false);
fVideoView->MakeSelectable(false);
fVideoView->SetAlignment(B_ALIGN_CENTER);
fVideoView->SetInsets(0, VIDEO_SIZE_Y / 3, 0 , 0);
// Capture controls
fCaptureSetupBox = new BBox("Capture Controls", B_WILL_DRAW);
fCaptureSetupBox->SetLabel(B_TRANSLATE("Capture controls"));
BGridLayout *controlsLayout = new BGridLayout(B_USE_DEFAULT_SPACING, 0);
controlsLayout->SetInsets(10, 15, 5, 5);
fCaptureSetupBox->SetLayout(controlsLayout);
// file name
fFileName = new BTextControl("File Name", B_TRANSLATE("File name:"),
fFilenameSetting->Value(), new BMessage(msg_filename));
fFileName->SetTarget(BMessenger(NULL, this));
// format menu
fImageFormatMenu = new BPopUpMenu(B_TRANSLATE("Image Format Menu"));
BTranslationUtils::AddTranslationItems(fImageFormatMenu, B_TRANSLATOR_BITMAP);
fImageFormatMenu->SetTargetForItems(this);
if (fImageFormatSettings->Value()
&& fImageFormatMenu->FindItem(fImageFormatSettings->Value()) != NULL) {
fImageFormatMenu->FindItem(
fImageFormatSettings->Value())->SetMarked(true);
} else if (fImageFormatMenu->FindItem("JPEG image") != NULL)
fImageFormatMenu->FindItem("JPEG image")->SetMarked(true);
else
fImageFormatMenu->ItemAt(0)->SetMarked(true);
fImageFormatSelector = new BMenuField("Format", B_TRANSLATE("Format:"),
fImageFormatMenu);
// capture rate
fCaptureRateMenu = new BPopUpMenu(B_TRANSLATE("Capture Rate Menu"));
for (int32 i = 0; i < kCaptureRatesCount; i++) {
BMessage* itemMessage = new BMessage(msg_rate_changed);
itemMessage->AddInt32("seconds", kCaptureRates[i].seconds);
fCaptureRateMenu->AddItem(new BMenuItem(kCaptureRates[i].name,
itemMessage));
}
fCaptureRateMenu->SetTargetForItems(this);
fCaptureRateMenu->FindItem(fCaptureRateSetting->Value())->SetMarked(true);
fCaptureRateSelector = new BMenuField("Rate", B_TRANSLATE("Rate:"),
fCaptureRateMenu);
BLayoutBuilder::Grid<>(controlsLayout)
.AddTextControl(fFileName, 0, 0)
.AddMenuField(fImageFormatSelector, 0, 1)
.AddMenuField(fCaptureRateSelector, 0, 2)
.Add(BSpaceLayoutItem::CreateGlue(), 0, 3, 2, 1);
// FTP setup box
fFtpSetupBox = new BBox("FTP Setup", B_WILL_DRAW);
fFtpSetupBox->SetLabel(B_TRANSLATE("Output"));
fUploadClientMenu = new BPopUpMenu(B_TRANSLATE("Send to" B_UTF8_ELLIPSIS));
for (int i = 0; i < kUploadClientsCount; i++) {
BMessage *m = new BMessage(msg_upl_client);
m->AddInt32("client", i);
fUploadClientMenu->AddItem(new BMenuItem(kUploadClients[i], m));
}
fUploadClientMenu->SetTargetForItems(this);
fUploadClientMenu->FindItem(fUploadClientSetting->Value())->SetMarked(true);
fUploadClientSelector = new BMenuField("UploadClient", NULL,
fUploadClientMenu);
fUploadClientSelector->SetLabel(B_TRANSLATE("Type:"));
BGridLayout *ftpLayout = new BGridLayout(B_USE_DEFAULT_SPACING, 0);
ftpLayout->SetInsets(10, 15, 5, 5);
fFtpSetupBox->SetLayout(ftpLayout);
fServerName = new BTextControl("Server", B_TRANSLATE("Server:"),
fServerSetting->Value(), new BMessage(msg_server));
fServerName->SetTarget(this);
fLoginId = new BTextControl("Login", B_TRANSLATE("Login:"),
fLoginSetting->Value(), new BMessage(msg_login));
fLoginId->SetTarget(this);
fPassword = new BTextControl("Password", B_TRANSLATE("Password:"),
fPasswordSetting->Value(), new BMessage(msg_password));
fPassword->SetTarget(this);
fPassword->TextView()->HideTyping(true);
// BeOS HideTyping() seems broken, it empties the text
fPassword->SetText(fPasswordSetting->Value());
fDirectory = new BTextControl("Directory", B_TRANSLATE("Directory:"),
//.........这里部分代码省略.........