Files
s7/Resources/Utilities/TimeredStatusBar.cpp
Saleem Edah-Tally 4b23b1f3de Allow cancelling a scan session.
- perform scanning in a thread
 - change the label of the scan button
 - trigger cancel with the same button and with the ESC key
 - process all GUI updates in asynchronous mode.

Do not use a top window as parent of popups:
 - If a top window goes away in an application with multiple instances of
 XInsaneWidget, any call to a scanner widget leads to a crash.

Minor changes.
2025-07-12 23:03:32 +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, 90};
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 );
}
}