<pre>
#include "wx/wx.h"
#include <sstream>
#include <string>
// The panel, a panel is what make it behave as a dialog box
class PanelClass: public wxPanel
{
public:
PanelClass(wxFrame *frame, int x, int y, int w, int h) : wxPanel(frame, wxID_ANY, wxPoint(x, y), wxSize(w, h))
{
Label1 = new wxStaticText(this, -1, "Med dette program kan du løse en andengradsligning af typen: ax^2+bx+c=0", wxPoint(5, 5), wxSize(290, 25));
Label2 = new wxStaticText(this, -1, "Indtast a:", wxPoint(5, 35), wxSize(60, 20));
a = new wxTextCtrl(this, Text1Id, "", wxPoint(60, 35), wxSize(50, 20));
Label3 = new wxStaticText(this, -1, "Indtast b:", wxPoint(5, 60), wxSize(60, 20));
b = new wxTextCtrl(this, Text2Id, "", wxPoint(60, 60), wxSize(50, 20));
Label4 = new wxStaticText(this, -1, "Indtast c:", wxPoint(5, 85), wxSize(60, 20));
c = new wxTextCtrl(this, Text3Id, "", wxPoint(60, 85), wxSize(50, 20));
Button1 = new wxButton(this, ButtonId, "Beregn", wxPoint(5, 110), wxSize(100, 20));
}
~PanelClass()
{
delete a;
delete b;
delete c;
delete Button1;
}
private:
// Some id's for my controls
enum CtrlId
{
Text1Id = 1001,
Text2Id,
Text3Id,
ButtonId
};
wxTextCtrl *a;
wxTextCtrl *b;
wxTextCtrl *c;
wxStaticText *Label1;
wxStaticText *Label2;
wxStaticText *Label3;
wxStaticText *Label4;
wxButton *Button1;
void OnAddButton(wxCommandEvent &event);
DECLARE_EVENT_TABLE()
};
// The event table for the panel, this routes messages/events to functions
BEGIN_EVENT_TABLE(PanelClass, wxPanel)
EVT_BUTTON(ButtonId, PanelClass:
nAddButton)
EVT_SIZE(PanelClass:
nSize)
END_EVENT_TABLE()
// The Frame, this is the topleve windows, which hosts the panel
class FrameClass : public wxFrame
{
public:
FrameClass(wxFrame *frame, const wxChar *title, int x, int y, int w, int h) :
wxFrame(frame, wxID_ANY, title, wxPoint(x, y), wxSize(w, h))
{
Panel = new PanelClass(this, x, y, w, h);
}
~FrameClass()
{
delete Panel;
}
PanelClass *Panel;
};
// The application, all applications has one
class AppClass: public wxApp
{
public:
bool OnInit()
{
Frame = new FrameClass(0, "Andengradsligning", 100, 100, 300, 200);
Frame->Show(true);
SetTopWindow(Frame);
return true;
}
FrameClass *Frame;
};
IMPLEMENT_APP(AppClass)
// The function that is called when the user hits the Add button.
void PanelClass:
nAddButton(wxCommandEvent &WXUNUSED(event))
{ }
</pre>
Sådan, nu ser det godt ud
Så er mit næste problem, hvordan jeg får lavet mine udregninger, og printet dem i et nye vindue?