1 #ifndef PROGRESSSTATUSBAR_HPP
2 #define PROGRESSSTATUSBAR_HPP
3 
4 #include <memory>
5 #include <string>
6 #include <functional>
7 #include <string>
8 
9 #include "Jobs/ProgressIndicator.hpp"
10 
11 class wxTimer;
12 class wxGauge;
13 class wxButton;
14 class wxTimerEvent;
15 class wxStatusBar;
16 class wxWindow;
17 class wxFrame;
18 class wxString;
19 class wxFont;
20 
21 namespace Slic3r {
22 
23 /**
24  * @brief The ProgressStatusBar class is the widgets occupying the lower area
25  * of the Slicer main window. It consists of a message area to the left and a
26  * progress indication area to the right with an optional cancel button.
27  */
28 class ProgressStatusBar : public ProgressIndicator
29 {
30     wxStatusBar *self;      // we cheat! It should be the base class but: perl!
31     wxGauge *m_prog;
32     wxButton *m_cancelbutton;
33     std::unique_ptr<wxTimer> m_timer;
34 public:
35 
36 
37     ProgressStatusBar(wxWindow *parent = nullptr, int id = -1);
38     ~ProgressStatusBar() override;
39 
40     int         get_progress() const;
41     // if the argument is less than 0 it shows the last state or
42     // pulses if no state was set before.
43     void        set_progress(int) override;
44     int         get_range() const override;
45     void        set_range(int = 100) override;
46     void        show_progress(bool);
47     void        start_busy(int = 100);
48     void        stop_busy();
is_busy() const49     inline bool is_busy() const { return m_busy; }
50     void        set_cancel_callback(CancelFn = CancelFn()) override;
reset_cancel_callback()51     inline void reset_cancel_callback() { set_cancel_callback(); }
52     void        run(int rate);
53     void        embed(wxFrame *frame = nullptr);
54     void        set_status_text(const wxString& txt);
55     void        set_status_text(const std::string& txt);
56     void        set_status_text(const char *txt) override;
57     wxString    get_status_text() const;
58     void        set_font(const wxFont &font);
59 
60     // Temporary methods to satisfy Perl side
61     void        show_cancel_button();
62     void        hide_cancel_button();
63 
64 private:
65     bool m_busy = false;
66     CancelFn m_cancel_cb;
67 };
68 
69 namespace GUI {
70     using Slic3r::ProgressStatusBar;
71 }
72 
73 }
74 
75 #endif // PROGRESSSTATUSBAR_HPP
76