{"id":3874,"date":"2021-12-17T06:59:17","date_gmt":"2021-12-17T06:59:17","guid":{"rendered":"http:\/\/truelogic.org\/wordpress\/?p=3874"},"modified":"2021-12-17T06:59:19","modified_gmt":"2021-12-17T06:59:19","slug":"5a-wxwidgets-absolute-positioning","status":"publish","type":"post","link":"https:\/\/truelogic.org\/wordpress\/2021\/12\/17\/5a-wxwidgets-absolute-positioning\/","title":{"rendered":"5a. wxWidgets &#8211; Absolute Positioning"},"content":{"rendered":"\n<p><strong>OVERVIEW<\/strong><\/p>\n\n\n\n<p>We take a look at placing controls in a window with absolute positioning. This is not of much practical use except if you make GUI which are of fixed sizes. In the example below, the controls will not change in size and position if you resize the window.<\/p>\n\n\n\n<p><strong>SAMPLE CODE<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">absolute.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    #include &lt;wx\/wx.h&gt;\n#endif\n\nclass Absolute: public wxFrame {\n\n    public:\n      Absolute(const wxString &amp;title);\n \n};\n<\/pre><\/div>\n\n\n<pre class=\"wp-block-preformatted\">absolute.cpp<\/pre>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n#include &quot;absolute.h&quot;\n\n\nAbsolute::Absolute(const wxString &amp;amp;title):\n\n    wxFrame(NULL, -1, title, wxDefaultPosition, wxSize(500,350)) {\n \n    wxPanel *panel = new wxPanel(this, -1);     \n    wxButton *btn = new wxButton(panel, -1, wxT(&quot;I am at 20,20&quot;), wxPoint(20,20));\n    wxStaticText *label = new wxStaticText(panel, -1, wxT(&quot;I am at 40,100&quot;), wxPoint(40,100));\n\n    wxTextCtrl *edit = new wxTextCtrl(panel, -1, wxT(&quot;This is first line\\nThis is second line&quot;),\n\t\t    \twxPoint(100,150), wxSize(220,40), wxTE_MULTILINE);\n\n    Center();\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: plain; title: ; notranslate\" title=\"\">\n#include &amp;lt;wx\/wxprec.h&gt;\n#ifndef WX_PRECOMP\n    #include &amp;lt;wx\/wx.h&gt;\n#endif\n\nclass Main: public wxApp {\n\n\tpublic:\n\t        virtual 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;absolute.h&quot;\n \nIMPLEMENT_APP(Main)\n\nbool Main::OnInit() {\n\n    Absolute *app = new Absolute(wxT(&quot;Absolute Positioning&quot;));\n    app-&gt;Show(true);\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=\"350\" src=\"https:\/\/truelogic.org\/wordpress\/wp-content\/uploads\/2021\/12\/Screenshot-from-2021-12-17-12-28-18.png\" alt=\"\" class=\"wp-image-3877\" srcset=\"https:\/\/truelogic.org\/wordpress\/wp-content\/uploads\/2021\/12\/Screenshot-from-2021-12-17-12-28-18.png 500w, https:\/\/truelogic.org\/wordpress\/wp-content\/uploads\/2021\/12\/Screenshot-from-2021-12-17-12-28-18-300x210.png 300w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<div class=\"mh-excerpt\"><p>OVERVIEW We take a look at placing controls in a window with absolute positioning. This is not of much practical use except if you make <a class=\"mh-excerpt-more\" href=\"https:\/\/truelogic.org\/wordpress\/2021\/12\/17\/5a-wxwidgets-absolute-positioning\/\" title=\"5a. wxWidgets &#8211; Absolute Positioning\">[&#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-3874","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\/3874","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=3874"}],"version-history":[{"count":3,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/posts\/3874\/revisions"}],"predecessor-version":[{"id":3878,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/posts\/3874\/revisions\/3878"}],"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=3874"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/categories?post=3874"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/tags?post=3874"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}