本文整理汇总了C++中BCheckBox类的典型用法代码示例。如果您正苦于以下问题:C++ BCheckBox类的具体用法?C++ BCheckBox怎么用?C++ BCheckBox使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BCheckBox类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BView
BView *PrefsWindow::create_volumes_pane(void)
{
BView *pane = new BView(BRect(0, 0, top_frame.right-20, top_frame.bottom-80), GetString(STR_VOLUMES_PANE_TITLE), B_FOLLOW_NONE, B_WILL_DRAW);
pane->SetViewColor(fill_color);
float right = pane->Bounds().right-10;
const char *str;
int32 index = 0;
volume_list = new VolumeListView(BRect(15, 10, pane->Bounds().right-30, 113), "volumes");
while ((str = PrefsFindString("disk", index++)) != NULL)
volume_list->AddItem(new BStringItem(str));
volume_list->SetSelectionMessage(new BMessage(MSG_VOLUME_SELECTED));
volume_list->SetInvocationMessage(new BMessage(MSG_VOLUME_INVOKED));
pane->AddChild(new BScrollView("volumes_border", volume_list, B_FOLLOW_LEFT | B_FOLLOW_TOP, 0, false, true));
pane->AddChild(new BButton(BRect(10, 118, pane->Bounds().right/3, 138), "add_volume", GetString(STR_ADD_VOLUME_BUTTON), new BMessage(MSG_ADD_VOLUME)));
pane->AddChild(new BButton(BRect(pane->Bounds().right/3, 118, pane->Bounds().right*2/3, 138), "create_volume", GetString(STR_CREATE_VOLUME_BUTTON), new BMessage(MSG_CREATE_VOLUME)));
pane->AddChild(new BButton(BRect(pane->Bounds().right*2/3, 118, pane->Bounds().right-11, 138), "remove_volume", GetString(STR_REMOVE_VOLUME_BUTTON), new BMessage(MSG_REMOVE_VOLUME)));
extfs_control = new PathControl(true, BRect(10, 145, right, 160), "extfs", GetString(STR_EXTFS_CTRL), PrefsFindString("extfs"), NULL);
extfs_control->SetDivider(90);
pane->AddChild(extfs_control);
BMenuField *menu_field;
BPopUpMenu *menu = new BPopUpMenu("");
menu_field = new BMenuField(BRect(10, 165, right, 180), "bootdriver", GetString(STR_BOOTDRIVER_CTRL), menu);
menu_field->SetDivider(90);
menu->AddItem(new BMenuItem(GetString(STR_BOOT_ANY_LAB), new BMessage(MSG_BOOT_ANY)));
menu->AddItem(new BMenuItem(GetString(STR_BOOT_CDROM_LAB), new BMessage(MSG_BOOT_CDROM)));
pane->AddChild(menu_field);
int32 i32 = PrefsFindInt32("bootdriver");
BMenuItem *item;
if (i32 == 0) {
if ((item = menu->FindItem(GetString(STR_BOOT_ANY_LAB))) != NULL)
item->SetMarked(true);
} else if (i32 == CDROMRefNum) {
if ((item = menu->FindItem(GetString(STR_BOOT_CDROM_LAB))) != NULL)
item->SetMarked(true);
}
nocdrom_checkbox = new BCheckBox(BRect(10, 185, right, 200), "nocdrom", GetString(STR_NOCDROM_CTRL), new BMessage(MSG_NOCDROM));
pane->AddChild(nocdrom_checkbox);
nocdrom_checkbox->SetValue(PrefsFindBool("nocdrom") ? B_CONTROL_ON : B_CONTROL_OFF);
return pane;
}
示例2: debugger
status_t
ProtocolSettings::Save(const char* account, BView* parent)
{
if (!parent)
debugger("Couldn't save protocol's settings GUI on a NULL parent!");
BMessage* settings = new BMessage();
BMessage cur;
for (int32 i = 0; fTemplate->FindMessage("setting", i, &cur) == B_OK; i++) {
const char* name = cur.FindString("name");
// Skip NULL names
if (!name)
continue;
int32 type = -1;
if (cur.FindInt32("type", &type) != B_OK)
continue;
BView* view = parent->FindView(name);
if (!view)
continue;
BTextControl* textControl
= dynamic_cast<BTextControl*>(view);
if (textControl) {
switch (type) {
case B_STRING_TYPE:
settings->AddString(name, textControl->Text());
break;
case B_INT32_TYPE:
settings->AddInt32(name, atoi(textControl->Text()));
break;
default:
return B_ERROR;
}
}
BMenuField* menuField
= dynamic_cast<BMenuField*>(view);
if (menuField) {
BMenuItem* item = menuField->Menu()->FindMarked();
if (!item)
return B_ERROR;
switch (type) {
case B_STRING_TYPE:
settings->AddString(name, item->Label());
break;
case B_INT32_TYPE:
settings->AddInt32(name, atoi(item->Label()));
break;
default:
return B_ERROR;
}
}
BCheckBox* checkBox
= dynamic_cast<BCheckBox*>(view);
if (checkBox)
settings->AddBool(name, (checkBox->Value() == B_CONTROL_ON));
NotifyingTextView* textView
= dynamic_cast<NotifyingTextView*>(view);
if (textView)
settings->AddString(name, textView->Text());
}
return _Save(account, settings);
}
示例3: switch
bool BContainer::GetElementStr(BItem* element,CString* str)
{
BCheckBox* boolItem;
BEdit* editItem;
BCombo* comboItem;
BFile* fileItem;
BButton* buttonItem;
CString temp;
GML::Utils::GString gStrTemp;
UINT someUIntValue;
int someIntValue;
double someDoubleValue;
switch(element->elementType)
{
case GML::Utils::AttributeList::BOOLEAN:
boolItem = (BCheckBox*)element;
if(boolItem->IsChecked())
str->Format("%s=True;",boolItem->label);
else
str->Format("%s=False;",boolItem->label);
return true;
case GML::Utils::AttributeList::UINT32:
editItem = (BEdit*)element;
editItem->GetText(temp);
gStrTemp.Set(temp.GetBuffer());
if(!gStrTemp.ConvertToUInt32(&someUIntValue))
return false;
str->Format("%s=%u;",editItem->label,someUIntValue);
return true;
case GML::Utils::AttributeList::INT32:
editItem = (BEdit*)element;
editItem->GetText(temp);
gStrTemp.Set(temp.GetBuffer());
if(!gStrTemp.ConvertToInt32(&someIntValue))
return false;
str->Format("%s=%d;",editItem->label,someIntValue);
return true;
case GML::Utils::AttributeList::DOUBLE:
editItem = (BEdit*)element;
editItem->GetText(temp);
gStrTemp.Set(temp.GetBuffer());
if(!gStrTemp.ConvertToDouble(&someDoubleValue))
return false;
str->Format("%s=%lf;",editItem->label,someDoubleValue);
return true;
case GML::Utils::AttributeList::STRING:
editItem = (BEdit*)element;
editItem->GetText(temp);
if(temp.Compare("")==0)
{
return false;
}
str->Format("%s=%s;",editItem->label,temp);
return true;
case TYPE_COMBO:
comboItem = (BCombo*)element;
comboItem->GetSelectedItem(temp);
str->Format("%s=%s;",comboItem->label,temp);
return true;
case TYPE_FILE:
fileItem = (BFile*)element;
fileItem->GetText(temp);
str->Format("%s=%s;",fileItem->label,temp);
return true;
case TYPE_ELEMENT_HEADER:
buttonItem = (BButton*)element;
buttonItem->GetString(&temp);
str->Format("%s",temp);
return true;
}
return false;
}
示例4: BView
BView* SeqPrefWin::NewFileView(BRect bounds, const BMessage& prefs) const
{
BView* v = new BView( bounds, FILE_STR, B_FOLLOW_ALL, 0 );
if( !v ) return v;
v->SetViewColor( Prefs().Color(AM_AUX_WINDOW_BG_C) );
float fh = view_font_height(v);
float bfh = bold_font_height();
float openH = bfh + 5 + fh + 5 + fh + 5 + fh;
/* The Remember Open Songs preference.
*/
float w = v->StringWidth("Remember open songs") + 25;
BRect f(bounds.left + 5, bounds.top + 5, bounds.left + 5 + w, bounds.top + 5 + fh);
BCheckBox* cb = new BCheckBox( f, REMEMBER_OPEN_STR, "Remember open songs", new BMessage(REMEMBER_OPEN_MSG) );
if( cb ) {
bool b;
if( prefs.FindBool(REMEBER_OPEN_SONGS_PREF, &b) != B_OK ) b = false;
cb->SetValue( (b) ? B_CONTROL_ON : B_CONTROL_OFF );
v->AddChild( cb );
}
/* The Skin preference.
*/
BMenu* menu = new BMenu("skin_menu");
BMessage skinMsg(CHANGE_SKIN_MSG);
BMenuItem* item = new BMenuItem( "Default", new BMessage(CHANGE_SKIN_TO_DEFAULT_MSG) );
item->SetMarked(true);
menu->AddItem(item);
menu->AddSeparatorItem();
menu->SetLabelFromMarked(true);
if( seq_make_skin_menu(menu, &skinMsg) == B_OK ) {
const char* label = "Choose skin:";
f.Set(f.left, f.bottom + 8, bounds.right - 5, f.bottom + 8 + fh + 10);
BMenuField* field = new BMenuField(f, "skin_field", label, menu);
if (field) {
field->SetDivider( v->StringWidth(label) + 10 );
v->AddChild(field);
} else delete menu;
} else delete menu;
/* The Open New Songs preferences.
*/
f.Set(bounds.left + 5, f.bottom + 10, bounds.right - 5, f.bottom + 10 + openH + 10);
BBox* box = new BBox( f,
"open_new_songs",
B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
if( box ) {
box->SetLabel( "Open New Songs" );
BRect boxB = box->Bounds();
BRect sf(boxB.left + 5, boxB.top + 5 + bfh, boxB.right - 5, boxB.top + 5 + bfh + fh);
const char* choice;
if( prefs.FindString(OPEN_NEW_SONG_PREF, &choice) != B_OK ) choice = 0;
BRadioButton* button = new BRadioButton( sf, OPEN_BLANK_STR, "Blank", new BMessage(OPEN_BLANK_MSG), B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP );
if( button ) {
if( choice && strcmp(choice, "blank") == 0 ) button->SetValue( B_CONTROL_ON );
box->AddChild( button );
}
sf.OffsetBy( 0, 5 + fh );
button = new BRadioButton( sf, OPEN_FOUR_STR, "With two channels of each device", new BMessage(OPEN_FOUR_MSG), B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP );
if( button ) {
if( choice && strcmp(choice, "channels") == 0 ) button->SetValue( B_CONTROL_ON );
box->AddChild( button );
}
sf.OffsetBy( 0, 5 + fh );
button = new BRadioButton( sf, OPEN_FILE_STR, "From file: <click to select>", new BMessage(OPEN_FILE_MSG), B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP );
if( button ) {
if( choice && strcmp(choice, "file") == 0 ) button->SetValue( B_CONTROL_ON );
entry_ref ref;
if( prefs.FindRef(OPEN_NEW_SONG_FILE_PREF, &ref) == B_OK )
button->SetLabel( label_for_open_new_from_file(&ref).String() );
box->AddChild( button );
}
v->AddChild( box );
f.OffsetBy(0, f.bottom - f.top + 10 );
}
/* The Open From Query preferences
*/
f.bottom = bounds.bottom - 27;
box = new BBox( f, "open_from_query", B_FOLLOW_ALL);
if( box ) {
box->SetLabel("Open From Query");
BRect boxB = box->Bounds();
BRect tableF(boxB.left + 5, boxB.top + 5 + bfh, boxB.right - 5, boxB.bottom - 35);
mOwqTable = new _OwqList( tableF, mPreferences );
if( mOwqTable ) {
mOwqTable->SetLatchWidth( 0 );
box->AddChild( mOwqTable );
mOwqTable->AddColumn( new BStringColumn(ON_STR, 40, 20, 100, B_TRUNCATE_END), 0 );
mOwqTable->AddColumn( new BStringColumn(NAME_STR, 100, 20, 150, B_TRUNCATE_END), 1 );
mOwqTable->AddColumn( new BStringColumn(QUERY_STR, 180, 20, 450, B_TRUNCATE_MIDDLE), 2 );
// mOwqTable->AddColumn( new BStringColumn(SKIP_TOP_LEVEL_STR, 100, 20, 250, B_TRUNCATE_END), 3 );
mOwqTable->SetSortColumn(mOwqTable->ColumnAt(1), false, true);
// mOwqTable->SetSortColumn(mOwqTable->ColumnAt(), true, true);
mOwqTable->SetSelectionMode( B_SINGLE_SELECTION_LIST );
BRect bF(tableF.left, tableF.bottom + 5, tableF.left + 55, tableF.Height() - 10);
BButton* add = new BButton( bF, "owq_add", "Add", new BMessage(OWQ_INVOKE_ADD), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM );
if( add ) box->AddChild( add );
bF.OffsetBy( bF.Width() + 5, 0 );
BButton* change = new BButton( bF, "owq_change", "Change", new BMessage(OWQ_CHANGE), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM );
if( change ) {
//.........这里部分代码省略.........
示例5: BStringView
BView* PreferencesWindow::_CreateConnectionPage(float spacing)
{
/*
BStringView* addingLabel = new BStringView("", B_TRANSLATE("Adding"));
BStringView* downloadingLabel = new BStringView("", B_TRANSLATE("Downloading"));
//BStringView* seedingLabel = new BStringView("", B_TRANSLATE("Seeding Limits"));
addingLabel->SetFont(be_bold_font);
downloadingLabel->SetFont(be_bold_font);
*/
BStringView* peerPortLabel = new BStringView("", B_TRANSLATE("Peer Port"));
BStringView* limitsLabel = new BStringView("", B_TRANSLATE("Limits"));
BStringView* otherLabel = new BStringView("", B_TRANSLATE("Other"));
peerPortLabel->SetFont(be_bold_font);
limitsLabel->SetFont(be_bold_font);
otherLabel->SetFont(be_bold_font);
BStringView* fListeningPortLabel = new BStringView("", B_TRANSLATE("Incoming port:"));
BStringView* fMaxConnectionLabel = new BStringView("", B_TRANSLATE("Max connections:"));
BStringView* fTorrentMaxConnectionLabel = new BStringView("", B_TRANSLATE("Connected peers limit:"));
//BStringView* fTorrentUploadSlotsLabel = new BStringView("", B_TRANSLATE("Connected peers per torrent limit:"));
fListeningPort = new BTextControl("_name", NULL, "", NULL);
fRandomPort = new BButton("", B_TRANSLATE("Random"), new BMessage(MSG_INCOMING_PORT_RANDOM_BEHAVIOR_CHANGED));
fApplyPort = new BButton("", B_TRANSLATE("Apply"), new BMessage(MSG_INCOMING_PORT_BEHAVIOR_CHANGED));
fEnableForwardingPort = new BCheckBox("", B_TRANSLATE("Enable UPnP / NAT-PMP port forwarding"), new BMessage(MSG_PORT_FORWARDING_BEHAVIOR_CHANGED));
fMaxConnection = new BTextControl("_name", "", "", NULL);
fApplyMaxConnection = new BButton("", B_TRANSLATE("Apply"), new BMessage(MSG_PEER_LIMIT_BEHAVIOR_CHANGED));
fTorrentMaxConnection = new BTextControl("_name", "", "", NULL);
fApplyTorrentMaxConnection = new BButton("", B_TRANSLATE("Apply"), new BMessage(MSG_PEER_LIMIT_PER_TORRENT_BEHAVIOR_CHANGED));
//BTextControl* fTorrentUploadSlots = new BTextControl("_name", "", "", NULL);
BCheckBox* fEnableDHTValue = new BCheckBox("", B_TRANSLATE("Enable Distributed Hash Table (DHT)"), new BMessage(MSG_DISTRIBUTED_HASH_TABLE_BEHAVIOR_CHANGED));
BCheckBox* fEnablePEXValue = new BCheckBox("", B_TRANSLATE("Enable Bit Torrent Peer EXchange (PEX)"), new BMessage(MSG_TORRENT_PEER_EXCHANGE_BEHAVIOR_CHANGED));
BCheckBox* fEnableUTPValue = new BCheckBox("", B_TRANSLATE("Enable Micro Transport Protocol (" UTF8_GREEK_MU_LETTER "TP)"), new BMessage(MSG_MICRO_TRANSPORT_PROTOCOL_BEHAVIOR_CHANGED));
BCheckBox* fEnableLPDValue = new BCheckBox("", B_TRANSLATE("Enable Local Peer Discovery (LPD)"), new BMessage(MSG_LOCAL_PEER_DISCOVERY_BEHAVIOR_CHANGED));
//
BPopUpMenu* menu = new BPopUpMenu("");
fEncryptionMenuItem[0] = new BMenuItem(B_TRANSLATE("Off"), _CreateEncryptionMenuMessage(0));
fEncryptionMenuItem[1] = new BMenuItem(B_TRANSLATE("Enabled"), _CreateEncryptionMenuMessage(1));
fEncryptionMenuItem[2] = new BMenuItem(B_TRANSLATE("Required"), _CreateEncryptionMenuMessage(2));
menu->AddItem(fEncryptionMenuItem[0]);
menu->AddItem(fEncryptionMenuItem[1]);
menu->AddItem(fEncryptionMenuItem[2]);
fEncryptionMenu = new BMenuField("", B_TRANSLATE("Encryption:"), menu);
//
BString textBuffer;
textBuffer << (int32)fTorrentPreferences->IncomingPort();
fListeningPort->SetText(textBuffer);
textBuffer = B_EMPTY_STRING;
textBuffer << (int32)fTorrentPreferences->PeerLimit();
fMaxConnection->SetText(textBuffer);
textBuffer = B_EMPTY_STRING;
textBuffer << (int32)fTorrentPreferences->PeerLimitPerTorrent();
fTorrentMaxConnection->SetText(textBuffer);
//textBuffer << (int32)fTorrentPreferences->IncomingPort();
//fTorrentUploadSlots->SetText(textBuffer);
fEnableForwardingPort->SetValue(fTorrentPreferences->PortForwardingEnabled() ? B_CONTROL_ON : B_CONTROL_OFF);
fEnableDHTValue->SetValue(fTorrentPreferences->DistributedHashTableEnabled() ? B_CONTROL_ON : B_CONTROL_OFF);
fEnablePEXValue->SetValue(fTorrentPreferences->PeerExchangeEnabled() ? B_CONTROL_ON : B_CONTROL_OFF);
fEnableUTPValue->SetValue(fTorrentPreferences->MicroTransportProtocolEnabled() ? B_CONTROL_ON : B_CONTROL_OFF);
fEnableLPDValue->SetValue(fTorrentPreferences->LocalPeerDiscoveryEnabled() ? B_CONTROL_ON : B_CONTROL_OFF);
fEncryptionMenuItem[fTorrentPreferences->EncryptionMode()]->SetMarked(true);
//
fListeningPort->SetExplicitMaxSize(BSize(60, 40));
fMaxConnection->SetExplicitMaxSize(BSize(60, 40));
fTorrentMaxConnection->SetExplicitMaxSize(BSize(60, 40));
//fTorrentUploadSlots->SetExplicitMaxSize(BSize(60, 40));
//
//
BView* view = BGroupLayoutBuilder(B_VERTICAL, spacing / 2)
.Add(peerPortLabel)
.Add(BGridLayoutBuilder(-1, spacing / 2)
.SetInsets(spacing / 2, -1, -1, -1)
.Add(fListeningPortLabel, 0, 0)
//.Add(BSpaceLayoutItem::CreateHorizontalStrut(spacing), 1, 0)
.Add(fListeningPort, 1, 0)
.Add(fRandomPort, 2, 0)
.Add(fApplyPort, 3, 0)
//.Add(BSpaceLayoutItem::CreateGlue(), 2, 0)
//.Add(BSpaceLayoutItem::CreateGlue(), 3, 0)
//.Add(BSpaceLayoutItem::CreateGlue(), 4, 0)
//.........这里部分代码省略.........
示例6: Calc
//calculate the view positions of all the MatrixLayoutItems
//on the items list with offsets based upon matrixLeft
//and matrixTop
void
LayoutMatrix :: Calc( const float paramMatrixLeft,
const float paramMatrixTop,
sem_id paramSemID)
{
int32 numItems = mpItemsList->CountItems();
if (!numItems) return;
if (acquire_sem(paramSemID) != B_NO_ERROR)
{
warning(myPrefs->FailAqSem);
return;
}
bool hasPopUpMenu = false;
TextItem * scratchTextItem;
for ( int i = 0;
i < numItems;
i++)
{
((LayoutMatrixItem *)(mpItemsList->ItemAt(i)))->Calc();
}
float widest = 0;
float tallest = 0;
int32 index = 0;
for ( int i = 0;
i < numItems;
i++)
{
LayoutMatrixItem * lmi = (LayoutMatrixItem *)mpItemsList->ItemAt(index++);
if (lmi->mfWidthPref > widest)
{
widest = lmi->mfWidthPref;
}
if (lmi->mfHeightPref > tallest)
{
tallest = lmi->mfHeightPref;
}
}
if (mui32Flags & SAMESIZE)
{//SAMESIZE makes all items the same size as the largest
index = 0;
//Resize all items to match largest:
for ( uint32 i = 0;
i < mui32Rows;
i++)
{
for ( uint32 j = 0;
j < mui32Columns;
j++)
{
LayoutMatrixItem * lmi = (LayoutMatrixItem *)mpItemsList->ItemAt(index++);
switch (lmi->mui32Kind)
{
case KIND_MYSPACER:
{
MySpacer * scratchMySpacer = (MySpacer *)lmi->mpItem;
if (scratchMySpacer->mbSAMEFromWidest)
{
scratchMySpacer->ResizeTo(widest, tallest);
}
}
break;
case KIND_MYBUTTON:
{
BButton * scratchMyButton = (BButton *)lmi->mpItem;
scratchMyButton->ResizeTo(widest, tallest);
}
break;
case KIND_MYSLIDER:
{
BSlider * scratchMySlider = (BSlider *)lmi->mpItem;
scratchMySlider->ResizeTo(widest, tallest);
}
break;
case KIND_STRINGDRAWER:
{
BStringView * scratchMyStringView = (BStringView *)lmi->mpItem;
scratchMyStringView->ResizeTo(widest, tallest);
}
break;
case KIND_MYCHECKBOX:
{
BCheckBox * scratchMyCheckBox = (BCheckBox *)lmi->mpItem;
scratchMyCheckBox->ResizeTo(widest, tallest);
}
break;
case KIND_MYPICTUREBUTTON:
{
BPictureButton * scratchMyPictureButton = (BPictureButton *)lmi->mpItem;
scratchMyPictureButton->ResizeTo(widest, tallest);
}
break;
case KIND_MYCOLORCONTROL:
{
BColorControl * scratchMyColorControl = (BColorControl *)lmi->mpItem;
scratchMyColorControl->ResizeTo(widest, tallest);
}
break;
//.........这里部分代码省略.........
示例7: BWindow
NetworkWindow::NetworkWindow()
:
BWindow(BRect(100, 100, 400, 400), B_TRANSLATE("Network"), B_TITLED_WINDOW,
B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS),
fServicesItem(NULL),
fDialUpItem(NULL),
fOtherItem(NULL)
{
// Profiles section
#if ENABLE_PROFILES
BPopUpMenu* profilesPopup = new BPopUpMenu("<none>");
_BuildProfilesMenu(profilesPopup, kMsgProfileSelected);
BMenuField* profilesMenuField = new BMenuField("profiles_menu",
B_TRANSLATE("Profile:"), profilesPopup);
profilesMenuField->SetFont(be_bold_font);
profilesMenuField->SetEnabled(false);
#endif
// Settings section
fRevertButton = new BButton("revert", B_TRANSLATE("Revert"),
new BMessage(kMsgRevert));
BMessage* message = new BMessage(kMsgToggleReplicant);
BCheckBox* showReplicantCheckBox = new BCheckBox("showReplicantCheckBox",
B_TRANSLATE("Show network status in Deskbar"), message);
showReplicantCheckBox->SetExplicitMaxSize(
BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
showReplicantCheckBox->SetValue(_IsReplicantInstalled());
fListView = new BOutlineListView("list", B_SINGLE_SELECTION_LIST,
B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE | B_FRAME_EVENTS | B_NAVIGABLE);
fListView->SetSelectionMessage(new BMessage(kMsgItemSelected));
BScrollView* scrollView = new BScrollView("ScrollView", fListView,
0, false, true);
scrollView->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
fAddOnShellView = new BView("add-on shell", 0,
new BGroupLayout(B_VERTICAL));
fAddOnShellView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
fInterfaceView = new InterfaceView();
// Build the layout
BLayoutBuilder::Group<>(this, B_VERTICAL)
.SetInsets(B_USE_DEFAULT_SPACING)
#if ENABLE_PROFILES
.AddGroup(B_HORIZONTAL, B_USE_SMALL_SPACING)
.Add(profilesMenuField)
.AddGlue()
.End()
#endif
.AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING)
.Add(scrollView)
.Add(fAddOnShellView)
.End()
.Add(showReplicantCheckBox)
.AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING)
.Add(fRevertButton)
.AddGlue()
.End();
gNetworkWindow = this;
_ScanInterfaces();
_ScanAddOns();
_UpdateRevertButton();
fListView->Select(0);
_SelectItem(fListView->ItemAt(0));
// Call this manually, so that CenterOnScreen() below already
// knows the final window size.
// Set size of the list view from its contents
float width;
float height;
fListView->GetPreferredSize(&width, &height);
width += 2 * be_control_look->DefaultItemSpacing();
fListView->SetExplicitSize(BSize(width, B_SIZE_UNSET));
fListView->SetExplicitMinSize(BSize(width, std::min(height, 400.f)));
CenterOnScreen();
fSettings.StartMonitoring(this);
start_watching_network(B_WATCH_NETWORK_INTERFACE_CHANGES
| B_WATCH_NETWORK_LINK_CHANGES | B_WATCH_NETWORK_WLAN_CHANGES, this);
}
示例8: receivedFromUpdate
/*! \brief Main function of the View.
* \details Receives and parses the messages and updates the preferences if needed.
* \param[in] in The message to be parsed.
*/
void CalendarModulePreferencesView::MessageReceived( BMessage* in )
{
CalendarModulePreferences* prefs = NULL;
uint32 tempUint32 = 0;
int8 tempInt8 = 0;
int tempInt = 0;
BString sb;
BAlert* alert = NULL;
BCheckBox* cb = NULL;
BMessage* toSend;
CalendarModule* calModule = NULL;
CategoryListView* catListView = NULL;
CategoryListItem* catListItem = NULL;
Category receivedFromUpdate( BString("") );
ColorUpdateWindow* cuWindow = NULL;
bool weekend, weekday, viewer, service;
switch ( in->what )
{
case kCalendarModuleChosen:
if ( B_OK != in->FindString( "Module ID" , &sb ) )
return BView::MessageReceived( in );
BuildInterfaceForModule( sb );
break;
case kCalendarModuleFirstDayOfWeekSelected:
if ( ( B_OK != in->FindString( "Calendar module", &sb ) ) ||
( B_OK != in->FindInt32( "Day", ( int32* )&tempUint32 ) ) ||
( ( prefs = pref_GetPreferencesForCalendarModule( sb ) ) == NULL ) )
{
// Can't update - don't know what the module is!
BView::MessageReceived( in );
}
prefs->SetFirstDayOfWeek( tempUint32 );
// Refresh the view
BuildInterfaceForModule( sb );
break;
case kCalendarModuleWeekendDaySelected:
if ( ( B_OK != in->FindString( "Calendar module", &sb ) ) ||
( B_OK != in->FindInt32( "Weekday const", ( int32* )&tempUint32 ) ) ||
( ( prefs = pref_GetPreferencesForCalendarModule( sb ) ) == NULL ) )
{
// Can't update - don't know what the module is!
BView::MessageReceived( in );
}
calModule = utl_FindCalendarModule( sb );
sb.SetTo( "Weekday" );
sb << tempUint32;
if ( B_OK != ( cb = ( BCheckBox* )this->FindView( sb.String() ) ) )
BView::MessageReceived( in );
if ( cb->Value() == 0 ) // Deselected - removing from weekends
{
prefs->RemoveFromWeekends( tempUint32 );
} else { // Selected - adding to weekends
prefs->AddToWeekends( tempUint32 );
}
// :)
if ( calModule ) {
if ( prefs->GetNumberOfWeekends() == calModule->GetDaysInWeek() ) {
alert = new BAlert( "I envy you!",
"Wow! Nice week you have! I really envy you!",
":)",
NULL,
NULL,
B_WIDTH_AS_USUAL,
B_EVEN_SPACING,
B_IDEA_ALERT );
if ( alert )
alert->Go();
}
}
break;
case ( kCategoryInvoked ):
catListView = dynamic_cast< CategoryListView* >( this->FindView( "Colors list view" ) );
if ( !catListView ) {
break;
}
// Modifying currently existing category
tempInt = catListView->CurrentSelection();
if ( tempInt < 0 )
{
//.........这里部分代码省略.........
示例9: switch
void
MouseWindow::MessageReceived(BMessage* message)
{
switch (message->what) {
case kMsgDefaults: {
// reverts to default settings
fSettings.Defaults();
fSettingsView->UpdateFromSettings();
fDefaultsButton->SetEnabled(false);
fRevertButton->SetEnabled(fSettings.IsRevertable());
break;
}
case kMsgRevert: {
// revert to last settings
fSettings.Revert();
fSettingsView->UpdateFromSettings();
fDefaultsButton->SetEnabled(fSettings.IsDefaultable());
fRevertButton->SetEnabled(false);
break;
}
case kMsgMouseType:
{
int32 type;
if (message->FindInt32("index", &type) == B_OK) {
fSettings.SetMouseType(++type);
fSettingsView->SetMouseType(type);
fDefaultsButton->SetEnabled(fSettings.IsDefaultable());
fRevertButton->SetEnabled(fSettings.IsRevertable());
}
break;
}
case kMsgMouseFocusMode:
{
int32 mode;
if (message->FindInt32("mode", &mode) == B_OK) {
fSettings.SetMouseMode((mode_mouse)mode);
fDefaultsButton->SetEnabled(fSettings.IsDefaultable());
fRevertButton->SetEnabled(fSettings.IsRevertable());
fSettingsView->fFocusFollowsMouseMenu->SetEnabled(
mode == B_FOCUS_FOLLOWS_MOUSE);
fSettingsView->fAcceptFirstClickBox->SetEnabled(
mode != B_FOCUS_FOLLOWS_MOUSE);
}
break;
}
case kMsgFollowsMouseMode:
{
int32 mode;
if (message->FindInt32("mode_focus_follows_mouse", &mode)
== B_OK) {
fSettings.SetFocusFollowsMouseMode(
(mode_focus_follows_mouse)mode);
fDefaultsButton->SetEnabled(fSettings.IsDefaultable());
fRevertButton->SetEnabled(fSettings.IsRevertable());
}
break;
}
case kMsgAcceptFirstClick:
{
BHandler *handler;
if (message->FindPointer("source",
reinterpret_cast<void**>(&handler)) == B_OK) {
bool acceptFirstClick = false;
BCheckBox *acceptFirstClickBox =
dynamic_cast<BCheckBox*>(handler);
if (acceptFirstClickBox)
acceptFirstClick = acceptFirstClickBox->Value()
== B_CONTROL_ON;
fSettings.SetAcceptFirstClick(acceptFirstClick);
fDefaultsButton->SetEnabled(fSettings.IsDefaultable());
fRevertButton->SetEnabled(fSettings.IsRevertable());
}
break;
}
case kMsgDoubleClickSpeed:
{
int32 value;
if (message->FindInt32("be:value", &value) == B_OK) {
// slow = 1000000, fast = 0
fSettings.SetClickSpeed(value * 1000);
fDefaultsButton->SetEnabled(fSettings.IsDefaultable());
fRevertButton->SetEnabled(fSettings.IsRevertable());
}
break;
}
case kMsgMouseSpeed:
{
int32 value;
if (message->FindInt32("be:value", &value) == B_OK) {
// slow = 8192, fast = 524287
fSettings.SetMouseSpeed((int32)pow(2,
//.........这里部分代码省略.........
示例10:
/*! \brief Updates targets of all controls currently in the view.
* \details BView::AttachToWindow(), among other things, modifies the targets
* of controls to point to main looper of the application. This is
* not desirable way. This function corrects it.
*/
void CalendarModulePreferencesView::UpdateTargetting( void )
{
BCheckBox* tempCheckBox = NULL;
int i, limit;
// Updating calendar chooser part
BMenuItem* menuItem = NULL;
if ( calendarModules ) {
limit = calendarModules->CountItems();
for ( i = 0; i < limit; ++i )
{
menuItem = dynamic_cast< BMenuItem* >( calendarModules->ItemAt( i ) );
if ( menuItem )
menuItem->SetTarget( this );
}
}
// Update Weekends selector box
BBox* tempBBox = ( BBox* )this->FindView( "Weekend selector" );
if ( tempBBox ) {
limit = tempBBox->CountChildren();
for ( i = 0; i < limit; ++i )
{
tempCheckBox = dynamic_cast< BCheckBox* >( tempBBox->ChildAt( i ) );
if ( tempCheckBox )
tempCheckBox->SetTarget( this );
}
}
// Update First day of week chooser
BPopUpMenu* tempMenu = ( BPopUpMenu* )this->FindView( "First day of week" );
if ( tempMenu )
{
limit = tempMenu->CountItems();
for ( i = 0; i < limit; ++i )
{
menuItem = dynamic_cast< BMenuItem* >( tempMenu->ItemAt( i ) );
if ( menuItem )
menuItem->SetTarget( this );
}
}
// Update day-month-year order chooser
tempMenu = ( BPopUpMenu* )this->FindView( "DmyOrderChooser" );
if ( tempMenu )
{
limit = tempMenu->CountItems();
for ( i = 0; i < limit; ++i )
{
menuItem = dynamic_cast< BMenuItem* >( tempMenu->ItemAt( i ) );
if ( menuItem )
menuItem->SetTarget( this );
}
}
// Update the target of Color selector
CategoryListView* catListView = ( CategoryListView* )this->FindView("Colors list view");
if ( catListView )
{
catListView->SetTarget( this );
}
} // <-- end of function CalendarModulePreferencesView::UpdateTargetting
示例11: 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 );
//.........这里部分代码省略.........
示例12: BWindow
// --------------------------------------------------------------
NetworkSetupWindow::NetworkSetupWindow(const char *title)
:
BWindow(BRect(100, 100, 600, 600), title, B_TITLED_WINDOW,
B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS)
{
BMenu *show_menu;
BMenu *profiles_menu;
BMenuField *menu_field;
BBox *top_box, *bottom_box, *line; // *group
BButton *button;
BCheckBox *check;
BRect r;
float x, w, h;
float size, min_size = 360;
// TODO: cleanup this mess!
show_menu = new BPopUpMenu("<please select me!>");
_BuildShowMenu(show_menu, SHOW_MSG);
#define H_MARGIN 10
#define V_MARGIN 10
#define SMALL_MARGIN 3
// Resize the window to minimal width
ResizeTo(fMinAddonViewRect.Width() + 2 * H_MARGIN, Bounds().Height());
top_box = new BBox(Bounds(), NULL, B_FOLLOW_NONE,
B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP,
B_PLAIN_BORDER);
AddChild(top_box);
r = top_box->Bounds();
r.InsetBy(H_MARGIN, V_MARGIN);
// ---- Profiles section
profiles_menu = new BPopUpMenu("<none>");
menu_field = new BMenuField(r, "profiles_menu", PROFILE_LABEL,
profiles_menu);
menu_field->SetFont(be_bold_font);
menu_field->SetDivider(be_bold_font->StringWidth(PROFILE_LABEL "#"));
top_box->AddChild(menu_field);
menu_field->ResizeToPreferred();
menu_field->GetPreferredSize(&w, &h);
size = w;
button = new BButton(r, "manage_profiles", MANAGE_PROFILES_LABEL,
new BMessage(MANAGE_PROFILES_MSG),
B_FOLLOW_TOP | B_FOLLOW_RIGHT);
button->GetPreferredSize(&w, &h);
button->ResizeToPreferred();
button->MoveTo(r.right - w, r.top);
top_box->AddChild(button);
size += SMALL_MARGIN + w;
min_size = max_c(min_size, (H_MARGIN + size + H_MARGIN));
r.top += h + V_MARGIN;
// ---- Separator line between Profiles section and Settings section
line = new BBox(BRect(r.left, r.top, r.right, r.top + 1), NULL,
B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP );
top_box->AddChild(line);
_BuildProfilesMenu(profiles_menu, SELECT_PROFILE_MSG);
r.top += 2 + V_MARGIN;
// ---- Settings section
// Make the show popup field half the whole width and centered
menu_field = new BMenuField(r, "show_menu", SHOW_LABEL, show_menu);
menu_field->SetFont(be_bold_font);
menu_field->SetDivider(be_bold_font->StringWidth(SHOW_LABEL "#"));
top_box->AddChild(menu_field);
menu_field->ResizeToPreferred();
menu_field->GetPreferredSize(&w, &h);
r.top += h+1 + V_MARGIN;
min_size = max_c(min_size, (H_MARGIN + w + H_MARGIN));
r = fMinAddonViewRect.OffsetByCopy(H_MARGIN, r.top);
fPanel = new BBox(r, "showview_box", B_FOLLOW_NONE,
B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP,
B_PLAIN_BORDER);
top_box->AddChild(fPanel);
top_box->ResizeTo(Bounds().Width(), r.bottom + 1 + V_MARGIN);
// ---- Bottom globals buttons section
r = Bounds();
r.top = top_box->Frame().bottom + 1;
bottom_box = new BBox(r, NULL, B_FOLLOW_NONE,
B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP,
B_PLAIN_BORDER);
AddChild(bottom_box);
//.........这里部分代码省略.........
示例13: atoi
bool
JobSetupView::UpdateJobData()
{
fJobData->SetShowPreview(fPreview->Value() == B_CONTROL_ON);
fJobData->SetColor(Color());
if (IsHalftoneConfigurationNeeded()) {
fJobData->SetGamma(Gamma());
fJobData->SetInkDensity(InkDensity());
fJobData->SetDitherType(DitherType());
}
int first_page;
int last_page;
if (B_CONTROL_ON == fAll->Value()) {
first_page = 1;
last_page = -1;
} else {
first_page = atoi(fFromPage->Text());
last_page = atoi(fToPage->Text());
}
fJobData->SetFirstPage(first_page);
fJobData->SetLastPage(last_page);
fJobData->SetPaperSource(PaperSource());
fJobData->SetNup(GetID(gNups, sizeof(gNups) / sizeof(gNups[0]),
fNup->FindMarked()->Label(), 1));
if (fPrinterCap->Supports(PrinterCap::kPrintStyle)) {
fJobData->SetPrintStyle((B_CONTROL_ON == fDuplex->Value())
? JobData::kDuplex : JobData::kSimplex);
}
fJobData->SetCopies(atoi(fCopies->Text()));
fJobData->SetCollate(B_CONTROL_ON == fCollate->Value());
fJobData->SetReverse(B_CONTROL_ON == fReverse->Value());
JobData::PageSelection pageSelection = JobData::kAllPages;
if (fOddNumberedPages->Value() == B_CONTROL_ON)
pageSelection = JobData::kOddNumberedPages;
if (fEvenNumberedPages->Value() == B_CONTROL_ON)
pageSelection = JobData::kEvenNumberedPages;
fJobData->SetPageSelection(pageSelection);
{
std::map<PrinterCap::CapID, BPopUpMenu*>::iterator it =
fDriverSpecificPopUpMenus.begin();
for(; it != fDriverSpecificPopUpMenus.end(); it++) {
PrinterCap::CapID category = it->first;
BPopUpMenu* popUpMenu = it->second;
const char* key = fPrinterCap->FindCap(
PrinterCap::kDriverSpecificCapabilities, (int)category)->Key();
const char* label = popUpMenu->FindMarked()->Label();
const char* value = static_cast<const EnumCap*>(fPrinterCap->
FindCap(category, label))->Key();
fJobData->Settings().SetString(key, value);
}
}
{
std::map<string, BCheckBox*>::iterator it =
fDriverSpecificCheckBoxes.begin();
for(; it != fDriverSpecificCheckBoxes.end(); it++) {
const char* key = it->first.c_str();
BCheckBox* checkBox = it->second;
bool value = checkBox->Value() == B_CONTROL_ON;
fJobData->Settings().SetBoolean(key, value);
}
}
{
std::map<PrinterCap::CapID, IntRange>::iterator it =
fDriverSpecificIntSliders.begin();
for(; it != fDriverSpecificIntSliders.end(); it++) {
IntRange& range = it->second;
fJobData->Settings().SetInt(range.Key(), range.Value());
}
}
{
std::map<PrinterCap::CapID, DoubleRange>::iterator it =
fDriverSpecificDoubleSliders.begin();
for(; it != fDriverSpecificDoubleSliders.end(); it++) {
DoubleRange& range = it->second;
fJobData->Settings().SetDouble(range.Key(), range.Value());
}
}
fJobData->Save();
return true;
}
示例14: Bounds
//------------------------------------------------------------------------------
void WindowEditor::InitFlagsBoxes()
{
BRect work = Bounds();
work.left = 10;
work.top = 100;
work.bottom -= 5;
work.right -= 10;
work.right -= 10;
int i = 20;
int inc = 10;
BBox* box = new BBox(work, "flags");
BCheckBox* cbox;
BMessage* msg;
box->SetLabel("Window Flags");
uint32 flags = fWindowInfo.flags;
bool longLabel;
for (int index = 0; WindowFlags[index].name; ++index)
{
longLabel = strlen(WindowFlags[index].label) > 20;
// First column of checkboxes
msg = new BMessage(MSG_WINDOW_SET_FLAG);
msg->AddInt32("flags", WindowFlags[index].flag);
cbox = new BCheckBox(BRect(10, i, longLabel ? 210 : 125, i + inc),
WindowFlags[index].name, WindowFlags[index].label, msg);
fFlagBoxes.push_back(cbox);
box->AddChild(cbox);
if (WindowFlags[index].flip == (flags & WindowFlags[index].flag))
{
cbox->SetValue(B_CONTROL_ON);
}
// We skip to the next row as needed to make room for long labels
if (!longLabel && WindowFlags[index + 1].name)
{
++index;
// Second column of checkboxes
msg = new BMessage(MSG_WINDOW_SET_FLAG);
msg->AddInt32("flags", WindowFlags[index].flag);
cbox = new BCheckBox(BRect(130, i, 210, i + inc),
WindowFlags[index].name,
WindowFlags[index].label,
msg);
fFlagBoxes.push_back(cbox);
box->AddChild(cbox);
if (WindowFlags[index].flip == (flags & WindowFlags[index].flag))
{
cbox->SetValue(B_CONTROL_ON);
}
}
i += inc * 2;
}
#if 0
msg = new BMessage(MSG_WINDOW_SET_FLAG);
msg->AddInt32("flags",B_NOT_MOVABLE);
box->AddChild(new BCheckBox(BRect(10,i,120,i+inc),"nmov","Movable",msg));
msg = new BMessage(MSG_WINDOW_SET_FLAG);
msg->AddInt32("flags",B_NOT_CLOSABLE);
box->AddChild(new BCheckBox(BRect(130,i,210,i+inc),"clos","Closable",msg));
msg = new BMessage(MSG_WINDOW_SET_FLAG);
i+= inc*2;
msg->AddInt32("flags",B_NOT_ZOOMABLE);
box->AddChild(new BCheckBox(BRect(10,i,120,i+inc),"zoom","Zoomable",msg));
msg = new BMessage(MSG_WINDOW_SET_FLAG);
msg->AddInt32("flags",B_NOT_MINIMIZABLE);
box->AddChild(new BCheckBox(BRect(130,i,210,i+inc),"mini","Minimizable",msg));
msg = new BMessage(MSG_WINDOW_SET_FLAG);
i+= inc*2;
msg->AddInt32("flags",B_NOT_H_RESIZABLE);
box->AddChild(new BCheckBox(BRect(10,i,210,i+inc),"hres","Horizontally Resizable",msg));
msg = new BMessage(MSG_WINDOW_SET_FLAG);
i+= inc*2;
msg->AddInt32("flags",B_NOT_V_RESIZABLE);
box->AddChild(new BCheckBox(BRect(10,i,125,i+inc),"vres","Vertically Resizable",msg));
menubox = new BCheckBox(BRect(130,i,210,i+inc),"menus","Menu Bar",new BMessage(MSG_WINDOW_ADD_MENU));
box->AddChild(menubox);
if (fWindowInfo.has_menu)
menubox->SetValue(B_CONTROL_ON);
msg = new BMessage(MSG_WINDOW_SET_FLAG);
i+= inc*2;
msg->AddInt32("flags",B_OUTLINE_RESIZE);
box->AddChild(new BCheckBox(BRect(10,i,210,i+inc),"roiw","Resize with Outline Instead of Window",msg));
msg = new BMessage(MSG_WINDOW_SET_FLAG);
i+= inc*2;
msg->AddInt32("flags",B_WILL_ACCEPT_FIRST_CLICK);
box->AddChild(new BCheckBox(BRect(10,i,210,i+inc),"wafc","Will Accept First Click",msg));
msg = new BMessage(MSG_WINDOW_SET_FLAG);
i+= inc*2;
msg->AddInt32("flags",B_AVOID_FRONT);
box->AddChild(new BCheckBox(BRect(10,i,120,i+inc),"avfr","Avoid Front",msg));
msg = new BMessage(MSG_WINDOW_SET_FLAG);
msg->AddInt32("flags",B_AVOID_FOCUS);
box->AddChild(new BCheckBox(BRect(130,i,210,i+inc),"avfo","Avoid Focus",msg));
msg = new BMessage(MSG_WINDOW_SET_FLAG);
i+= inc*2;
msg->AddInt32("flags",B_NO_WORKSPACE_ACTIVATION);
box->AddChild(new BCheckBox(BRect(10,i,210,i+inc),"nwoa","Do Not Activate Workspace",msg));
msg = new BMessage(MSG_WINDOW_SET_FLAG);
//.........这里部分代码省略.........
示例15: BView
//----------------Real code----------------------
BMailProtocolConfigView::BMailProtocolConfigView(uint32 options_mask)
:
BView (BRect(0,0,100,20), "protocol_config_view", B_FOLLOW_LEFT
| B_FOLLOW_TOP, B_WILL_DRAW),
fBodyDownloadConfig(NULL)
{
BRect rect(5,5,245,25);
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
// determine font height
font_height fontHeight;
GetFontHeight(&fontHeight);
sItemHeight = (int32)(fontHeight.ascent + fontHeight.descent + fontHeight.leading) + 13;
rect.bottom = rect.top - 2 + sItemHeight;
if (options_mask & B_MAIL_PROTOCOL_HAS_HOSTNAME)
AddChild(AddTextField(rect, "host", B_TRANSLATE("Mail server:")));
if (options_mask & B_MAIL_PROTOCOL_HAS_USERNAME)
AddChild(AddTextField(rect, "user", B_TRANSLATE("Username:")));
if (options_mask & B_MAIL_PROTOCOL_HAS_PASSWORD) {
BTextControl *control = AddTextField(rect, "pass",
B_TRANSLATE("Password:"));
control->TextView()->HideTyping(true);
AddChild(control);
}
if (options_mask & B_MAIL_PROTOCOL_HAS_FLAVORS)
AddChild(AddMenuField(rect, "flavor", B_TRANSLATE("Connection type:")));
if (options_mask & B_MAIL_PROTOCOL_HAS_AUTH_METHODS)
AddChild(AddMenuField(rect, "auth_method", B_TRANSLATE("Login type:")));
// set divider
float width = FindWidestLabel(this);
for (int32 i = CountChildren();i-- > 0;) {
if (BTextControl *text = dynamic_cast<BTextControl *>(ChildAt(i)))
text->SetDivider(width + 6);
}
if (options_mask & B_MAIL_PROTOCOL_CAN_LEAVE_MAIL_ON_SERVER) {
AddChild(AddCheckBox(rect, "leave_mail_on_server",
B_TRANSLATE("Leave mail on server"), new BMessage('lmos')));
BCheckBox* box = AddCheckBox(rect, "delete_remote_when_local",
B_TRANSLATE("Remove mail from server when deleted"));
box->SetEnabled(false);
AddChild(box);
}
if (options_mask & B_MAIL_PROTOCOL_PARTIAL_DOWNLOAD) {
fBodyDownloadConfig = new BodyDownloadConfig();
fBodyDownloadConfig->MoveBy(0, rect.bottom + 5);
AddChild(fBodyDownloadConfig);
}
// resize views
float height;
GetPreferredSize(&width,&height);
ResizeTo(width,height);
for (int32 i = CountChildren();i-- > 0;) {
// this doesn't work with BTextControl, does anyone know why? -- axeld.
if (BView *view = ChildAt(i))
view->ResizeTo(width - 10,view->Bounds().Height());
}
}