Inital fill in background, removed tabs, -1->wxID_ANY, TRUE->true, FALSE->false

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@27470 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Włodzimierz Skiba
2004-05-27 17:29:32 +00:00
parent 2d1d813e2d
commit e0e31ccdbc

View File

@@ -51,12 +51,13 @@ hack doesn't fix.
static int detail = 9; // CHANGE THIS... 7,8,9 etc static int detail = 9; // CHANGE THIS... 7,8,9 etc
static bool running = FALSE; static bool running = false;
static wxMenuBar *menuBar = NULL; static wxMenuBar *menuBar = NULL;
// Define a new application type // Define a new application type
class MyApp: public wxApp class MyApp: public wxApp
{ public: {
public:
bool OnInit(); bool OnInit();
}; };
@@ -70,7 +71,8 @@ public:
void OnCloseWindow(wxCloseEvent& event); void OnCloseWindow(wxCloseEvent& event);
void OnExit(wxCommandEvent& event); void OnExit(wxCommandEvent& event);
DECLARE_EVENT_TABLE()
DECLARE_EVENT_TABLE()
}; };
// Define a new canvas which can receive some events // Define a new canvas which can receive some events
@@ -94,7 +96,7 @@ DECLARE_EVENT_TABLE()
bool MyApp::OnInit() bool MyApp::OnInit()
{ {
// Create the main frame window // Create the main frame window
MyFrame *frame = new MyFrame(NULL, _T("Fractal Mountains for wxWidgets"), wxPoint(-1, -1), wxSize(640, 480)); MyFrame *frame = new MyFrame(NULL, _T("Fractal Mountains for wxWidgets"), wxDefaultPosition, wxSize(640, 480));
// Make a menubar // Make a menubar
wxMenu *file_menu = new wxMenu; wxMenu *file_menu = new wxMenu;
@@ -109,9 +111,9 @@ bool MyApp::OnInit()
(void) new MyCanvas(frame); (void) new MyCanvas(frame);
// Show the frame // Show the frame
frame->Show(TRUE); frame->Show(true);
return TRUE; return true;
} }
BEGIN_EVENT_TABLE(MyFrame, wxFrame) BEGIN_EVENT_TABLE(MyFrame, wxFrame)
@@ -121,7 +123,7 @@ END_EVENT_TABLE()
// My frame constructor // My frame constructor
MyFrame::MyFrame(wxFrame *frame, const wxString& title, const wxPoint& pos, const wxSize& size): MyFrame::MyFrame(wxFrame *frame, const wxString& title, const wxPoint& pos, const wxSize& size):
wxFrame(frame, -1, title, pos, size, wxDEFAULT_FRAME_STYLE | wxFULL_REPAINT_ON_RESIZE) wxFrame(frame, wxID_ANY, title, pos, size, wxDEFAULT_FRAME_STYLE | wxFULL_REPAINT_ON_RESIZE )
{ {
} }
@@ -133,13 +135,13 @@ void MyFrame::OnExit(wxCommandEvent& WXUNUSED(event))
void MyFrame::OnCloseWindow(wxCloseEvent& WXUNUSED(event)) void MyFrame::OnCloseWindow(wxCloseEvent& WXUNUSED(event))
{ {
static bool destroyed = FALSE; static bool destroyed = false;
if (destroyed) if (destroyed)
return; return;
this->Destroy(); this->Destroy();
destroyed = TRUE; destroyed = true;
} }
BEGIN_EVENT_TABLE(MyCanvas, wxWindow) BEGIN_EVENT_TABLE(MyCanvas, wxWindow)
@@ -148,7 +150,7 @@ END_EVENT_TABLE()
// Define a constructor for my canvas // Define a constructor for my canvas
MyCanvas::MyCanvas(wxFrame *frame): MyCanvas::MyCanvas(wxFrame *frame):
wxWindow(frame, -1) wxWindow(frame, wxID_ANY)
{ {
wxColour wxCol1(255,255,255); wxColour wxCol1(255,255,255);
SnowPen = wxPen(wxCol1, 2, wxSOLID); SnowPen = wxPen(wxCol1, 2, wxSOLID);
@@ -166,6 +168,7 @@ MyCanvas::MyCanvas(wxFrame *frame):
void MyCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) void MyCanvas::OnPaint(wxPaintEvent& WXUNUSED(event))
{ {
wxPaintDC dc(this); wxPaintDC dc(this);
PrepareDC(dc);
Draw(dc); Draw(dc);
} }
@@ -173,11 +176,14 @@ void MyCanvas::Draw(wxDC& dc)
{ {
if (running) return; if (running) return;
running = TRUE; running = true;
menuBar->EnableTop(0, FALSE); menuBar->EnableTop(0, false);
Randomize(); Randomize();
dc.SetBackground(*wxLIGHT_GREY_BRUSH);
dc.Clear();
int Left, Top, Right, Bottom; int Left, Top, Right, Bottom;
GetClientSize(&Right, &Bottom); GetClientSize(&Right, &Bottom);
@@ -203,8 +209,8 @@ void MyCanvas::Draw(wxDC& dc)
Fractal(dc, Left, Top, Right, Bottom, 0, 0, 0, 0, detail, Std, Ratio); Fractal(dc, Left, Top, Right, Bottom, 0, 0, 0, 0, detail, Std, Ratio);
menuBar->EnableTop(0, TRUE); menuBar->EnableTop(0, true);
running = FALSE; running = false;
} }
void MyCanvas::Fractal(wxDC& dc, int X1, int Y1, int X2, int Y2, int Z1, int Z2, int Z3, int Z4, int Iteration, double Std, double Ratio) void MyCanvas::Fractal(wxDC& dc, int X1, int Y1, int X2, int Y2, int Z1, int Z2, int Z3, int Z4, int Iteration, double Std, double Ratio)