#include "BlinkingMessageDialog.h"
|
#define MSG_WINDOW_SIZE wxSize(200,80)
|
|
BlinkingMessageDialog::BlinkingMessageDialog(wxWindow* parent, const wxString& message) : wxFrame(parent, wxID_ANY, "¿ÉתծÌáʾ", wxDefaultPosition, MSG_WINDOW_SIZE, wxDEFAULT_FRAME_STYLE & ~(wxMAXIMIZE_BOX | wxMINIMIZE_BOX))
|
{
|
long style = GetWindowStyle();//& ~(wxCAPTION);
|
style |= wxSTAY_ON_TOP;
|
SetWindowStyle(style);
|
|
SetBackgroundColour(*wxWHITE);
|
|
m_shakeCount = 0;
|
|
wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL);
|
wxStaticText* text = new wxStaticText(this, wxID_ANY, message);
|
text->SetForegroundColour(*wxRED);
|
sizer->Add(text, 0, wxALL | wxALIGN_CENTER);
|
SetSizer(sizer);
|
|
// Start blinking
|
m_timer = new wxTimer(this, wxID_ANY);
|
Bind(wxEVT_TIMER, &BlinkingMessageDialog::OnTimer, this);
|
m_timer->Start(100);
|
//»ñÈ¡ÆÁÄ»ÓÒϽÇ
|
int screenWidth = GetSystemMetrics(SM_CXSCREEN);
|
int screenHeight = GetSystemMetrics(SM_CYSCREEN);
|
// ÓÒϽÇλÖÃ
|
wxPoint bottomRight(screenWidth - MSG_WINDOW_SIZE.GetWidth()-10, screenHeight - MSG_WINDOW_SIZE.GetHeight()-10);
|
SetPosition(bottomRight);
|
}
|
|
void BlinkingMessageDialog::show()
|
{
|
|
if (!IsShown()) {
|
m_timer->Stop();
|
m_shakeCount = 0;
|
m_timer->Start(100);
|
Show();
|
}
|
}
|
|
void BlinkingMessageDialog::OnTimer(wxTimerEvent& event)
|
{
|
if (m_shakeCount < 100) { // Shake for 6 cycles
|
int dx = (m_shakeCount % 2 == 0) ? 10 : -10;
|
int dy = (m_shakeCount % 2 == 0) ? 10 : -10;
|
Move(GetPosition() + wxPoint(dx, dy));
|
m_shakeCount++;
|
}
|
else {
|
m_timer->Stop();
|
Close();
|
}
|
}
|