mirror of
https://github.com/cookiengineer/audacity
synced 2025-07-17 09:07:41 +02:00
Added TieNumericTextBox() function - and used it for DtmfDialog.
This commit is contained in:
parent
97620f561a
commit
b1f7a0f890
@ -510,6 +510,36 @@ wxTextCtrl * ShuttleGuiBase::AddTextBox(const wxString &Caption, const wxString
|
||||
return pTextCtrl;
|
||||
}
|
||||
|
||||
wxTextCtrl * ShuttleGuiBase::AddNumericTextBox(const wxString &Caption, const wxString &Value, const int nChars)
|
||||
{
|
||||
UseUpId();
|
||||
if( mShuttleMode != eIsCreating )
|
||||
return wxDynamicCast(wxWindow::FindWindowById( miId, mpDlg), wxTextCtrl);
|
||||
wxTextCtrl * pTextCtrl;
|
||||
wxSize Size(wxDefaultSize);
|
||||
if( nChars > 0 )
|
||||
{
|
||||
Size.SetWidth( nChars *5 );
|
||||
}
|
||||
AddPrompt( Caption );
|
||||
miProp=0;
|
||||
|
||||
#ifdef RIGHT_ALIGNED_TEXTBOXES
|
||||
long flags = wxTE_RIGHT;
|
||||
#else
|
||||
long flags = wxTE_LEFT;
|
||||
#endif
|
||||
|
||||
wxTextValidator Validator(wxFILTER_NUMERIC);
|
||||
mpWind = pTextCtrl = new wxTextCtrl(mpParent, miId, Value,
|
||||
wxDefaultPosition, Size, Style( flags ),
|
||||
Validator // It's OK to pass this. It will be cloned.
|
||||
);
|
||||
mpWind->SetName( Caption );
|
||||
UpdateSizers();
|
||||
return pTextCtrl;
|
||||
}
|
||||
|
||||
/// Multiline text box that grows.
|
||||
wxTextCtrl * ShuttleGuiBase::AddTextWindow(const wxString &Value)
|
||||
{
|
||||
@ -1147,6 +1177,46 @@ wxTextCtrl * ShuttleGuiBase::TieTextBox( const wxString &Prompt, WrappedType & W
|
||||
return pTextBox;
|
||||
}
|
||||
|
||||
wxTextCtrl * ShuttleGuiBase::TieNumericTextBox( const wxString &Prompt, WrappedType & WrappedRef, const int nChars)
|
||||
{
|
||||
// The Add function does a UseUpId(), so don't do it here in that case.
|
||||
if( mShuttleMode == eIsCreating )
|
||||
return AddNumericTextBox( Prompt, WrappedRef.ReadAsString(), nChars );
|
||||
|
||||
UseUpId();
|
||||
wxTextCtrl * pTextBox=NULL;
|
||||
|
||||
wxWindow * pWnd = wxWindow::FindWindowById( miId, mpDlg);
|
||||
pTextBox = wxDynamicCast(pWnd, wxTextCtrl);
|
||||
|
||||
switch( mShuttleMode )
|
||||
{
|
||||
// IF setting internal storage from the controls.
|
||||
case eIsGettingFromDialog:
|
||||
{
|
||||
wxASSERT( pTextBox );
|
||||
WrappedRef.WriteToAsString( pTextBox->GetValue() );
|
||||
}
|
||||
break;
|
||||
case eIsSettingToDialog:
|
||||
{
|
||||
wxASSERT( pTextBox );
|
||||
pTextBox->SetValue( WrappedRef.ReadAsString() );
|
||||
}
|
||||
break;
|
||||
// IF Saving settings to external storage...
|
||||
// or IF Getting settings from external storage.
|
||||
case eIsGettingViaShuttle:
|
||||
case eIsSavingViaShuttle:
|
||||
DoDataShuttle( Prompt, WrappedRef );
|
||||
break;
|
||||
default:
|
||||
wxASSERT( false );
|
||||
break;
|
||||
}
|
||||
return pTextBox;
|
||||
}
|
||||
|
||||
wxSlider * ShuttleGuiBase::TieSlider( const wxString &Prompt, WrappedType & WrappedRef, const int max, int min )
|
||||
{
|
||||
// The Add function does a UseUpId(), so don't do it here in that case.
|
||||
@ -1357,6 +1427,24 @@ wxTextCtrl * ShuttleGuiBase::TieTextBox( const wxString &Prompt, double &Value,
|
||||
return TieTextBox( Prompt, WrappedRef, nChars );
|
||||
}
|
||||
|
||||
wxTextCtrl * ShuttleGuiBase::TieNumericTextBox( const wxString &Prompt, wxString &Selected, const int nChars)
|
||||
{
|
||||
WrappedType WrappedRef(Selected);
|
||||
return TieNumericTextBox( Prompt, WrappedRef, nChars );
|
||||
}
|
||||
|
||||
wxTextCtrl * ShuttleGuiBase::TieNumericTextBox( const wxString &Prompt, int &Selected, const int nChars)
|
||||
{
|
||||
WrappedType WrappedRef( Selected );
|
||||
return TieNumericTextBox( Prompt, WrappedRef, nChars );
|
||||
}
|
||||
|
||||
wxTextCtrl * ShuttleGuiBase::TieNumericTextBox( const wxString &Prompt, double &Value, const int nChars)
|
||||
{
|
||||
WrappedType WrappedRef( Value );
|
||||
return TieNumericTextBox( Prompt, WrappedRef, nChars );
|
||||
}
|
||||
|
||||
wxSlider * ShuttleGuiBase::TieSlider( const wxString &Prompt, int &pos, const int max, const int min )
|
||||
{
|
||||
WrappedType WrappedRef( pos );
|
||||
@ -1617,6 +1705,23 @@ wxTextCtrl * ShuttleGuiBase::TieTextBox(
|
||||
return pText;
|
||||
}
|
||||
|
||||
/// Variant of the standard TieTextBox which does the two step exchange
|
||||
/// between gui and stack variable and stack variable and shuttle.
|
||||
wxTextCtrl * ShuttleGuiBase::TieNumericTextBox(
|
||||
const wxString & Prompt,
|
||||
const wxString & SettingName,
|
||||
const wxString & Default,
|
||||
const int nChars)
|
||||
{
|
||||
wxTextCtrl * pText=(wxTextCtrl*)NULL;
|
||||
|
||||
wxString Temp = Default;
|
||||
WrappedType WrappedRef( Temp );
|
||||
if( DoStep(1) ) DoDataShuttle( SettingName, WrappedRef );
|
||||
if( DoStep(2) ) pText = TieNumericTextBox( Prompt, WrappedRef, nChars );
|
||||
if( DoStep(3) ) DoDataShuttle( SettingName, WrappedRef );
|
||||
return pText;
|
||||
}
|
||||
/// Variant of the standard TieTextBox which does the two step exchange
|
||||
/// between gui and stack variable and stack variable and shuttle.
|
||||
/// This one does it for double values...
|
||||
@ -1636,6 +1741,25 @@ wxTextCtrl * ShuttleGuiBase::TieTextBox(
|
||||
return pText;
|
||||
}
|
||||
|
||||
/// Variant of the standard TieTextBox which does the two step exchange
|
||||
/// between gui and stack variable and stack variable and shuttle.
|
||||
/// This one does it for double values...
|
||||
wxTextCtrl * ShuttleGuiBase::TieNumericTextBox(
|
||||
const wxString & Prompt,
|
||||
const wxString & SettingName,
|
||||
const double & Default,
|
||||
const int nChars)
|
||||
{
|
||||
wxTextCtrl * pText=(wxTextCtrl*)NULL;
|
||||
|
||||
double Temp = Default;
|
||||
WrappedType WrappedRef( Temp );
|
||||
if( DoStep(1) ) DoDataShuttle( SettingName, WrappedRef );
|
||||
if( DoStep(2) ) pText = TieNumericTextBox( Prompt, WrappedRef, nChars );
|
||||
if( DoStep(3) ) DoDataShuttle( SettingName, WrappedRef );
|
||||
return pText;
|
||||
}
|
||||
|
||||
/// Variant of the standard TieChoice which does the two step exchange
|
||||
/// between gui and stack variable and stack variable and shuttle.
|
||||
/// @param Prompt The prompt shown beside the control.
|
||||
|
@ -91,6 +91,7 @@ public:
|
||||
wxBitmapButton * AddBitmapButton(const wxBitmap &Bitmap, int PositionFlags = wxALIGN_CENTRE);
|
||||
wxStaticText * AddVariableText(const wxString &Str, bool bCenter = false, int PositionFlags = 0);
|
||||
wxTextCtrl * AddTextBox(const wxString &Caption, const wxString &Value, const int nChars);
|
||||
wxTextCtrl * AddNumericTextBox(const wxString &Caption, const wxString &Value, const int nChars);
|
||||
wxTextCtrl * AddTextWindow(const wxString &Value);
|
||||
wxListBox * AddListBox(const wxArrayString * pChoices, long style = 0);
|
||||
wxListCtrl * AddListControl();
|
||||
@ -158,6 +159,11 @@ public:
|
||||
wxTextCtrl * TieTextBox( const wxString &Prompt, int &Selected, const int nChars=0);
|
||||
wxTextCtrl * TieTextBox( const wxString &Prompt, double &Value, const int nChars=0);
|
||||
|
||||
wxTextCtrl * TieNumericTextBox( const wxString &Prompt, WrappedType & WrappedRef, const int nChars);
|
||||
wxTextCtrl * TieNumericTextBox( const wxString &Caption, wxString & Value, const int nChars=0);
|
||||
wxTextCtrl * TieNumericTextBox( const wxString &Prompt, int &Selected, const int nChars=0);
|
||||
wxTextCtrl * TieNumericTextBox( const wxString &Prompt, double &Value, const int nChars=0);
|
||||
|
||||
wxCheckBox * TieCheckBox( const wxString &Prompt, WrappedType & WrappedRef );
|
||||
wxCheckBox * TieCheckBox( const wxString &Prompt, const wxString &Selected );
|
||||
wxCheckBox * TieCheckBox( const wxString &Prompt, bool & Var );
|
||||
@ -215,6 +221,16 @@ public:
|
||||
const wxString & SettingName,
|
||||
const double & Default,
|
||||
const int nChars);
|
||||
wxTextCtrl * TieNumericTextBox(
|
||||
const wxString &Prompt,
|
||||
const wxString &SettingName,
|
||||
const wxString &Default,
|
||||
const int nChars);
|
||||
wxTextCtrl * TieNumericTextBox(
|
||||
const wxString & Prompt,
|
||||
const wxString & SettingName,
|
||||
const double & Default,
|
||||
const int nChars);
|
||||
wxSlider * TieSlider(
|
||||
const wxString & Prompt,
|
||||
const wxString & SettingName,
|
||||
|
@ -449,7 +449,7 @@ void DtmfDialog::PopulateOrExchange( ShuttleGui & S )
|
||||
// The added colon to improve visual consistency was placed outside
|
||||
// the translatable strings to avoid breaking translations close to 2.0.
|
||||
// TODO: Make colon part of the translatable string after 2.0.
|
||||
S.TieTextBox(_("Amplitude (0-1)") + wxString(wxT(":")), dAmplitude, 10);
|
||||
S.TieNumericTextBox(_("Amplitude (0-1)") + wxString(wxT(":")), dAmplitude, 10);
|
||||
|
||||
S.AddPrompt(_("Duration:"));
|
||||
if (mDtmfDurationT == NULL)
|
||||
|
Loading…
x
Reference in New Issue
Block a user