I haven't seen an tutorials other than searching the web and experimenting. If you are familiar with Other IDE's, then this one is a breeze because it is similar to all other IDE's out there.
To Create a project, just do file->new->project and it will pretty much configure everything from that point once you choose a project type.
I prefer wxWindows (ver 2.4.2). If you want to dink around, download the 2.4.2 devpak and add the following to a project. It is a simple bouncing ball project and shows how to create device contexts, bitmaps and masks.
#ifndef __BASIC___H
#define __BASIC___H
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
#if defined(__WXGTK__) || defined(__WXMOTIF__) || defined(__WXMAC__) || defined(__WXMGL__) || defined(__WXX11__)
#include "mondrian.xpm"
#endif
#endif
#ifndef MAIN_H
#define MAIN_H
#include "__basic__.h"
#include "myCanvas.h"
class MyApp : public wxApp
{
public:
virtual bool OnInit();
};
class MyFrame : public wxFrame
{
public:
MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size,
long style = wxDEFAULT_FRAME_STYLE);
~MyFrame();
void OnQuit(wxCommandEvent& event);
void OnAbout(wxCommandEvent& event);
int dx, dy;
private:
myCanvas *mc;
wxTimer myTimer;
void OnTimer(wxTimerEvent& event);
DECLARE_EVENT_TABLE()
};
enum
{
Minimal_Quit = 1,
Minimal_About = wxID_ABOUT,
Timer_ID = -99999,
TimerMS = 1
};
#endif
#ifndef MYCANVAS_H
#define MYCANVAS_H
#include "__basic__.h"
#define CANVASX 640
#define CANVASY 480
#define PPUX 32
#define PPUY 32
#define UX ( CANVASX / PPUX )
#define UY ( CANVASY / PPUY )
class myCanvas : public wxScrolledWindow
{
public:
myCanvas(wxWindow *win);
wxBitmap SetBlankBitmap(void);
wxBitmap DrawIT(void);
wxMask bmpMask;
void SetY( int py );
void SetX( int py );
int GetX( void );
int GetY( void );
private:
int y;
int x;
wxBitmap myBmp;
void OnPaint(wxCommandEvent& event);
void OnLeftDown(wxMouseEvent& event);
DECLARE_EVENT_TABLE();
};
#endif
#include "main.h"
#include "myCanvas.h"
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_MENU(Minimal_Quit, MyFrame::OnQuit)
EVT_MENU(Minimal_About, MyFrame::OnAbout)
EVT_TIMER(Timer_ID, MyFrame::OnTimer)
END_EVENT_TABLE()
IMPLEMENT_APP(MyApp)
bool MyApp::OnInit()
{
MyFrame *frame = new MyFrame(_T("Minimal wxWindows App"),
wxPoint(50, 50), wxSize(660, 560));
frame->Show(TRUE);
return TRUE;
}
MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size, long style)
: wxFrame(NULL, -1, title, pos, size, style), myTimer(this, Timer_ID)
{
myTimer.Start(TimerMS);
mc = new myCanvas(this);
mc->SetX(100);
mc->SetY(100);
dx = mc->GetX() % 10 + 1;
dy = mc->GetY() % 10 + 1;
SetIcon(wxICON(mondrian));
#if wxUSE_MENUS
wxMenu *menuFile = new wxMenu;
wxMenu *helpMenu = new wxMenu;
helpMenu->Append(Minimal_About, _T("&About...\tF1"), _T("Show about dialog"));
menuFile->Append(Minimal_Quit, _T("E&xit\tAlt-X"), _T("Quit this program"));
wxMenuBar *menuBar = new wxMenuBar();
menuBar->Append(menuFile, _T("&File"));
menuBar->Append(helpMenu, _T("&Help"));
SetMenuBar(menuBar);
#endif
#if wxUSE_STATUSBAR
CreateStatusBar(2);
SetStatusText(_T("Welcome to wxWindows!"));
#endif
}
MyFrame::~MyFrame()
{
delete mc; myTimer.Stop(); }
void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
{
Close(TRUE);
}
void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
{
wxString msg;
msg.Printf( _T("This is the About dialog of the minimal sample.\n")
_T("Welcome to %s"), wxVERSION_STRING);
wxMessageBox(msg, _T("About Minimal"), wxOK | wxICON_INFORMATION, this);
}
void MyFrame::OnTimer(wxTimerEvent& event)
{
static int i = 460;
if (i < 0) i = 460;
mc->SetBlankBitmap();
mc->RefreshRect(wxRect(wxPoint(mc->GetX(), mc->GetY()), wxSize( 40, 40 )));
mc->DrawIT();
if (mc->GetX() < 0 || mc->GetX() >= CANVASX)
dx = - dx;
if (mc->GetY() < 0 || mc->GetY() >= CANVASY)
dy = - dy;
mc->SetX(mc->GetX() + dx);
mc->SetY(mc->GetY() + dy);
mc->RefreshRect(wxRect(wxPoint(mc->GetX(), mc->GetY()), wxSize( 40, 40 )));
}
#include "myCanvas.h"
BEGIN_EVENT_TABLE(myCanvas, wxScrolledWindow)
EVT_PAINT(myCanvas::OnPaint)
EVT_LEFT_DOWN(myCanvas::OnLeftDown)
END_EVENT_TABLE()
myCanvas::myCanvas(wxWindow *win)
: wxScrolledWindow( win
,-1
,wxPoint(0,0)
,wxSize(CANVASX, CANVASY)
,wxHSCROLL | wxVSCROLL
,_T("myCanvas"))
{
SetScrollbars(PPUX, PPUY, UX, UY);
DrawIT();
}
void myCanvas::SetX(int px) { x = px; }
void myCanvas::SetY(int py){ y = py; }
int myCanvas::GetX(void) { return x; }
int myCanvas::GetY(void) { return y; }
void myCanvas::OnPaint(wxCommandEvent& event)
{
wxPaintDC dc(this); PrepareDC(dc); dc.DrawBitmap(myBmp, GetX(), GetY(), true); }
wxBitmap myCanvas::DrawIT()
{
wxMemoryDC mdc; myBmp=wxBitmap(40, 40); mdc.SelectObject(myBmp); bmpMask=wxMask(myBmp, wxColour(0,0,0)); myBmp.SetMask(&bmpMask);
mdc.DrawCircle(20, 20, 20); return myBmp; }
wxBitmap myCanvas::SetBlankBitmap()
{
wxMemoryDC mdc; myBmp=wxBitmap(40, 40); mdc.SelectObject(myBmp); return myBmp; }
void myCanvas::OnLeftDown(wxMouseEvent& event)
{
wxMessageBox(_T("Click"), _T("Click"), wxOK | wxICON_INFORMATION, this);
}
|