prefview.cpp
字号:
rect1.top = rect1.bottom + GRID_UNIT;
box = new BBox( rect1, "ToolbarAppearance",
B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP );
box->SetLabel( "Show 'My Music' Toolbars As" );
BRadioButton* radioButton;
rect1 = box->Bounds();
rect1.InsetBy( GRID_UNIT, GRID_UNIT );
radioButton = new BRadioButton( rect1, "TextOnly", "Text Only",
new BMessage( MSG_SET_TEXT_ONLY ) );
radioButton->ResizeToPreferred();
box->AddChild( radioButton );
radioButton->SetValue( m_originalValues.useTextLabels ? B_CONTROL_ON
: B_CONTROL_OFF );
m_controls.push_back( radioButton );
radioButton->GetPreferredSize( &w, &h );
rect1.left += w + GRID_UNIT;
radioButton = new BRadioButton( rect1, "ImagesOnly", "Images Only",
new BMessage( MSG_SET_IMAGES_ONLY ) );
radioButton->ResizeToPreferred();
box->AddChild( radioButton );
radioButton->SetValue( m_originalValues.useImages ? B_CONTROL_ON
: B_CONTROL_OFF );
m_controls.push_back( radioButton );
radioButton->GetPreferredSize( &w, &h );
rect1.left += w + GRID_UNIT;
radioButton = new BRadioButton( rect1, "TextAndImages", "Text and Images",
new BMessage( MSG_SET_TEXT_AND_IMAGES ) );
radioButton->ResizeToPreferred();
box->AddChild( radioButton );
radioButton->SetValue( ( m_originalValues.useTextLabels &&
m_originalValues.useImages )
? B_CONTROL_ON : B_CONTROL_OFF );
m_controls.push_back( radioButton );
box->ResizeTo( box->Frame().Width(), GRID_UNIT * 2 +h );
m_general->AddChild( box );
rect1 = box->Frame();
// -------------- Miscellaneous box group -------------------------------
rect1.top = rect1.bottom + GRID_UNIT;
box = new BBox( rect1, "Miscellaneous",
B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP );
box->SetLabel( "Miscellaneous" );
// Save current playlist on exit
rect1 = box->Bounds();
rect1.InsetBy( GRID_UNIT, GRID_UNIT );
checkBox = new BCheckBox( rect1, "SaveCurrentPlaylistOnExit",
"Save current playlist when exiting "
"the application",
new BMessage( MSG_SET_SAVE_PLAYLIST_ON_EXIT ),
B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP );
checkBox->SetValue( m_originalValues.savePlaylistOnExit ? B_CONTROL_ON
: B_CONTROL_OFF );
box->AddChild( checkBox );
m_controls.push_back( checkBox );
rect1 = checkBox->Frame();
// Play immediately, or queue?
rect1.top = rect1.bottom + GRID_UNIT;
checkBox = new BCheckBox( rect1, "PlayImmediately",
"By default queue tracks rather than play "
"them immediately",
new BMessage( MSG_SET_PLAY_IMMEDIATELY ),
B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP );
checkBox->SetValue( m_originalValues.playImmediately ? B_CONTROL_ON
: B_CONTROL_OFF );
box->AddChild( checkBox );
m_controls.push_back( checkBox );
rect1 = checkBox->Frame();
box->ResizeTo( box->Frame().Width(), rect1.bottom + GRID_UNIT );
m_general->AddChild( box );
}
void
PrefView::CreateThemesPane( void )
{
string current;
map<string, string>::iterator i;
int32 index;
m_themeMan->GetCurrentTheme( current );
PRINT(( "current theme %s\n", current.c_str() ));
m_themeMan->GetThemeList( m_themeList );
for ( i = m_themeList.begin(); i != m_themeList.end(); i++ )
{
PRINT(( "\"%s\"->\"%s\"\n", (*i).first.c_str(), (*i).second.c_str() ));
}
BRect rect( m_themes->Bounds() );
rect.InsetBy( GRID_UNIT, GRID_UNIT );
rect.right -= B_V_SCROLL_BAR_WIDTH;
BListView* themeListView = new BListView( rect, "ThemeList",
B_SINGLE_SELECTION_LIST,
B_FOLLOW_ALL );
themeListView->SetSelectionMessage( new BMessage( MSG_THEME_SELECTED ) );
themeListView->SetInvocationMessage( new BMessage( MSG_THEME_SELECTED ) );
index = 0;
for ( i = m_themeList.begin(); i != m_themeList.end(); i++, index++ )
{
themeListView->AddItem( new BStringItem( (*i).first.c_str() ) );
PRINT(( "adding %s, current theme %s\n", (*i).first.c_str(), current.c_str() ));
if ( (*i).first == current )
{
themeListView->Select( index );
}
}
m_themes->AddChild( new BScrollView( "Scroll", themeListView,
B_FOLLOW_ALL, 0, false, true ) );
}
// ----------------------------------------------------
// Advanced settings, decoder prio, etc.
// ----------------------------------------------------
void
PrefView::CreateAdvancedPane( void )
{
BRect rect( m_advanced->Bounds() );
BBox* box;
float w, h;
// --------------------- Decoder box ---------------------------------
rect.InsetBy( GRID_UNIT, GRID_UNIT );
box = new BBox( rect, "DecoderThreadPriority",
B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP );
box->SetLabel( "Decoder" );
rect = box->Bounds();
rect.InsetBy( BOX_INSET, BOX_INSET );
// Decoder thread priority.
BSlider* slider = new BSlider( rect, "DecoderPriority",
"Decoder Thread Priority",
new BMessage( MSG_SET_DECODER_PRIORITY ),
2, 30, B_BLOCK_THUMB,
B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP );
slider->SetLimitLabels( "Low", "High" );
slider->ResizeToPreferred();
slider->SetValue( m_originalValues.decoderThreadPriority );
box->AddChild( slider );
m_controls.push_back( slider );
rect = slider->Frame();
box->ResizeTo( box->Frame().Width(), rect.bottom + GRID_UNIT );
rect = box->Frame();
m_advanced->AddChild( box );
// ------------------- Buffer Size box ---------------------------
rect.top = rect.bottom + GRID_UNIT;
box = new BBox( rect, "BufferSizeBox", B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP );
box->SetLabel( "Buffer Sizes" );
rect = box->Bounds();
rect.InsetBy( BOX_INSET, BOX_INSET );
// Input Buffer Size
BTextControl* textCtrl;
char buf[256];
textCtrl = new BTextControl( rect, "InputBufferSize",
"Input Buffer Size (Kilobytes)",
"",
new BMessage( MSG_SET_INPUT_BUFFER_SIZE ),
B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP );
textCtrl->SetModificationMessage(
new BMessage( MSG_SET_INPUT_BUFFER_SIZE ) );
sprintf( buf, "%ld", m_originalValues.inputBufferSize );
textCtrl->SetText( buf );
textCtrl->GetPreferredSize( &w, &h );
box->AddChild( textCtrl );
m_controls.push_back( textCtrl );
rect = textCtrl->Frame();
// Output Buffer Size
rect.top = rect.bottom + GRID_UNIT;
textCtrl = new BTextControl( rect, "OutputBufferSize",
"Output Buffer Size (Kilobytes)",
"",
new BMessage( MSG_SET_OUTPUT_BUFFER_SIZE ),
B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP );
textCtrl->SetModificationMessage(
new BMessage( MSG_SET_OUTPUT_BUFFER_SIZE ) );
sprintf( buf, "%ld", m_originalValues.outputBufferSize );
textCtrl->SetText( buf );
textCtrl->GetPreferredSize( &w, &h );
box->AddChild( textCtrl );
m_controls.push_back( textCtrl );
rect = textCtrl->Frame();
// Pre-buffer Length
rect.top = rect.bottom + GRID_UNIT;
textCtrl = new BTextControl( rect, "PreBufferLength",
"Pre-buffer Length (Seconds)",
"",
new BMessage( MSG_SET_PRE_BUFFER_LENGTH ),
B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP );
textCtrl->SetModificationMessage(
new BMessage( MSG_SET_PRE_BUFFER_LENGTH ) );
sprintf( buf, "%ld", m_originalValues.preBufferLength );
textCtrl->SetText( buf );
textCtrl->GetPreferredSize( &w, &h );
box->AddChild( textCtrl );
m_controls.push_back( textCtrl );
rect = textCtrl->Frame();
box->ResizeTo( box->Frame().Width(), rect.bottom + BOX_INSET );
m_advanced->AddChild( box );
rect = box->Frame();
}
// ----------------------------------------------------
// About pane
// ----------------------------------------------------
void
PrefView::CreateAboutPane( void )
{
BRect r = m_about->Bounds();
r.InsetBy( 10, 10 );
BRect textRect = r;
textRect.OffsetTo( B_ORIGIN );
BTextView* textView = new BTextView( r, "AboutText", textRect,
B_FOLLOW_NONE, B_WILL_DRAW );
textView->MakeSelectable( false );
textView->MakeEditable( false );
textView->SetText( FREEAMP_ABOUT_TEXT );
m_about->AddChild( textView );
}
// ----------------------------------------------------
// methods for setting pref values
// ----------------------------------------------------
void
PrefView::SetSaveMusicDirectory( const char* path )
{
m_proposedValues.saveMusicDirectory = string( path );
m_saveMusicFolder->SetText( path );
}
void
PrefView::SetCheckForUpdates( bool flag )
{
m_proposedValues.checkForUpdates = flag;
}
void
PrefView::SetDecoderThreadPriority( int32 prio )
{
m_proposedValues.decoderThreadPriority = prio;
}
// ---------------------------------------------------
// PrefTabView
// ---------------------------------------------------
PrefTabView::PrefTabView( BRect r, const char* name )
: BTabView( r, name )
{
}
PrefTabView::~PrefTabView()
{
}
void
PrefTabView::Select( int32 tab )
{
BTabView::Select( tab );
BView* pane = TabAt( tab )->View();
pane->ResizeTo( Bounds().Width()-10.0, Bounds().Height()-10.0-TabHeight() );
pane->Invalidate();
}
PrefPane::PrefPane( BRect r, const char* name )
: BView( r, name, B_FOLLOW_ALL, B_WILL_DRAW )
{
}
PrefPane::~PrefPane()
{
}
void
PrefPane::AttachedToWindow( void )
{
SetViewColor( Parent()->ViewColor() );
BView::AttachedToWindow();
}
// vi: set ts=4:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -