本文整理汇总了C++中BGridLayout::AddView方法的典型用法代码示例。如果您正苦于以下问题:C++ BGridLayout::AddView方法的具体用法?C++ BGridLayout::AddView怎么用?C++ BGridLayout::AddView使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BGridLayout
的用法示例。
在下文中一共展示了BGridLayout::AddView方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BFile
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: 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);
}
示例3: BStringView
PluginInfoView::PluginInfoView(BasePlugin *_plugin):BGridView(5,5){
if (pcTypes.size() == 0){
pcTypes[P_C_EDITOR_PLUGIN_TYPE ]="Editor";
pcTypes[P_C_COMMANDO_PLUGIN_TYPE]="Command";
pcTypes[P_C_ITEM_PLUGIN_TYPE]="Item";
pcTypes[P_C_ITEM_INPORT_EXPORT_TYPE]="Import/Export";
}
BGridLayout *layout = (BGridLayout* )this->GetLayout();
layout->AddView(new BStringView("Name","Name:"),0,0);
layout->AddView(new BStringView("NameData",_plugin->GetName()),1,0);
layout->AddView(new BStringView("Type","Type:"),0,2);
layout->AddView(new BStringView("TypeData",pcTypes[_plugin->GetType()]),1,2);
layout->AddView(new BStringView("Autor","Autor:"),0,3);
layout->AddView(new BStringView("AutorData", _plugin->GetAutor()),1,3);
layout->AddView(new BStringView("Version","Version:"),0,4);
layout->AddView(new BStringView("VersionData",_plugin->GetVersionsString()),1,4);
layout->AddView(new BStringView("Description","Description:"),0,5);
BTextView *textView=new BTextView("DescriptionData");
textView->SetText(_plugin->GetDescription());
textView->MakeEditable(false);
layout->AddView(textView,1,5,1,5);
}
示例4: 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);
//.........这里部分代码省略.........
示例5: app
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)
//.........这里部分代码省略.........
示例6: BMessage
//.........这里部分代码省略.........
message->AddFloat("width", pageFormat[i].width);
message->AddFloat("height", pageFormat[i].height);
BMenuItem* item = new BMenuItem(pageFormat[i].label, message);
pageSize->AddItem(item);
if (label.Compare(pageFormat[i].label) == 0)
item->SetMarked(true);
}
BPopUpMenu* orientationPopUpMenu = new BPopUpMenu("Orientation");
orientationPopUpMenu->SetRadioMode(true);
fOrientationMenu = new BMenuField("orientation", "Orientation:",
orientationPopUpMenu);
fOrientationMenu->Menu()->SetLabelFromMarked(true);
for (int32 i = 0; orientation[i].label != NULL; i++) {
BMessage* message = new BMessage(ORIENTATION_CHANGED);
message->AddInt32("orientation", orientation[i].orientation);
BMenuItem* item = new BMenuItem(orientation[i].label, message);
orientationPopUpMenu->AddItem(item);
if (fCurrentOrientation == orientation[i].orientation)
item->SetMarked(true);
}
BPopUpMenu* compatibility = new BPopUpMenu("PDF compatibility");
compatibility->SetRadioMode(true);
fPDFCompatibilityMenu = new BMenuField("pdf_compatibility",
"PDF compatibility:", compatibility);
fPDFCompatibilityMenu->Menu()->SetLabelFromMarked(true);
for (int32 i = 0; pdf_compatibility[i] != NULL; i++) {
BMenuItem* item = new BMenuItem(pdf_compatibility[i], NULL);
compatibility->AddItem(item);
if (setting_value == pdf_compatibility[i])
item->SetMarked(true);
}
fPDFCompressionSlider = new BSlider("pdf_compression",
"Compression:", NULL, 0, 9, B_HORIZONTAL);
fPDFCompressionSlider->SetLimitLabels("None", "Best");
fPDFCompressionSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
fPDFCompressionSlider->SetValue(compression);
BBox *separator = new BBox("separator");
separator->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, 1));
BButton *cancel = new BButton("cancel", "Cancel", new BMessage(CANCEL_MSG));
BButton *ok = new BButton("ok", "OK", new BMessage(OK_MSG));
ok->MakeDefault(true);
BButton *fontsButton = new BButton("fonts", "Fonts" B_UTF8_ELLIPSIS,
new BMessage(FONTS_MSG));
BButton* advancedButton = new BButton("advanced",
"Advanced" B_UTF8_ELLIPSIS,
new BMessage(ADVANCED_MSG));
BGridView* settings = new BGridView();
BGridLayout* settingsLayout = settings->GridLayout();
settingsLayout->AddItem(fPageSizeMenu->CreateLabelLayoutItem(), 0, 0);
settingsLayout->AddItem(fPageSizeMenu->CreateMenuBarLayoutItem(), 1, 0);
settingsLayout->AddItem(fOrientationMenu->CreateLabelLayoutItem(), 0, 1);
settingsLayout->AddItem(fOrientationMenu->CreateMenuBarLayoutItem(), 1, 1);
settingsLayout->AddItem(fPDFCompatibilityMenu->CreateLabelLayoutItem(), 0, 2);
settingsLayout->AddItem(fPDFCompatibilityMenu->CreateMenuBarLayoutItem(), 1, 2);
settingsLayout->AddView(fPDFCompressionSlider, 0, 3, 2);
settingsLayout->SetSpacing(0, 0);
SetLayout(new BGroupLayout(B_VERTICAL));
AddChild(BGroupLayoutBuilder(B_VERTICAL, 0)
.AddGroup(B_HORIZONTAL, 5, 1)
.AddGroup(B_VERTICAL, 0, 1.0f)
.Add(fMarginView)
.AddGlue()
.End()
.AddGroup(B_VERTICAL, 0, 1.0f)
.Add(settings)
.AddGlue()
.End()
.End()
.Add(separator)
.AddGroup(B_HORIZONTAL, 10, 1.0f)
.Add(fontsButton)
.Add(advancedButton)
.AddGlue()
.Add(cancel)
.Add(ok)
.End()
.SetInsets(10, 10, 10, 10)
);
BRect winFrame(Frame());
BRect screenFrame(BScreen().Frame());
MoveTo((screenFrame.right - winFrame.right) / 2,
(screenFrame.bottom - winFrame.bottom) / 2);
}
示例7: BRect
/*! \function ColorUpdateWindow::ColorUpdateWindow
* \brief Constructor.
* \param[in] corner One of the corners of the window IN SCREEN COORDINATES!
* \param[in] label Label of the color. (Usually name of the category).
* \param[in] enableEditingLabel If "true", label can be edited. If "false", it's constant.
* \param[in] title Title of the window
* \param[in] defaultColor Original color. Defaults to black.
* \param[in] targetLooper The target which receives message with the results.
* \param[in] currentScreen Defines the screen the program runs in. Usually it's
* B_MAIN_SCREEN_ID.
* \param[in] message The template message to be used. If this parameter is NULL,
* a new message is constructed.
*/
ColorUpdateWindow::ColorUpdateWindow( BPoint corner,
BString& label,
rgb_color &defaultColor,
bool enableEditingLabel,
BString title,
BHandler *targetHandler,
screen_id currentScreen,
BMessage* message )
:
BWindow( BRect( 100, 100, 300, 500 ),
title.String(),
B_MODAL_WINDOW,
B_NOT_CLOSABLE | B_NOT_ZOOMABLE | B_NOT_RESIZABLE | B_NOT_MINIMIZABLE | B_ASYNCHRONOUS_CONTROLS | B_WILL_ACCEPT_FIRST_CLICK ),
originalString( label ),
originalColor( defaultColor),
labelView( NULL ),
okButton( NULL ),
revertButton( NULL ),
messageToSend( NULL ),
target( targetHandler ),
dirty( false )
{
BSize layoutSize;
BLayoutItem* item = NULL;
float width, height, dontCare;
BView* background = new BView( this->Bounds(),
"Background",
B_FOLLOW_LEFT | B_FOLLOW_TOP,
B_FRAME_EVENTS | B_WILL_DRAW );
if ( !background )
{
/* Panic! */
exit(1);
}
background->SetViewColor( ui_color( B_PANEL_BACKGROUND_COLOR ) );
this->enableEditingLabel = enableEditingLabel;
/* There are three parts in the interface of the control.
* Upmost is the label, which, according to the user's settings,
* can be editable or not.
* Next is the color control.
* Last is the row of two buttons, Revert and Ok.
*/
// Debugging
printf( "Color Selected = %u, Color Reverted = %u.\n",
kColorSelected,
kColorReverted );
// Construct background view and layout
BGridLayout* layout = new BGridLayout( B_VERTICAL );
if ( !layout ) { /* Panic! */ exit(1); }
layout->SetInsets( 5, 5, 5, 5 );
background->SetLayout( layout );
this->AddChild( background );
// Constructing the name label, editable or not.
if ( enableEditingLabel )
{
labelView = new BTextControl( BRect(0, 0, 1, 1),
"Label",
NULL,
label.String(),
NULL );
} else {
labelView = new BStringView( BRect (0, 0, 1, 1),
"Label",
label.String() );
}
if ( !labelView )
{
/* Panic! */
exit(1);
}
labelView->ResizeToPreferred();
item = layout->AddView( labelView, 0, 0, 3, 1 );
if ( !item ) { /* Panic! */ exit(1); }
item->SetExplicitAlignment( BAlignment( B_ALIGN_USE_FULL_WIDTH, B_ALIGN_VERTICAL_CENTER ) );
// item->SetExplicitMinSize( BSize( width, height ) );
// Construct color control
BMessage* toSend = new BMessage( kColorChanged );
if ( !toSend ) { /* Panic! */ exit(1); }
colorControl = new BColorControl( BPoint( 0, 0 ),
B_CELLS_32x8,
//.........这里部分代码省略.........
示例8: boldFont
//.........这里部分代码省略.........
B_FOLLOW_ALL_SIDES,
B_WILL_DRAW );
if ( !background ) {
/* Panic! */
fLastError = B_NO_MEMORY;
return;
}
this->AddChild( background );
BGridLayout* gridLayout = new BGridLayout();
if ( !gridLayout ) {
/* Panic! */
fLastError = B_NO_MEMORY;
return;
}
background->SetLayout( gridLayout );
background->SetViewColor( ui_color( B_PANEL_BACKGROUND_COLOR ) );
gridLayout->SetInsets( 5, 5, 5, 5 );
/*-------------------------------------------------
* First line - explaining what's happening here
*------------------------------------------------*/
BStringView* exp = new BStringView( BRect( 0, 0, 1, 1 ),
"Explanation 1",
( bIsReminder ?
"A Reminder has occured!" :
"An Event has occured!" ) );
if ( ! exp ) {
/* Panic! */
fLastError = B_NO_MEMORY;
return;
}
exp->SetFont( &boldFont );
exp->ResizeToPreferred();
BLayoutItem* layoutItem = gridLayout->AddView( exp, 0, 0, numberOfColumnsInLayout, 1 );
if ( layoutItem ) {
layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_CENTER, B_ALIGN_TOP ) );
}
/*-----------------------------------------------------------------
* Second line - event's name on category's color as background
*----------------------------------------------------------------*/
// Create background
// Note: the pulse is requested for this Window to receive Pulse notifications.
fBackground = new BView( BRect( 0, 0, 1, 1 ),
"Background",
B_FOLLOW_LEFT_RIGHT | B_FOLLOW_V_CENTER | B_PULSE_NEEDED,
B_WILL_DRAW );
if ( !fBackground ) {
/* Panic! */
fLastError = B_NO_MEMORY;
return;
}
fBackground->SetViewColor( ui_color( B_PANEL_BACKGROUND_COLOR ) );
layoutItem = gridLayout->AddView( fBackground, 0, 1, numberOfColumnsInLayout, 1 );
if ( layoutItem ) {
layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_USE_FULL_WIDTH, B_ALIGN_USE_FULL_HEIGHT ) );
}
BGroupLayout* bgLayout = new BGroupLayout( B_VERTICAL );
if ( !bgLayout ) {
/* Panic! */
fLastError = B_NO_MEMORY;
return;
}
fBackground->SetLayout( bgLayout );
示例9: BMessage
//.........这里部分代码省略.........
new BMessage(msg_rate_4h)));
fCaptureRateMenu->AddItem(new BMenuItem("Every 8 hours",
new BMessage(msg_rate_8h)));
fCaptureRateMenu->AddItem(new BMenuItem("Every 24 hours",
new BMessage(msg_rate_24h)));
fCaptureRateMenu->AddItem(new BMenuItem("Never",
new BMessage(msg_rate_never)));
fCaptureRateMenu->SetTargetForItems(this);
fCaptureRateMenu->FindItem(fCaptureRateSetting->Value())->SetMarked(true);
fCaptureRateSelector = new BMenuField("Rate", "Rate:",
fCaptureRateMenu, NULL);
controlsLayout->AddItem(fFileName->CreateLabelLayoutItem(), 0, 0);
controlsLayout->AddItem(fFileName->CreateTextViewLayoutItem(), 1, 0);
controlsLayout->AddItem(fImageFormatSelector->CreateLabelLayoutItem(), 0, 1);
controlsLayout->AddItem(fImageFormatSelector->CreateMenuBarLayoutItem(), 1, 1);
controlsLayout->AddItem(fCaptureRateSelector->CreateLabelLayoutItem(), 0, 2);
controlsLayout->AddItem(fCaptureRateSelector->CreateMenuBarLayoutItem(), 1, 2);
controlsLayout->AddItem(BSpaceLayoutItem::CreateGlue(), 0, 3, 2);
// FTP setup box
fFtpSetupBox = new BBox("FTP Setup", B_WILL_DRAW);
fUploadClientMenu = new BPopUpMenu("Send to" B_UTF8_ELLIPSIS);
for (int i = 0; kUploadClient[i]; i++) {
BMessage *m = new BMessage(msg_upl_client);
m->AddInt32("client", i);
fUploadClientMenu->AddItem(new BMenuItem(kUploadClient[i], m));
}
fUploadClientMenu->SetTargetForItems(this);
fUploadClientMenu->FindItem(fUploadClientSetting->Value())->SetMarked(true);
fUploadClientSelector = new BMenuField("UploadClient", NULL,
fUploadClientMenu, NULL);
fFtpSetupBox->SetLabel("Output");
// this doesn't work with the layout manager
// fFtpSetupBox->SetLabel(fUploadClientSelector);
fUploadClientSelector->SetLabel("Type:");
BGridLayout *ftpLayout = new BGridLayout(kXBuffer, 0);
ftpLayout->SetInsets(10, 15, 5, 5);
fFtpSetupBox->SetLayout(ftpLayout);
fServerName = new BTextControl("Server", "Server:",
fServerSetting->Value(), new BMessage(msg_server));
fServerName->SetTarget(this);
fLoginId = new BTextControl("Login", "Login:",
fLoginSetting->Value(), new BMessage(msg_login));
fLoginId->SetTarget(this);
fPassword = new BTextControl("Password", "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", "Directory:",
fDirectorySetting->Value(), new BMessage(msg_directory));
fDirectory->SetTarget(this);
fPassiveFtp = new BCheckBox("Passive FTP", "Passive FTP",
new BMessage(msg_passiveftp));
fPassiveFtp->SetTarget(this);
fPassiveFtp->SetValue(fPassiveFtpSetting->Value());
ftpLayout->AddItem(fUploadClientSelector->CreateLabelLayoutItem(), 0, 0);
ftpLayout->AddItem(fUploadClientSelector->CreateMenuBarLayoutItem(), 1, 0);
ftpLayout->AddItem(fServerName->CreateLabelLayoutItem(), 0, 1);
ftpLayout->AddItem(fServerName->CreateTextViewLayoutItem(), 1, 1);
ftpLayout->AddItem(fLoginId->CreateLabelLayoutItem(), 0, 2);
ftpLayout->AddItem(fLoginId->CreateTextViewLayoutItem(), 1, 2);
ftpLayout->AddItem(fPassword->CreateLabelLayoutItem(), 0, 3);
ftpLayout->AddItem(fPassword->CreateTextViewLayoutItem(), 1, 3);
ftpLayout->AddItem(fDirectory->CreateLabelLayoutItem(), 0, 4);
ftpLayout->AddItem(fDirectory->CreateTextViewLayoutItem(), 1, 4);
ftpLayout->AddView(fPassiveFtp, 0, 5, 2);
fStatusLine = new BStringView("Status Line", "Waiting" B_UTF8_ELLIPSIS);
BGroupLayout *groupLayout = new BGroupLayout(B_VERTICAL);
groupLayout->SetInsets(kXBuffer, kYBuffer, kXBuffer, kYBuffer);
theView->SetLayout(groupLayout);
theView->AddChild(BSpaceLayoutItem::CreateVerticalStrut(kYBuffer));
theView->AddChild(BGroupLayoutBuilder(B_HORIZONTAL)
.Add(BSpaceLayoutItem::CreateHorizontalStrut(0.0))
.Add(fVideoView)
.Add(BSpaceLayoutItem::CreateHorizontalStrut(0.0))
);
theView->AddChild(BSpaceLayoutItem::CreateVerticalStrut(kYBuffer));
theView->AddChild(BGroupLayoutBuilder(B_HORIZONTAL, kXBuffer)
.Add(fCaptureSetupBox)
.Add(fFtpSetupBox)
);
theView->AddChild(BSpaceLayoutItem::CreateVerticalStrut(kYBuffer));
theView->AddChild(fStatusLine);
}
示例10: r
/*! \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 )
{
//.........这里部分代码省略.........
示例11: 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 */
//.........这里部分代码省略.........
示例12: size
//.........这里部分代码省略.........
/* 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;
}
示例13: DebuggerPrintout
//.........这里部分代码省略.........
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 );
/* Set the name of the checkbox.
* This is used to identify if the checkbox was checked or unchecked.
*/
tempString.SetTo( "Weekday" );
tempString << day;
/* Creating the checkbox */
dayCheckBox = new BCheckBox( BRect(0, 0, 1, 1),
tempString.String(),
weekdayNames[ day ].longName.String(),
toSend );
if (!dayCheckBox)
{
// Panic!
exit(1);
}
dayCheckBox->ResizeToPreferred();
// Check if the checkbox should be checked
if ( weekends->HasItem( ( void* )day ) ) {
dayCheckBox->SetValue( 1 );
} else {
dayCheckBox->SetValue( 0 );
}
/* Adding the item to the BBox */
layoutItem = layout->AddView( dayCheckBox, indexX, indexY );
if ( layoutItem )
{
layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_LEFT, B_ALIGN_TOP ) );
// layoutItem->SetExplicitMaxSize( BSize( (int )dayCheckBox->Bounds().Width(), (int )dayCheckBox->Bounds().Height() ) );
layout->SetMaxRowHeight( indexY, (int )dayCheckBox->Bounds().Height() + 10 );
layout->SetRowWeight( indexY, 0 );
}
/* Advancing to the next cell in grid */
// If arrived to the last item in the first column, advancing to second
// The +1 is needed because i starts from 0, but days are starting from 1
if ( ( i + 1 ) == ( unsigned int )( ( daysInWeek + 1 ) / 2 ) )
{
indexX = 1;
indexY = 0;
}
else // Staying in the same column, but advancing down
{
++indexY;
}
/* Advancing to the next day */
( day == daysInWeek ) ? day = kSunday : ++day;
} // <-- end of "for (all days in week)"
// Resizing the BBox to the correct size.
// Note: dayCheckBox is surely not NULL; if it were, we would exit earlier.
height =(int )( ( dayCheckBox->Bounds().Height() + 5 ) * ( int )( ( daysInWeek + 1 ) / 2 ) - 5 );
// Formula: ( ^height of one checkbox^ + ^separator^ ) * ( ^number of days in column^ ) - ^one unneeded extra separator^
enclosingBox->ResizeTo( enclosingBox->Bounds().Width() - 10, ( int )height );
// layout->SetExplicitMaxSize( BSize( enclosingBox->Bounds().Width() - 5, ( int )height + 25 ) );
return enclosingBox;
}
示例14: BMessage
KeyRequestView()
:
BView("KeyRequestView", B_WILL_DRAW),
fPassword(NULL)
{
SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
BGroupLayout* rootLayout = new(std::nothrow) BGroupLayout(B_VERTICAL);
if (rootLayout == NULL)
return;
SetLayout(rootLayout);
BGridView* controls = new(std::nothrow) BGridView();
if (controls == NULL)
return;
BGridLayout* layout = controls->GridLayout();
float inset = ceilf(be_plain_font->Size() * 0.7);
rootLayout->SetInsets(inset, inset, inset, inset);
rootLayout->SetSpacing(inset);
layout->SetSpacing(inset, inset);
BStringView* label = new(std::nothrow) BStringView("keyringLabel",
B_TRANSLATE("Keyring:"));
if (label == NULL)
return;
int32 row = 0;
layout->AddView(label, 0, row);
fKeyringName = new(std::nothrow) BStringView("keyringName", "");
if (fKeyringName == NULL)
return;
layout->AddView(fKeyringName, 1, row++);
fPassword = new(std::nothrow) BTextControl(B_TRANSLATE("Password:"), "", NULL);
if (fPassword == NULL)
return;
BLayoutItem* layoutItem = fPassword->CreateTextViewLayoutItem();
layoutItem->SetExplicitMinSize(BSize(fPassword->StringWidth(
"0123456789012345678901234567890123456789") + inset,
B_SIZE_UNSET));
layout->AddItem(fPassword->CreateLabelLayoutItem(), 0, row);
layout->AddItem(layoutItem, 1, row++);
BGroupView* buttons = new(std::nothrow) BGroupView(B_HORIZONTAL);
if (buttons == NULL)
return;
fCancelButton = new(std::nothrow) BButton(B_TRANSLATE("Cancel"),
new BMessage(kMessageCancel));
buttons->GroupLayout()->AddView(fCancelButton);
buttons->GroupLayout()->AddItem(BSpaceLayoutItem::CreateGlue());
fUnlockButton = new(std::nothrow) BButton(B_TRANSLATE("Unlock"),
new BMessage(kMessageUnlock));
buttons->GroupLayout()->AddView(fUnlockButton);
BTextView* message = new(std::nothrow) BTextView("message");
message->SetText(B_TRANSLATE("An application wants to access the "
"keyring below, but it is locked with a passphrase. Please enter "
"the passphrase to unlock the keyring.\n"
"If you unlock the keyring, it stays unlocked until the system is "
"shut down or the keyring is manually locked again.\n"
"If you cancel this dialog the keyring will remain locked."));
message->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
rgb_color textColor = ui_color(B_PANEL_TEXT_COLOR);
message->SetFontAndColor(be_plain_font, B_FONT_ALL, &textColor);
message->MakeEditable(false);
message->MakeSelectable(false);
message->SetWordWrap(true);
rootLayout->AddView(message);
rootLayout->AddView(controls);
rootLayout->AddView(buttons);
}
示例15: BPopUpMenu
StyleView::StyleView(BRect frame)
:
BView("style view", 0),
fCommandStack(NULL),
fCurrentColor(NULL),
fStyle(NULL),
fGradient(NULL),
fIgnoreCurrentColorNotifications(false),
fIgnoreControlGradientNotifications(false),
fPreviousBounds(frame.OffsetToCopy(B_ORIGIN))
{
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
// style type
BMenu* menu = new BPopUpMenu(B_TRANSLATE("<unavailable>"));
BMessage* message = new BMessage(MSG_SET_STYLE_TYPE);
message->AddInt32("type", STYLE_TYPE_COLOR);
menu->AddItem(new BMenuItem(B_TRANSLATE("Color"), message));
message = new BMessage(MSG_SET_STYLE_TYPE);
message->AddInt32("type", STYLE_TYPE_GRADIENT);
menu->AddItem(new BMenuItem(B_TRANSLATE("Gradient"), message));
BGridLayout* layout = new BGridLayout(5, 5);
SetLayout(layout);
fStyleType = new BMenuField(B_TRANSLATE("Style type"), menu);
// gradient type
menu = new BPopUpMenu(B_TRANSLATE("<unavailable>"));
message = new BMessage(MSG_SET_GRADIENT_TYPE);
message->AddInt32("type", GRADIENT_LINEAR);
menu->AddItem(new BMenuItem(B_TRANSLATE("Linear"), message));
message = new BMessage(MSG_SET_GRADIENT_TYPE);
message->AddInt32("type", GRADIENT_CIRCULAR);
menu->AddItem(new BMenuItem(B_TRANSLATE("Radial"), message));
message = new BMessage(MSG_SET_GRADIENT_TYPE);
message->AddInt32("type", GRADIENT_DIAMOND);
menu->AddItem(new BMenuItem(B_TRANSLATE("Diamond"), message));
message = new BMessage(MSG_SET_GRADIENT_TYPE);
message->AddInt32("type", GRADIENT_CONIC);
menu->AddItem(new BMenuItem(B_TRANSLATE("Conic"), message));
fGradientType = new BMenuField(B_TRANSLATE("Gradient type"), menu);
fGradientControl = new GradientControl(new BMessage(MSG_SET_COLOR), this);
layout->AddItem(BSpaceLayoutItem::CreateVerticalStrut(3), 0, 0, 4);
layout->AddItem(BSpaceLayoutItem::CreateHorizontalStrut(3), 0, 1, 1, 3);
layout->AddItem(fStyleType->CreateLabelLayoutItem(), 1, 1);
layout->AddItem(fStyleType->CreateMenuBarLayoutItem(), 2, 1);
layout->AddItem(fGradientType->CreateLabelLayoutItem(), 1, 2);
layout->AddItem(fGradientType->CreateMenuBarLayoutItem(), 2, 2);
layout->AddView(fGradientControl, 1, 3, 2);
layout->AddItem(BSpaceLayoutItem::CreateHorizontalStrut(3), 3, 1, 1, 3);
layout->AddItem(BSpaceLayoutItem::CreateVerticalStrut(3), 0, 4, 4);
fStyleType->SetEnabled(false);
fGradientType->SetEnabled(false);
fGradientControl->SetEnabled(false);
fGradientControl->Gradient()->AddObserver(this);
}