Specify list control columns and styles all in one call
This commit is contained in:
parent
17ee2478bc
commit
ae353fe61f
|
@ -72,10 +72,9 @@ void AutoRecoveryDialog::PopulateOrExchange(ShuttleGui& S)
|
|||
|
||||
S.StartStatic(_("Recoverable projects"));
|
||||
{
|
||||
mFileList = S.Id(ID_FILE_LIST).AddListControlReportMode();
|
||||
/*i18n-hint: (noun). It's the name of the project to recover.*/
|
||||
mFileList->InsertColumn(0, _("Name"));
|
||||
mFileList->SetColumnWidth(0, wxLIST_AUTOSIZE);
|
||||
mFileList = S.Id(ID_FILE_LIST)
|
||||
/*i18n-hint: (noun). It's the name of the project to recover.*/
|
||||
.AddListControlReportMode( { _("Name") } );
|
||||
PopulateList();
|
||||
}
|
||||
S.EndStatic();
|
||||
|
|
|
@ -137,8 +137,8 @@ void ApplyMacroDialog::PopulateOrExchange(ShuttleGui &S)
|
|||
{
|
||||
S.SetStyle(wxSUNKEN_BORDER | wxLC_REPORT | wxLC_HRULES | wxLC_VRULES |
|
||||
wxLC_SINGLE_SEL);
|
||||
mMacros = S.Id(MacrosListID).Prop(1).AddListControlReportMode();
|
||||
mMacros->InsertColumn(0, _("Macro"), wxLIST_FORMAT_LEFT);
|
||||
mMacros = S.Id(MacrosListID).Prop(1)
|
||||
.AddListControlReportMode( { _("Macro") } );
|
||||
}
|
||||
S.EndStatic();
|
||||
|
||||
|
@ -410,10 +410,10 @@ void ApplyMacroDialog::OnApplyToFiles(wxCommandEvent & WXUNUSED(event))
|
|||
|
||||
S.SetStyle(wxSUNKEN_BORDER | wxLC_REPORT | wxLC_HRULES | wxLC_VRULES |
|
||||
wxLC_SINGLE_SEL);
|
||||
fileList = S.Id(CommandsListID).AddListControlReportMode();
|
||||
fileList = S.Id(CommandsListID)
|
||||
.AddListControlReportMode( { _("File") } );
|
||||
// AssignImageList takes ownership
|
||||
fileList->AssignImageList(imageList.release(), wxIMAGE_LIST_SMALL);
|
||||
fileList->InsertColumn(0, _("File"), wxLIST_FORMAT_LEFT);
|
||||
}
|
||||
S.EndStatic();
|
||||
|
||||
|
@ -618,9 +618,9 @@ void MacrosWindow::PopulateOrExchange(ShuttleGui & S)
|
|||
{
|
||||
S.SetStyle(wxSUNKEN_BORDER | wxLC_REPORT | wxLC_HRULES | wxLC_SINGLE_SEL |
|
||||
wxLC_EDIT_LABELS);
|
||||
mMacros = S.Id(MacrosListID).Prop(1).AddListControlReportMode();
|
||||
// i18n-hint: This is the heading for a column in the edit macros dialog
|
||||
mMacros->InsertColumn(0, _("Macro"), wxLIST_FORMAT_LEFT);
|
||||
mMacros = S.Id(MacrosListID).Prop(1)
|
||||
// i18n-hint: This is the heading for a column in the edit macros dialog
|
||||
.AddListControlReportMode( { _("Macro") } );
|
||||
S.StartVerticalLay(wxALIGN_TOP, 0);
|
||||
{
|
||||
S.Id(AddButtonID).AddButton(_("&New"));
|
||||
|
@ -646,16 +646,13 @@ void MacrosWindow::PopulateOrExchange(ShuttleGui & S)
|
|||
|
||||
S.SetStyle(wxSUNKEN_BORDER | wxLC_REPORT | wxLC_HRULES | wxLC_VRULES |
|
||||
wxLC_SINGLE_SEL);
|
||||
mList = S.Id(CommandsListID).AddListControlReportMode();
|
||||
|
||||
//A dummy first column, which is then deleted, is a workaround - under Windows the first column
|
||||
//can't be right aligned.
|
||||
mList->InsertColumn(0, wxT(""), wxLIST_FORMAT_LEFT);
|
||||
/* i18n-hint: This is the number of the command in the list */
|
||||
mList->InsertColumn(ItemNumberColumn + 1, _("Num"), wxLIST_FORMAT_RIGHT);
|
||||
mList->InsertColumn(ActionColumn + 1, _("Command "), wxLIST_FORMAT_RIGHT);
|
||||
mList->InsertColumn(ParamsColumn + 1, _("Parameters"), wxLIST_FORMAT_LEFT);
|
||||
mList->DeleteColumn(0);
|
||||
mList = S.Id(CommandsListID)
|
||||
.AddListControlReportMode({
|
||||
/* i18n-hint: This is the number of the command in the list */
|
||||
{ _("Num"), wxLIST_FORMAT_RIGHT },
|
||||
{ _("Command "), wxLIST_FORMAT_RIGHT },
|
||||
{ _("Parameters"), wxLIST_FORMAT_LEFT }
|
||||
});
|
||||
|
||||
S.StartVerticalLay(wxALIGN_TOP, 0);
|
||||
{
|
||||
|
|
|
@ -356,11 +356,10 @@ void DependencyDialog::PopulateOrExchange(ShuttleGui& S)
|
|||
|
||||
S.StartStatic(_("Project Dependencies"),1);
|
||||
{
|
||||
mFileListCtrl = S.Id(FileListID).AddListControlReportMode();
|
||||
mFileListCtrl->InsertColumn(0, _("Audio File"));
|
||||
mFileListCtrl->SetColumnWidth(0, 220);
|
||||
mFileListCtrl->InsertColumn(1, _("Disk Space"));
|
||||
mFileListCtrl->SetColumnWidth(1, 120);
|
||||
mFileListCtrl = S.Id(FileListID).AddListControlReportMode({
|
||||
{ _("Audio File"), wxLIST_FORMAT_LEFT, 220 },
|
||||
{ _("Disk Space"), wxLIST_FORMAT_LEFT, 120 }
|
||||
});
|
||||
PopulateList();
|
||||
|
||||
mCopySelectedFilesButton =
|
||||
|
|
|
@ -83,12 +83,12 @@ HistoryWindow::HistoryWindow(AudacityProject *parent, UndoManager *manager):
|
|||
{
|
||||
S.StartStatic(_("&Manage History"), 1);
|
||||
{
|
||||
mList = S.AddListControlReportMode();
|
||||
// Do this BEFORE inserting the columns. On the Mac at least, the
|
||||
// columns are deleted and later InsertItem()s will cause Audacity to crash.
|
||||
mList->SetSingleStyle(wxLC_SINGLE_SEL);
|
||||
mList->InsertColumn(0, _("Action"), wxLIST_FORMAT_LEFT, 260);
|
||||
mList->InsertColumn(1, _("Reclaimable Space"), wxLIST_FORMAT_LEFT, 125);
|
||||
mList = S
|
||||
.AddListControlReportMode(
|
||||
{ { _("Action"), wxLIST_FORMAT_LEFT, 260 },
|
||||
{ _("Reclaimable Space"), wxLIST_FORMAT_LEFT, 125 } },
|
||||
wxLC_SINGLE_SEL
|
||||
);
|
||||
|
||||
//Assign rather than set the image list, so that it is deleted later.
|
||||
// AssignImageList takes ownership
|
||||
|
|
|
@ -565,16 +565,14 @@ void PluginRegistrationDialog::PopulateOrExchange(ShuttleGui &S)
|
|||
S.EndHorizontalLay();
|
||||
|
||||
S.SetStyle(wxSUNKEN_BORDER | wxLC_REPORT | wxLC_HRULES | wxLC_VRULES );
|
||||
mEffects = S.Id(ID_List).AddListControlReportMode();
|
||||
mEffects = S.Id(ID_List)
|
||||
.AddListControlReportMode({ _("Name"), _("State"), _("Path") });
|
||||
mEffects->Bind(wxEVT_KEY_DOWN,
|
||||
&PluginRegistrationDialog::OnListChar,
|
||||
this);
|
||||
#if wxUSE_ACCESSIBILITY
|
||||
mEffects->SetAccessible(mAx = safenew CheckListAx(mEffects));
|
||||
#endif
|
||||
mEffects->InsertColumn(COL_Name, _("Name"));
|
||||
mEffects->InsertColumn(COL_State, _("State"));
|
||||
mEffects->InsertColumn(COL_Path, _("Path"));
|
||||
|
||||
S.StartHorizontalLay(wxALIGN_LEFT | wxEXPAND, 0);
|
||||
{
|
||||
|
|
|
@ -699,20 +699,6 @@ wxListBox * ShuttleGuiBase::AddListBox(const wxArrayStringEx &choices, long styl
|
|||
}
|
||||
|
||||
|
||||
wxListCtrl * ShuttleGuiBase::AddListControl()
|
||||
{
|
||||
UseUpId();
|
||||
if( mShuttleMode != eIsCreating )
|
||||
return wxDynamicCast(wxWindow::FindWindowById( miId, mpDlg), wxListCtrl);
|
||||
wxListCtrl * pListCtrl;
|
||||
SetProportions( 1 );
|
||||
mpWind = pListCtrl = safenew wxListCtrl(GetParent(), miId,
|
||||
wxDefaultPosition, wxDefaultSize, Style( wxLC_ICON ));
|
||||
pListCtrl->SetMinSize( wxSize( 120,150 ));
|
||||
UpdateSizers();
|
||||
return pListCtrl;
|
||||
}
|
||||
|
||||
wxGrid * ShuttleGuiBase::AddGrid()
|
||||
{
|
||||
UseUpId();
|
||||
|
@ -727,7 +713,30 @@ wxGrid * ShuttleGuiBase::AddGrid()
|
|||
return pGrid;
|
||||
}
|
||||
|
||||
wxListCtrl * ShuttleGuiBase::AddListControlReportMode()
|
||||
wxListCtrl * ShuttleGuiBase::AddListControl(
|
||||
std::initializer_list<const ListControlColumn> columns,
|
||||
long listControlStyles
|
||||
)
|
||||
{
|
||||
UseUpId();
|
||||
if( mShuttleMode != eIsCreating )
|
||||
return wxDynamicCast(wxWindow::FindWindowById( miId, mpDlg), wxListCtrl);
|
||||
wxListCtrl * pListCtrl;
|
||||
SetProportions( 1 );
|
||||
mpWind = pListCtrl = safenew wxListCtrl(GetParent(), miId,
|
||||
wxDefaultPosition, wxDefaultSize, Style( wxLC_ICON ));
|
||||
pListCtrl->SetMinSize( wxSize( 120,150 ));
|
||||
UpdateSizers();
|
||||
|
||||
DoInsertListColumns( pListCtrl, listControlStyles, columns );
|
||||
|
||||
return pListCtrl;
|
||||
}
|
||||
|
||||
wxListCtrl * ShuttleGuiBase::AddListControlReportMode(
|
||||
std::initializer_list<const ListControlColumn> columns,
|
||||
long listControlStyles
|
||||
)
|
||||
{
|
||||
UseUpId();
|
||||
if( mShuttleMode != eIsCreating )
|
||||
|
@ -739,9 +748,43 @@ wxListCtrl * ShuttleGuiBase::AddListControlReportMode()
|
|||
Style( wxLC_REPORT | wxLC_HRULES | wxLC_VRULES | wxSUNKEN_BORDER ));
|
||||
// pListCtrl->SetMinSize( wxSize( 120,150 ));
|
||||
UpdateSizers();
|
||||
|
||||
DoInsertListColumns( pListCtrl, listControlStyles, columns );
|
||||
|
||||
return pListCtrl;
|
||||
}
|
||||
|
||||
void ShuttleGuiBase::DoInsertListColumns(
|
||||
wxListCtrl *pListCtrl,
|
||||
long listControlStyles,
|
||||
std::initializer_list<const ListControlColumn> columns )
|
||||
{
|
||||
// Old comment from HistoryWindow.cpp follows
|
||||
// -- is it still correct for wxWidgets 3?
|
||||
|
||||
// Do this BEFORE inserting the columns. On the Mac at least, the
|
||||
// columns are deleted and later InsertItem()s will cause Audacity to crash.
|
||||
for ( auto style = 1l; style <= listControlStyles; style <<= 1 )
|
||||
if ( (style & listControlStyles) )
|
||||
pListCtrl->SetSingleStyle(style, true);
|
||||
|
||||
long iCol = 0;
|
||||
bool dummyColumn =
|
||||
columns.size() > 0 && begin(columns)->format == wxLIST_FORMAT_RIGHT;
|
||||
|
||||
//A dummy first column, which is then deleted, is a workaround -
|
||||
// under Windows the first column can't be right aligned.
|
||||
if (dummyColumn)
|
||||
pListCtrl->InsertColumn( iCol++, wxString{} );
|
||||
|
||||
for (auto &column : columns)
|
||||
pListCtrl->InsertColumn(
|
||||
iCol++, column.heading, column.format, column.width );
|
||||
|
||||
if (dummyColumn)
|
||||
pListCtrl->DeleteColumn( 0 );
|
||||
}
|
||||
|
||||
wxTreeCtrl * ShuttleGuiBase::AddTree()
|
||||
{
|
||||
UseUpId();
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include <vector>
|
||||
#include <wx/slider.h> // to inherit
|
||||
#include "MemoryX.h"
|
||||
#include <wx/listbase.h> // for wxLIST_FORMAT_LEFT
|
||||
|
||||
#include "WrappedType.h"
|
||||
|
||||
|
@ -163,8 +164,26 @@ public:
|
|||
wxTextCtrl * AddNumericTextBox(const wxString &Caption, const wxString &Value, const int nChars);
|
||||
wxTextCtrl * AddTextWindow(const wxString &Value);
|
||||
wxListBox * AddListBox(const wxArrayStringEx &choices, long style = 0);
|
||||
wxListCtrl * AddListControl();
|
||||
wxListCtrl * AddListControlReportMode();
|
||||
|
||||
struct ListControlColumn{
|
||||
ListControlColumn(
|
||||
wxString h, int f = wxLIST_FORMAT_LEFT, int w = wxLIST_AUTOSIZE)
|
||||
: heading(h), format(f), width(w)
|
||||
{}
|
||||
|
||||
wxString heading;
|
||||
int format;
|
||||
int width;
|
||||
};
|
||||
wxListCtrl * AddListControl(
|
||||
std::initializer_list<const ListControlColumn> columns = {},
|
||||
long listControlStyles = 0
|
||||
);
|
||||
wxListCtrl * AddListControlReportMode(
|
||||
std::initializer_list<const ListControlColumn> columns = {},
|
||||
long listControlStyles = 0
|
||||
);
|
||||
|
||||
wxGrid * AddGrid();
|
||||
wxCheckBox * AddCheckBox( const wxString &Prompt, bool Selected);
|
||||
wxCheckBox * AddCheckBoxOnRight( const wxString &Prompt, bool Selected);
|
||||
|
@ -334,6 +353,12 @@ protected:
|
|||
|
||||
private:
|
||||
void SetSizeHints( const wxArrayStringEx & items );
|
||||
|
||||
void DoInsertListColumns(
|
||||
wxListCtrl *pListCtrl,
|
||||
long listControlStyles,
|
||||
std::initializer_list<const ListControlColumn> columns );
|
||||
|
||||
public:
|
||||
static void SetSizeHints( wxWindow *window, const wxArrayStringEx & items );
|
||||
|
||||
|
|
|
@ -3334,8 +3334,10 @@ void EditCurvesDialog::PopulateOrExchange(ShuttleGui & S)
|
|||
S.StartStatic(_("&Curves"), 1);
|
||||
{
|
||||
S.SetStyle(wxSUNKEN_BORDER | wxLC_REPORT | wxLC_HRULES | wxLC_VRULES );
|
||||
mList = S.Id(CurvesListID).AddListControlReportMode();
|
||||
mList->InsertColumn(0, _("Curve Name"), wxLIST_FORMAT_RIGHT);
|
||||
mList = S.Id(CurvesListID)
|
||||
.AddListControlReportMode({
|
||||
{ _("Curve Name"), wxLIST_FORMAT_RIGHT }
|
||||
});
|
||||
}
|
||||
S.EndStatic();
|
||||
S.StartVerticalLay(0);
|
||||
|
|
|
@ -511,8 +511,8 @@ void AudioUnitEffectExportDialog::PopulateOrExchange(ShuttleGui & S)
|
|||
{
|
||||
S.SetStyle(wxLC_REPORT | wxLC_HRULES | wxLC_VRULES |
|
||||
wxLC_NO_SORT_HEADER);
|
||||
mList = S.AddListControlReportMode();
|
||||
mList->InsertColumn(0, _("Preset"), wxLIST_FORMAT_LEFT);
|
||||
mList = S
|
||||
.AddListControlReportMode( { _("Preset") } );
|
||||
}
|
||||
S.EndStatic();
|
||||
}
|
||||
|
@ -684,9 +684,8 @@ void AudioUnitEffectImportDialog::PopulateOrExchange(ShuttleGui & S)
|
|||
{
|
||||
S.SetStyle(wxLC_REPORT | wxLC_HRULES | wxLC_VRULES |
|
||||
wxLC_NO_SORT_HEADER);
|
||||
mList = S.AddListControlReportMode();
|
||||
mList->InsertColumn(0, _("Preset"), wxLIST_FORMAT_LEFT);
|
||||
mList->InsertColumn(1, _("Location"), wxLIST_FORMAT_LEFT);
|
||||
mList = S
|
||||
.AddListControlReportMode( { _("Preset"), _("Location") } );
|
||||
}
|
||||
S.EndStatic();
|
||||
}
|
||||
|
|
|
@ -148,14 +148,14 @@ void ExtImportPrefs::PopulateOrExchange(ShuttleGui & S)
|
|||
}
|
||||
S.AddWindow(RuleTable, wxEXPAND | wxALL);
|
||||
|
||||
PluginList = S.Id(EIPPluginList).AddListControl ();
|
||||
PluginList = S.Id(EIPPluginList).AddListControl(
|
||||
{ { _("Importer order"), wxLIST_FORMAT_LEFT,
|
||||
wxLIST_AUTOSIZE_USEHEADER } },
|
||||
wxLC_REPORT | wxLC_SINGLE_SEL
|
||||
);
|
||||
|
||||
if (fillRuleTable)
|
||||
{
|
||||
PluginList->SetSingleStyle (wxLC_REPORT, true);
|
||||
PluginList->SetSingleStyle (wxLC_SINGLE_SEL, true);
|
||||
PluginList->InsertColumn (0, _("Importer order"));
|
||||
|
||||
ExtImportPrefsDropTarget *dragtarget2 {};
|
||||
PluginList->SetDropTarget (
|
||||
dragtarget2 = safenew ExtImportPrefsDropTarget(
|
||||
|
@ -164,8 +164,6 @@ void ExtImportPrefs::PopulateOrExchange(ShuttleGui & S)
|
|||
);
|
||||
dragtarget2->SetPrefs (this);
|
||||
|
||||
PluginList->SetColumnWidth (0, wxLIST_AUTOSIZE_USEHEADER);
|
||||
|
||||
auto &items = Importer::Get().GetImportItems();
|
||||
{
|
||||
int i = -1;
|
||||
|
|
Loading…
Reference in New Issue