BView *PrefsWindow::create_serial_pane(void) { BView *pane = new BView(BRect(0, 0, top_frame.right-20, top_frame.bottom-80), GetString(STR_SERIAL_NETWORK_PANE_TITLE), B_FOLLOW_NONE, B_WILL_DRAW); pane->SetViewColor(fill_color); float right = pane->Bounds().right-10; BMenuField *menu_field; BPopUpMenu *menu_a = new BPopUpMenu(""); add_serial_names(menu_a, MSG_SER_A); menu_field = new BMenuField(BRect(10, 5, right, 20), "seriala", GetString(STR_SERIALA_CTRL), menu_a); menu_field->SetDivider(90); pane->AddChild(menu_field); set_serial_label(menu_a, "seriala"); BPopUpMenu *menu_b = new BPopUpMenu(""); add_serial_names(menu_b, MSG_SER_B); menu_field = new BMenuField(BRect(10, 26, right, 41), "serialb", GetString(STR_SERIALB_CTRL), menu_b); menu_field->SetDivider(90); pane->AddChild(menu_field); set_serial_label(menu_b, "serialb"); ether_checkbox = new BCheckBox(BRect(10, 47, right, 62), "ether", GetString(STR_ETHER_ENABLE_CTRL), new BMessage(MSG_ETHER)); pane->AddChild(ether_checkbox); ether_checkbox->SetValue(PrefsFindString("ether") ? B_CONTROL_ON : B_CONTROL_OFF); udptunnel_checkbox = new BCheckBox(BRect(10, 67, right, 72), "udptunnel", GetString(STR_UDPTUNNEL_CTRL), new BMessage(MSG_UDPTUNNEL)); pane->AddChild(udptunnel_checkbox); udptunnel_checkbox->SetValue(PrefsFindBool("udptunnel") ? B_CONTROL_ON : B_CONTROL_OFF); udpport_ctrl = new NumberControl(BRect(10, 87, right / 2, 105), 118, "udpport", GetString(STR_UDPPORT_CTRL), PrefsFindInt32("udpport"), NULL); pane->AddChild(udpport_ctrl); hide_show_serial_ctrls(); return pane; }
void FadeView::AttachedToWindow() { fEnableCheckBox->SetTarget(this); fRunSlider->SetTarget(this); fTurnOffCheckBox->SetTarget(this); fTurnOffSlider->SetTarget(this); fFadeNow->SetTarget(this); fFadeNever->SetTarget(this); fPasswordCheckBox->SetTarget(this); fPasswordSlider->SetTarget(this); fEnableCheckBox->SetValue( fSettings.TimeFlags() & ENABLE_SAVER ? B_CONTROL_ON : B_CONTROL_OFF); fRunSlider->SetTime(fSettings.BlankTime()); fTurnOffSlider->SetTime(fSettings.OffTime() + fSettings.BlankTime()); fFadeNow->SetCorner(fSettings.BlankCorner()); fFadeNever->SetCorner(fSettings.NeverBlankCorner()); fPasswordCheckBox->SetValue(fSettings.LockEnable()); fPasswordSlider->SetTime(fSettings.PasswordTime()); _UpdateColors(); UpdateTurnOffScreen(); UpdateStatus(); }
BRect LibraryWindow::ScanFolder(BPoint location, const char *path, float *maxwidth) { BDirectory dir(path); if (dir.InitCheck() != B_OK) return BRect(0,0,-1,-1); float width = 0.0; dir.Rewind(); entry_ref ref; BRect r(location.x,location.y,location.x + 1,location.y + 1); while (dir.GetNextRef(&ref) == B_OK) { BString str(ref.name); int32 soPos = str.FindLast(".so"); int32 aPos = str.FindLast(".a"); if (soPos < 0 && aPos < 0) continue; if (soPos >= 0 && soPos < str.CountChars() - 3) continue; if (aPos >= 0 && aPos < str.CountChars() - 2) continue; Lock(); BMessage *msg = new BMessage(M_TOGGLE_LIB); msg->AddRef("ref",&ref); msg->AddString("path",path); BCheckBox *box = new BCheckBox(r,ref.name,ref.name,msg); box->ResizeToPreferred(); r = box->Frame(); fCheckList->AddChild(box); fSystemLibs.AddItem(box); // Make sure that there isn't any shortcut normalization BPath dirpath(path); dirpath.Append(ref.name); if (fProject && fProject->HasLibrary(dirpath.Path())) box->SetValue(B_CONTROL_ON); else box->SetValue(B_CONTROL_OFF); Unlock(); width = MAX(r.right,width); r.OffsetBy(0,r.Height()); } if (r.Height() == 1) r.Set(0, 0, -1, -1); *maxwidth = width; return r; }
void BMailProtocolConfigView::SetTo(MailAddonSettings& settings) { const BMessage* archive = &settings.Settings(); BString host = archive->FindString("server"); if (archive->HasInt32("port")) host << ':' << archive->FindInt32("port"); SetTextControl(this,"host", host.String()); SetTextControl(this,"user", archive->FindString("username")); char *password = get_passwd(archive, "cpasswd"); if (password) { SetTextControl(this,"pass", password); delete[] password; } else SetTextControl(this,"pass", archive->FindString("password")); if (archive->HasInt32("flavor")) { BMenuField *menu = (BMenuField *)(FindView("flavor")); if (menu != NULL) { if (BMenuItem *item = menu->Menu()->ItemAt(archive->FindInt32("flavor"))) item->SetMarked(true); } } if (archive->HasInt32("auth_method")) { BMenuField *menu = (BMenuField *)(FindView("auth_method")); if (menu != NULL) { if (BMenuItem *item = menu->Menu()->ItemAt(archive->FindInt32("auth_method"))) { item->SetMarked(true); if (item->Command() != 'none') { enable_control("user"); enable_control("pass"); } } } } BCheckBox *box = (BCheckBox *)(FindView("leave_mail_on_server")); if (box != NULL) box->SetValue(archive->FindBool("leave_mail_on_server") ? B_CONTROL_ON : B_CONTROL_OFF); box = (BCheckBox *)(FindView("delete_remote_when_local")); if (box != NULL) { box->SetValue(archive->FindBool("delete_remote_when_local") ? B_CONTROL_ON : B_CONTROL_OFF); if (archive->FindBool("leave_mail_on_server")) box->SetEnabled(true); else box->SetEnabled(false); } if (fBodyDownloadConfig) fBodyDownloadConfig->SetTo(settings); }
void SetPrefs(const BMessage* prefs) { if( !prefs ) return; mOldPrefs.MakeEmpty(); mOldPrefs = *prefs; delete mRef; mRef = 0; bool b; const char* str; entry_ref ref; if( mOnBox && prefs->FindBool( "on", &b ) == B_OK ) mOnBox->SetValue( (b) ? B_CONTROL_ON : B_CONTROL_OFF ); if( mNameCtrl && prefs->FindString( "name", &str ) == B_OK ) mNameCtrl->SetText( str ); if( prefs->FindRef( "ref", &ref ) == B_OK ) mRef = new entry_ref( ref ); if( mSkipBox && prefs->FindBool( "skip", &b ) == B_OK ) mSkipBox->SetValue( (b) ? B_CONTROL_ON : B_CONTROL_OFF ); }
void FadeView::UpdateTurnOffScreen() { bool enabled = (fSettings.TimeFlags() & ENABLE_DPMS_MASK) != 0; BScreen screen(Window()); uint32 dpmsCapabilities = screen.DPMSCapabilites(); fTurnOffScreenFlags = 0; if (dpmsCapabilities & B_DPMS_OFF) fTurnOffScreenFlags |= ENABLE_DPMS_OFF; if (dpmsCapabilities & B_DPMS_STAND_BY) fTurnOffScreenFlags |= ENABLE_DPMS_STAND_BY; if (dpmsCapabilities & B_DPMS_SUSPEND) fTurnOffScreenFlags |= ENABLE_DPMS_SUSPEND; fTurnOffCheckBox->SetValue(enabled && fTurnOffScreenFlags != 0 ? B_CONTROL_ON : B_CONTROL_OFF); enabled = fEnableCheckBox->Value() == B_CONTROL_ON; fTurnOffCheckBox->SetEnabled(enabled && fTurnOffScreenFlags != 0); if (fTurnOffScreenFlags != 0) { fTurnOffNotSupported->Hide(); fTurnOffSlider->Show(); } else { fTurnOffSlider->Hide(); fTurnOffNotSupported->Show(); } }
void JobSetupView::AddCheckBox(const DriverSpecificCap* capability, BGridLayout* gridLayout, int& row) { PrinterCap::CapID category = static_cast<PrinterCap::CapID>( capability->ID()); const BooleanCap* booleanCap = fPrinterCap->FindBooleanCap(category); if (booleanCap == NULL) { fprintf(stderr, "Internal error: BooleanCap for '%s' not found!\n", capability->Label()); return; } const char* key = capability->Key(); BString name; name << "pds_" << key; BCheckBox* checkBox = new BCheckBox(name.String(), capability->Label(), NULL); bool value = booleanCap->DefaultValue(); if (fJobData->Settings().HasBoolean(key)) value = fJobData->Settings().GetBoolean(key); if (value) checkBox->SetValue(B_CONTROL_ON); gridLayout->AddView(checkBox, 0, row, 2); row ++; fDriverSpecificCheckBoxes[capability->Key()] = checkBox; }
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; }
DetailsBuilder::DetailsBuilder(BView* parent, BView* details, BRect bounds, Statement* group, const BMessage& settings) : fParent(parent) , fDetails(details) , fBounds(bounds) , fGroup(group) , fMenu(NULL) , fMenuField(NULL) , fSettings(settings) { fKeyword = fGroup.GetGroupName(); if (fKeyword == NULL) return; fValue = settings.FindString(fKeyword); const char* label = fGroup.GetGroupTranslation(); if (label == NULL) { label = fKeyword; } BView* view = NULL; if (fGroup.GetType() == GroupStatement::kPickOne) { fMenu = new BMenu("<pick one>"); fMenu->SetRadioMode(true); fMenu->SetLabelFromMarked(true); fMenuField = new BMenuField(fBounds, "menuField", label, fMenu); view = fMenuField; } else if (fGroup.GetType() == GroupStatement::kBoolean) { BMessage* message = GetMessage(kMsgBooleanChanged, ""); BCheckBox* cb = new BCheckBox(fBounds, "", label, message); view = cb; cb->SetValue((fValue != NULL && strcmp(fValue, "True") == 0) ? B_CONTROL_ON : B_CONTROL_OFF); } AddView(view); }
void MessageView::ValueChanged(void) { char *name; uint32 type; int32 count; #ifdef B_ZETA_VERSION_1_0_0 for (int32 i = 0; configMessage->GetInfo(B_ANY_TYPE, i,(const char **) &name, &type, &count) == B_OK; i++) #else for (int32 i = 0; configMessage->GetInfo(B_ANY_TYPE, i,(char **) &name, &type, &count) == B_OK; i++) #endif { //calculate the Position where to add the next View float top = ItemTop(); BRect rect = BRect(MARGIN_SPACE,top,Bounds().right-MARGIN_SPACE,top); switch(type) { case B_STRING_TYPE: { char *string; configMessage->FindString(name,count-1,(const char **)&string); BTextControl *stringItem = new BTextControl(rect,name,name,string,NULL); AddChild(stringItem); BMessage *tmpMessage = new BMessage(B_CONTROL_INVOKED); tmpMessage->AddString("name",name); tmpMessage->AddInt32("count",count-1); tmpMessage->AddInt32("type",type); stringItem->SetMessage(tmpMessage); break; } case B_RECT_TYPE: { BRect valueRect; configMessage->FindRect(name,count-1,&valueRect); RectItem *rectItem = new RectItem(rect,name,valueRect); AddChild(rectItem); BMessage *tmpMessage = new BMessage(B_CONTROL_INVOKED); tmpMessage->AddString("name",name); tmpMessage->AddInt32("count",count-1); tmpMessage->AddInt32("type",type); rectItem->SetMessage(tmpMessage); break; } case B_FLOAT_TYPE: { float value; configMessage->FindFloat(name,count-1,&value); BString floatString; floatString<<value; BTextControl *stringItem = new BTextControl(rect,name,name,floatString.String(),NULL); AddChild(stringItem); BMessage *tmpMessage = new BMessage(B_CONTROL_INVOKED); tmpMessage->AddString("name",name); tmpMessage->AddInt32("count",count-1); tmpMessage->AddInt32("type",type); stringItem->SetMessage(tmpMessage); break; } case B_INT8_TYPE: case B_INT16_TYPE: case B_INT32_TYPE: { int32 value; configMessage->FindInt32(name,count-1,&value); BString intString; intString<<value; BTextControl *stringItem = new BTextControl(rect,name,name,intString.String(),NULL); AddChild(stringItem); BMessage *tmpMessage = new BMessage(B_CONTROL_INVOKED); tmpMessage->AddString("name",name); tmpMessage->AddInt32("count",count-1); tmpMessage->AddInt32("type",type); stringItem->SetMessage(tmpMessage); break; } case B_BOOL_TYPE: { bool value; configMessage->FindBool(name,count-1,&value); BCheckBox *boolItem = new BCheckBox(rect,name,name,NULL); AddChild(boolItem); boolItem->SetValue(value); BMessage *tmpMessage = new BMessage(B_CONTROL_INVOKED); tmpMessage->AddString("name",name); tmpMessage->AddInt32("count",count-1); tmpMessage->AddInt32("type",type); boolItem->SetMessage(tmpMessage); break; } } } }
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 ) { change->SetEnabled( false ); box->AddChild( change ); } bF.OffsetBy( bF.Width() + 5, 0 ); BButton* remove = new BButton( bF, "owq_remove", "Remove", new BMessage(OWQ_REMOVE), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM ); if( remove ) { remove->SetEnabled( false ); box->AddChild( remove ); } mOwqTable->SetButtons( add, change, remove ); } v->AddChild( box ); } return v; }
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) // .Add(fEnableForwardingPort, 0, 1, 3, 1) // ) .Add(limitsLabel) .Add(BGridLayoutBuilder(spacing / 2, spacing / 2) .SetInsets(spacing / 2, -1, -1, -1) .Add(fMaxConnectionLabel, 0, 0) .Add(fMaxConnection, 1, 0) .Add(fApplyMaxConnection, 2, 0) // padding //.Add(BSpaceLayoutItem::CreateGlue(), 3, 0) //.Add(BSpaceLayoutItem::CreateGlue(), 4, 0) // .Add(fTorrentMaxConnectionLabel, 0, 1) .Add(fTorrentMaxConnection, 1, 1) .Add(fApplyTorrentMaxConnection, 2, 1) // //.Add(fTorrentUploadSlotsLabel, 0, 2) //.Add(fTorrentUploadSlots, 1, 2) ) .Add(otherLabel) .Add(BGridLayoutBuilder(spacing / 2, spacing / 2) .SetInsets(spacing / 2, -1, -1, -1) .Add(fEnableDHTValue, 0, 0, 3, 1) .Add(fEnablePEXValue, 0, 1, 3, 1) .Add(fEnableUTPValue, 0, 2, 3, 1) .Add(fEnableLPDValue, 0, 3, 3, 1) // .Add(fEncryptionMenu->CreateLabelLayoutItem(), 0, 4) .Add(fEncryptionMenu->CreateMenuBarLayoutItem(), 1, 4) ) .SetInsets(spacing, spacing, spacing, spacing) .TopView() ; view->SetName("Connection"); return view; }
BView* PreferencesWindow::_CreateTorrentsPage(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); // // // //fAutoAddTorrentsFrom = new BCheckBox("auto_add_torrents_from", // B_TRANSLATE("Automatically add torrents from:"), // new BMessage(MSG_ADD_TORRENT_FROM_FOLDER_CHANGED)); //fAutoAddTorrentsFrom->SetValue(B_CONTROL_OFF); // // //fAutoAddTorrentsFromFolder = new FolderSelect("auto_add_torrents_from_folder", // NULL, "/test/path"/*new BMessage(MSG_DOWNLOAD_FOLDER_CHANGED)*/); // //fAutoAddTorrentsFromFolder->SetEnabled(false); BCheckBox* fShowOptionsDialog = new BCheckBox("Show options dialog", B_TRANSLATE("Show options dialog"), NULL /*new BMessage(MSG_AUTO_HIDE_INTERFACE_BEHAVIOR_CHANGED)*/); fShowOptionsDialog->SetValue(B_CONTROL_OFF); BCheckBox* fStartWhenAdded = new BCheckBox("start_when_added", B_TRANSLATE("Start when added"), new BMessage(MSG_START_WHEN_ADDED_BEHAVIOR_CHANGED)); fStartWhenAdded->SetValue(fTorrentPreferences->StartWhenAddedEnabled() ? B_CONTROL_ON : B_CONTROL_OFF); fIncompleteFileNaming = new BCheckBox("incomplete_file_naming", B_TRANSLATE("Append \".part\" to incomplete files' names"), new BMessage(MSG_INCOMPLETE_FILENAMING_BEHAVIOR_CHANGED)); fIncompleteFileNaming->SetValue(fTorrentPreferences->IncompleteFileNamingEnabled() ? B_CONTROL_ON : B_CONTROL_OFF); BStringView* fTorrentSaveLocation = new BStringView("", B_TRANSLATE("Save to Location:")); fTorrentSaveLocationPath = new FolderSelect("download_folder_select", fTorrentPreferences->DownloadFolder(), new BMessage(MSG_DOWNLOAD_FOLDER_BEHAVIOR_CHANGED)); fIncompleteDirEnabled = new BCheckBox("incomplete_torrent_folder", B_TRANSLATE("Incomplete torrents folder"), new BMessage(MSG_INCOMPLETE_FOLDER_BEHAVIOR_CHANGED)); fIncompleteDirEnabled->SetValue(fTorrentPreferences->IncompleteFolderEnabled() ? B_CONTROL_ON : B_CONTROL_OFF); fIncompleteDirPath = new FolderSelect("incomplete_torrent_folder_path", fTorrentPreferences->IncompleteFolder(), new BMessage(MSG_INCOMPLETE_FOLDER_PATH_BEHAVIOR_CHANGED)); fIncompleteDirPath->SetEnabled(fTorrentPreferences->IncompleteFolderEnabled()); // // // BView* view = BGroupLayoutBuilder(B_VERTICAL, spacing / 2) .Add(addingLabel) //.Add(BGridLayoutBuilder(spacing / 2, spacing / 2) // .Add(fAutoAddTorrentsFrom, 0, 0) // .Add(fAutoAddTorrentsFromFolder, 1, 0) //) .Add(BGridLayoutBuilder(spacing, spacing / 2) .SetInsets(spacing / 2, -1, -1, -1) .Add(fShowOptionsDialog, 0, 0) .Add(fStartWhenAdded, 0, 1) ) .Add(downloadingLabel) .Add(BGridLayoutBuilder(spacing, spacing / 2) .SetInsets(spacing / 2, -1, -1, -1) .Add(fIncompleteFileNaming, 0, 0, 2, 1) .Add(fTorrentSaveLocation, 0, 1) .Add(fTorrentSaveLocationPath, 1, 1) .Add(fIncompleteDirEnabled, 0, 2) .Add(fIncompleteDirPath, 1, 2) ) .Add(BSpaceLayoutItem::CreateHorizontalStrut(spacing)) .SetInsets(spacing, spacing, spacing, spacing) .TopView() ; view->SetName("Torrents"); return view; }
// -------------------------------------------------------------- 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); r.OffsetTo(0, 0); r.InsetBy(H_MARGIN, V_MARGIN); check = new BCheckBox(r, "dont_touch", DONT_TOUCH_LABEL, new BMessage(DONT_TOUCH_MSG), B_FOLLOW_TOP | B_FOLLOW_LEFT); check->GetPreferredSize(&w, &h); check->ResizeToPreferred(); check->SetValue(B_CONTROL_ON); check->MoveTo(H_MARGIN, r.top); bottom_box->AddChild(check); size = w; button = new BButton(r, "apply_now", APPLY_NOW_LABEL, new BMessage(APPLY_NOW_MSG), B_FOLLOW_TOP | B_FOLLOW_RIGHT); button->GetPreferredSize(&w, &h); button->ResizeToPreferred(); x = r.right - w; button->MoveTo(x, r.top); bottom_box->AddChild(button); fApplyNowButton = button; size += SMALL_MARGIN + w; button = new BButton(r, "revert", REVERT_LABEL, new BMessage(REVERT_MSG), B_FOLLOW_TOP | B_FOLLOW_RIGHT); button->GetPreferredSize(&w, &h); button->ResizeToPreferred(); button->MoveTo(x - w - SMALL_MARGIN, r.top); bottom_box->AddChild(button); fRevertButton = button; fRevertButton->SetEnabled(false); size += SMALL_MARGIN + w; min_size = max_c(min_size, (H_MARGIN + size + H_MARGIN)); r.bottom = r.top + h; r.InsetBy(-H_MARGIN, -V_MARGIN); bottom_box->ResizeTo(Bounds().Width(), r.Height()); // Resize window to enclose top and bottom boxes ResizeTo(Bounds().Width(), bottom_box->Frame().bottom); // Enable boxes resizing modes top_box->SetResizingMode(B_FOLLOW_ALL); fPanel->SetResizingMode(B_FOLLOW_ALL); bottom_box->SetResizingMode(B_FOLLOW_BOTTOM | B_FOLLOW_LEFT_RIGHT); // Set default/minimal window size ResizeTo(min_size, Bounds().Height()); SetSizeLimits(min_size, 20000, Bounds().Height(), 20000); fAddonView = NULL; }
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); }
//------------------------------------------------------------------------------ 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); i+= inc*2; msg->AddInt32("flags",B_NOT_ANCHORED_ON_ACTIVATE); box->AddChild(new BCheckBox(BRect(10,i,210,i+inc),"brcu","Bring Window To Current Workspace",msg)); msg = new BMessage(MSG_WINDOW_SET_FLAG); i+= inc*2; msg->AddInt32("flags",B_ASYNCHRONOUS_CONTROLS); box->AddChild(new BCheckBox(BRect(10,i,210,+inc),"async","Asynchronous Controls (Should Be On)",msg)); #endif #if 0 if (!(flags & B_NOT_MOVABLE)) ((BCheckBox *)(box->ChildAt(0)))->SetValue(B_CONTROL_ON); if (!(flags & B_NOT_CLOSABLE)) ((BCheckBox *)(box->ChildAt(1)))->SetValue(B_CONTROL_ON); if (!(flags & B_NOT_ZOOMABLE)) ((BCheckBox *)(box->ChildAt(2)))->SetValue(B_CONTROL_ON); if (!(flags & B_NOT_MINIMIZABLE)) ((BCheckBox *)(box->ChildAt(3)))->SetValue(B_CONTROL_ON); if (!(flags & B_NOT_H_RESIZABLE)) ((BCheckBox *)(box->ChildAt(4)))->SetValue(B_CONTROL_ON); if (!(flags & B_NOT_V_RESIZABLE)) ((BCheckBox *)(box->ChildAt(5)))->SetValue(B_CONTROL_ON); if (flags & B_OUTLINE_RESIZE) ((BCheckBox *)(box->ChildAt(7)))->SetValue(B_CONTROL_ON); if (flags & B_WILL_ACCEPT_FIRST_CLICK) ((BCheckBox *)(box->ChildAt(8)))->SetValue(B_CONTROL_ON); if (flags & B_AVOID_FRONT) ((BCheckBox *)(box->ChildAt(9)))->SetValue(B_CONTROL_ON); if (flags & B_AVOID_FOCUS) ((BCheckBox *)(box->ChildAt(10)))->SetValue(B_CONTROL_ON); if (flags & B_NO_WORKSPACE_ACTIVATION) ((BCheckBox *)(box->ChildAt(11)))->SetValue(B_CONTROL_ON); if (flags & B_NOT_ANCHORED_ON_ACTIVATE) ((BCheckBox *)(box->ChildAt(12)))->SetValue(B_CONTROL_ON); if (flags & B_ASYNCHRONOUS_CONTROLS) ((BCheckBox *)(box->ChildAt(13)))->SetValue(B_CONTROL_ON); #endif AddChild(box); cbox = (BCheckBox*)FindView("menus"); if (cbox) { cbox->SetValue(fWindowInfo.has_menu); cbox->SetMessage(new BMessage(MSG_WINDOW_ADD_MENU)); } }
void PrefsWindow::MessageReceived(BMessage* message) { switch(message->what) { case PrefsConstants::K_PREFS_VIEW_RESET_COLOUR_DEFAULTS: { ResetToDefaults(PrefsConstants::K_RESET_COLOUR_PREFS); } break; case PrefsConstants::K_PREFS_VIEW_RESET_COMMAND_DEFAULTS: { ResetToDefaults(PrefsConstants::K_RESET_COMMAND_PREFS); } break; case PrefsConstants::K_PREFS_VIEW_RESET_TOOLBAR_DEFAULTS: { ResetToDefaults(PrefsConstants::K_RESET_TOOLBAR_PREFS); } break; case PrefsConstants::K_PREFS_VIEW_RESET_GENERAL_DEFAULTS: { ResetToDefaults(PrefsConstants::K_RESET_GENERAL_PREFS); } break; case PrefsConstants::K_PREFS_UPDATE: { //update the preferences message, from view values BString prefsID; if (message->FindString(K_PREFS_ID, &prefsID) == B_OK) { BView *changedView = m_parent->FindView(prefsID.String()); prefsLock.Lock(); //different view have different kinds of values if (is_instance_of(changedView, BTextControl)) { //a textcontrol value was changed, update preferences with new text BTextControl *textControl = dynamic_cast<BTextControl*>(changedView); preferences.ReplaceString(prefsID.String(), textControl->Text()); } else if (is_instance_of(changedView, BCheckBox)) { //a checkbox value was changed, update preferences with new bool value(on/off) BCheckBox *checkBox = dynamic_cast<BCheckBox*>(changedView); preferences.ReplaceBool(prefsID.String(), checkBox->Value()); } else if (is_instance_of(changedView, BSlider)) { //a slider value was changed, update preferences with new slider value BSlider *slider = dynamic_cast<BSlider*>(changedView); preferences.ReplaceInt32(prefsID.String(), slider->Value()); } else if (is_instance_of(changedView, ColourButton)) { //a colourcontrol value was changed, update preferences with new colour ColourButton *colourControl = dynamic_cast<ColourButton*>(changedView); preferences.ReplaceData(prefsID.String(),B_RGB_COLOR_TYPE, &colourControl->Value(), sizeof(rgb_color)); } prefsLock.Unlock(); } } break; case PrefsConstants::K_LOAD_PREFERENCES: { //set preferences view values to values of the preferences message BString prefsID; if (message->FindString(K_PREFS_ID, &prefsID) == B_OK) { //find out which view value has to be updated BView *changedView = m_parent->FindView(prefsID.String()); prefsLock.Lock(); char *name; uint32 type; int32 count; for (int32 i = 0; preferences.GetInfo(B_ANY_TYPE, i, &name, &type, &count) == B_OK; i++) { //find out what kind of field we are using switch (type) { case B_INT32_TYPE: { int32 value; preferences.FindInt32(name, &value); if (is_instance_of(changedView, BSlider)) { BSlider *slider = dynamic_cast<BSlider*>(changedView); slider->SetValue(value); } } break; case B_BOOL_TYPE: { bool value; preferences.FindBool(name, &value); if (is_instance_of(changedView, BCheckBox)) { BCheckBox *checkBox = dynamic_cast<BCheckBox*>(changedView); checkBox->SetValue(value); } } break; case B_RGB_COLOR_TYPE: { rgb_color *colour; ssize_t size; preferences.FindData(name, B_RGB_COLOR_TYPE, (const void**)&colour, &size); if (is_instance_of(changedView, ColourButton)) { ColourButton *colourControl = dynamic_cast<ColourButton*>(changedView); colourControl->SetValue(*colour); } } break; case B_STRING_TYPE: { BString string; preferences.FindString(name, &string); if (is_instance_of(changedView, ColourButton)) { BTextControl *textControl = dynamic_cast<BTextControl*>(changedView); textControl->SetText(string.String()); } } break; } } prefsLock.Unlock(); //make sure the new view values are drawn! changedView->Invalidate(); } } break; default: BWindow::MessageReceived(message); break; } }
void PartitionsPage::_FillPartitionsView(BView* view) { // show | name | type | size | path int32 rowNumber = 0; BMessage message; for (int32 i = 0; fSettings->FindMessage("partition", i, &message) == B_OK; i++, rowNumber++) { // get partition data bool show; BString name; BString type; BString path; int64 size; message.FindBool("show", &show); message.FindString("name", &name); message.FindString("type", &type); message.FindString("path", &path); message.FindInt64("size", &size); // check box BCheckBox* checkBox = new BCheckBox("show", "", _CreateControlMessage(kMessageShow, i)); if (show) checkBox->SetValue(1); // name BTextControl* nameControl = new BTextControl("name", "", name.String(), _CreateControlMessage(kMessageName, i)); nameControl->SetExplicitMinSize(BSize(StringWidth("WWWWWWWWWWWWWW"), B_SIZE_UNSET)); // size BString sizeText; _CreateSizeText(size, &sizeText); sizeText << ", " << type.String(); BStringView* typeView = new BStringView("type", sizeText.String()); typeView->SetExplicitAlignment( BAlignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_UNSET)); // path BStringView* pathView = new BStringView("path", path.String()); pathView->SetExplicitAlignment( BAlignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_UNSET)); if (rowNumber > 0) { BLayoutBuilder::Grid<>((BGridLayout*)view->GetLayout()) .Add(new BSeparatorView(B_HORIZONTAL), 0, rowNumber, 4, 1) .SetRowWeight(rowNumber, 0); rowNumber++; } BLayoutBuilder::Grid<>((BGridLayout*)view->GetLayout()) .Add(checkBox, 0, rowNumber, 1, 2) .Add(nameControl, 1, rowNumber, 1, 2) .Add(BSpaceLayoutItem::CreateHorizontalStrut(10), 2, rowNumber) .Add(typeView, 3, rowNumber) .Add(pathView, 3, rowNumber + 1) .SetRowWeight(rowNumber + 1, 1); rowNumber++; } }
/*! * \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 ); /* 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; }
BView *PrefsWindow::create_graphics_pane(void) { BView *pane = new BView(BRect(0, 0, top_frame.right-20, top_frame.bottom-80), GetString(STR_GRAPHICS_SOUND_PANE_TITLE), B_FOLLOW_NONE, B_WILL_DRAW); pane->SetViewColor(fill_color); float right = pane->Bounds().right-10; const char *mode_str = PrefsFindString("screen"); int width = 512, height = 384; scr_mode_bit = 0; display_type = DISPLAY_WINDOW; if (mode_str) { if (sscanf(mode_str, "win/%d/%d", &width, &height) == 2) display_type = DISPLAY_WINDOW; else if (sscanf(mode_str, "scr/%d", &scr_mode_bit) == 1) display_type = DISPLAY_SCREEN; } BMenuField *menu_field; BMenuItem *item; BPopUpMenu *menu; menu = new BPopUpMenu(""); menu_field = new BMenuField(BRect(10, 5, right, 20), "videotype", GetString(STR_VIDEO_TYPE_CTRL), menu); menu_field->SetDivider(120); menu->AddItem(item = new BMenuItem(GetString(STR_WINDOW_LAB), new BMessage(MSG_VIDEO_WINDOW))); if (display_type == DISPLAY_WINDOW) item->SetMarked(true); menu->AddItem(item = new BMenuItem(GetString(STR_FULLSCREEN_LAB), new BMessage(MSG_VIDEO_SCREEN))); if (display_type == DISPLAY_SCREEN) item->SetMarked(true); pane->AddChild(menu_field); menu = new BPopUpMenu(""); frameskip_menu = new BMenuField(BRect(10, 26, right, 41), "frameskip", GetString(STR_FRAMESKIP_CTRL), menu); frameskip_menu->SetDivider(120); menu->AddItem(new BMenuItem(GetString(STR_REF_5HZ_LAB), new BMessage(MSG_REF_5HZ))); menu->AddItem(new BMenuItem(GetString(STR_REF_7_5HZ_LAB), new BMessage(MSG_REF_7_5HZ))); menu->AddItem(new BMenuItem(GetString(STR_REF_10HZ_LAB), new BMessage(MSG_REF_10HZ))); menu->AddItem(new BMenuItem(GetString(STR_REF_15HZ_LAB), new BMessage(MSG_REF_15HZ))); menu->AddItem(new BMenuItem(GetString(STR_REF_30HZ_LAB), new BMessage(MSG_REF_30HZ))); pane->AddChild(frameskip_menu); int32 i32 = PrefsFindInt32("frameskip"); if (i32 == 12) { if ((item = menu->FindItem(GetString(STR_REF_5HZ_LAB))) != NULL) item->SetMarked(true); } else if (i32 == 8) { if ((item = menu->FindItem(GetString(STR_REF_7_5HZ_LAB))) != NULL) item->SetMarked(true); } else if (i32 == 6) { if ((item = menu->FindItem(GetString(STR_REF_10HZ_LAB))) != NULL) item->SetMarked(true); } else if (i32 == 4) { if ((item = menu->FindItem(GetString(STR_REF_15HZ_LAB))) != NULL) item->SetMarked(true); } else if (i32 == 2) { if ((item = menu->FindItem(GetString(STR_REF_30HZ_LAB))) != NULL) item->SetMarked(true); } display_x_ctrl = new NumberControl(BRect(10, 48, right / 2, 66), 118, "width", GetString(STR_DISPLAY_X_CTRL), width, NULL); pane->AddChild(display_x_ctrl); display_y_ctrl = new NumberControl(BRect(10, 69, right / 2, 87), 118, "height", GetString(STR_DISPLAY_Y_CTRL), height, NULL); pane->AddChild(display_y_ctrl); menu = new BPopUpMenu(""); scr_mode_menu = new BMenuField(BRect(10, 26, right, 41), "screenmode", GetString(STR_SCREEN_MODE_CTRL), menu); scr_mode_menu->SetDivider(120); for (int i=0; scr_mode[i].mode_mask; i++) { menu->AddItem(item = new BMenuItem(GetString(scr_mode[i].str), new BMessage(MSG_SCREEN_MODE + i))); if (scr_mode[i].mode_mask & (1 << scr_mode_bit)) item->SetMarked(true); } pane->AddChild(scr_mode_menu); nosound_checkbox = new BCheckBox(BRect(10, 90, right, 105), "nosound", GetString(STR_NOSOUND_CTRL), new BMessage(MSG_NOSOUND)); pane->AddChild(nosound_checkbox); nosound_checkbox->SetValue(PrefsFindBool("nosound") ? B_CONTROL_ON : B_CONTROL_OFF); hide_show_graphics_ctrls(); return pane; }
void AGMSBayesianSpamFilterConfig::AttachedToWindow () { char numberString [30]; BRect tempRect; char *tempStringPntr; SetViewColor (ui_color (B_PANEL_BACKGROUND_COLOR)); // Make the checkbox for choosing whether the spam is marked by a // modification to the subject of the mail message. tempRect = Bounds (); fAddSpamToSubjectCheckBoxPntr = new BCheckBox ( tempRect, "AddToSubject", "Add spam rating to start of subject", new BMessage (kAddSpamToSubjectPressed)); AddChild (fAddSpamToSubjectCheckBoxPntr); fAddSpamToSubjectCheckBoxPntr->ResizeToPreferred (); fAddSpamToSubjectCheckBoxPntr->SetValue (fAddSpamToSubject); fAddSpamToSubjectCheckBoxPntr->SetTarget (this); tempRect = Bounds (); tempRect.top = fAddSpamToSubjectCheckBoxPntr->Frame().bottom + 1; tempRect.bottom = tempRect.top + 20; // Add the checkbox on the right for the no words means spam option. fNoWordsMeansSpamCheckBoxPntr = new BCheckBox ( tempRect, "NoWordsMeansSpam", "or empty e-mail", new BMessage (kNoWordsMeansSpam)); AddChild (fNoWordsMeansSpamCheckBoxPntr); fNoWordsMeansSpamCheckBoxPntr->ResizeToPreferred (); fNoWordsMeansSpamCheckBoxPntr->MoveBy ( floorf (tempRect.right - fNoWordsMeansSpamCheckBoxPntr->Frame().right), 0.0); fNoWordsMeansSpamCheckBoxPntr->SetValue (fNoWordsMeansSpam); fNoWordsMeansSpamCheckBoxPntr->SetTarget (this); // Add the box displaying the spam cutoff ratio to the left, in the space // remaining between the left edge and the no words checkbox. tempRect.right = fNoWordsMeansSpamCheckBoxPntr->Frame().left - be_plain_font->StringWidth ("a"); tempStringPntr = "Spam above:"; sprintf (numberString, "%06.4f", (double) fSpamCutoffRatio); fSpamCutoffRatioTextBoxPntr = new BTextControl ( tempRect, "spamcutoffratio", tempStringPntr, numberString, NULL /* BMessage */); AddChild (fSpamCutoffRatioTextBoxPntr); fSpamCutoffRatioTextBoxPntr->SetDivider ( be_plain_font->StringWidth (tempStringPntr) + 1 * be_plain_font->StringWidth ("a")); tempRect = Bounds (); tempRect.top = fSpamCutoffRatioTextBoxPntr->Frame().bottom + 1; tempRect.bottom = tempRect.top + 20; // Add the box displaying the genuine cutoff ratio, on a line by itself. tempStringPntr = "Genuine below and uncertain above:"; sprintf (numberString, "%08.6f", (double) fGenuineCutoffRatio); fGenuineCutoffRatioTextBoxPntr = new BTextControl ( tempRect, "genuinecutoffratio", tempStringPntr, numberString, NULL /* BMessage */); AddChild (fGenuineCutoffRatioTextBoxPntr); fGenuineCutoffRatioTextBoxPntr->SetDivider ( be_plain_font->StringWidth (tempStringPntr) + 1 * be_plain_font->StringWidth ("a")); tempRect = Bounds (); tempRect.top = fGenuineCutoffRatioTextBoxPntr->Frame().bottom + 1; tempRect.bottom = tempRect.top + 20; // Checkbox for automatically training on incoming mail. fAutoTrainingCheckBoxPntr = new BCheckBox ( tempRect, "autoTraining", "Learn from all incoming e-mail", new BMessage (kAutoTrainingPressed)); AddChild (fAutoTrainingCheckBoxPntr); fAutoTrainingCheckBoxPntr->ResizeToPreferred (); fAutoTrainingCheckBoxPntr->SetValue (fAutoTraining); fAutoTrainingCheckBoxPntr->SetTarget (this); tempRect = Bounds (); tempRect.top = fAutoTrainingCheckBoxPntr->Frame().bottom + 1; tempRect.bottom = tempRect.top + 20; // Button for editing the server settings. /* fServerSettingsButtonPntr = new BButton ( tempRect, "serverSettings", "Advanced Server Settings…", new BMessage (kServerSettingsPressed)); AddChild (fServerSettingsButtonPntr); fServerSettingsButtonPntr->ResizeToPreferred (); fServerSettingsButtonPntr->SetTarget (this); tempRect = Bounds (); tempRect.top = fServerSettingsButtonPntr->Frame().bottom + 1; tempRect.bottom = tempRect.top + 20; // Checkbox for closing the server when done. fQuitServerWhenFinishedCheckBoxPntr = new BCheckBox ( tempRect, "quitWhenFinished", "Close spam scanner when finished.", new BMessage (kQuitWhenFinishedPressed)); AddChild (fQuitServerWhenFinishedCheckBoxPntr); fQuitServerWhenFinishedCheckBoxPntr->ResizeToPreferred (); fQuitServerWhenFinishedCheckBoxPntr->SetValue (fQuitServerWhenFinished); fQuitServerWhenFinishedCheckBoxPntr->SetTarget (this); tempRect = Bounds (); tempRect.top = fQuitServerWhenFinishedCheckBoxPntr->Frame().bottom + 1; tempRect.bottom = tempRect.top + 20; */ }
BView* PrefsWindow::constructToolbarBox(BRect frame) { BBox* toolbarBox = new BBox(frame); toolbarBox->SetLabel("Toolbars"); float vertCbSpacing = 25.0f, offset = 30.0f, adjust = 5.0f, bwidth = 80.0f, bheight = 30.0f, bspacing = 10.0f ; BRect checkboxRect = BRect((offset * 2.0f / 3.0f), offset - adjust,(offset * 2.0f/ 3.0f) + 150.0f, offset - adjust + vertCbSpacing - 5.0f); BCheckBox *tbInvertCheck = new BCheckBox(checkboxRect, K_IS_TEXTBAR_INVERTED,"Invert Toolbar Colours", GetPrefsMessage(K_IS_TEXTBAR_INVERTED)); bool isTexBarInverted = false; tbInvertCheck->SetValue(isTexBarInverted); toolbarBox->AddChild(tbInvertCheck); checkboxRect.OffsetBy(0, vertCbSpacing); BCheckBox *tbGreekHiddenCheck = new BCheckBox(checkboxRect, K_IS_GREEK_HIDDEN,"Greek Letters", GetPrefsMessage(K_IS_GREEK_HIDDEN)); bool isGreekHidden = false; tbGreekHiddenCheck->SetValue(isGreekHidden); toolbarBox->AddChild(tbGreekHiddenCheck); checkboxRect.OffsetBy(0, vertCbSpacing); BCheckBox *tbBigHiddenCheck = new BCheckBox(checkboxRect, K_IS_BIG_HIDDEN,"Big Operators", GetPrefsMessage(K_IS_BIG_HIDDEN)); bool isBigHidden = false; tbBigHiddenCheck->SetValue(isBigHidden); toolbarBox->AddChild(tbBigHiddenCheck); checkboxRect.OffsetBy(0, vertCbSpacing); BCheckBox *tbBinaryHiddenCheck = new BCheckBox(checkboxRect, K_IS_BINARY_HIDDEN,"Binary Operators", GetPrefsMessage(K_IS_BINARY_HIDDEN)); bool isBinaryHidden = false; tbBinaryHiddenCheck->SetValue(isBinaryHidden); toolbarBox->AddChild(tbBinaryHiddenCheck); checkboxRect.OffsetBy(0, vertCbSpacing); BCheckBox *tbMiscHiddenCheck = new BCheckBox(checkboxRect, K_IS_MISC_HIDDEN,"Misc Symbols", GetPrefsMessage(K_IS_MISC_HIDDEN)); bool isMiscHidden = false; tbMiscHiddenCheck->SetValue(isMiscHidden); toolbarBox->AddChild(tbMiscHiddenCheck); checkboxRect.OffsetBy(0, vertCbSpacing); BCheckBox *tbBinRelHiddenCheck = new BCheckBox(checkboxRect, K_IS_BIN_REL_HIDDEN,"Binary Relations", GetPrefsMessage(K_IS_BIN_REL_HIDDEN)); bool isBinHidden = false; tbBinRelHiddenCheck->SetValue(isBinHidden); toolbarBox->AddChild(tbBinRelHiddenCheck); checkboxRect.OffsetBy(0, vertCbSpacing); BCheckBox *tbMMAHiddenCheck = new BCheckBox(checkboxRect, K_IS_MMA_HIDDEN,"Math Mode Accents", GetPrefsMessage(K_IS_MMA_HIDDEN)); bool isMMAHidden = false; tbMMAHiddenCheck->SetValue(isMMAHidden); toolbarBox->AddChild(tbMMAHiddenCheck); checkboxRect.OffsetBy(0, vertCbSpacing); BCheckBox *tbIntlHiddenCheck = new BCheckBox(checkboxRect, K_IS_INT_HIDDEN,"International", GetPrefsMessage(K_IS_INT_HIDDEN)); bool isIntlHidden = false; tbIntlHiddenCheck->SetValue(isIntlHidden); toolbarBox->AddChild(tbIntlHiddenCheck); checkboxRect.OffsetBy(0, vertCbSpacing); BCheckBox *tbTypeFaceHiddenCheck = new BCheckBox(checkboxRect, K_IS_TYPE_FACE_HIDDEN,"Type Faces", GetPrefsMessage(K_IS_TYPE_FACE_HIDDEN)); bool isTypeFaceHidden = false; tbTypeFaceHiddenCheck->SetValue(isTypeFaceHidden); toolbarBox->AddChild(tbTypeFaceHiddenCheck); checkboxRect.OffsetBy(0, vertCbSpacing); BCheckBox *tbFunctionHiddenCheck = new BCheckBox(checkboxRect, K_IS_FUNCTION_HIDDEN,"Functions", GetPrefsMessage(K_IS_FUNCTION_HIDDEN)); bool isFunctionHidden = false; tbFunctionHiddenCheck->SetValue(isFunctionHidden); toolbarBox->AddChild(tbFunctionHiddenCheck); checkboxRect.OffsetBy(0, vertCbSpacing); BRect toolbarRect = toolbarBox->Bounds(); BRect toolbarbtnRect(toolbarRect.right-bspacing-bwidth,toolbarRect.bottom-bspacing-bheight,toolbarRect.right-bspacing,toolbarRect.bottom-bspacing); BButton *resetToolbarDefaults = new BButton(toolbarbtnRect,"resetToolbarDefaults","Defaults", new BMessage(PrefsConstants::K_PREFS_VIEW_RESET_TOOLBAR_DEFAULTS)); toolbarBox->AddChild(resetToolbarDefaults); return toolbarBox; }