From 7129dcef91f95bda311d6812ba1bac347ff4a2ae Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Mon, 19 Feb 2018 12:19:58 +0100 Subject: [PATCH] Added STATUS_TEXT_POPUP for simple popup text display --- common/status_popup.cpp | 21 +++++++++++++++++++ include/status_popup.h | 28 +++++++++++++++++++++++++ pcbnew/router/pns_tune_status_popup.cpp | 23 +++++--------------- pcbnew/router/pns_tune_status_popup.h | 6 +----- 4 files changed, 55 insertions(+), 23 deletions(-) diff --git a/common/status_popup.cpp b/common/status_popup.cpp index 80a9ffe555..5ba303a775 100644 --- a/common/status_popup.cpp +++ b/common/status_popup.cpp @@ -73,3 +73,24 @@ void STATUS_POPUP::onExpire( wxTimerEvent& aEvent ) { Hide(); } + + +STATUS_TEXT_POPUP::STATUS_TEXT_POPUP( EDA_DRAW_FRAME* aParent ) : + STATUS_POPUP( aParent ) +{ + m_statusLine = new wxStaticText( m_panel, wxID_ANY, wxEmptyString ) ; + m_topSizer->Add( m_statusLine, 1, wxALL | wxEXPAND, 5 ); +} + + +void STATUS_TEXT_POPUP::SetText( const wxString& aText ) +{ + m_statusLine->SetLabel( aText ); + updateSize(); +} + + +void STATUS_TEXT_POPUP::SetTextColor( const wxColour& aColor ) +{ + m_statusLine->SetForegroundColour( aColor ); +} diff --git a/include/status_popup.h b/include/status_popup.h index 65bb21bf7c..9fbdb3087f 100644 --- a/include/status_popup.h +++ b/include/status_popup.h @@ -65,4 +65,32 @@ protected: wxTimer m_expireTimer; }; + +/** + * Class STATUS_TEXT_POPUP + * + * Extension of STATUS_POPUP, displaying a single line text. + */ +class STATUS_TEXT_POPUP : public STATUS_POPUP +{ +public: + STATUS_TEXT_POPUP( EDA_DRAW_FRAME* aParent ); + virtual ~STATUS_TEXT_POPUP() {} + + /** + * Display a text. + * @param aText is the text to be displayed. + */ + void SetText( const wxString& aText ); + + /** + * Change text color. + * @param aColor is the new text color. + */ + void SetTextColor( const wxColour& aColor ); + +protected: + wxStaticText* m_statusLine; +}; + #endif /* __STATUS_POPUP_H_*/ diff --git a/pcbnew/router/pns_tune_status_popup.cpp b/pcbnew/router/pns_tune_status_popup.cpp index b3ab3524cc..bb58b8a481 100644 --- a/pcbnew/router/pns_tune_status_popup.cpp +++ b/pcbnew/router/pns_tune_status_popup.cpp @@ -24,16 +24,9 @@ #include "pns_meander_placer.h" PNS_TUNE_STATUS_POPUP::PNS_TUNE_STATUS_POPUP( EDA_DRAW_FRAME* aParent ) : - STATUS_POPUP( aParent ) + STATUS_TEXT_POPUP( aParent ) { m_panel->SetBackgroundColour( wxColour( 64, 64, 64 ) ); - m_statusLine = new wxStaticText( m_panel, wxID_ANY, wxEmptyString ) ; - m_topSizer->Add( m_statusLine, 1, wxALL | wxEXPAND, 5 ); -} - - -PNS_TUNE_STATUS_POPUP::~PNS_TUNE_STATUS_POPUP() -{ } @@ -44,25 +37,19 @@ void PNS_TUNE_STATUS_POPUP::UpdateStatus( PNS::ROUTER* aRouter ) if( !placer ) return; - m_statusLine->SetLabel( placer->TuningInfo() ); - - wxColour color; + SetText( placer->TuningInfo() ); switch( placer->TuningStatus() ) { case PNS::MEANDER_PLACER::TUNED: - color = wxColour( 0, 255, 0 ); + SetTextColor( wxColour( 0, 255, 0 ) ); break; case PNS::MEANDER_PLACER::TOO_SHORT: - color = wxColour( 255, 128, 128 ); + SetTextColor( wxColour( 255, 128, 128 ) ); break; case PNS::MEANDER_PLACER::TOO_LONG: - color = wxColour( 128, 128, 255 ); + SetTextColor( wxColour( 128, 128, 255 ) ); break; } - - m_statusLine->SetForegroundColour( color ); - - updateSize(); } diff --git a/pcbnew/router/pns_tune_status_popup.h b/pcbnew/router/pns_tune_status_popup.h index 471c99bb0a..76c5c79b7c 100644 --- a/pcbnew/router/pns_tune_status_popup.h +++ b/pcbnew/router/pns_tune_status_popup.h @@ -34,16 +34,12 @@ class ROUTER; } -class PNS_TUNE_STATUS_POPUP : public STATUS_POPUP +class PNS_TUNE_STATUS_POPUP : public STATUS_TEXT_POPUP { public: PNS_TUNE_STATUS_POPUP( EDA_DRAW_FRAME* aParent ); - ~PNS_TUNE_STATUS_POPUP(); void UpdateStatus( PNS::ROUTER* aRouter ); - -private: - wxStaticText* m_statusLine; }; #endif /* __PNS_TUNE_STATUS_POPUP_H_*/