{"id":4105,"date":"2022-01-13T13:46:06","date_gmt":"2022-01-13T13:46:06","guid":{"rendered":"http:\/\/truelogic.org\/wordpress\/?p=4105"},"modified":"2022-01-13T13:46:06","modified_gmt":"2022-01-13T13:46:06","slug":"9b-wxwidgets-wxnotebook","status":"publish","type":"post","link":"https:\/\/truelogic.org\/wordpress\/2022\/01\/13\/9b-wxwidgets-wxnotebook\/","title":{"rendered":"9b.wxWidgets &#8211; wxNoteBook"},"content":{"rendered":"\n<p><strong>OVERVIEW<\/strong><\/p>\n\n\n\n<p>A wxNotebook is basically a tab control which lets you group controls together in tab sections. In the sample code below, we create a mini-spreadsheet application by having a wxGrid control in each tab. Rather than create separate wxGrid controls for each tab, we define an array of wxGrid controls and create them in a loop. wxGrid is dealt with in more detail in a later section.<\/p>\n\n\n\n<p><strong>SAMPLE CODE<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">notebook.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#include &lt;wx\/notebook.h&gt;\n#include &lt;wx\/grid.h&gt;\n\n\nclass Notebook: public wxFrame {\n\tpublic:\n\t\tNotebook(const wxString &amp;title);\t\n\n\tprivate:\n\t\twxNotebook *mNotebook;\t\n\t\twxGrid  *mGrid&#x5B;5];\n};\n<\/pre><\/div>\n\n\n<pre class=\"wp-block-preformatted\">notebook.cpp<\/pre>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\n#include &quot;notebook.h&quot;\n\nNotebook::Notebook(const wxString &amp;title):\n\twxFrame(NULL, -1, title, wxDefaultPosition, wxSize(700,550)) {\n\n\tmNotebook = new wxNotebook(this, -1, wxDefaultPosition, wxDefaultSize, wxNB_BOTTOM);\n\twxString stitle;\n\n\tfor(int i = 0; i &lt; 5; i++) {\n\t   mGrid&#x5B;i] = new wxGrid(mNotebook, -1);\n\t   mGrid&#x5B;i]-&gt;CreateGrid(20,30);\n\t   mGrid&#x5B;i]-&gt;SetRowLabelSize(50);\n\t   mGrid&#x5B;i]-&gt;SetColLabelSize(25);\n\t   mGrid&#x5B;i]-&gt;SetRowLabelAlignment(wxALIGN_RIGHT, wxALIGN_CENTER);\n\t   for(int r = 0; r &lt; 20; r++) {\n\t      mGrid&#x5B;i]-&gt;SetRowSize(r, 25);\n\t   }\n\t   stitle = &quot;Sheet &quot;;\n\t   stitle.Append(wxString::Format(wxT(&quot;%d&quot;), (i+1)));\n\t   mNotebook-&gt;AddPage(mGrid&#x5B;i], stitle);\n\t}\n\n\tCenter();\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<\/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;notebook.h&quot;\n\nIMPLEMENT_APP(Main)\n\nbool Main::OnInit() {\n\tNotebook *app = new Notebook(wxT(&quot;NoteBook&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=\"700\" height=\"550\" src=\"https:\/\/truelogic.org\/wordpress\/wp-content\/uploads\/2022\/01\/Screenshot-from-2022-01-13-19-13-54.png\" alt=\"\" class=\"wp-image-4108\" srcset=\"https:\/\/truelogic.org\/wordpress\/wp-content\/uploads\/2022\/01\/Screenshot-from-2022-01-13-19-13-54.png 700w, https:\/\/truelogic.org\/wordpress\/wp-content\/uploads\/2022\/01\/Screenshot-from-2022-01-13-19-13-54-620x487.png 620w, https:\/\/truelogic.org\/wordpress\/wp-content\/uploads\/2022\/01\/Screenshot-from-2022-01-13-19-13-54-300x236.png 300w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"700\" height=\"550\" src=\"https:\/\/truelogic.org\/wordpress\/wp-content\/uploads\/2022\/01\/Screenshot-from-2022-01-13-19-14-16.png\" alt=\"\" class=\"wp-image-4109\" srcset=\"https:\/\/truelogic.org\/wordpress\/wp-content\/uploads\/2022\/01\/Screenshot-from-2022-01-13-19-14-16.png 700w, https:\/\/truelogic.org\/wordpress\/wp-content\/uploads\/2022\/01\/Screenshot-from-2022-01-13-19-14-16-620x487.png 620w, https:\/\/truelogic.org\/wordpress\/wp-content\/uploads\/2022\/01\/Screenshot-from-2022-01-13-19-14-16-300x236.png 300w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<div class=\"mh-excerpt\"><p>OVERVIEW A wxNotebook is basically a tab control which lets you group controls together in tab sections. In the sample code below, we create a <a class=\"mh-excerpt-more\" href=\"https:\/\/truelogic.org\/wordpress\/2022\/01\/13\/9b-wxwidgets-wxnotebook\/\" title=\"9b.wxWidgets &#8211; wxNoteBook\">[&#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-4105","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\/4105","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=4105"}],"version-history":[{"count":4,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/posts\/4105\/revisions"}],"predecessor-version":[{"id":4111,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/posts\/4105\/revisions\/4111"}],"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=4105"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/categories?post=4105"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/tags?post=4105"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}