Main Page | Modules | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members

guiclient/test.cpp

Go to the documentation of this file.
00001 #include "wx/wxprec.h"
00002 #ifndef WX_PRECOMP
00003         #warning Precompiled wx header not used.
00004     #include "wx/wx.h"
00005 #endif
00006 
00017 class ButtonPanel : public wxControl //, public wxPanel
00018 {
00019         public:
00020                 ButtonPanel(wxWindow* parent) : //, wxTextCtrl *console) : 
00021                         wxControl(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize)//,\
00022                         wxPanel(parent)
00023                 {
00024                         panel = new wxPanel(this);
00025                         wxBoxSizer *buttonsizer = new wxBoxSizer(wxVERTICAL);
00026                         stop = new wxButton(panel,wxID_ANY,wxT("&Stop"), wxPoint(100,100));
00027                         forward = new wxButton(panel,wxID_ANY,wxT("&Forward"));
00028                         backward = new wxButton(panel,wxID_ANY,wxT("&Backward"));
00029                         buttonsizer->Add(stop,3,wxEXPAND | wxALL, 10);
00030                         buttonsizer->Add(forward,4,wxEXPAND | wxALL, 10);
00031                         buttonsizer->Add(backward,5,wxEXPAND | wxALL, 10);
00032                         buttonsizer->SetSizeHints(this);
00033                         panel->SetSizer(buttonsizer);
00034                         _parent = parent;
00035 //                              _console = console;
00036                 };
00037 
00038                 void OnResize(wxSizeEvent &event)
00039                 {
00040                         panel->SetSize(event.GetSize());
00041                 }
00042                 void OnSetFocus(wxFocusEvent &event)
00043                 {
00044                         stop->SetLabel(wxT("&Stop (focused)"));
00045                         stop->SetBackgroundColour(*wxBLACK);
00046                         this->SetForegroundColour(*wxRED);
00047                         this->SetBackgroundColour(*wxBLACK);
00048                         panel->SetForegroundColour(*wxRED);
00049                         panel->SetBackgroundColour(*wxBLACK);
00050                         panel->Refresh();
00051                         //wxMessageBox(wxT("focus"));
00052                 }
00053                 void OnKillFocus(wxFocusEvent &event)
00054                 {
00055                         stop->SetLabel(wxT("&Stop"));
00056                         stop->SetBackgroundColour(wxNullColour);
00057                         this->SetForegroundColour(wxNullColour);
00058                         this->SetBackgroundColour(wxNullColour);
00059                         panel->SetForegroundColour(wxNullColour);
00060                         panel->SetBackgroundColour(wxNullColour);
00061                 }
00062                 wxPanel *panel;
00063                 wxWindow *_parent;
00064                 wxButton *stop, *forward, *backward;
00065         private:
00066 //              wxTextCtrl *_console;
00067                 DECLARE_EVENT_TABLE()
00068 };
00069 
00070 
00071 #if 0
00072 void ButtonPanel::OnFocus(wxFocusEvent &event)
00073 {
00074         //*_console << wxT("Focus on ButtonPanel\n");   
00075 }
00076 #endif
00077 
00088 class GuiClientApp : public wxApp
00089 {
00090   public:
00091         virtual bool OnInit();
00092         virtual int OnRun();
00093 };
00094 
00105 class GuiClientFrame : public wxFrame
00106 {
00107   public:
00108         GuiClientFrame (const wxString &title,
00109                     const wxPoint &pos,
00110                     const wxSize &size);
00111         void OnButton(wxCommandEvent& event);
00112 
00113 private:
00114         //wxTextCtrl *console;
00115     DECLARE_EVENT_TABLE()
00116 
00117 };
00118 
00119 enum event_t
00120 {
00121     ID_Quit = 1,
00122     ID_About,
00123         ID_Stop,
00124         ID_Forward,
00125         ID_Back,
00126         ID_Left,
00127         ID_Right,
00128         ID_Commandline,
00129         ID_Console,
00130 };
00131 
00132 
00133 BEGIN_EVENT_TABLE(ButtonPanel, wxControl)
00134         EVT_SIZE(ButtonPanel::OnResize)
00135         EVT_SET_FOCUS(ButtonPanel::OnSetFocus)
00136         EVT_KILL_FOCUS(ButtonPanel::OnKillFocus)
00137 END_EVENT_TABLE()
00138 
00139 BEGIN_EVENT_TABLE(GuiClientFrame, wxFrame)
00140         EVT_BUTTON(wxID_ANY, GuiClientFrame::OnButton)
00141 #if 0
00142     EVT_MENU(ID_Quit,           GuiClientFrame::OnQuit)
00143     EVT_MENU(ID_About,          GuiClientFrame::OnAbout)
00144         EVT_MENU(ID_Stop,               GuiClientFrame::OnMove)
00145         EVT_MENU(ID_Forward,    GuiClientFrame::OnMove)
00146         EVT_MENU(ID_Back,               GuiClientFrame::OnMove)
00147         EVT_MENU(ID_Left,               GuiClientFrame::OnMove)
00148         EVT_MENU(ID_Right,              GuiClientFrame::OnMove)
00149         EVT_BUTTON(ID_Stop,             GuiClientFrame::OnMove)
00150         EVT_BUTTON(ID_Forward,  GuiClientFrame::OnMove)
00151         EVT_BUTTON(ID_Back,             GuiClientFrame::OnMove)
00152         EVT_BUTTON(ID_Left,             GuiClientFrame::OnMove)
00153         EVT_BUTTON(ID_Right,    GuiClientFrame::OnMove)
00154         EVT_TEXT_ENTER(ID_Commandline,  GuiClientFrame::OnCommandEnter)
00155         EVT_SOCKET(wxID_ANY,    GuiClientFrame::OnSocket)
00156 #endif
00157 END_EVENT_TABLE()
00158 
00159 IMPLEMENT_APP(GuiClientApp)
00160 
00161 
00162 
00173 bool GuiClientApp::OnInit()
00174 { const wxString title(wxT("Hello World!"));
00175 
00176   GuiClientFrame *frame = \
00177                 new GuiClientFrame(title, wxPoint(-1, -1), wxSize(600, 800));
00178   SetTopWindow(frame);
00179   return TRUE;  
00180 }
00181 
00192 int GuiClientApp::OnRun()
00193 {
00194      wxApp::OnRun();
00195      return TRUE;
00196 } 
00197 
00198 
00209 GuiClientFrame::GuiClientFrame
00210         (const wxString &title, const wxPoint &pos, const wxSize &size)
00211     : wxFrame ( (wxFrame *) NULL, wxID_ANY, title, pos, size) 
00212 {
00213         CreateStatusBar();
00214         //console = new wxTextCtrl(textpanel, ID_Console, wxT(""), wxDefaultPosition, \
00215                 wxDefaultSize, wxTE_MULTILINE | wxTE_READONLY);
00216         //commandline = new wxTextCtrl(textpanel, ID_Commandline, wxT(""), \
00217                 wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER);
00218         wxPanel *panel = new wxPanel(this);     
00219         wxBoxSizer *mainsizer = new wxBoxSizer(wxHORIZONTAL);
00220         mainsizer->Add(new ButtonPanel(panel),1,wxEXPAND);
00221         mainsizer->Add(new ButtonPanel(panel),2,wxEXPAND);
00222 
00223 
00224         mainsizer->SetSizeHints(this);
00225         mainsizer->SetSizeHints(panel);
00226         panel->SetSizer(mainsizer);
00227                 
00228         //show window
00229         Show(true);
00230 }
00231 
00242 void GuiClientFrame::OnButton(wxCommandEvent& event)
00243 {
00244         SetStatusText(wxT("ButtonPressed"));
00245 }
00246 
00247 

Generated on Fri Sep 1 14:25:44 2006 for Raptor by  doxygen 1.4.4