MCPcopy Create free account
hub / github.com/NatLabRockies/SAM / ShowTableEditor

Function ShowTableEditor

src/ide.cpp:604–652  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

602END_EVENT_TABLE()
603
604static bool ShowTableEditor( VarInfoLookup &vi )
605{
606 wxDialog dlg( NULL, wxID_ANY, "Edit labels", wxDefaultPosition, wxScaleSize(600, 750), wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
607 wxExtGridCtrl *grid = new wxExtGridCtrl( &dlg, wxID_ANY );
608 grid->EnableCopyPaste( true );
609 grid->CreateGrid( vi.size(), 4 );
610 grid->SetColLabelValue( 0, "Variable" );
611 grid->SetColLabelValue( 1, "Label" );
612 grid->SetColLabelValue( 2, "Units" );
613 grid->SetColLabelValue( 3, "Group" );
614
615 wxArrayString list = vi.ListAll();
616 list.Sort();
617 for( size_t i=0;i<list.size();i++ )
618 {
619 grid->SetCellValue( i, 0, list[i] );
620 grid->SetCellBackgroundColour( i, 0, wxColour(230,230,230) );
621 grid->SetCellValue( i, 1, vi.Label( list[i] ) );
622 grid->SetCellValue( i, 2, vi.Units( list[i] ) );
623 grid->SetCellValue( i, 3, vi.Group( list[i] ) );
624 }
625
626 grid->SetColLabelSize( wxGRID_AUTOSIZE );
627 grid->AutoSize();
628
629 wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL );
630 sizer->Add( grid, 1, wxALL|wxEXPAND, 0 );
631 sizer->Add( dlg.CreateButtonSizer( wxOK|wxCANCEL ), 0, wxALL|wxEXPAND, 10 );
632 dlg.SetSizer( sizer );
633
634 if ( wxID_OK == dlg.ShowModal() )
635 {
636 int nupd = 0;
637 for ( int i=0;i<grid->GetNumberRows(); i++ )
638 {
639 if ( VarInfo *pv = vi.Lookup( grid->GetCellValue( i, 0 ) ) )
640 {
641 pv->Label = grid->GetCellValue( i, 1 );
642 pv->Units = grid->GetCellValue( i, 2 );
643 pv->Group = grid->GetCellValue( i, 3 );
644 nupd++;
645 }
646 }
647 wxMessageBox( wxString::Format("%d variables updated", nupd) );
648 return true;
649 }
650 else
651 return false;
652}
653
654enum {
655 ID_FORM_EDITOR = wxID_HIGHEST + 231,

Callers 1

OnCommandMethod · 0.85

Calls 12

sizeMethod · 0.80
SortMethod · 0.80
LabelMethod · 0.80
UnitsMethod · 0.80
GroupMethod · 0.80
GetCellValueMethod · 0.80
SetColLabelValueMethod · 0.45
ListAllMethod · 0.45
AddMethod · 0.45
ShowModalMethod · 0.45
GetNumberRowsMethod · 0.45
LookupMethod · 0.45

Tested by

no test coverage detected