KiCad PCB EDA Suite
STATUS_POPUP Class Reference

A tiny, headerless popup window used to display useful status (e.g. More...

#include <status_popup.h>

Inheritance diagram for STATUS_POPUP:
STATUS_TEXT_POPUP PNS_TUNE_STATUS_POPUP

Public Member Functions

 STATUS_POPUP (wxWindow *aParent)
 Transient mouse following popup window implementation. More...
 
virtual ~STATUS_POPUP ()
 
virtual void Popup (wxWindow *aFocus=nullptr)
 
virtual void PopupFor (int aMsecs)
 
virtual void Move (const wxPoint &aWhere)
 
virtual void Move (const VECTOR2I &aWhere)
 
void Expire (int aMsecs)
 Hide the popup after a specified time. More...
 

Protected Member Functions

void updateSize ()
 
void onCharHook (wxKeyEvent &aEvent)
 Expire timer even handler. More...
 
void onExpire (wxTimerEvent &aEvent)
 

Protected Attributes

wxPanel * m_panel
 
wxBoxSizer * m_topSizer
 
wxTimer m_expireTimer
 

Detailed Description

A tiny, headerless popup window used to display useful status (e.g.

line length tuning info) next to the mouse cursor.

Definition at line 44 of file status_popup.h.

Constructor & Destructor Documentation

◆ STATUS_POPUP()

STATUS_POPUP::STATUS_POPUP ( wxWindow *  aParent)

Transient mouse following popup window implementation.

Definition at line 34 of file status_popup.cpp.

34  :
35  wxPopupWindow( aParent ),
36  m_expireTimer( this )
37 {
38  m_panel = new wxPanel( this, wxID_ANY );
39  m_topSizer = new wxBoxSizer( wxVERTICAL );
40  m_panel->SetSizer( m_topSizer );
41  m_panel->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW ) );
42 
43  Connect( wxEVT_TIMER, wxTimerEventHandler( STATUS_POPUP::onExpire ), nullptr, this );
44 
45 #ifdef __WXOSX_MAC__
46  // Key events from popups don't get put through the wxWidgets event system on OSX,
47  // so we have to fall back to the CHAR_HOOK to forward hotkeys from the popup to
48  // the canvas / frame.
49  Connect( wxEVT_CHAR_HOOK, wxKeyEventHandler( STATUS_POPUP::onCharHook ), nullptr, this );
50 #endif
51 }
void onExpire(wxTimerEvent &aEvent)
wxPanel * m_panel
Definition: status_popup.h:70
void onCharHook(wxKeyEvent &aEvent)
Expire timer even handler.
wxTimer m_expireTimer
Definition: status_popup.h:72
wxBoxSizer * m_topSizer
Definition: status_popup.h:71

References m_panel, m_topSizer, onCharHook(), and onExpire().

◆ ~STATUS_POPUP()

virtual STATUS_POPUP::~STATUS_POPUP ( )
inlinevirtual

Definition at line 48 of file status_popup.h.

48 {}

Member Function Documentation

◆ Expire()

void STATUS_POPUP::Expire ( int  aMsecs)

Hide the popup after a specified time.

Parameters
aMsecsis the time expressed in milliseconds

Definition at line 96 of file status_popup.cpp.

97 {
98  m_expireTimer.StartOnce( aMsecs );
99 }
wxTimer m_expireTimer
Definition: status_popup.h:72

References m_expireTimer.

Referenced by PopupFor().

◆ Move() [1/2]

void STATUS_POPUP::Move ( const wxPoint &  aWhere)
virtual

Definition at line 90 of file status_popup.cpp.

91 {
92  SetPosition( aWhere );
93 }
void SetPosition(const wxString &aStr, const wxString &aDefaultMeasurementUnit, int *aX, int *aY, const wxString &aActualConversion)

References PCAD2KICAD::SetPosition().

Referenced by PAD_TOOL::EnumeratePads(), and LENGTH_TUNER_TOOL::updateStatusPopup().

◆ Move() [2/2]

void STATUS_POPUP::Move ( const VECTOR2I aWhere)
virtual

Definition at line 84 of file status_popup.cpp.

85 {
86  SetPosition( wxPoint( aWhere.x, aWhere.y ) );
87 }
void SetPosition(const wxString &aStr, const wxString &aDefaultMeasurementUnit, int *aX, int *aY, const wxString &aActualConversion)

References PCAD2KICAD::SetPosition(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ onCharHook()

void STATUS_POPUP::onCharHook ( wxKeyEvent &  aEvent)
protected

Expire timer even handler.

Definition at line 54 of file status_popup.cpp.

55 {
56  // Key events from the status popup don't get put through the wxWidgets event system on
57  // OSX, so we have to fall back to the CHAR_HOOK to forward hotkeys from the popup to
58  // the canvas / frame.
59  aEvent.SetEventType( wxEVT_CHAR );
60 
61  EDA_DRAW_FRAME* frame = dynamic_cast<EDA_DRAW_FRAME*>( GetParent() );
62 
63  if( frame )
64  frame->GetCanvas()->OnEvent( aEvent );
65  else
66  GetParent()->GetEventHandler()->ProcessEvent( aEvent );
67 }
void OnEvent(wxEvent &aEvent)
Used to forward events to the canvas from popups, etc.
virtual EDA_DRAW_PANEL_GAL * GetCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
The base class for create windows for drawing purpose.

References EDA_DRAW_FRAME::GetCanvas(), and EDA_DRAW_PANEL_GAL::OnEvent().

Referenced by STATUS_POPUP().

◆ onExpire()

void STATUS_POPUP::onExpire ( wxTimerEvent &  aEvent)
protected

Definition at line 109 of file status_popup.cpp.

110 {
111  Hide();
112 }

Referenced by STATUS_POPUP().

◆ Popup()

void STATUS_POPUP::Popup ( wxWindow *  aFocus = nullptr)
virtual

Definition at line 70 of file status_popup.cpp.

71 {
72  Show( true );
73  Raise();
74 }

Referenced by PAD_TOOL::EnumeratePads(), LENGTH_TUNER_TOOL::performTuning(), and PopupFor().

◆ PopupFor()

void STATUS_POPUP::PopupFor ( int  aMsecs)
virtual

Definition at line 77 of file status_popup.cpp.

78 {
79  Popup();
80  Expire( aMsecs );
81 }
virtual void Popup(wxWindow *aFocus=nullptr)
void Expire(int aMsecs)
Hide the popup after a specified time.

References Expire(), and Popup().

◆ updateSize()

void STATUS_POPUP::updateSize ( )
protected

Definition at line 102 of file status_popup.cpp.

103 {
104  m_topSizer->Fit( m_panel );
105  SetClientSize( m_panel->GetSize() );
106 }
wxPanel * m_panel
Definition: status_popup.h:70
wxBoxSizer * m_topSizer
Definition: status_popup.h:71

References m_panel, and m_topSizer.

Referenced by STATUS_TEXT_POPUP::SetText().

Member Data Documentation

◆ m_expireTimer

wxTimer STATUS_POPUP::m_expireTimer
protected

Definition at line 72 of file status_popup.h.

Referenced by Expire().

◆ m_panel

wxPanel* STATUS_POPUP::m_panel
protected

◆ m_topSizer

wxBoxSizer* STATUS_POPUP::m_topSizer
protected

Definition at line 71 of file status_popup.h.

Referenced by STATUS_POPUP(), STATUS_TEXT_POPUP::STATUS_TEXT_POPUP(), and updateSize().


The documentation for this class was generated from the following files: