Created
December 25, 2015 12:35
-
-
Save rickardlindberg/a1d487c1d4b389cb3698 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <wx/wxprec.h> | |
#ifndef WX_PRECOMP | |
#include <wx/wx.h> | |
#endif | |
class MyApp: public wxApp | |
{ | |
public: | |
virtual bool OnInit(); | |
}; | |
class MainFrame: public wxFrame | |
{ | |
public: | |
MainFrame(const wxString& title, const wxPoint& pos, const wxSize& size); | |
private: | |
wxButton * button; | |
wxTextCtrl * text; | |
void OnChangeBgClicked(wxCommandEvent& event); | |
DECLARE_EVENT_TABLE(); | |
}; | |
enum | |
{ | |
ID_CHANGE_BG_BUTTON = 1 | |
}; | |
BEGIN_EVENT_TABLE(MainFrame, wxFrame) | |
EVT_BUTTON(ID_CHANGE_BG_BUTTON, MainFrame::OnChangeBgClicked) | |
END_EVENT_TABLE() | |
IMPLEMENT_APP(MyApp); | |
bool MyApp::OnInit() | |
{ | |
MainFrame *frame = new MainFrame(wxT("bgtest"), wxPoint(50, 50), wxSize(450, 340)); | |
frame->Show(true); | |
return true; | |
} | |
MainFrame::MainFrame(const wxString& title, const wxPoint& pos, const wxSize& size) | |
: wxFrame(NULL, wxID_ANY, title, pos, size) | |
{ | |
this->button = new wxButton(this, ID_CHANGE_BG_BUTTON, wxT("change bg")); | |
this->text = new wxTextCtrl(this, wxID_ANY); | |
wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL); | |
sizer->Add(this->button); | |
sizer->Add(this->text); | |
SetSizerAndFit(sizer); | |
} | |
void MainFrame::OnChangeBgClicked(wxCommandEvent& event) | |
{ | |
this->text->SetBackgroundColour(wxT("pink")); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment