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.

140 lines
4.6 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 (C) 1992-2012 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. /**
  25. * @file dialog_helpers.h
  26. * @brief Helper dialog and control classes.
  27. * @note Due to use of wxFormBuilder to create dialogs many of them should be removed.
  28. */
  29. #ifndef DIALOG_HELPERS_H_
  30. #define DIALOG_HELPERS_H_
  31. #include <../common/dialogs/eda_list_dialog_base.h>
  32. #include <common.h> // EDA_UNITS
  33. void ConvertMarkdown2Html( const wxString& aMarkdownInput, wxString& aHtmlOutput );
  34. class EDA_DRAW_FRAME;
  35. /**
  36. * EDA_LIST_DIALOG
  37. *
  38. * A dialog which shows:
  39. * a list of elements for selection,
  40. * a text control to display help or info about the selected item.
  41. * 2 buttons (OK and Cancel)
  42. *
  43. */
  44. class EDA_LIST_DIALOG : public EDA_LIST_DIALOG_BASE
  45. {
  46. public:
  47. /**
  48. * Constructor:
  49. * @param aParent Pointer to the parent window.
  50. * @param aTitle = The title shown on top.
  51. * @param aItemHeaders an optional array containing the column header names for the dialog.
  52. * @param aItemList = A wxArrayString of the list of elements.
  53. * @param aRefText = An item name if an item must be preselected.
  54. */
  55. EDA_LIST_DIALOG( EDA_DRAW_FRAME* aParent, const wxString& aTitle,
  56. const wxArrayString& aItemHeaders,
  57. const std::vector<wxArrayString>& aItemList,
  58. const wxString& aRefText );
  59. // ~EDA_LIST_DIALOG() {}
  60. void SetListLabel( const wxString& aLabel );
  61. void SetOKLabel( const wxString& aLabel );
  62. void Append( const wxArrayString& aItemStr );
  63. void InsertItems( const std::vector<wxArrayString>& aItemList, int aPosition = 0 );
  64. /**
  65. * Function GetTextSelection
  66. * return the selected text from \a aColumn in the wxListCtrl in the dialog.
  67. *
  68. * @param aColumn is the column to return the text from.
  69. * @return a wxString object containing the selected text from \a aColumn.
  70. */
  71. wxString GetTextSelection( int aColumn = 0 );
  72. private:
  73. void onListItemActivated( wxListEvent& event ) override;
  74. void textChangeInFilterBox(wxCommandEvent& event) override;
  75. void initDialog( const wxArrayString& aItemHeaders, const wxString& aSelection);
  76. void sortList();
  77. private:
  78. const std::vector<wxArrayString>* m_itemsList;
  79. };
  80. /**************************************************************************/
  81. /* Class to edit/enter a coordinate (pair of values) ( INCHES or MM ) in */
  82. /* dialog boxes, */
  83. /**************************************************************************/
  84. class EDA_POSITION_CTRL
  85. {
  86. public:
  87. EDA_UNITS m_UserUnit;
  88. wxTextCtrl* m_FramePosX;
  89. wxTextCtrl* m_FramePosY;
  90. private:
  91. wxStaticText* m_TextX, * m_TextY;
  92. public:
  93. EDA_POSITION_CTRL( wxWindow* parent, const wxString& title, const wxPoint& pos_to_edit,
  94. EDA_UNITS user_unit, wxBoxSizer* BoxSizer );
  95. ~EDA_POSITION_CTRL();
  96. void Enable( bool x_win_on, bool y_win_on );
  97. void SetValue( int x_value, int y_value );
  98. wxPoint GetValue();
  99. };
  100. /*************************************************************
  101. * Class to edit/enter a size (pair of values for X and Y size)
  102. * ( INCHES or MM ) in dialog boxes
  103. ***************************************************************/
  104. class EDA_SIZE_CTRL : public EDA_POSITION_CTRL
  105. {
  106. public:
  107. EDA_SIZE_CTRL( wxWindow* parent, const wxString& title, const wxSize& size_to_edit,
  108. EDA_UNITS user_unit, wxBoxSizer* BoxSizer );
  109. ~EDA_SIZE_CTRL() { }
  110. wxSize GetValue();
  111. };
  112. #endif // DIALOG_HELPERS_H_