本文整理汇总了C++中BTabView类的典型用法代码示例。如果您正苦于以下问题:C++ BTabView类的具体用法?C++ BTabView怎么用?C++ BTabView使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BTabView类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Bounds
// ResourceUsageWindow::InitWindow -- Initialization Commands here
void ResourceUsageWindow::InitWindow(BList &list)
{
BRect rtab = Bounds();
BRect rlist = Bounds();
rtab.top += 10;
rlist.top += 10;
rlist.left += 12;
rlist.right -= 15 + B_V_SCROLL_BAR_WIDTH;
rlist.bottom -= 47;
// Create the TabView and Tabs
BTabView *tabView = new BTabView(rtab,"resource_usage_tabview");
tabView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
rtab = tabView->Bounds();
rtab.InsetBy(5,5);
// Create the ListViews
BListView *IRQListView = new BListView(rlist, "IRQListView",
B_SINGLE_SELECTION_LIST, B_FOLLOW_LEFT | B_FOLLOW_TOP,
B_WILL_DRAW | B_NAVIGABLE);
BListView *DMAListView = new BListView(rlist, "DMAListView",
B_SINGLE_SELECTION_LIST, B_FOLLOW_LEFT | B_FOLLOW_TOP,
B_WILL_DRAW | B_NAVIGABLE);
BListView *IORangeListView = new BListView(rlist, "IORangeListView",
B_SINGLE_SELECTION_LIST, B_FOLLOW_LEFT | B_FOLLOW_TOP,
B_WILL_DRAW | B_NAVIGABLE);
BListView *memoryListView = new BListView(rlist, "memoryListView",
B_SINGLE_SELECTION_LIST, B_FOLLOW_LEFT | B_FOLLOW_TOP,
B_WILL_DRAW | B_NAVIGABLE);
BScrollView *IRQScrollView = new BScrollView("scroll_list1", IRQListView,
B_FOLLOW_LEFT|B_FOLLOW_TOP, 0, false, true, B_FANCY_BORDER);
BScrollView *DMAScrollView = new BScrollView("scroll_list2", DMAListView,
B_FOLLOW_LEFT|B_FOLLOW_TOP, 0, false, true, B_FANCY_BORDER);
BScrollView *IORangeScrollView = new BScrollView("scroll_list3",
IORangeListView, B_FOLLOW_LEFT|B_FOLLOW_TOP, 0, false, true,
B_FANCY_BORDER);
BScrollView *memoryScrollView = new BScrollView("scroll_list4",
memoryListView, B_FOLLOW_LEFT|B_FOLLOW_TOP, 0, false, true,
B_FANCY_BORDER);
BTab *tab = new BTab();
tabView->AddTab(IRQScrollView, tab);
tab->SetLabel(B_TRANSLATE("IRQ"));
tab = new BTab();
tabView->AddTab(DMAScrollView, tab);
tab->SetLabel(B_TRANSLATE("DMA"));
tab = new BTab();
tabView->AddTab(IORangeScrollView, tab);
tab->SetLabel(B_TRANSLATE("IO Range"));
tab = new BTab();
tabView->AddTab(memoryScrollView, tab);
tab->SetLabel(B_TRANSLATE("Memory Range"));
{
uint32 mask = 1;
for (int i=0;i<16;mask<<=1,i++) {
bool first = true;
for (int32 j=0; j<list.CountItems(); j++) {
DevicesInfo *deviceInfo = (DevicesInfo *)list.ItemAt(j);
struct device_configuration *current = deviceInfo->GetCurrent();
resource_descriptor r;
int32 num = count_resource_descriptors_of_type(current,
B_IRQ_RESOURCE);
for (int32 k=0;k<num;k++) {
get_nth_resource_descriptor_of_type(current, k, B_IRQ_RESOURCE,
&r, sizeof(resource_descriptor));
if (mask & r.d.m.mask) {
IRQListView->AddItem(new IRQDMAItem(first ? i : -1,
deviceInfo->GetCardName()));
first = false;
}
}
}
if (first) {
IRQListView->AddItem(new IRQDMAItem(i, ""));
}
}
}
{
uint32 mask = 1;
for (int i=0;i<8;mask<<=1,i++) {
bool first = true;
for (int32 j=0; j<list.CountItems(); j++) {
DevicesInfo *deviceInfo = (DevicesInfo *)list.ItemAt(j);
struct device_configuration *current = deviceInfo->GetCurrent();
resource_descriptor r;
int32 num = count_resource_descriptors_of_type(current,
//.........这里部分代码省略.........
示例2: BWindow
ConfigWindow::ConfigWindow()
:
BWindow(BRect(100, 100, 600, 540), B_TRANSLATE_SYSTEM_NAME("E-mail"),
B_TITLED_WINDOW,
B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_NOT_RESIZABLE),
fLastSelectedAccount(NULL),
fSaveSettings(false)
{
// create controls
BRect rect(Bounds());
BView *top = new BView(rect, NULL, B_FOLLOW_ALL, 0);
top->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
AddChild(top);
// determine font height
font_height fontHeight;
top->GetFontHeight(&fontHeight);
int32 height = (int32)(fontHeight.ascent + fontHeight.descent
+ fontHeight.leading) + 5;
rect.InsetBy(10, 10);
rect.bottom -= 18 + height;
BTabView *tabView = new BTabView(rect, NULL);
BView *view;
rect = tabView->Bounds();
rect.bottom -= tabView->TabHeight() + 4;
tabView->AddTab(view = new BView(rect, NULL, B_FOLLOW_ALL, 0));
tabView->TabAt(0)->SetLabel(B_TRANSLATE("Accounts"));
view->SetViewColor(top->ViewColor());
// accounts listview
rect = view->Bounds().InsetByCopy(10, 10);
rect.right = 190 - B_V_SCROLL_BAR_WIDTH;
rect.bottom -= height + 18;
fAccountsListView = new AccountsListView(rect, this);
view->AddChild(new BScrollView(NULL, fAccountsListView, B_FOLLOW_ALL, 0,
false, true));
rect.right += B_V_SCROLL_BAR_WIDTH;
rect.left -= 2;
rect.top = rect.bottom + 10;
rect.bottom = rect.top + height;
BRect sizeRect = rect;
sizeRect.right = sizeRect.left + 30 + view->StringWidth(
B_TRANSLATE("Add"));
view->AddChild(new BButton(sizeRect, NULL, B_TRANSLATE("Add"),
new BMessage(kMsgAddAccount), B_FOLLOW_BOTTOM));
sizeRect.left = sizeRect.right + 5;
sizeRect.right = sizeRect.left + 30 + view->StringWidth(
B_TRANSLATE("Remove"));
view->AddChild(fRemoveButton = new BButton(
sizeRect, NULL, B_TRANSLATE("Remove"),
new BMessage(kMsgRemoveAccount), B_FOLLOW_BOTTOM));
// accounts config view
rect = view->Bounds();
rect.left = fAccountsListView->Frame().right + B_V_SCROLL_BAR_WIDTH + 16;
rect.right -= 10;
fConfigView = new CenterContainer(rect);
view->AddChild(fConfigView);
_MakeHowToView();
// general settings
rect = tabView->ContainerView()->Bounds();
tabView->AddTab(view = new CenterContainer(rect));
tabView->TabAt(1)->SetLabel(B_TRANSLATE("Settings"));
rect = view->Bounds().InsetByCopy(10, 10);
rect.bottom = rect.top + height * 5 + 15;
BBox *box = new BBox(rect);
box->SetLabel(B_TRANSLATE("Mail checking"));
view->AddChild(box);
rect = box->Bounds().InsetByCopy(10, 10);
rect.top += 7;
rect.bottom = rect.top + height;
BRect tile = rect.OffsetByCopy(0, 1);
int32 labelWidth = (int32)view->StringWidth(B_TRANSLATE("Check every")) + 6;
tile.right = 80 + labelWidth;
fIntervalControl = new BTextControl(tile, "time",
B_TRANSLATE("Check every"), NULL, NULL);
fIntervalControl->SetDivider(labelWidth);
box->AddChild(fIntervalControl);
BPopUpMenu* frequencyPopUp = new BPopUpMenu(B_EMPTY_STRING);
const char* frequencyStrings[] = {
B_TRANSLATE_COMMENT("never", "mail checking frequency"),
B_TRANSLATE("minutes"),
B_TRANSLATE("hours"),
B_TRANSLATE("days")};
for (int32 i = 0; i < 4; i++) {
BMenuItem* item = new BMenuItem(frequencyStrings[i],
new BMessage(kMsgIntervalUnitChanged));
frequencyPopUp->AddItem(item);
//.........这里部分代码省略.........
示例3: iupdrvTabsGetCurrentTab
int iupdrvTabsGetCurrentTab(Ihandle* ih)
{
BTabView* tv = (BTabView*)ih->handle;
return tv->Selection();
}
示例4: main
int
main(int argc, char** argv)
{
BApplication app("application/x-vnd.haiku-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);
// B_PLAIN_BORDER);
// B_NO_BORDER);
columnListView->AddColumn(new BTitledColumn("Short",
150, 50, 500, B_ALIGN_LEFT), 0);
columnListView->AddColumn(new BTitledColumn("Medium Length",
100, 50, 500, B_ALIGN_CENTER), 1);
columnListView->AddColumn(new BTitledColumn("Some Long Column Name",
130, 50, 500, B_ALIGN_RIGHT), 2);
// 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);
BGroupView* content = new BGroupView(B_VERTICAL, kInset);
BLayoutBuilder::Group<>(content)
.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");
//.........这里部分代码省略.........
示例5: BWindow
BluetoothWindow::BluetoothWindow(BRect frame)
: BWindow(frame, B_TRANSLATE("Bluetooth"), B_TITLED_WINDOW,
B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS)
{
SetLayout(new BGroupLayout(B_HORIZONTAL));
fDefaultsButton = new BButton("defaults", B_TRANSLATE("Defaults"),
new BMessage(kMsgSetDefaults), B_WILL_DRAW);
fRevertButton = new BButton("revert", B_TRANSLATE("Revert"),
new BMessage(kMsgRevert), B_WILL_DRAW);
// Add the menu bar
fMenubar = new BMenuBar(Bounds(), "menu_bar");
// Add File menu to menu bar
BMenu* menu = new BMenu(B_TRANSLATE("Server"));
menu->AddItem(new BMenuItem(
B_TRANSLATE("Start bluetooth services" B_UTF8_ELLIPSIS),
new BMessage(kMsgStartServices), 0));
menu->AddItem(new BMenuItem(
B_TRANSLATE("Stop bluetooth services" B_UTF8_ELLIPSIS),
new BMessage(kMsgStopServices), 0));
menu->AddSeparatorItem();
menu->AddItem(new BMenuItem(
B_TRANSLATE("Show bluetooth console" B_UTF8_ELLIPSIS),
new BMessage(kMsgStartServices), 0));
menu->AddItem(new BMenuItem(
B_TRANSLATE("Refresh LocalDevices" B_UTF8_ELLIPSIS),
new BMessage(kMsgRefresh), 0));
fMenubar->AddItem(menu);
menu = new BMenu(B_TRANSLATE("View"));
menu->AddItem(new BMenuItem(
B_TRANSLATE("Connections & channels" B_UTF8_ELLIPSIS), NULL, 0));
menu->AddItem(new BMenuItem(
B_TRANSLATE("Remote devices list" B_UTF8_ELLIPSIS), NULL, 0));
fMenubar->AddItem(menu);
menu = new BMenu(B_TRANSLATE("Help"));
menu->AddItem(new BMenuItem(B_TRANSLATE("About Bluetooth" B_UTF8_ELLIPSIS),
new BMessage(B_ABOUT_REQUESTED), 0));
fMenubar->AddItem(menu);
BTabView* tabView = new BTabView("tabview", B_WIDTH_FROM_LABEL);
fSettingsView = new BluetoothSettingsView(B_TRANSLATE("Settings"));
// fConnChan = new ConnChanView("Connections & Channels", B_WILL_DRAW);
fRemoteDevices = new RemoteDevicesView(
B_TRANSLATE("Remote devices"), B_WILL_DRAW);
tabView->AddTab(fRemoteDevices);
// tabView->AddTab(fConnChan);
tabView->AddTab(fSettingsView);
fRevertButton->SetEnabled(false);
AddChild(BGroupLayoutBuilder(B_VERTICAL, 0)
.Add(fMenubar)
.Add(BSpaceLayoutItem::CreateVerticalStrut(5))
.Add(tabView)
.Add(BSpaceLayoutItem::CreateVerticalStrut(5))
.Add(BGroupLayoutBuilder(B_HORIZONTAL, 0)
.Add(fRevertButton)
.AddGlue()
.Add(fDefaultsButton)
)
.SetInsets(5, 5, 5, 5)
);
}
示例6: BWindow
BluetoothWindow::BluetoothWindow(BRect frame)
:
BWindow(frame, B_TRANSLATE_SYSTEM_NAME("Bluetooth"), B_TITLED_WINDOW,
B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS)
{
fDefaultsButton = new BButton("defaults", B_TRANSLATE("Defaults"),
new BMessage(kMsgSetDefaults), B_WILL_DRAW);
fRevertButton = new BButton("revert", B_TRANSLATE("Revert"),
new BMessage(kMsgRevert), B_WILL_DRAW);
// Add the menu bar
fMenubar = new BMenuBar(Bounds(), "menu_bar");
// Add File menu to menu bar
BMenu* menu = new BMenu(B_TRANSLATE("Server"));
menu->AddItem(new BMenuItem(
B_TRANSLATE("Start bluetooth services" B_UTF8_ELLIPSIS),
new BMessage(kMsgStartServices), 0));
menu->AddItem(new BMenuItem(
B_TRANSLATE("Stop bluetooth services" B_UTF8_ELLIPSIS),
new BMessage(kMsgStopServices), 0));
menu->AddSeparatorItem();
menu->AddItem(new BMenuItem(
B_TRANSLATE("Refresh local devices" B_UTF8_ELLIPSIS),
new BMessage(kMsgRefresh), 0));
fMenubar->AddItem(menu);
menu = new BMenu(B_TRANSLATE("Help"));
menu->AddItem(new BMenuItem(B_TRANSLATE("About Bluetooth" B_UTF8_ELLIPSIS),
new BMessage(B_ABOUT_REQUESTED), 0));
fMenubar->AddItem(menu);
BTabView* tabView = new BTabView("tabview", B_WIDTH_FROM_LABEL);
tabView->SetBorder(B_NO_BORDER);
fSettingsView = new BluetoothSettingsView(B_TRANSLATE("Settings"));
// fConnChan = new ConnChanView("Connections & Channels", B_WILL_DRAW);
fRemoteDevices = new RemoteDevicesView(
B_TRANSLATE("Remote devices"), B_WILL_DRAW);
tabView->AddTab(fRemoteDevices);
// tabView->AddTab(fConnChan);
tabView->AddTab(fSettingsView);
fRevertButton->SetEnabled(false);
BLayoutBuilder::Group<>(this, B_VERTICAL, 0)
.SetInsets(0)
.Add(fMenubar)
.AddStrut(B_USE_HALF_ITEM_SPACING)
.Add(tabView)
.AddStrut(B_USE_HALF_ITEM_SPACING)
.Add(new BSeparatorView(B_HORIZONTAL))
.AddGroup(B_HORIZONTAL)
.SetInsets(B_USE_WINDOW_SPACING, B_USE_DEFAULT_SPACING,
B_USE_WINDOW_SPACING, B_USE_WINDOW_SPACING)
.Add(fDefaultsButton)
.Add(fRevertButton)
.AddGlue()
.End()
.End();
}
示例7: BWindow
LocaleWindow::LocaleWindow()
:
BWindow(BRect(0, 0, 0, 0), "Locale", B_TITLED_WINDOW, B_QUIT_ON_WINDOW_CLOSE
| B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS)
{
BCountry* defaultCountry;
be_locale_roster->GetDefaultCountry(&defaultCountry);
SetLayout(new BGroupLayout(B_HORIZONTAL));
float spacing = be_control_look->DefaultItemSpacing();
BTabView* tabView = new BTabView("tabview");
BGroupView* languageTab = new BGroupView(B_TRANSLATE("Language"),
B_HORIZONTAL, spacing);
// first list: available languages
fLanguageListView = new LanguageListView("available",
B_MULTIPLE_SELECTION_LIST);
BScrollView* scrollView = new BScrollView("scroller", fLanguageListView,
B_WILL_DRAW | B_FRAME_EVENTS, false, true);
fLanguageListView->SetInvocationMessage(new BMessage(kMsgLanguageInvoked));
fLanguageListView->SetDragMessage(new BMessage(kMsgLanguageDragged));
// Fill the language list from the LocaleRoster data
BMessage installedLanguages;
if (be_locale_roster->GetInstalledLanguages(&installedLanguages) == B_OK) {
BString currentID;
LanguageListItem* lastAddedCountryItem = NULL;
for (int i = 0; installedLanguages.FindString("langs", i, ¤tID)
== B_OK; i++) {
// Now get an human-readable, localized name for each language
BLanguage* currentLanguage;
be_locale_roster->GetLanguage(currentID.String(),
¤tLanguage);
BString name;
currentLanguage->GetName(name);
// TODO: as long as the app_server doesn't support font overlays,
// use the translated name if problematic characters are used...
const char* string = name.String();
while (uint32 code = BUnicodeChar::FromUTF8(&string)) {
if (code > 1424) {
currentLanguage->GetTranslatedName(name);
break;
}
}
LanguageListItem* item = new LanguageListItem(name,
currentID.String(), currentLanguage->Code());
if (currentLanguage->IsCountrySpecific()
&& lastAddedCountryItem != NULL
&& lastAddedCountryItem->Code() == item->Code()) {
fLanguageListView->AddUnder(item, lastAddedCountryItem);
} else {
// This is a language variant, add it at top-level
fLanguageListView->AddItem(item);
if (!currentLanguage->IsCountrySpecific()) {
item->SetExpanded(false);
lastAddedCountryItem = item;
}
}
delete currentLanguage;
}
fLanguageListView->FullListSortItems(compare_typed_list_items);
} else {
BAlert* alert = new BAlert("Error",
B_TRANSLATE("Unable to find the available languages! You can't "
"use this preflet!"),
B_TRANSLATE("OK"), NULL, NULL,
B_WIDTH_AS_USUAL, B_OFFSET_SPACING, B_STOP_ALERT);
alert->Go();
}
// Second list: active languages
fPreferredListView = new LanguageListView("preferred",
B_MULTIPLE_SELECTION_LIST);
BScrollView* scrollViewEnabled = new BScrollView("scroller",
fPreferredListView, B_WILL_DRAW | B_FRAME_EVENTS, false, true);
fPreferredListView->SetInvocationMessage(
new BMessage(kMsgPreferredLanguageInvoked));
fPreferredListView->SetDeleteMessage(
new BMessage(kMsgPreferredLanguageDeleted));
fPreferredListView->SetDragMessage(
new BMessage(kMsgPreferredLanguageDragged));
BLayoutBuilder::Group<>(languageTab)
.AddGroup(B_VERTICAL, spacing)
.Add(new BStringView("", B_TRANSLATE("Available languages")))
.Add(scrollView)
.End()
.AddGroup(B_VERTICAL, spacing)
.Add(new BStringView("", B_TRANSLATE("Preferred languages")))
.Add(scrollViewEnabled)
//.........这里部分代码省略.........