#include #ifndef BASIC_H #define BASIC_H class wxDialogDemoApp : public wxApp{ public: virtual bool OnInit(); }; class BasicFrame : public wxFrame{ private: wxPanel *panel; wxButton *button; wxStaticText *text; wxMenuBar *menubar; wxMenu *examplemenu; enum { MENU_INFO_ABOUT }; DECLARE_EVENT_TABLE() public: BasicFrame(const wxChar *title, int xpos, int ypos, int width, int height); ~BasicFrame(); void OnClose(wxCommandEvent& event); void OnMenuInfoAbout(wxCommandEvent& event); }; class AboutDialog : public wxDialog { private: wxStaticText *m_pInfoText; wxButton *m_pOkButton; DECLARE_EVENT_TABLE() public: AboutDialog(wxWindow *parent); virtual ~AboutDialog() {} void SetText(const wxString& text); void OnClose(wxCloseEvent& event); }; #endif ------------------ #include #include "base.h" IMPLEMENT_APP(wxDialogDemoApp) // Klasse -- wxDialogDemoApp bool wxDialogDemoApp::OnInit(){ BasicFrame *frame = new BasicFrame(wxT("Kolashare"), 50, 50, 200, 150); frame->Show(TRUE); SetTopWindow(frame); return TRUE; } // Klasse -- BasicFrame BasicFrame::BasicFrame(const wxChar *title, int xpos, int ypos, int width, int height):wxFrame((wxFrame*)NULL, -1, title, wxPoint(xpos, ypos), wxSize(width, height), wxDEFAULT_FRAME_STYLE){ menubar = new wxMenuBar(); examplemenu = new wxMenu(); panel = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(120,100)); button = new wxButton(panel, wxID_OK, wxT("OK"), wxPoint(100,80), wxDefaultSize); text = new wxStaticText(panel, -1, wxT(""), wxPoint(60,20), wxSize(100,100), wxALIGN_LEFT); text->SetLabel(wxT("Kolashare Client")); examplemenu->Append(MENU_INFO_ABOUT, wxT("&About")); menubar->Append(examplemenu, wxT("&Info")); SetMenuBar(menubar); } BasicFrame::~BasicFrame(){} void BasicFrame::OnMenuInfoAbout(wxCommandEvent& event){ AboutDialog *dlg = new AboutDialog(this); dlg->SetText(wxT("(c)2006 Kolashare Client\nToolkit: wxWidgets\n")); dlg->ShowModal(); } void BasicFrame::OnClose(wxCommandEvent& event){ Destroy(); } // Klasse -- AboutDialog AboutDialog::AboutDialog(wxWindow *parent):wxDialog(parent, -1, wxT("About"), wxDefaultPosition, wxSize(200,200), wxDEFAULT_DIALOG_STYLE){ m_pInfoText = new wxStaticText(this, -1, wxT(""), wxPoint(5,5), wxSize(100,100), wxALIGN_RIGHT); m_pOkButton = new wxButton(this, wxID_OK, wxT("OK"), wxPoint(100,160)); } void AboutDialog::SetText(const wxString& text){ m_pInfoText->SetLabel(text); } void AboutDialog::OnClose(wxCloseEvent& event){ Destroy(); } // EreignisTable -- BasicFrame BEGIN_EVENT_TABLE(BasicFrame, wxFrame) EVT_MENU(MENU_INFO_ABOUT, BasicFrame::OnMenuInfoAbout) EVT_BUTTON(wxID_OK,BasicFrame::OnClose) END_EVENT_TABLE() // EreignisTable -- AboutDialog BEGIN_EVENT_TABLE(AboutDialog, wxDialog) EVT_CLOSE(AboutDialog::OnClose) END_EVENT_TABLE()