WX_STATUS_POPUP refactor

- Rename WX_STATUS_POPUP -> STATUS_POPUP
- Added Expire() to show a popup temporarily
- Code formatting
This commit is contained in:
Maciej Suminski 2018-02-19 12:09:40 +01:00
parent 7775f59eec
commit 9673ac4ecd
5 changed files with 56 additions and 36 deletions

View File

@ -294,6 +294,7 @@ set( COMMON_SRCS
searchhelpfilefullpath.cpp searchhelpfilefullpath.cpp
selcolor.cpp selcolor.cpp
settings.cpp settings.cpp
status_popup.cpp
systemdirsappend.cpp systemdirsappend.cpp
trigo.cpp trigo.cpp
undo_redo_container.cpp undo_redo_container.cpp
@ -301,7 +302,6 @@ set( COMMON_SRCS
validators.cpp validators.cpp
wildcards_and_files_ext.cpp wildcards_and_files_ext.cpp
worksheet.cpp worksheet.cpp
wx_status_popup.cpp
wxdataviewctrl_helpers.cpp wxdataviewctrl_helpers.cpp
xnode.cpp xnode.cpp
zoom.cpp zoom.cpp

View File

@ -26,40 +26,50 @@
* Transient mouse following popup window implementation. * Transient mouse following popup window implementation.
*/ */
#include <wx_status_popup.h> #include <status_popup.h>
#include <pcb_edit_frame.h> #include <draw_frame.h>
WX_STATUS_POPUP::WX_STATUS_POPUP( PCB_EDIT_FRAME* aParent ) : STATUS_POPUP::STATUS_POPUP( EDA_DRAW_FRAME* aParent ) :
wxPopupWindow( aParent ) wxPopupWindow( aParent ), m_expireTimer( this )
{ {
m_panel = new wxPanel( this, wxID_ANY ); m_panel = new wxPanel( this, wxID_ANY );
m_panel->SetBackgroundColour( *wxLIGHT_GREY ); m_panel->SetBackgroundColour( *wxLIGHT_GREY );
m_topSizer = new wxBoxSizer( wxVERTICAL ); m_topSizer = new wxBoxSizer( wxVERTICAL );
m_panel->SetSizer( m_topSizer ); m_panel->SetSizer( m_topSizer );
m_panel->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW ) );
Connect( wxEVT_TIMER, wxTimerEventHandler( STATUS_POPUP::onExpire ), NULL, this );
} }
void WX_STATUS_POPUP::updateSize() void STATUS_POPUP::Popup( wxWindow* )
{
m_topSizer->Fit( m_panel );
SetClientSize( m_panel->GetSize() );
}
WX_STATUS_POPUP::~WX_STATUS_POPUP()
{
}
void WX_STATUS_POPUP::Popup( wxWindow* )
{ {
Show( true ); Show( true );
Raise(); Raise();
} }
void WX_STATUS_POPUP::Move( const wxPoint& aWhere ) void STATUS_POPUP::Move( const wxPoint& aWhere )
{ {
SetPosition ( aWhere ); SetPosition( aWhere );
}
void STATUS_POPUP::Expire( int aMsecs )
{
m_expireTimer.StartOnce( aMsecs );
}
void STATUS_POPUP::updateSize()
{
m_topSizer->Fit( m_panel );
SetClientSize( m_panel->GetSize() );
}
void STATUS_POPUP::onExpire( wxTimerEvent& aEvent )
{
Hide();
} }

View File

@ -22,37 +22,47 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#ifndef __WX_STATUS_POPUP_H_ #ifndef __STATUS_POPUP_H_
#define __WX_STATUS_POPUP_H_ #define __STATUS_POPUP_H_
#include <common.h> #include <common.h>
#include <wx/popupwin.h> #include <wx/popupwin.h>
class PCB_EDIT_FRAME; class EDA_DRAW_FRAME;
/** /**
* Class WX_STATUS_POPUP * Class STATUS_POPUP
* *
* A tiny, headerless popup window used to display useful status (e.g. line length * A tiny, headerless popup window used to display useful status (e.g. line length
* tuning info) next to the mouse cursor. * tuning info) next to the mouse cursor.
*/ */
class WX_STATUS_POPUP: public wxPopupWindow class STATUS_POPUP: public wxPopupWindow
{ {
public: public:
WX_STATUS_POPUP( PCB_EDIT_FRAME* aParent ); STATUS_POPUP( EDA_DRAW_FRAME* aParent );
virtual ~WX_STATUS_POPUP(); virtual ~STATUS_POPUP() {}
virtual void Popup(wxWindow* aFocus = NULL); virtual void Popup( wxWindow* aFocus = nullptr );
virtual void Move( const wxPoint &aWhere ); virtual void Move( const wxPoint &aWhere );
protected: /**
* Hides the popup after a specified time.
*
* @param aMsecs is the time expressed in milliseconds
*/
void Expire( int aMsecs );
protected:
void updateSize(); void updateSize();
///> Expire timer even handler
void onExpire( wxTimerEvent& aEvent );
wxPanel* m_panel; wxPanel* m_panel;
wxBoxSizer* m_topSizer; wxBoxSizer* m_topSizer;
wxTimer m_expireTimer;
}; };
#endif /* __WX_STATUS_POPUP_H_*/ #endif /* __STATUS_POPUP_H_*/

View File

@ -23,8 +23,8 @@
#include "pns_router.h" #include "pns_router.h"
#include "pns_meander_placer.h" #include "pns_meander_placer.h"
PNS_TUNE_STATUS_POPUP::PNS_TUNE_STATUS_POPUP( PCB_EDIT_FRAME* aParent ) : PNS_TUNE_STATUS_POPUP::PNS_TUNE_STATUS_POPUP( EDA_DRAW_FRAME* aParent ) :
WX_STATUS_POPUP( aParent ) STATUS_POPUP( aParent )
{ {
m_panel->SetBackgroundColour( wxColour( 64, 64, 64 ) ); m_panel->SetBackgroundColour( wxColour( 64, 64, 64 ) );
m_statusLine = new wxStaticText( m_panel, wxID_ANY, wxEmptyString ) ; m_statusLine = new wxStaticText( m_panel, wxID_ANY, wxEmptyString ) ;

View File

@ -26,7 +26,7 @@
#ifndef __PNS_TUNE_STATUS_POPUP_H_ #ifndef __PNS_TUNE_STATUS_POPUP_H_
#define __PNS_TUNE_STATUS_POPUP_H_ #define __PNS_TUNE_STATUS_POPUP_H_
#include <wx_status_popup.h> #include <status_popup.h>
namespace PNS { namespace PNS {
@ -34,11 +34,11 @@ class ROUTER;
} }
class PNS_TUNE_STATUS_POPUP : public WX_STATUS_POPUP class PNS_TUNE_STATUS_POPUP : public STATUS_POPUP
{ {
public: public:
PNS_TUNE_STATUS_POPUP( PCB_EDIT_FRAME* aParent ); PNS_TUNE_STATUS_POPUP( EDA_DRAW_FRAME* aParent );
~PNS_TUNE_STATUS_POPUP(); ~PNS_TUNE_STATUS_POPUP();
void UpdateStatus( PNS::ROUTER* aRouter ); void UpdateStatus( PNS::ROUTER* aRouter );