mirror of
https://github.com/cookiengineer/audacity
synced 2025-09-19 17:40:51 +02:00
Rename, privatize, combine ShuttleGui members related to radios
This commit is contained in:
parent
89f3369556
commit
c5e21ead18
@ -140,7 +140,7 @@ void ShuttleGuiBase::Init()
|
||||
mpWind = NULL;
|
||||
mpSubSizer = NULL;
|
||||
|
||||
mSettingName = wxT("");
|
||||
mRadioSettingName = wxT("");
|
||||
mRadioCount = -1;
|
||||
|
||||
miBorder = 5;
|
||||
@ -483,33 +483,32 @@ wxComboBox * ShuttleGuiBase::AddCombo( const wxString &Prompt, const wxString &S
|
||||
}
|
||||
|
||||
|
||||
wxRadioButton * ShuttleGuiBase::AddRadioButton(const wxString &Prompt)
|
||||
wxRadioButton * ShuttleGuiBase::DoAddRadioButton(
|
||||
const wxString &Prompt, int style)
|
||||
{
|
||||
/// \todo This function and the next one, suitably adapted, could be
|
||||
/// \todo This function and the next two, suitably adapted, could be
|
||||
/// used by TieRadioButton.
|
||||
UseUpId();
|
||||
if( mShuttleMode != eIsCreating )
|
||||
return wxDynamicCast(wxWindow::FindWindowById( miId, mpDlg), wxRadioButton);
|
||||
wxRadioButton * pRad;
|
||||
mpWind = pRad = safenew wxRadioButton(GetParent(), miId, Prompt,
|
||||
wxDefaultPosition, wxDefaultSize, Style( wxRB_GROUP ) );
|
||||
wxDefaultPosition, wxDefaultSize, Style( style ) );
|
||||
mpWind->SetName(wxStripMenuCodes(Prompt));
|
||||
pRad->SetValue(true );
|
||||
if ( style )
|
||||
pRad->SetValue( true );
|
||||
UpdateSizers();
|
||||
return pRad;
|
||||
}
|
||||
|
||||
wxRadioButton * ShuttleGuiBase::AddRadioButton(const wxString &Prompt)
|
||||
{
|
||||
return DoAddRadioButton( Prompt, wxRB_GROUP );
|
||||
}
|
||||
|
||||
wxRadioButton * ShuttleGuiBase::AddRadioButtonToGroup(const wxString &Prompt)
|
||||
{
|
||||
UseUpId();
|
||||
if( mShuttleMode != eIsCreating )
|
||||
return wxDynamicCast(wxWindow::FindWindowById( miId, mpDlg), wxRadioButton);
|
||||
wxRadioButton * pRad;
|
||||
mpWind = pRad = safenew wxRadioButton(GetParent(), miId, Prompt,
|
||||
wxDefaultPosition, wxDefaultSize, Style( 0 ) );
|
||||
mpWind->SetName(wxStripMenuCodes(Prompt));
|
||||
UpdateSizers();
|
||||
return pRad;
|
||||
return DoAddRadioButton( Prompt, 0 );
|
||||
}
|
||||
|
||||
#ifdef __WXMAC__
|
||||
@ -1449,8 +1448,16 @@ wxChoice * ShuttleGuiBase::TieChoice(
|
||||
return pChoice;
|
||||
}
|
||||
|
||||
wxRadioButton * ShuttleGuiBase::TieRadioButton(const wxString &Prompt, WrappedType & WrappedRef)
|
||||
/// This function must be within a StartRadioButtonGroup - EndRadioButtonGroup pair.
|
||||
wxRadioButton * ShuttleGuiBase::TieRadioButton(
|
||||
const wxString &Prompt,
|
||||
const wxString &Value)
|
||||
{
|
||||
// In what follows, WrappedRef is used in read only mode, but we
|
||||
// don't have a 'read-only' version, so we copy to deal with the constness.
|
||||
wxString Temp = Value;
|
||||
WrappedType WrappedRef( Temp );
|
||||
|
||||
wxASSERT( mRadioCount >= 0); // Did you remember to use StartRadioButtonGroup() ?
|
||||
mRadioCount++;
|
||||
UseUpId();
|
||||
@ -1493,12 +1500,14 @@ wxRadioButton * ShuttleGuiBase::TieRadioButton(const wxString &Prompt, WrappedTy
|
||||
}
|
||||
|
||||
/// Call this before any TieRadioButton calls.
|
||||
/// This is the generic version and requires mRadioValue already initialised.
|
||||
/// Versions for specific types must do that initialisation.
|
||||
void ShuttleGuiBase::StartRadioButtonGroup( const wxString & SettingName )
|
||||
void ShuttleGuiBase::StartRadioButtonGroup( const wxString & SettingName, const wxString & DefaultValue )
|
||||
{
|
||||
wxASSERT( mRadioValue && mRadioValue->eWrappedType != eWrappedNotSet );
|
||||
mSettingName = SettingName;
|
||||
// Configure the generic type mechanism to use OUR string.
|
||||
mRadioValueString = DefaultValue;
|
||||
mRadioValue.create( mRadioValueString );
|
||||
|
||||
// Now actually start the radio button group.
|
||||
mRadioSettingName = SettingName;
|
||||
mRadioCount = 0;
|
||||
if( mShuttleMode == eIsCreating )
|
||||
DoDataShuttle( SettingName, *mRadioValue );
|
||||
@ -1509,8 +1518,9 @@ void ShuttleGuiBase::StartRadioButtonGroup( const wxString & SettingName )
|
||||
void ShuttleGuiBase::EndRadioButtonGroup()
|
||||
{
|
||||
if( mShuttleMode == eIsGettingFromDialog )
|
||||
DoDataShuttle( mSettingName, *mRadioValue );
|
||||
DoDataShuttle( mRadioSettingName, *mRadioValue );
|
||||
mRadioValue.reset();// Clear it out...
|
||||
mRadioSettingName = wxT("");
|
||||
mRadioCount = -1; // So we detect a problem.
|
||||
}
|
||||
|
||||
@ -1963,30 +1973,6 @@ wxChoice * ShuttleGuiBase::TieNumberAsChoice(
|
||||
Prompt, SettingName, Default, Choices, InternalChoices );
|
||||
}
|
||||
|
||||
/// String specific version of StartRadioButtonGroup.
|
||||
/// All 'TieRadioButton()' enclosed must be strings.
|
||||
void ShuttleGuiBase::StartRadioButtonGroup( const wxString & SettingName, const wxString & DefaultValue )
|
||||
{
|
||||
// Configure the generic type mechanism to use OUR string.
|
||||
mRadioValueString = DefaultValue;
|
||||
mRadioValue.create( mRadioValueString );
|
||||
// Now actually start the radio button group.
|
||||
StartRadioButtonGroup( SettingName );
|
||||
}
|
||||
|
||||
|
||||
/// This function must be within a StartRadioButtonGroup - EndRadioButtonGroup pair.
|
||||
wxRadioButton * ShuttleGuiBase::TieRadioButton(
|
||||
const wxString &Prompt,
|
||||
const wxString &Value)
|
||||
{
|
||||
// In what follows, WrappedRef is used in read only mode, but we
|
||||
// don't have a 'read-only' version, so we copy to deal with the constness.
|
||||
wxString Temp = Value;
|
||||
WrappedType WrappedRef( Temp );
|
||||
return TieRadioButton( Prompt, WrappedRef );
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------//
|
||||
|
||||
// We're now into ShuttleGuiBase sizer and misc functions.
|
||||
|
@ -175,10 +175,8 @@ public:
|
||||
wxPanel * StartInvisiblePanel();
|
||||
void EndInvisiblePanel();
|
||||
|
||||
void StartRadioButtonGroup( const wxString & SettingName );
|
||||
void EndRadioButtonGroup();
|
||||
|
||||
void StartRadioButtonGroup( const wxString & SettingName, const wxString &DefaultValue );
|
||||
void EndRadioButtonGroup();
|
||||
|
||||
void DoDataShuttle( const wxString &Name, WrappedType & WrappedRef );
|
||||
|
||||
@ -215,7 +213,6 @@ public:
|
||||
wxSlider * TieSlider( const wxString &Prompt, float &pos, const float fMin, const float fMax);
|
||||
wxSlider * TieVSlider( const wxString &Prompt, float &pos, const float fMin, const float fMax);
|
||||
|
||||
wxRadioButton * TieRadioButton( const wxString & Prompt, WrappedType &WrappedRef);
|
||||
wxRadioButton * TieRadioButton( const wxString &Prompt, const wxString &Value);
|
||||
|
||||
wxSpinCtrl * TieSpinCtrl( const wxString &Prompt, WrappedType & WrappedRef, const int max, const int min = 0 );
|
||||
@ -343,13 +340,6 @@ protected:
|
||||
|
||||
teShuttleMode mShuttleMode;
|
||||
|
||||
// These five are needed to handle radio button groups.
|
||||
wxString mSettingName; /// The setting controlled by a group.
|
||||
int mRadioCount; /// The index of this radio item. -1 for none.
|
||||
|
||||
Maybe<WrappedType> mRadioValue; /// The wrapped value associated with the active radio button.
|
||||
wxString mRadioValueString; /// Unwrapped string value.
|
||||
|
||||
int miSizerProp;
|
||||
int mSizerDepth;
|
||||
int miBorder;
|
||||
@ -371,6 +361,13 @@ protected:
|
||||
wxWindow * mpWind;
|
||||
wxMenuBar * mpMenuBar;
|
||||
wxMenu * mpMenu;
|
||||
|
||||
private:
|
||||
wxString mRadioSettingName; /// The setting controlled by a group.
|
||||
Maybe<WrappedType> mRadioValue; /// The wrapped value associated with the active radio button.
|
||||
int mRadioCount; /// The index of this radio item. -1 for none.
|
||||
wxString mRadioValueString; /// Unwrapped string value.
|
||||
wxRadioButton * DoAddRadioButton(const wxString &Prompt, int style);
|
||||
};
|
||||
|
||||
// A rarely used helper function that sets a pointer
|
||||
|
Loading…
x
Reference in New Issue
Block a user