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
selcolor.cpp
settings.cpp
status_popup.cpp
systemdirsappend.cpp
trigo.cpp
undo_redo_container.cpp
@ -301,7 +302,6 @@ set( COMMON_SRCS
validators.cpp
wildcards_and_files_ext.cpp
worksheet.cpp
wx_status_popup.cpp
wxdataviewctrl_helpers.cpp
xnode.cpp
zoom.cpp

View File

@ -26,40 +26,50 @@
* Transient mouse following popup window implementation.
*/
#include <wx_status_popup.h>
#include <pcb_edit_frame.h>
#include <status_popup.h>
#include <draw_frame.h>
WX_STATUS_POPUP::WX_STATUS_POPUP( PCB_EDIT_FRAME* aParent ) :
wxPopupWindow( aParent )
STATUS_POPUP::STATUS_POPUP( EDA_DRAW_FRAME* aParent ) :
wxPopupWindow( aParent ), m_expireTimer( this )
{
m_panel = new wxPanel( this, wxID_ANY );
m_panel->SetBackgroundColour( *wxLIGHT_GREY );
m_topSizer = new wxBoxSizer( wxVERTICAL );
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()
{
m_topSizer->Fit( m_panel );
SetClientSize( m_panel->GetSize() );
}
WX_STATUS_POPUP::~WX_STATUS_POPUP()
{
}
void WX_STATUS_POPUP::Popup( wxWindow* )
void STATUS_POPUP::Popup( wxWindow* )
{
Show( true );
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
*/
#ifndef __WX_STATUS_POPUP_H_
#define __WX_STATUS_POPUP_H_
#ifndef __STATUS_POPUP_H_
#define __STATUS_POPUP_H_
#include <common.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
* tuning info) next to the mouse cursor.
*/
class WX_STATUS_POPUP: public wxPopupWindow
class STATUS_POPUP: public wxPopupWindow
{
public:
WX_STATUS_POPUP( PCB_EDIT_FRAME* aParent );
virtual ~WX_STATUS_POPUP();
STATUS_POPUP( EDA_DRAW_FRAME* aParent );
virtual ~STATUS_POPUP() {}
virtual void Popup(wxWindow* aFocus = NULL);
virtual void Popup( wxWindow* aFocus = nullptr );
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();
///> Expire timer even handler
void onExpire( wxTimerEvent& aEvent );
wxPanel* m_panel;
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_meander_placer.h"
PNS_TUNE_STATUS_POPUP::PNS_TUNE_STATUS_POPUP( PCB_EDIT_FRAME* aParent ) :
WX_STATUS_POPUP( aParent )
PNS_TUNE_STATUS_POPUP::PNS_TUNE_STATUS_POPUP( EDA_DRAW_FRAME* aParent ) :
STATUS_POPUP( aParent )
{
m_panel->SetBackgroundColour( wxColour( 64, 64, 64 ) );
m_statusLine = new wxStaticText( m_panel, wxID_ANY, wxEmptyString ) ;

View File

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