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.

138 lines
5.2 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2020-2023 KiCad Developers, see AUTHORS.txt for contributors.
  5. *
  6. * This program is free software: you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License as published by the
  8. * Free Software Foundation, either version 3 of the License, or (at your
  9. * option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #ifndef _DIALOG_PAGES_SETTINGS_H_
  20. #define _DIALOG_PAGES_SETTINGS_H_
  21. #include <page_info.h>
  22. #include <title_block.h>
  23. #include <widgets/unit_binder.h>
  24. #include <widgets/std_bitmap_button.h>
  25. #include <dialog_page_settings_base.h>
  26. class DS_DATA_MODEL;
  27. /*!
  28. * DIALOG_PAGES_SETTINGS class declaration
  29. */
  30. class DIALOG_PAGES_SETTINGS: public DIALOG_PAGES_SETTINGS_BASE
  31. {
  32. public:
  33. DIALOG_PAGES_SETTINGS( EDA_DRAW_FRAME* aParent, double aIuPerMils,
  34. const VECTOR2D& aMaxUserSizeMils );
  35. virtual ~DIALOG_PAGES_SETTINGS();
  36. const wxString GetWksFileName()
  37. {
  38. return m_textCtrlFilePicker->GetValue();
  39. }
  40. void SetWksFileName(const wxString& aFilename )
  41. {
  42. m_textCtrlFilePicker->SetValue( aFilename );
  43. }
  44. void EnableWksFileNamePicker( bool aEnable )
  45. {
  46. m_textCtrlFilePicker->Enable( aEnable );
  47. m_browseButton->Enable( aEnable );
  48. }
  49. private:
  50. virtual void onTransferDataToWindow() {}
  51. virtual bool onSavePageSettings()
  52. {
  53. // default just return true savepagesettings to succeed
  54. return true;
  55. }
  56. virtual bool TransferDataToWindow() override;
  57. virtual bool TransferDataFromWindow() override;
  58. // event handlers for page size choice
  59. void OnPaperSizeChoice( wxCommandEvent& event ) override;
  60. void OnUserPageSizeXTextUpdated( wxCommandEvent& event ) override;
  61. void OnUserPageSizeYTextUpdated( wxCommandEvent& event ) override;
  62. void OnPageOrientationChoice( wxCommandEvent& event ) override;
  63. // event handler for texts in title block
  64. void OnRevisionTextUpdated( wxCommandEvent& event ) override;
  65. void OnDateTextUpdated( wxCommandEvent& event ) override;
  66. void OnTitleTextUpdated( wxCommandEvent& event ) override;
  67. void OnCompanyTextUpdated( wxCommandEvent& event ) override;
  68. void OnComment1TextUpdated( wxCommandEvent& event ) override;
  69. void OnComment2TextUpdated( wxCommandEvent& event ) override;
  70. void OnComment3TextUpdated( wxCommandEvent& event ) override;
  71. void OnComment4TextUpdated( wxCommandEvent& event ) override;
  72. void OnComment5TextUpdated( wxCommandEvent& event ) override;
  73. void OnComment6TextUpdated( wxCommandEvent& event ) override;
  74. void OnComment7TextUpdated( wxCommandEvent& event ) override;
  75. void OnComment8TextUpdated( wxCommandEvent& event ) override;
  76. void OnComment9TextUpdated( wxCommandEvent& event ) override;
  77. // Handle button click for setting the date from the picker
  78. void OnDateApplyClick( wxCommandEvent& event ) override;
  79. // .kicad_wks file description selection
  80. void OnWksFileSelection( wxCommandEvent& event ) override;
  81. // Save in the current title block the new page settings
  82. // return true if changes are made, or false if not
  83. bool SavePageSettings();
  84. void SetCurrentPageSizeSelection( const wxString& aPaperSize );
  85. // Update drawing sheet example
  86. void UpdateDrawingSheetExample();
  87. // Get page layout info from selected dialog items
  88. void GetPageLayoutInfoFromDialog();
  89. // Get custom page size in mils from dialog
  90. void GetCustomSizeMilsFromDialog();
  91. /// @return true if the local prj config is chande
  92. /// i.e. if the drawing sheet file has chnaged
  93. bool LocalPrjConfigChanged() { return m_localPrjConfigChanged; }
  94. protected:
  95. EDA_DRAW_FRAME* m_parent;
  96. BASE_SCREEN* m_screen;
  97. wxString m_projectPath; // the curr project path
  98. wxArrayString m_pageFmt; /// list of page sizes (not translated)
  99. bool m_initialized;
  100. bool m_localPrjConfigChanged; /// the page layuout filename was changed
  101. wxBitmap* m_pageBitmap; /// Temporary bitmap for the drawing sheet example.
  102. VECTOR2D m_layout_size; /// Logical drawing sheet size.
  103. VECTOR2D m_maxPageSizeMils; /// The max page size allowed by the caller frame
  104. PAGE_INFO m_pageInfo; /// Temporary page info.
  105. bool m_customFmt; /// true if the page selection is custom
  106. TITLE_BLOCK m_tb; /// Temporary title block (basic inscriptions).
  107. DS_DATA_MODEL* m_drawingSheet; // the alternate and temporary drawing sheet shown by the
  108. // dialog when the initial one is replaced by a new one
  109. double m_iuPerMils;
  110. private:
  111. UNIT_BINDER m_customSizeX;
  112. UNIT_BINDER m_customSizeY;
  113. };
  114. #endif // _DIALOG_PAGES_SETTINGS_H_