You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

96 lines
3.3 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2010 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
  5. * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version 2
  10. * of the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, you may find one here:
  19. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  20. * or you may search the http://www.gnu.org website for the version 2 license,
  21. * or you may write to the Free Software Foundation, Inc.,
  22. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  23. */
  24. #ifndef EDA_LIST_DIALOG_H
  25. #define EDA_LIST_DIALOG_H
  26. #include <../common/dialogs/eda_list_dialog_base.h>
  27. class EDA_DRAW_FRAME;
  28. /**
  29. * A dialog which shows:
  30. * - a list of elements for selection,
  31. * - a text control to display help or info about the selected item.
  32. * - 2 buttons (OK and Cancel)
  33. *
  34. */
  35. class EDA_LIST_DIALOG : public EDA_LIST_DIALOG_BASE
  36. {
  37. public:
  38. /**
  39. * @param aParent Pointer to the parent window.
  40. * @param aTitle The title shown on top.
  41. * @param aItemHeaders an optional array containing the column header names for the dialog.
  42. * @param aItemList A wxArrayString of the list of elements.
  43. * @param aPreselectText An item name if an item must be preselected.
  44. */
  45. EDA_LIST_DIALOG( wxWindow* aParent, const wxString& aTitle, const wxArrayString& aItemHeaders,
  46. const std::vector<wxArrayString>& aItemList,
  47. const wxString& aPreselectText = wxEmptyString,
  48. bool aSortList = true );
  49. EDA_LIST_DIALOG( wxWindow* aParent, const wxString& aTitle, bool aSortList = true );
  50. void SetListLabel( const wxString& aLabel );
  51. void SetOKLabel( const wxString& aLabel );
  52. void HideFilter();
  53. void Append( const wxArrayString& aItemStr );
  54. void InsertItems( const std::vector<wxArrayString>& aItemList, int aPosition = 0 );
  55. /**
  56. * Return the selected text from \a aColumn in the wxListCtrl in the dialog.
  57. *
  58. * @param aColumn is the column to return the text from.
  59. * @return the selected text from \a aColumn.
  60. */
  61. wxString GetTextSelection( int aColumn = 0 );
  62. long GetSelection();
  63. bool Show( bool show ) override;
  64. protected:
  65. void initDialog( const wxArrayString& aItemHeaders, const std::vector<wxArrayString>& aItemList,
  66. const wxString& aPreselectText);
  67. private:
  68. virtual void onSize( wxSizeEvent& event ) override;
  69. void onListItemActivated( wxListEvent& event ) override;
  70. void textChangeInFilterBox(wxCommandEvent& event) override;
  71. void sortList();
  72. private:
  73. // The list of items, locally stored
  74. std::vector<wxArrayString> m_itemsList;
  75. bool m_sortList;
  76. };
  77. #endif // EDA_LIST_DIALOG_H