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.

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