wxTimerを実装してみる

ここを参考に。
http://docs.wxwidgets.org/trunk/classwx_timer_event.html

#include <iostream>
#include "wx/wx.h"
#include "wx/timer.h" 

int TIMER_ID = 1;

class MyFrame : public wxFrame
{
public:
    MyFrame();
    void OnTimer(wxTimerEvent& event);
private:
    wxTimer m_timer;
    wxDECLARE_EVENT_TABLE();
};

class MyApp : public wxApp
{
public:
  virtual bool OnInit();
};

wxBEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_TIMER(TIMER_ID, MyFrame::OnTimer)
wxEND_EVENT_TABLE()

IMPLEMENT_APP(MyApp)

MyFrame::MyFrame()
       : m_timer(this, TIMER_ID)
{
    m_timer.Start(1000);    // 1 second interval
}

void MyFrame::OnTimer(wxTimerEvent& event)
{
    printf("timer fired\n");
}

bool MyApp::OnInit(){
  MyFrame *frame = new MyFrame();
  return true;
}