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.

109 lines
3.3 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version 2
  9. * of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, you may find one here:
  18. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  19. * or you may search the http://www.gnu.org website for the version 2 license,
  20. * or you may write to the Free Software Foundation, Inc.,
  21. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  22. */
  23. #ifndef CLI_PROGRESS_REPORTER_H
  24. #define CLI_PROGRESS_REPORTER_H
  25. #include <wx/string.h>
  26. #include <progress_reporter.h>
  27. #include <kicommon.h>
  28. /**
  29. * Reporter forwarding messages to stdout or stderr as appropriate
  30. */
  31. class KICOMMON_API CLI_PROGRESS_REPORTER : public PROGRESS_REPORTER
  32. {
  33. public:
  34. CLI_PROGRESS_REPORTER() {}
  35. virtual ~CLI_PROGRESS_REPORTER() {}
  36. static PROGRESS_REPORTER& GetInstance();
  37. /**
  38. * Set the number of phases.
  39. */
  40. virtual void SetNumPhases( int aNumPhases ) override {}
  41. virtual void AddPhases( int aNumPhases ) override {};
  42. /**
  43. * Initialize the \a aPhase virtual zone of the dialog progress bar.
  44. */
  45. virtual void BeginPhase( int aPhase ) override {}
  46. /**
  47. * Use the next available virtual zone of the dialog progress bar.
  48. */
  49. virtual void AdvancePhase() override {}
  50. /**
  51. * Use the next available virtual zone of the dialog progress bar and updates the message.
  52. */
  53. virtual void AdvancePhase( const wxString& aMessage ) override;
  54. /**
  55. * Display \a aMessage in the progress bar dialog.
  56. */
  57. virtual void Report( const wxString& aMessage ) override;
  58. /**
  59. * Set the progress value to aProgress (0..1).
  60. */
  61. virtual void SetCurrentProgress( double aProgress ) override {}
  62. /**
  63. * Fix the value that gives the 100 percent progress bar length
  64. * (inside the current virtual zone).
  65. */
  66. virtual void SetMaxProgress( int aMaxProgress ) override {}
  67. /**
  68. * Increment the progress bar length (inside the current virtual zone).
  69. */
  70. virtual void AdvanceProgress() override {}
  71. /**
  72. * Update the UI (if any).
  73. *
  74. * @warning This should only be called from the main thread.
  75. *
  76. * @return false if the user cancelled.
  77. */
  78. virtual bool KeepRefreshing( bool aWait = false ) override { return false; }
  79. /**
  80. * Change the title displayed on the window caption.
  81. *
  82. * Has meaning only for some reporters. Does nothing for others.
  83. *
  84. * @warning This should only be called from the main thread.
  85. */
  86. virtual void SetTitle( const wxString& aTitle ) override {}
  87. virtual bool IsCancelled() const override { return false; }
  88. private:
  89. void printLine( const wxString& aMessage );
  90. };
  91. #endif