Files
s7/Resources/Utilities/TimeredStatusBar.cpp
Saleem Edah-Tally ef6f25ef27 Initial commit.
2025-06-28 17:40:42 +02:00

59 lines
1.3 KiB
C++

/*
* File: TimeredStatusBar.cpp
* Author: Saleem EDAH-TALLY - nmset@yandex.com
* License: CeCILL-C
* Copyright Saleem EDAH-TALLY - © 2017
*
* Created on April 22, 2018, 3:55 PM
*/
#include "TimeredStatusBar.h"
TimeredStatusBar::TimeredStatusBar ( wxWindow * parent)
: wxStatusBar ( parent, wxID_ANY )
{
m_numFields = 3;
/* We use default reasonable widths for CAPS and NUM. */
const int widths[3] = {-1, 70, 70};
SetFieldsCount ( m_numFields, widths );
m_timer.Stop();
m_timer.SetOwner ( this );
Bind ( wxEVT_TIMER, &TimeredStatusBar::OnTimer, this );
Bind ( wxEVT_IDLE, &TimeredStatusBar::OnIdle, this );
}
TimeredStatusBar::~TimeredStatusBar()
{
}
void TimeredStatusBar::SetTransientText ( const wxString& text, int duration )
{
wxStatusBar::SetStatusText ( text, 0 );
m_timer.Start ( duration, wxTIMER_ONE_SHOT );
}
void TimeredStatusBar::OnTimer ( wxTimerEvent& evt )
{
wxStatusBar::SetStatusText ( wxEmptyString, 0 );
}
void TimeredStatusBar::OnIdle ( wxIdleEvent& evt )
{
if ( wxGetKeyState ( WXK_NUMLOCK ) )
{
SetStatusText (_("NUM"), m_numFields - 2 );
}
else
{
SetStatusText ( wxEmptyString, m_numFields - 2 );
}
if ( wxGetKeyState ( WXK_CAPITAL ) )
{
SetStatusText (_("CAPS"), m_numFields - 1 );
}
else
{
SetStatusText ( wxEmptyString, m_numFields - 1 );
}
}