KiCad PCB EDA Suite
Loading...
Searching...
No Matches
kistatusbar_popup.cpp
Go to the documentation of this file.
1
/*
2
* This program source code file is part of KiCad, a free EDA CAD application.
3
*
4
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5
*
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program. If not, see <https://www.gnu.org/licenses/>.
18
*/
19
20
#include <
widgets/kistatusbar_popup.h
>
21
22
#include <wx/app.h>
23
#include <wx/time.h>
24
25
26
long
long
KISTATUSBAR_POPUP::s_lastDismissed
= 0;
27
const
std::type_info*
KISTATUSBAR_POPUP::s_lastDismissedType
=
nullptr
;
28
29
30
KISTATUSBAR_POPUP::KISTATUSBAR_POPUP
( wxWindow* aParent ) :
31
wxPopupTransientWindow( aParent, wxBORDER_SIMPLE | wxPU_CONTAINS_CONTROLS )
32
{
33
SetSize( FromDIP( wxSize( 300, 150 ) ) );
34
35
Bind( wxEVT_CHAR_HOOK, &
KISTATUSBAR_POPUP::onCharHook
,
this
);
36
}
37
38
39
void
KISTATUSBAR_POPUP::PopupAt
(
const
wxPoint& aCorner )
40
{
41
Move( aCorner - GetSize() );
42
Popup();
43
}
44
45
46
bool
KISTATUSBAR_POPUP::IsDismissingClick
(
const
std::type_info& aPopupType )
47
{
48
if
( !
s_lastDismissedType
|| *
s_lastDismissedType
!= aPopupType )
49
return
false
;
50
51
if
( wxGetLocalTimeMillis().GetValue() -
s_lastDismissed
>= 300 )
52
return
false
;
53
54
s_lastDismissed
= 0;
55
return
true
;
56
}
57
58
59
void
KISTATUSBAR_POPUP::OnDismiss
()
60
{
61
s_lastDismissed
= wxGetLocalTimeMillis().GetValue();
62
s_lastDismissedType
= &
typeid
( *this );
63
64
// Dismissal can repeat before the deferred delete runs, as MSW deactivation does after Escape
65
if
( !wxTheApp->IsScheduledForDestruction(
this
) )
66
Destroy();
67
}
68
69
70
void
KISTATUSBAR_POPUP::onCharHook
( wxKeyEvent& aEvent )
71
{
72
if
( aEvent.GetKeyCode() == WXK_ESCAPE )
73
DismissAndNotify();
74
else
75
aEvent.Skip();
76
}
KISTATUSBAR_POPUP::KISTATUSBAR_POPUP
KISTATUSBAR_POPUP(wxWindow *aParent)
Definition
kistatusbar_popup.cpp:30
KISTATUSBAR_POPUP::OnDismiss
void OnDismiss() override
Definition
kistatusbar_popup.cpp:59
KISTATUSBAR_POPUP::PopupAt
void PopupAt(const wxPoint &aCorner)
Show the popup with its bottom-right corner at aCorner, in screen coordinates.
Definition
kistatusbar_popup.cpp:39
KISTATUSBAR_POPUP::onCharHook
void onCharHook(wxKeyEvent &aEvent)
Definition
kistatusbar_popup.cpp:70
KISTATUSBAR_POPUP::s_lastDismissedType
static const std::type_info * s_lastDismissedType
Definition
kistatusbar_popup.h:60
KISTATUSBAR_POPUP::s_lastDismissed
static long long s_lastDismissed
Definition
kistatusbar_popup.h:59
KISTATUSBAR_POPUP::IsDismissingClick
static bool IsDismissingClick(const std::type_info &aPopupType)
Return true, once, for a click that arrives just after a popup of type aPopupType was dismissed.
Definition
kistatusbar_popup.cpp:46
kistatusbar_popup.h
src
common
widgets
kistatusbar_popup.cpp
Generated on Wed Nov 18 2026 00:05:54 for KiCad PCB EDA Suite by
1.13.2