{"id":3802,"date":"2021-12-13T06:18:31","date_gmt":"2021-12-13T06:18:31","guid":{"rendered":"http:\/\/truelogic.org\/wordpress\/?p=3802"},"modified":"2021-12-13T06:18:32","modified_gmt":"2021-12-13T06:18:32","slug":"3d-wxwidgets-panels","status":"publish","type":"post","link":"https:\/\/truelogic.org\/wordpress\/2021\/12\/13\/3d-wxwidgets-panels\/","title":{"rendered":"3d. wxWidgets &#8211; Panels"},"content":{"rendered":"\n<p><strong>OVERVIEW<\/strong><\/p>\n\n\n\n<p>Panels are the basic containers which are used while creating UI layouts. They are created within the main wxFrame and help create top-level grouping and positioning of controls. If layouts are not being used, then all positioning is done using fixed (x,y) points. We are not covering layouts here so we are hard-coding the placement of all controls. Since hard-coded placements are not responsive to change in window size, we have made the wxFrame non-resizable in the code below.<\/p>\n\n\n\n<p><strong>SAMPLE CODE<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">panels.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\n\nclass Panels: public wxFrame {\n\tpublic:\n\t\tPanels(const wxString&amp; title);\n};\n<\/pre><\/div>\n\n\n<pre class=\"wp-block-preformatted\">panels.cpp<\/pre>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\n#include &quot;panels.h&quot;\n\nPanels::Panels(const wxString&amp; title):\n\twxFrame(NULL, -1, title, wxDefaultPosition, wxSize(500,200)) {\n\n\twxPanel *panLeft = new wxPanel(this, -1, wxPoint(0,0), wxSize(250,100));\n\twxPanel *panRight = new wxPanel(this, -1, wxPoint(251,0), wxSize(250,100));\n\tpanLeft-&gt;SetBackgroundColour(wxColour(100,200,200));\n\tpanRight-&gt;SetBackgroundColour(wxColour(100,100,100));\n\n\twxStaticText *label1 = new wxStaticText(panLeft,-1, wxT(&quot;Left Panel&quot;), wxPoint(5,5));\n\twxStaticText *label2 = new wxStaticText(panRight,-1, wxT(&quot;Right Panel&quot;), wxPoint(5,5));\n\n\tSetMinSize(GetSize());\n\tSetMaxSize(GetSize());\n\tCenter();\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<\/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;panels.h&quot;\n\nIMPLEMENT_APP(Main)\n\nbool Main::OnInit() {\n\tPanels *app = new Panels(wxT(&quot;Panels&quot;));\n\tapp-&gt;Show(true);\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=\"500\" height=\"200\" src=\"https:\/\/truelogic.org\/wordpress\/wp-content\/uploads\/2021\/12\/Screenshot-from-2021-12-13-11-46-52.png\" alt=\"\" class=\"wp-image-3805\" srcset=\"https:\/\/truelogic.org\/wordpress\/wp-content\/uploads\/2021\/12\/Screenshot-from-2021-12-13-11-46-52.png 500w, https:\/\/truelogic.org\/wordpress\/wp-content\/uploads\/2021\/12\/Screenshot-from-2021-12-13-11-46-52-300x120.png 300w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<div class=\"mh-excerpt\"><p>OVERVIEW Panels are the basic containers which are used while creating UI layouts. They are created within the main wxFrame and help create top-level grouping <a class=\"mh-excerpt-more\" href=\"https:\/\/truelogic.org\/wordpress\/2021\/12\/13\/3d-wxwidgets-panels\/\" title=\"3d. wxWidgets &#8211; Panels\">[&#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,365],"tags":[],"class_list":["post-3802","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cc","category-wxwidgets"],"_links":{"self":[{"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/posts\/3802","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=3802"}],"version-history":[{"count":4,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/posts\/3802\/revisions"}],"predecessor-version":[{"id":3807,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/posts\/3802\/revisions\/3807"}],"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=3802"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/categories?post=3802"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/tags?post=3802"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}