{"id":3913,"date":"2021-12-20T14:01:25","date_gmt":"2021-12-20T14:01:25","guid":{"rendered":"http:\/\/truelogic.org\/wordpress\/?p=3913"},"modified":"2021-12-20T14:01:27","modified_gmt":"2021-12-20T14:01:27","slug":"5b-4-wxwidgets-flexgridsizer","status":"publish","type":"post","link":"https:\/\/truelogic.org\/wordpress\/2021\/12\/20\/5b-4-wxwidgets-flexgridsizer\/","title":{"rendered":"5b-4. wxWidgets &#8211; FlexGridSizer"},"content":{"rendered":"\n<p><strong>OVERVIEW<\/strong><\/p>\n\n\n\n<p>The difference between wxGridSizer and wxFlexGridSizer is that in wxFlexGridSizer, rows can have different heights and columns can have different widths. For eg. in  a 4 x 4 grid, row 1 may be given a separate height as compared to the other rows and column 3 may be given a separate width as compared to the other columns.<\/p>\n\n\n\n<p>The arguments used to create a wxFlexGridSizer are (rows, columns, vertical spacing, horizontal spacing)<\/p>\n\n\n\n<p>In the sample code below, we setup a dialog with labels on the left and text boxes on the right. The last textbox is a multi-line textbox so it stretches down the rest of the window.<\/p>\n\n\n\n<p><strong>SAMPLE CODE<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">wxflexgridsizer.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 FlexGridSizer: public wxFrame {\n\tpublic:\n\t\tFlexGridSizer(const wxString &amp;title);\t\n};\n<\/pre><\/div>\n\n\n<pre class=\"wp-block-preformatted\">wxflexgidsizer.cpp<\/pre>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\n#include &quot;wxflexgridsizer.h&quot;\n\nFlexGridSizer::FlexGridSizer(const wxString &amp;title):\n\twxFrame(NULL, -1, title, wxDefaultPosition, wxSize(500,250)) {\n\n\twxPanel *basePanel = new wxPanel(this,-1);\n\twxFlexGridSizer *fgs = new wxFlexGridSizer(4,2,3,10);\n\tbasePanel-&gt;SetSizer(fgs);\n\n\twxStaticText *lblA1=  new wxStaticText(basePanel, -1, wxT(&quot;Answer 1&quot;));\n\twxStaticText *lblA2=  new wxStaticText(basePanel, -1, wxT(&quot;Answer 2&quot;));\n\twxStaticText *lblA3=  new wxStaticText(basePanel, -1, wxT(&quot;Answer 3&quot;));\n\twxStaticText *lblA4=  new wxStaticText(basePanel, -1, wxT(&quot;Answer 4&quot;));\n\n\n\twxTextCtrl *txtA1=  new wxTextCtrl(basePanel, -1, wxT(&quot;&quot;));\n\twxTextCtrl *txtA2=  new wxTextCtrl(basePanel, -1, wxT(&quot;&quot;));\n\twxTextCtrl *txtA3=  new wxTextCtrl(basePanel, -1, wxT(&quot;&quot;));\n\twxTextCtrl *txtA4=  new wxTextCtrl(basePanel, -1, wxT(&quot;&quot;), wxPoint(-1,-1), wxSize(-1,-1), wxTE_MULTILINE);\n\n\tfgs-&gt;Add(lblA1); fgs-&gt;Add(txtA1, 1, wxEXPAND);\n\tfgs-&gt;Add(lblA2); fgs-&gt;Add(txtA2, 1, wxEXPAND);\n\tfgs-&gt;Add(lblA3); fgs-&gt;Add(txtA3, 1, wxEXPAND);\n\tfgs-&gt;Add(lblA4); fgs-&gt;Add(txtA4, 1, wxEXPAND);\n\n\tfgs-&gt;AddGrowableRow(3, 1);\n\tfgs-&gt;AddGrowableCol(1,1);\n\n\n\tCenter();\n}\n<\/pre><\/div>\n\n\n<p>The output is given below<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"500\" height=\"250\" src=\"https:\/\/truelogic.org\/wordpress\/wp-content\/uploads\/2021\/12\/Screenshot-from-2021-12-20-19-30-07.png\" alt=\"\" class=\"wp-image-3916\" srcset=\"https:\/\/truelogic.org\/wordpress\/wp-content\/uploads\/2021\/12\/Screenshot-from-2021-12-20-19-30-07.png 500w, https:\/\/truelogic.org\/wordpress\/wp-content\/uploads\/2021\/12\/Screenshot-from-2021-12-20-19-30-07-300x150.png 300w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<div class=\"mh-excerpt\"><p>OVERVIEW The difference between wxGridSizer and wxFlexGridSizer is that in wxFlexGridSizer, rows can have different heights and columns can have different widths. For eg. in <a class=\"mh-excerpt-more\" href=\"https:\/\/truelogic.org\/wordpress\/2021\/12\/20\/5b-4-wxwidgets-flexgridsizer\/\" title=\"5b-4. wxWidgets &#8211; FlexGridSizer\">[&#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-3913","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\/3913","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=3913"}],"version-history":[{"count":4,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/posts\/3913\/revisions"}],"predecessor-version":[{"id":3918,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/posts\/3913\/revisions\/3918"}],"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=3913"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/categories?post=3913"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/tags?post=3913"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}