{"id":4194,"date":"2022-01-24T16:14:26","date_gmt":"2022-01-24T16:14:26","guid":{"rendered":"http:\/\/truelogic.org\/wordpress\/?p=4194"},"modified":"2022-01-24T16:14:27","modified_gmt":"2022-01-24T16:14:27","slug":"11g-wxwidgets-shapes","status":"publish","type":"post","link":"https:\/\/truelogic.org\/wordpress\/2022\/01\/24\/11g-wxwidgets-shapes\/","title":{"rendered":"11g.wxWidgets &#8211; Shapes"},"content":{"rendered":"\n<p><strong>OVERVIEW<\/strong><\/p>\n\n\n\n<p>Apart from the basic rectangles and lines, there are more complex shapes which can be drawn: Ellipse, Rounded Rectangle, Arc, Circle, Splines and Polygons. <\/p>\n\n\n\n<p><strong>SAMPLE CODE<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">shapes.h<\/pre>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\n#include &lt;wx\/wxprec.h&gt;\n#ifndef WX_PRECOMP\n\t#include &lt;wx\/wx.h&gt;\n#endif\n\nclass Shapes: public wxFrame {\n\tpublic:\n\t\tShapes(const wxString &amp;title);\n\t\tvoid onPaint(wxPaintEvent &amp;event);\n\t\n};\n\n<\/pre><\/div>\n\n\n<pre class=\"wp-block-preformatted\">shapes.cpp<\/pre>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\n#include &quot;shapes.h&quot;\n\nShapes::Shapes(const wxString &amp;title):\n\twxFrame(NULL, -1, title, wxDefaultPosition, wxSize(600,500)) {\n\tsrand(time(NULL));\n\tBind(wxEVT_PAINT, &amp;Shapes::onPaint, this);\n\tSetBackgroundColour(wxColour(255,255,255));\n}\n\nvoid Shapes::onPaint(wxPaintEvent &amp;event) {\n\twxPaintDC dc(this);\n\n\tdc.DrawEllipse(20, 20, 90, 60);\n\tdc.DrawRoundedRectangle(130, 20, 90, 60, 10);\n\tdc.DrawArc(240, 40, 340, 40, 290, 20);\n  \tdc.DrawRectangle(20, 120, 80, 50);\n  \tdc.DrawCircle(170, 230, 35);\n\tdc.DrawRectangle(250, 200, 60, 60);\n\n\tdc.SetPen(wxPen(wxColour(100,200,0), 1, wxPENSTYLE_SOLID));\n\n\twxPoint lines &#x5B;] = { wxPoint(10,160), wxPoint(120, 220),  wxPoint(50, 210), wxPoint(300, 210) };\n\tdc.DrawLines(4, lines);\n\n\twxPoint splines&#x5B;] = { wxPoint(240, 170), wxPoint(210, 70), wxPoint(185, 80), wxPoint(125, 110) };\n\tdc.DrawSpline(4, splines);\n\n\twxPoint polygon&#x5B;] = { wxPoint(130, 140), wxPoint(180, 170), wxPoint(180, 140), wxPoint(220, 110), wxPoint(140, 100) };\n\tdc.DrawPolygon(4, polygon);\n}\n\n<\/pre><\/div>\n\n\n<pre class=\"wp-block-preformatted\">main.h<\/pre>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\n#include &lt;wx\/wxprec.h&gt;\n#ifndef WX_PRECOMP\n\t#include &lt;wx\/wx.h&gt;\n#endif\n\nclass Main: public wxApp {\n\n\tpublic:\n\t\tvirtual bool OnInit();\n};\n\n<\/pre><\/div>\n\n\n<pre class=\"wp-block-preformatted\">main.cpp<\/pre>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\n#include &quot;main.h&quot;\n#include &quot;shapes.h&quot;\n\nIMPLEMENT_APP(Main)\n\nbool Main::OnInit() {\n\tShapes *app = new Shapes(wxT(&quot;Shapes&quot;));\n\tapp-&gt;Show(true);\n\n}\n\n\n<\/pre><\/div>\n\n\n<p>The output is shown below<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"600\" height=\"500\" src=\"https:\/\/truelogic.org\/wordpress\/wp-content\/uploads\/2022\/01\/Screenshot-from-2022-01-24-21-43-47.png\" alt=\"\" class=\"wp-image-4195\" srcset=\"https:\/\/truelogic.org\/wordpress\/wp-content\/uploads\/2022\/01\/Screenshot-from-2022-01-24-21-43-47.png 600w, https:\/\/truelogic.org\/wordpress\/wp-content\/uploads\/2022\/01\/Screenshot-from-2022-01-24-21-43-47-300x250.png 300w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<div class=\"mh-excerpt\"><p>OVERVIEW Apart from the basic rectangles and lines, there are more complex shapes which can be drawn: Ellipse, Rounded Rectangle, Arc, Circle, Splines and Polygons. <a class=\"mh-excerpt-more\" href=\"https:\/\/truelogic.org\/wordpress\/2022\/01\/24\/11g-wxwidgets-shapes\/\" title=\"11g.wxWidgets &#8211; Shapes\">[&#8230;]<\/a><\/p>\n<\/div>","protected":false},"author":1,"featured_media":3595,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[302],"tags":[],"class_list":["post-4194","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cc"],"_links":{"self":[{"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/posts\/4194","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/comments?post=4194"}],"version-history":[{"count":1,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/posts\/4194\/revisions"}],"predecessor-version":[{"id":4196,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/posts\/4194\/revisions\/4196"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/media\/3595"}],"wp:attachment":[{"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/media?parent=4194"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/categories?post=4194"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/tags?post=4194"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}