LoadLayoutArchiveWindow(BRect frame) : BWindow(frame, "Layout Loaded From Archive", B_TITLED_WINDOW, B_QUIT_ON_WINDOW_CLOSE | B_AUTO_UPDATE_SIZE_LIMITS) { fLayout = new BALMLayout(10, 10); BALM::BALMLayoutBuilder builder(this, fLayout); // Restore gui specifications. BFile guiFile; _FindGUISpecifications(kGUIFileName, guiFile); LayoutArchive layoutArchive(fLayout); if (layoutArchive.RestoreFromFile(&guiFile) != B_OK) { BString text = "Can't find layout specification file: \""; text << kGUIFileName; text << "\""; BAlert* alert = new BAlert("Layout Specifications Not Found", text, "Quit"); alert->Go(); PostMessage(B_QUIT_REQUESTED); } // Access the views in the layout. BButton* button = layoutArchive.FindView<BButton>("ButtonTest"); if (button != NULL) button->SetLabel("Hey"); BRadioButton* radioButton = layoutArchive.FindView<BRadioButton>("RadioButtonTest"); if (radioButton != NULL) radioButton->SetLabel("World"); }
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; }
void SeqPrefWin::SetOpenNewFromFileRef(const entry_ref* ref) { SetRefPref(OPEN_NEW_SONG_FILE_PREF, ref); BRadioButton* button = dynamic_cast<BRadioButton*>( FindView(OPEN_FILE_STR) ); if( button ) button->SetLabel( label_for_open_new_from_file(ref).String() ); }