This clears and updates the contents of mList, the commands for the current macro.
| 722 | |
| 723 | /// This clears and updates the contents of mList, the commands for the current macro. |
| 724 | void MacrosWindow::PopulateList() |
| 725 | { |
| 726 | int topItem = mList->GetTopItem(); |
| 727 | mList->DeleteAllItems(); |
| 728 | |
| 729 | for (int i = 0; i < mMacroCommands.GetCount(); i++) { |
| 730 | AddItem(mMacroCommands.GetCommand(i), |
| 731 | mMacroCommands.GetParams(i)); |
| 732 | } |
| 733 | /*i18n-hint: This is the last item in a list.*/ |
| 734 | AddItem(_("- END -"), wxT("")); |
| 735 | |
| 736 | // Select the name in the list...this will fire an event. |
| 737 | if (mSelectedCommand >= (int)mList->GetItemCount()) { |
| 738 | mSelectedCommand = 0; |
| 739 | } |
| 740 | mList->SetItemState(mSelectedCommand, |
| 741 | wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED, |
| 742 | wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED); |
| 743 | if( 0 <= topItem && topItem < (int)mList->GetItemCount()) |
| 744 | { |
| 745 | // Workaround for scrolling being windows only. |
| 746 | // Try to scroll back to where we once were... |
| 747 | mList->EnsureVisible( (int)mList->GetItemCount() -1 ); |
| 748 | mList->EnsureVisible( topItem ); |
| 749 | // And then make sure whatever is selected is still visible... |
| 750 | if (mSelectedCommand >= 0) { |
| 751 | mList->EnsureVisible( mSelectedCommand ); |
| 752 | } |
| 753 | } |
| 754 | } |
| 755 | |
| 756 | /// Add one item into mList |
| 757 | void MacrosWindow::AddItem(const CommandID &Action, const wxString &Params) |
nothing calls this directly
no test coverage detected