Define new event to post status text messages to a status bar; meant for child items to post information to the status bar that propagate up

This commit is contained in:
Joseph Lenox 2018-05-02 22:49:54 -05:00
parent 4d9d2c88dc
commit 434fc0aa2e
3 changed files with 46 additions and 0 deletions

View File

@ -186,6 +186,7 @@ IF(wxWidgets_FOUND)
${GUI_LIBDIR}/GUI.cpp ${GUI_LIBDIR}/GUI.cpp
${GUI_LIBDIR}/MainFrame.cpp ${GUI_LIBDIR}/MainFrame.cpp
${GUI_LIBDIR}/Plater.cpp ${GUI_LIBDIR}/Plater.cpp
${GUI_LIBDIR}/ProgressStatusBar.cpp
${GUI_LIBDIR}/Plater/Plate2D.cpp ${GUI_LIBDIR}/Plater/Plate2D.cpp
${GUI_LIBDIR}/Plater/PlaterObject.cpp ${GUI_LIBDIR}/Plater/PlaterObject.cpp
${GUI_LIBDIR}/Settings.cpp ${GUI_LIBDIR}/Settings.cpp

View File

@ -0,0 +1,10 @@
#include "ProgressStatusBar.hpp"
namespace Slic3r { namespace GUI {
void ProgressStatusBar::SendStatusText(wxEvtHandler* dest, wxWindowID origin, const wxString& msg) {
wxQueueEvent(dest, new StatusTextEvent(EVT_STATUS_TEXT_POST, origin, msg));
}
}} // Namespace Slic3r::GUI

View File

@ -0,0 +1,35 @@
#ifndef PROGRESSSTATUSBAR_HPP
#define PROGRESSSTATUSBAR_HPP
#include <wx/event.h>
#include <wx/statusbr.h>
namespace Slic3r { namespace GUI {
class StatusTextEvent : public wxEvent {
public:
StatusTextEvent(wxEventType eventType, int winid, const wxString& msg)
: wxEvent(winid, eventType),
message(msg) { }
bool ShouldPropagate() const { return true; } // propagate this event
/// One accessor
const wxString& GetMessage() const {return message;}
/// implement the base class pure virtual
virtual wxEvent *Clone() const { return new StatusTextEvent(*this); }
private:
const wxString message;
};
wxDEFINE_EVENT(EVT_STATUS_TEXT_POST, StatusTextEvent);
class ProgressStatusBar : public wxStatusBar {
public:
//< Post an event to owning box and let it percolate up to a window that sets the appropriate status text.
static void SendStatusText(wxEvtHandler* dest, wxWindowID origin, const wxString& msg);
ProgressStatusBar(wxWindow* parent, int id) : wxStatusBar(parent, id) { }
};
}} // Namespace Slic3r::GUI
#endif // PROGRESSSTATUSBAR_HPP