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.

112 lines
3.4 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2017 CERN
  5. * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
  6. *
  7. * Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
  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. #ifndef PROGRESS_REPORTER_H
  27. #define PROGRESS_REPORTER_H
  28. /**
  29. * A progress reporter interface for use in multi-threaded environments. The various advancement
  30. * and message methods can be called from sub-threads. The KeepRefreshing method *MUST* be called
  31. * only from the main thread (primarily a MSW requirement, which won't allow access to UI objects
  32. * allocated from a separate thread).
  33. */
  34. class PROGRESS_REPORTER
  35. {
  36. public:
  37. PROGRESS_REPORTER()
  38. { }
  39. PROGRESS_REPORTER( const PROGRESS_REPORTER& ) = delete;
  40. virtual ~PROGRESS_REPORTER()
  41. { }
  42. /**
  43. * Set the number of phases.
  44. */
  45. virtual void SetNumPhases( int aNumPhases ) = 0;
  46. virtual void AddPhases( int aNumPhases ) = 0;
  47. /**
  48. * Initialize the \a aPhase virtual zone of the dialog progress bar.
  49. */
  50. virtual void BeginPhase( int aPhase ) = 0;
  51. /**
  52. * Use the next available virtual zone of the dialog progress bar.
  53. */
  54. virtual void AdvancePhase() = 0;
  55. /**
  56. * Use the next available virtual zone of the dialog progress bar and updates the message.
  57. */
  58. virtual void AdvancePhase( const wxString& aMessage ) = 0;
  59. /**
  60. * Display \a aMessage in the progress bar dialog.
  61. */
  62. virtual void Report( const wxString& aMessage ) = 0;
  63. /**
  64. * Set the progress value to aProgress (0..1).
  65. */
  66. virtual void SetCurrentProgress( double aProgress ) = 0;
  67. /**
  68. * Fix the value that gives the 100 percent progress bar length
  69. * (inside the current virtual zone).
  70. */
  71. virtual void SetMaxProgress( int aMaxProgress ) = 0;
  72. /**
  73. * Increment the progress bar length (inside the current virtual zone).
  74. */
  75. virtual void AdvanceProgress() = 0;
  76. /**
  77. * Update the UI (if any).
  78. *
  79. * @warning This should only be called from the main thread.
  80. *
  81. * @return false if the user cancelled.
  82. */
  83. virtual bool KeepRefreshing( bool aWait = false ) = 0;
  84. /**
  85. * Change the title displayed on the window caption.
  86. *
  87. * Has meaning only for some reporters. Does nothing for others.
  88. *
  89. * @warning This should only be called from the main thread.
  90. */
  91. virtual void SetTitle( const wxString& aTitle ) = 0;
  92. virtual bool IsCancelled() const = 0;
  93. };
  94. #endif