21#include <wx/aui/auibook.h>
33 GetGrid()->PopEventHandler(
true );
42 wxBoxSizer* sizer =
new wxBoxSizer( wxVERTICAL );
46 grid->CreateGrid( 1, 7 );
47 grid->EnableGridLines(
true );
48 grid->SetMargins( 0, 0 );
49 grid->SetSelectionMode( wxGrid::wxGridSelectRows );
52 grid->SetColSize( 0, 30 );
53 grid->SetColSize( 1, 48 );
54 grid->SetColSize( 2, 48 );
55 grid->SetColSize( 3, 240 );
56 grid->SetColSize( 4, 100 );
57 grid->SetColSize( 5, 80 );
58 grid->SetColSize( 6, 240 );
59 grid->SetColLabelSize( 22 );
60 grid->SetColLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
63 grid->EnableDragRowSize(
false );
64 grid->SetRowLabelSize( 0 );
65 grid->SetRowLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
68 grid->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_CENTER );
77 sizer->Add(
grid, 1, wxALL|wxEXPAND, 5 );
79 panel->SetSizer( sizer );
87 aNotebook->AddPage( panel, aTitle,
false );
93 wxAuiNotebook* notebook =
dynamic_cast<wxAuiNotebook*
>( GetParent() );
98 int page = notebook->GetPageIndex(
this );
100 if( page == wxNOT_FOUND )
103 if( !notebook->GetPageText( page ).EndsWith( wxT(
" *" ) ) )
104 notebook->SetPageText( page,
m_baseTitle + wxT(
" *" ) );
110 wxAuiNotebook* notebook =
dynamic_cast<wxAuiNotebook*
>( GetParent() );
115 int page = notebook->GetPageIndex(
this );
117 if( page == wxNOT_FOUND )
127 wxFileName file(
table.Path() );
129 std::unique_ptr<LIBRARY_TABLE> sourceTable =
132 if(
table.IsReadOnly() )
138 if( sourceTable->Rows().size() !=
table.Rows().size() )
141 for(
size_t i = 0; i <
table.Rows().size(); ++i )
153 return table != *sourceTable;
159 int row = aEvent.GetRow();
160 int col = aEvent.GetCol();
165 wxString editValue =
grid->GetCellValue( row, col );
167 if( wxGridCellEditor* cellEditor =
grid->GetCellEditor( row, col ) )
169 if( cellEditor->IsCreated() && cellEditor->GetWindow()->IsShown() )
170 editValue = cellEditor->GetValue();
172 cellEditor->DecRef();
175 grid->GetTable()->SetValue( row, col, editValue );
192 if(
table.IsReadOnly() )
204 table.Save().map_error(
207 wxMessageBox(
_(
"Error saving nested library table:\n\n" ) + aError.
message,
208 _(
"File Save Error" ), wxOK | wxICON_ERROR );
223 wxString tablePath =
table.Path();
229 if( row.Disabled() || row.Hidden() )
230 libMgr.
SetLibOverride( tablePath, row.Nickname(), row.Disabled(), row.Hidden() );
241 if( !
GetGrid()->CommitPendingChanges() )
void CheckTableRow(LIBRARY_TABLE_ROW &aRow)
void ClearLibOverride(const wxString &aTablePath, const wxString &aNickname)
Removes any override for a library that no longer needs one.
void ApplyLibOverrides(LIBRARY_TABLE &aTable)
Applies stored user overrides (disabled/hidden) to rows of a read-only table.
void SetLibOverride(const wxString &aTablePath, const wxString &aNickname, bool aDisabled, bool aHidden)
Set a user override for a library in a read-only nested table.
LIBRARY_MANAGER_ADAPTER * Adapter() const
LIBRARY_TABLE_ROW & At(size_t aIndex)
static void AddTable(wxAuiNotebook *aNotebook, const wxString &aTitle, bool aClosable)
void onGridCellChanging(wxGridEvent &aEvent)
bool SaveOverrides()
Save enable/visible overrides for a read-only nested table to user settings.
bool GetCanClose() override
LIB_TABLE_NOTEBOOK_PANEL(wxWindow *parent, wxWindowID id=wxID_ANY)
~LIB_TABLE_NOTEBOOK_PANEL() override
LIB_TABLE_GRID_DATA_MODEL * GetModel()
void SetClosable(bool aYes)
virtual LIBRARY_MANAGER & GetLibraryManager() const
bool HandleUnsavedChanges(wxWindow *aParent, const wxString &aMessage, const std::function< bool()> &aSaveFunction)
Display a dialog with Save, Cancel and Discard Changes buttons.
This file is part of the common library.
PGM_BASE & Pgm()
The global program "get" accessor.
std::vector< std::vector< std::string > > table