diff --git a/Makefile b/Makefile index ee397e8..6795637 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ default: wxmsg wxmsg: wxmsg.cpp - $(CXX) $(CXXFLAGS) -o $@ $< + $(CXX) $(CXXFLAGS) -o $@ $< `wx-config --libs` `wx-config --cxxflags` diff --git a/wxmsg.cpp b/wxmsg.cpp index 298f451..d7251b6 100644 --- a/wxmsg.cpp +++ b/wxmsg.cpp @@ -34,9 +34,72 @@ #include #include +#define wxmsg_BUTTON_BASE_ID 100 + +#include "wx/wx.h" + using namespace std; -const char usagemsg[] = +class wxmsgApp: public wxApp { +public: + wxmsgApp(const wxString& message, vector& buttons); + virtual bool OnInit(); +private: + wxString message; + vector buttons; +}; + +class wxmsgFrame: public wxFrame { +public: + wxmsgFrame(const wxString& title, const wxString& message, vector& buttons); +private: + wxPanel *m_panel; + vector buttons; +}; + +wxmsgApp::wxmsgApp ( const wxString& _message, vector& _buttons ) + : wxApp ( ) +{ + message = _message; + buttons = _buttons; +} + +bool wxmsgApp::OnInit ( ) { + if ( !wxApp::OnInit() ) { + return false; + } + + wxFrame *frame = new wxmsgFrame(_T("wxmsg"), message, buttons); + frame->Show(); + return true; +} + +wxmsgFrame::wxmsgFrame ( const wxString& title, const wxString& message, vector& str_buttons ) + : wxFrame(NULL, wxID_ANY, title, wxPoint(0, 50), wxDefaultSize, wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE | wxCLIP_CHILDREN | wxTAB_TRAVERSAL) +{ + int i = 0; + + m_panel = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxCLIP_CHILDREN); + wxBoxSizer *sizerMain = new wxBoxSizer(wxVERTICAL); + + sizerMain->Add(new wxStaticBox(m_panel, wxID_ANY, message)); + + wxBoxSizer *sizerBtns = new wxBoxSizer(wxHORIZONTAL); + sizerMain->Add(sizerBtns); + + buttons = vector(); + for ( i = 0; i < str_buttons.size(); i++ ) { + buttons.push_back(new wxButton(m_panel, wxmsg_BUTTON_BASE_ID + i, wxString(str_buttons[i].c_str(), wxConvUTF8))); + sizerBtns->Add(buttons[i]); + } + + m_panel->SetSizer(sizerMain); + sizerMain->Fit(this); + sizerMain->SetSizeHints(this); +} + + +const string usagemsg = "usage: -> man xmessage\n" "\n" " also: wxmsg -v show version\n" @@ -44,7 +107,7 @@ " wxmsg -l display (BSD) license\n" ; -const char licensemsg[] = +const string licensemsg = "wxmsg is copyright (c) 2007 Andreas Jaggi \n" "All rights reserved.\n" "\n" @@ -71,8 +134,7 @@ "THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n" ; -const char versionmsg[] = "wxmsg 0.0\n"; - +const string versionmsg = "wxmsg 0.0\n"; #define usage() cout << usagemsg #define license() cout << licensemsg @@ -210,6 +272,8 @@ exit(1); } + wxmsgApp* app = new wxmsgApp(_T("message"), buttons); + /* TODO: add wxWidgets interface here (instead of this cruft) */ while ( !buttons.empty() ) {