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.

82 lines
2.9 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2007 Jean-Pierre Charras, jp.charras at wanadoo.fr
  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. /**
  25. * This file is part of the common library.
  26. *
  27. * @file kidialog.h
  28. * @see common.h
  29. */
  30. #ifndef KIDIALOG_H_
  31. #define KIDIALOG_H_
  32. #include <kicommon.h>
  33. #include <wx/richmsgdlg.h>
  34. /**
  35. * Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.
  36. */
  37. class KICOMMON_API KIDIALOG : public wxRichMessageDialog
  38. {
  39. public:
  40. ///< Dialog type. Selects appropriate icon and default dialog title
  41. enum KD_TYPE { KD_NONE, KD_INFO, KD_QUESTION, KD_WARNING, KD_ERROR };
  42. KIDIALOG( wxWindow* aParent, const wxString& aMessage, const wxString& aCaption,
  43. long aStyle = wxOK );
  44. KIDIALOG( wxWindow* aParent, const wxString& aMessage, KD_TYPE aType,
  45. const wxString& aCaption = "" );
  46. bool SetOKCancelLabels( const ButtonLabel& ok, const ButtonLabel& cancel ) override
  47. {
  48. m_cancelMeansCancel = false;
  49. return wxRichMessageDialog::SetOKCancelLabels( ok, cancel );
  50. }
  51. /// Shows the 'do not show again' checkbox.
  52. void DoNotShowCheckbox( wxString file, int line );
  53. /// Checks the 'do not show again' setting for the dialog.
  54. bool DoNotShowAgain() const;
  55. void ForceShowAgain();
  56. bool Show( bool aShow = true ) override;
  57. int ShowModal() override;
  58. protected:
  59. // Helper functions for wxRichMessageDialog constructor
  60. static wxString getCaption( KD_TYPE aType, const wxString& aCaption );
  61. static long getStyle( KD_TYPE aType );
  62. protected:
  63. unsigned long m_hash; // Unique id
  64. bool m_cancelMeansCancel; // If the Cancel button is renamed then it should be
  65. // saved by the DoNotShowAgain checkbox. If it's really
  66. // a cancel then it should not.
  67. };
  68. #endif /* KIDIALOG_H_ */