Commit e0cc8a2f authored by Dick Hollenbeck's avatar Dick Hollenbeck

implement move up, move down in lib table editor

parent 9e41a812
...@@ -231,7 +231,6 @@ class DIALOG_FP_LIB_TABLE : public DIALOG_FP_LIB_TABLE_BASE ...@@ -231,7 +231,6 @@ class DIALOG_FP_LIB_TABLE : public DIALOG_FP_LIB_TABLE_BASE
void pageChangedHandler( wxAuiNotebookEvent& event ) void pageChangedHandler( wxAuiNotebookEvent& event )
{ {
int pageNdx = m_auinotebook->GetSelection(); int pageNdx = m_auinotebook->GetSelection();
m_cur_grid = pageNdx==0 ? m_global_grid : m_project_grid; m_cur_grid = pageNdx==0 ? m_global_grid : m_project_grid;
D(printf("%s cur_grid is %s\n", __func__, pageNdx==0 ? "global" : "project" );) D(printf("%s cur_grid is %s\n", __func__, pageNdx==0 ? "global" : "project" );)
...@@ -239,37 +238,33 @@ class DIALOG_FP_LIB_TABLE : public DIALOG_FP_LIB_TABLE_BASE ...@@ -239,37 +238,33 @@ class DIALOG_FP_LIB_TABLE : public DIALOG_FP_LIB_TABLE_BASE
void appendRowHandler( wxMouseEvent& event ) void appendRowHandler( wxMouseEvent& event )
{ {
D(printf("%s\n", __func__);)
m_cur_grid->AppendRows( 1 ); m_cur_grid->AppendRows( 1 );
} }
void deleteRowHandler( wxMouseEvent& event ) void deleteRowHandler( wxMouseEvent& event )
{ {
D(printf("%s\n", __func__);)
int curRow = m_cur_grid->GetGridCursorRow(); int curRow = m_cur_grid->GetGridCursorRow();
m_cur_grid->DeleteRows( curRow ); m_cur_grid->DeleteRows( curRow );
} }
void moveUpHandler( wxMouseEvent& event ) void moveUpHandler( wxMouseEvent& event )
{ {
D(printf("%s\n", __func__);)
int curRow = m_cur_grid->GetGridCursorRow(); int curRow = m_cur_grid->GetGridCursorRow();
if( curRow >= 1 ) if( curRow >= 1 )
{ {
FP_TBL_MODEL* tbl = (FP_TBL_MODEL*) m_cur_grid->GetTable(); int curCol = m_cur_grid->GetGridCursorCol();
ROW save = tbl->rows[curRow]; FP_TBL_MODEL* tbl = (FP_TBL_MODEL*) m_cur_grid->GetTable();
tbl->DeleteRows( curRow, 1 ); ROW move_me = tbl->rows[curRow];
tbl->InsertRows( --curRow, 1 );
tbl->rows[curRow] = save; tbl->rows.erase( tbl->rows.begin() + curRow );
--curRow;
tbl->rows.insert( tbl->rows.begin() + curRow, move_me );
if( tbl->GetView() ) if( tbl->GetView() )
{ {
// fire a msg to cause redrawing
wxGridTableMessage msg( tbl, wxGridTableMessage msg( tbl,
wxGRIDTABLE_NOTIFY_ROWS_INSERTED, wxGRIDTABLE_NOTIFY_ROWS_INSERTED,
curRow, curRow,
...@@ -277,11 +272,39 @@ class DIALOG_FP_LIB_TABLE : public DIALOG_FP_LIB_TABLE_BASE ...@@ -277,11 +272,39 @@ class DIALOG_FP_LIB_TABLE : public DIALOG_FP_LIB_TABLE_BASE
tbl->GetView()->ProcessTableMessage( msg ); tbl->GetView()->ProcessTableMessage( msg );
} }
m_cur_grid->SetGridCursor( curRow, curCol );
} }
} }
void moveDownHandler( wxMouseEvent& event ) void moveDownHandler( wxMouseEvent& event )
{ {
FP_TBL_MODEL* tbl = (FP_TBL_MODEL*) m_cur_grid->GetTable();
int curRow = m_cur_grid->GetGridCursorRow();
if( unsigned( curRow + 1 ) < tbl->rows.size() )
{
int curCol = m_cur_grid->GetGridCursorCol();
ROW move_me = tbl->rows[curRow];
tbl->rows.erase( tbl->rows.begin() + curRow );
++curRow;
tbl->rows.insert( tbl->rows.begin() + curRow, move_me );
if( tbl->GetView() )
{
// fire a msg to cause redrawing
wxGridTableMessage msg( tbl,
wxGRIDTABLE_NOTIFY_ROWS_INSERTED,
curRow - 1,
0 );
tbl->GetView()->ProcessTableMessage( msg );
}
m_cur_grid->SetGridCursor( curRow, curCol );
}
D(printf("%s\n", __func__);) D(printf("%s\n", __func__);)
} }
......
...@@ -240,7 +240,8 @@ void FP_CACHE::Load() ...@@ -240,7 +240,8 @@ void FP_CACHE::Load()
} }
// reader now owns fp, will close on exception or return // reader now owns fp, will close on exception or return
PCB_PARSER parser( new FILE_LINE_READER( fp, fpFileName ) ); FILE_LINE_READER reader( fp, fpFileName );
PCB_PARSER parser( &reader );
std::string name = TO_UTF8( fpFileName ); std::string name = TO_UTF8( fpFileName );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment