| 1 |
#include <iostream> |
| 2 |
#include <sstream> |
| 3 |
#ifdef __GNUG__ |
| 4 |
#pragma implementation "wxpoem.h" |
| 5 |
#endif |
| 6 |
|
| 7 |
#include "oodle.h" |
| 8 |
#include "tetris.h" |
| 9 |
|
| 10 |
// For compilers that support precompilation, includes "wx.h". |
| 11 |
#include "wx/wxprec.h" |
| 12 |
|
| 13 |
#ifdef __BORLANDC__ |
| 14 |
#pragma hdrstop |
| 15 |
#endif |
| 16 |
|
| 17 |
#ifndef WX_PRECOMP |
| 18 |
#include "wx/wx.h" |
| 19 |
#endif |
| 20 |
|
| 21 |
using namespace std; |
| 22 |
|
| 23 |
|
| 24 |
class MyApp : public wxApp |
| 25 |
{ |
| 26 |
public: |
| 27 |
virtual bool OnInit(); |
| 28 |
|
| 29 |
}; |
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
class MyFrame : public wxFrame |
| 34 |
{ |
| 35 |
public: |
| 36 |
|
| 37 |
MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size); |
| 38 |
virtual ~MyFrame(); |
| 39 |
|
| 40 |
void DoBegin(); |
| 41 |
void DoPause(); |
| 42 |
void DoStop(); |
| 43 |
|
| 44 |
//void OnIdle(wxTimerEvent& WXUNUSED(event)); |
| 45 |
void OnQuit(wxCommandEvent& event); |
| 46 |
/*void OnOpen(wxCommandEvent& event); |
| 47 |
void OnScroll(wxScrollEvent& event); |
| 48 |
void OnPlay(wxCommandEvent& event); |
| 49 |
void OnBegin(wxCommandEvent& event); |
| 50 |
void OnEnd(wxCommandEvent& event); |
| 51 |
void OnPause(wxCommandEvent& event); |
| 52 |
void OnStop(wxCommandEvent& event); |
| 53 |
void OnSpeed(wxCommandEvent& event); |
| 54 |
void OnLoop(wxCommandEvent& event); |
| 55 |
void OnColor(wxCommandEvent& event);*/ |
| 56 |
|
| 57 |
DECLARE_EVENT_TABLE() |
| 58 |
|
| 59 |
enum |
| 60 |
{ |
| 61 |
ID_Moves = 100 |
| 62 |
/* ID_Quit = 1, |
| 63 |
ID_Open, |
| 64 |
ID_Controls_Begin, |
| 65 |
ID_Controls_End, |
| 66 |
ID_Controls_Play, |
| 67 |
ID_Controls_Pause, |
| 68 |
ID_Controls_Stop, |
| 69 |
ID_Speed_Text, |
| 70 |
ID_Loop, |
| 71 |
ID_Color, |
| 72 |
ID_TIMER*/ |
| 73 |
}; |
| 74 |
|
| 75 |
// wxScrollBar *scroll; |
| 76 |
// wxTimer* m_timer; |
| 77 |
// wxChoice* loop, *color; |
| 78 |
// wxTextCtrl* speedctl; |
| 79 |
|
| 80 |
}; |
| 81 |
|
| 82 |
BEGIN_EVENT_TABLE(MyFrame, wxFrame) |
| 83 |
/* EVT_MENU(ID_Quit, MyFrame::OnQuit) |
| 84 |
EVT_MENU(ID_Open, MyFrame::OnOpen) |
| 85 |
EVT_SCROLL(MyFrame::OnScroll) |
| 86 |
EVT_BUTTON(ID_Controls_Play, MyFrame::OnPlay) |
| 87 |
EVT_TIMER(ID_TIMER, MyFrame::OnIdle) |
| 88 |
EVT_BUTTON(ID_Controls_Begin, MyFrame::OnBegin) |
| 89 |
EVT_BUTTON(ID_Controls_Pause, MyFrame::OnPause) |
| 90 |
EVT_BUTTON(ID_Controls_Stop, MyFrame::OnStop) |
| 91 |
EVT_BUTTON(ID_Controls_End, MyFrame::OnEnd) |
| 92 |
EVT_TEXT(ID_Speed_Text, MyFrame::OnSpeed) |
| 93 |
EVT_CHOICE(ID_Color, MyFrame::OnColor) |
| 94 |
EVT_CHOICE(ID_Loop, MyFrame::OnLoop)*/ |
| 95 |
END_EVENT_TABLE() |
| 96 |
|
| 97 |
|
| 98 |
IMPLEMENT_APP(MyApp) |
| 99 |
|
| 100 |
bool MyApp::OnInit() |
| 101 |
{ |
| 102 |
MyFrame *frame = new MyFrame( "PuzzleEdit", wxDefaultPosition, wxDefaultSize ); |
| 103 |
frame->Show(TRUE); |
| 104 |
SetTopWindow(frame); |
| 105 |
|
| 106 |
return TRUE; |
| 107 |
} |
| 108 |
MyFrame::~MyFrame() |
| 109 |
{ |
| 110 |
// delete m_timer; |
| 111 |
} |
| 112 |
|
| 113 |
MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size) |
| 114 |
: wxFrame((wxFrame *)NULL, -1, title, pos, size) |
| 115 |
{ |
| 116 |
SetStatusBarPane( -1 ); |
| 117 |
CreateStatusBar(); |
| 118 |
|
| 119 |
wxPanel *panel1 = new wxPanel(this, -1); |
| 120 |
//wxPanel *panel2 = new wxPanel(this, -1); |
| 121 |
|
| 122 |
wxBoxSizer *sizer2 = new wxBoxSizer(wxVERTICAL); |
| 123 |
wxBoxSizer *szHoriz = new wxBoxSizer(wxHORIZONTAL); |
| 124 |
wxFlexGridSizer *sizer1 = new wxFlexGridSizer(12, 6, 0 , 0 ); |
| 125 |
|
| 126 |
wxString btnTxt = "0"; |
| 127 |
for (int i = 1; i < 12*6+1; i++) |
| 128 |
{ |
| 129 |
sizer1->Add( new wxButton(panel1, i, btnTxt, wxDefaultPosition ) , 0, 0); |
| 130 |
} |
| 131 |
|
| 132 |
sizer2->Add(sizer1, 0, wxALIGN_CENTRE_HORIZONTAL ); |
| 133 |
szHoriz->Add( new wxStaticText(panel1, -1, "Number of Moves: ", wxDefaultPosition),0, wxALIGN_CENTER ); |
| 134 |
szHoriz->Add(new wxTextCtrl(panel1, ID_Moves, "", wxDefaultPosition, wxSize(10, -1) ), 0, wxALIGN_CENTER); |
| 135 |
sizer2->Add(szHoriz, 0, wxALIGN_CENTRE_HORIZONTAL ); |
| 136 |
|
| 137 |
//sizer2->Add (new wxButton(panel1, 0, btnTxt, wxDefaultPosition ) , 0, wxALIGN_CENTER | wxALIGN_CENTRE_VERTICAL); |
| 138 |
panel1->SetSizer( sizer2 ); |
| 139 |
panel1->SetAutoLayout( TRUE ); |
| 140 |
sizer2->Fit( panel1 ); |
| 141 |
|
| 142 |
} |
| 143 |
|
| 144 |
void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) |
| 145 |
{ |
| 146 |
Close(TRUE); |
| 147 |
} |
| 148 |
|