{"id":4080,"date":"2022-01-06T12:43:18","date_gmt":"2022-01-06T12:43:18","guid":{"rendered":"http:\/\/truelogic.org\/wordpress\/?p=4080"},"modified":"2022-01-06T12:43:19","modified_gmt":"2022-01-06T12:43:19","slug":"8e-wxwidgets-wxstatictext","status":"publish","type":"post","link":"https:\/\/truelogic.org\/wordpress\/2022\/01\/06\/8e-wxwidgets-wxstatictext\/","title":{"rendered":"8e.wxWidgets &#8211; wxStaticText"},"content":{"rendered":"\n<p><strong>OVERVIEW<\/strong><\/p>\n\n\n\n<p>We have used wxStaticText a lot in the previous examples. It is used to display either a single or multiple lines of text. In the sample code below, we will display multiple lines of text in a panel.<\/p>\n\n\n\n<p><strong>SAMPLE CODE<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">statictext.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 StaticText: public wxFrame {\n\n    public:\n      StaticText(const wxString &amp;title);\n\n};\n\n<\/pre><\/div>\n\n\n<pre class=\"wp-block-preformatted\">statictext.cpp<\/pre>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\n#include &quot;statictext.h&quot;\n\nStaticText::StaticText(const wxString &amp;title):\n\n    wxFrame(NULL, -1, title, wxDefaultPosition, wxSize(500,200)) {\n \n    wxPanel *panel = new wxPanel(this, -1);   \n    panel-&gt;SetBackgroundColour(wxColour(200,200,100)); \n\n    wxStaticText *label = new wxStaticText(panel, -1, wxT(&quot;&quot;), wxPoint(20,10), wxDefaultSize);\n    wxString text = wxT(&quot;This is line 1.\\nThis is line 2.\\nThis is line 3.\\n&quot;);\n    label-&gt;SetLabel(text);\n\n    Center();\n\n}\n\n\n\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    #include &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;statictext.h&quot;\n \nIMPLEMENT_APP(Main)\n\nbool Main::OnInit() {\n\n    StaticText *app = new StaticText(wxT(&quot;StaticText&quot;));\n    app-&gt;Show(true);\n}\n<\/pre><\/div>\n\n\n<p><\/p>\n\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\/2022\/01\/Screenshot-from-2022-01-06-18-10-48.png\" alt=\"\" class=\"wp-image-4083\" srcset=\"https:\/\/truelogic.org\/wordpress\/wp-content\/uploads\/2022\/01\/Screenshot-from-2022-01-06-18-10-48.png 500w, https:\/\/truelogic.org\/wordpress\/wp-content\/uploads\/2022\/01\/Screenshot-from-2022-01-06-18-10-48-300x120.png 300w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<div class=\"mh-excerpt\"><p>OVERVIEW We have used wxStaticText a lot in the previous examples. It is used to display either a single or multiple lines of text. In <a class=\"mh-excerpt-more\" href=\"https:\/\/truelogic.org\/wordpress\/2022\/01\/06\/8e-wxwidgets-wxstatictext\/\" title=\"8e.wxWidgets &#8211; wxStaticText\">[&#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-4080","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\/4080","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=4080"}],"version-history":[{"count":4,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/posts\/4080\/revisions"}],"predecessor-version":[{"id":4085,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/posts\/4080\/revisions\/4085"}],"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=4080"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/categories?post=4080"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/tags?post=4080"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}