Created
June 11, 2014 14:28
-
-
Save vadz/13b92eebb0369ac68ba6 to your computer and use it in GitHub Desktop.
Test of wxWidgets DrawEllipticArc()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <wx/app.h> | |
#include <wx/dcclient.h> | |
#include <wx/frame.h> | |
#include <wx/panel.h> | |
#include <wx/sizer.h> | |
#include <wx/spinctrl.h> | |
class ArcFrame : public wxFrame | |
{ | |
public: | |
ArcFrame() | |
: wxFrame(NULL, wxID_ANY, "DrawEllipticArc() test") | |
{ | |
const auto canvas = new wxWindow(this, wxID_ANY, wxDefaultPosition, | |
wxSize(300, 200), | |
wxFULL_REPAINT_ON_RESIZE); | |
const auto panel = new wxPanel(this); | |
const auto startAngle = new wxSpinCtrl(panel); | |
startAngle->SetRange(-720, 720); | |
const auto endAngle = new wxSpinCtrl(panel); | |
endAngle->SetRange(-720, 720); | |
const auto drawArc = [=](wxCommandEvent&) { canvas->Refresh(); }; | |
startAngle->Bind(wxEVT_SPINCTRL, drawArc); | |
endAngle->Bind(wxEVT_SPINCTRL, drawArc); | |
canvas->Bind(wxEVT_PAINT, [=](wxPaintEvent&) { | |
wxPaintDC dc(canvas); | |
dc.DrawEllipticArc(wxPoint(0, 0), canvas->GetClientSize(), | |
startAngle->GetValue(), endAngle->GetValue()); | |
}); | |
const auto sizerControls = new wxBoxSizer(wxHORIZONTAL); | |
sizerControls->Add(startAngle, wxSizerFlags().Centre().Border()); | |
sizerControls->Add(endAngle, wxSizerFlags().Centre().Border()); | |
panel->SetSizer(sizerControls); | |
const auto sizer = new wxBoxSizer(wxVERTICAL); | |
sizer->Add(panel, wxSizerFlags().Expand()); | |
sizer->Add(canvas, wxSizerFlags(1).Expand()); | |
SetSizerAndFit(sizer); | |
Show(); | |
} | |
}; | |
class ArcApp : public wxApp | |
{ | |
public: | |
bool OnInit() override | |
{ | |
new ArcFrame(); | |
return true; | |
} | |
}; | |
wxIMPLEMENT_APP(ArcApp); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment