동적 이벤트 테이블


MyApp.h
#pragma  once

#include  <wx/wx.h>

class MyApp:public wxApp
{
public:
    MyApp(void);
    ~MyApp(void);

   virtual  bool OnInit();
};

DECLARE_APP(MyApp);

MyApp.cpp
#include  "MyApp.h"
#include  "MyFrame.h"

IMPLEMENT_APP(MyApp);

MyApp::MyApp(void)
{
}


MyApp::~MyApp(void)
{
}

bool
MyApp::OnInit()
{
   wxFrame* m = new  MyFrame("Dynamic Event Table");
    m->Show(true);
   return  true;
}

MyFrame.h
#pragma  once

#include  <wx/wx.h>

class  MyFunctor{
public:
   void operator()(wxCommandEvent& event){
       wxMessageBox("MyFunctor Event");
   }
};

class  MyFrame:public  wxFrame
{
private:
   wxButton* exit_;
   bool isAttached_;

   MyFunctor fn_;

public:
    MyFrame(const  wxString& title);
    ~MyFrame(void);

private:
   void OnExit(wxCommandEvent& event);
   void OnToggle(wxCommandEvent& event);
};

MyFrame.cpp
#include  "MyFrame.h"

MyFrame::MyFrame(const  wxString& title)
    :wxFrame(NULL, wxID_ANY, title)
{
   wxPanel* panel = new  wxPanel(this);

    exit_ = new  wxButton(panel,wxID_ANY,"Exit",wxPoint(100,10));
    exit_->Bind( wxEVT_BUTTON, &MyFrame::OnExit, this);
    isAttached_ = true;

   wxButton* toggle = new  wxButton(panel,wxID_ANY,"toggle",wxPoint(100,60));
    toggle->Bind( wxEVT_BUTTON, &MyFrame::OnToggle, this);


   wxButton* lambda = new  wxButton(panel,wxID_ANY,"lambda",wxPoint(100,110));
    lambda->Bind( wxEVT_BUTTON,
                [](wxCommandEvent& event){
                   wxMessageBox("lambda event");
               }      
      
       );

   wxButton* fn = new  wxButton(panel,wxID_ANY,"fn",wxPoint(100,160));
    fn->Bind( wxEVT_BUTTON,fn_);
}

void 
MyFrame::OnExit(wxCommandEvent& event){
    wxMessageBox("OnExit");
}

void 
MyFrame::OnToggle(wxCommandEvent& event){
   this->isAttached_ = ! this->isAttached_;

   switch( this->isAttached_){
      case  true:
          exit_->Bind( wxEVT_BUTTON, &MyFrame::OnExit, this);
         break;

      case  false:
          exit_->Unbind( wxEVT_BUTTON, &MyFrame::OnExit, this);
         break;
   }

}


MyFrame::~MyFrame(void)
{
}

- 목록:

2 thoughts on “wxPaintDC 이해하기

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>