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.

132 lines
3.5 KiB

  1. #ifndef DIALOG_EDIT_ONE_FIELD_H_
  2. #define DIALOG_EDIT_ONE_FIELD_H_
  3. /*
  4. * This program source code file is part of KiCad, a free EDA CAD application.
  5. *
  6. * Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@gipsa-lab.inpg.com
  7. * Copyright (C) 2004-2012 KiCad Developers, see change_log.txt for contributors.
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; either version 2
  12. * of the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, you may find one here:
  21. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  22. * or you may search the http://www.gnu.org website for the version 2 license,
  23. * or you may write to the Free Software Foundation, Inc.,
  24. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  25. */
  26. #include <dialog_lib_edit_text_base.h>
  27. class SCH_BASE_FRAME;
  28. class LIB_FIELD;
  29. class SCH_FIELD;
  30. // Basic class to edit a field: a schematic or a lib component field
  31. class DIALOG_EDIT_ONE_FIELD : public DIALOG_LIB_EDIT_TEXT_BASE
  32. {
  33. protected:
  34. SCH_BASE_FRAME* m_parent;
  35. int m_textshape;
  36. int m_textsize;
  37. int m_textorient;
  38. EDA_TEXT_HJUSTIFY_T m_textHjustify;
  39. EDA_TEXT_VJUSTIFY_T m_textVjustify;
  40. bool m_text_invisible;
  41. public:
  42. DIALOG_EDIT_ONE_FIELD( SCH_BASE_FRAME* aParent, const wxString& aTitle ):
  43. DIALOG_LIB_EDIT_TEXT_BASE( aParent )
  44. {
  45. m_parent = aParent;
  46. SetTitle( aTitle );
  47. }
  48. // ~DIALOG_EDIT_ONE_FIELD() {};
  49. virtual void TransfertDataToField();
  50. void SetTextField( const wxString& aText )
  51. {
  52. m_TextValue->SetValue( aText );
  53. }
  54. protected:
  55. void initDlg_base( );
  56. void OnOkClick( wxCommandEvent& aEvent )
  57. {
  58. EndModal(wxID_OK);
  59. }
  60. void OnCancelClick( wxCommandEvent& aEvent )
  61. {
  62. EndModal(wxID_CANCEL);
  63. }
  64. };
  65. // Class to edit a lib component field
  66. class DIALOG_LIB_EDIT_ONE_FIELD : public DIALOG_EDIT_ONE_FIELD
  67. {
  68. private:
  69. LIB_FIELD* m_field;
  70. public:
  71. DIALOG_LIB_EDIT_ONE_FIELD( SCH_BASE_FRAME* aParent, const wxString& aTitle,
  72. LIB_FIELD* aField ):
  73. DIALOG_EDIT_ONE_FIELD( aParent, aTitle )
  74. {
  75. m_field = aField;
  76. initDlg();
  77. GetSizer()->SetSizeHints(this);
  78. Centre();
  79. }
  80. ~DIALOG_LIB_EDIT_ONE_FIELD() {};
  81. void TransfertDataToField();
  82. wxString GetTextField();
  83. private:
  84. void initDlg( );
  85. };
  86. // Class to edit a schematic component field
  87. class DIALOG_SCH_EDIT_ONE_FIELD : public DIALOG_EDIT_ONE_FIELD
  88. {
  89. private:
  90. SCH_FIELD* m_field;
  91. public:
  92. DIALOG_SCH_EDIT_ONE_FIELD( SCH_BASE_FRAME* aParent,
  93. const wxString& aTitle, SCH_FIELD* aField ):
  94. DIALOG_EDIT_ONE_FIELD( aParent, aTitle )
  95. {
  96. m_field = aField;
  97. initDlg();
  98. GetSizer()->SetSizeHints(this);
  99. Centre();
  100. }
  101. // ~DIALOG_SCH_EDIT_ONE_FIELD() {};
  102. void TransfertDataToField();
  103. wxString GetTextField();
  104. private:
  105. void initDlg( );
  106. };
  107. #endif // DIALOG_EDIT_ONE_FIELD_H_