<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.codeblocks.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Chatumao</id>
	<title>Code::Blocks - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.codeblocks.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Chatumao"/>
	<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php/Special:Contributions/Chatumao"/>
	<updated>2026-05-16T23:54:49Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.35.0</generator>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=WxSmith_tutorial:_Working_with_multiple_resources&amp;diff=7575</id>
		<title>WxSmith tutorial: Working with multiple resources</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=WxSmith_tutorial:_Working_with_multiple_resources&amp;diff=7575"/>
		<updated>2013-05-12T13:56:15Z</updated>

		<summary type="html">&lt;p&gt;Chatumao: /* Working with Multiple Windows */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:wxSmith Documentation]]&lt;br /&gt;
= Working with Multiple Windows =&lt;br /&gt;
&lt;br /&gt;
In this tutorial, I'll show you how to create an application with more than one window. We will have, as usual, a main window; and in it we will create and show at the click of one button a wxFrame window and at the click of another button, a wxDialog window. One important difference between these two windows is that a wxDialog has the possibility of stopping the application until it is closed. It is generally used for asking the user a question or questions which demand answers before computation can proceed. Otherwise, the wxFrame generally has greater capabilities. &lt;br /&gt;
 &lt;br /&gt;
As usual, we will start with an empty project. Let's name the project &amp;quot;Tutorial_4&amp;quot;. As always, remember to add the Close() statement. Check that the empty application compiles, runs and closes fine.&lt;br /&gt;
 &lt;br /&gt;
New windows can be added from the '''wxSmith''' menu item from the main menu of Code::Blocks. You can find there the following possibilities: &lt;br /&gt;
&lt;br /&gt;
*'''Add wxPanel''' - this will add a new panel into the window &lt;br /&gt;
*'''Add wxFloatingFrame''' –  this will add Floating frame window&lt;br /&gt;
*'''Add wxDialog''' - this adds a new dialog window &lt;br /&gt;
*'''Add wxFrame''' - this adds a new frame window. &lt;br /&gt;
&lt;br /&gt;
Let's first add a new wxDialog. When you choose this option you will see the following window: &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut04_001.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here we can set the following parameters: &lt;br /&gt;
*Class name -  the name of the class which will be generated for the resource. It will also be the name of a resource &lt;br /&gt;
*Header file – the name of the header file with the class declaration &lt;br /&gt;
*Source file – the name of the source file with the class definition &lt;br /&gt;
*XRC file - if you check this option you can enter the name of an XRC file which will contain the XRC's structure (XRC files will be covered in a tutorial not yet written.) &lt;br /&gt;
*Add XRC file to autoload list - this option is available only with XRC files and notifies wxSmith that it should automatically load the XRC file when the application starts. &lt;br /&gt;
&lt;br /&gt;
Now let's change the name of the window to something more distinctive like &amp;quot;FirstDialog&amp;quot;. Note that if you change the class name, the names of the files are also updated. (More correctly, they are updated as long as you don't change them manually). &lt;br /&gt;
&lt;br /&gt;
After clicking OK, you will be prompted for a list of build targets into which the new window will be added. Select both ''debug'' and ''release'', and we can continue.&lt;br /&gt;
 &lt;br /&gt;
A new dialog is automatically opened in the editor. In the top bar of the frame of the editor, note that there are two .wxs files available to the editor, Tutorial_4Frame.wxs and the newly created FirstDialog1.wxs.  Both are completely blank. Into FirstDialog.wxs let's add some simple content so that it looks like this in the editor:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut04_002.png]]&lt;br /&gt;
&lt;br /&gt;
It is a good review exercise to figure out from this figure what has been done. It is very similar to what we did at the beginning of the previous tutorial. Before reading further, try your hand at making it.  (To tell the truth, it doesn't matter much what you put in because all we are going to do with it is show it, But if you need a review, here is what I did: 1. Put a wxBoxSizer on the editor. 2. Put a wxPanel in the sizer  (and remembered to turn on its Expand property). 3. Put on the panel a wxStaticBoxSizer, changed its orientation to Vertical,  and set its label to “This is the first dialog.” 4. Into the StaticBoxSizer put first a wxTextCtrl and then a wxStaticText item.)  At this point, the Show Preview button on the extreme right of the editor will show us what we have, while running the program will show nothing, because the application has no programming to show our dialog. &lt;br /&gt;
&lt;br /&gt;
Now let's go back to the wxSmith item on the Code::Blocks menu and add a wxFrame window (FirstFrame) and add some content into it:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut04_003.png]]&lt;br /&gt;
&lt;br /&gt;
Again, it is good review to make the window look like this, but the content is not critical for what follows.&lt;br /&gt;
&lt;br /&gt;
== Using a Dialog Window Modally ==&lt;br /&gt;
&lt;br /&gt;
Dialogs (but not frames) can be shown modally. When  a dialog is shown modally, all other windows in the application are frozen until the dialog finishes its job. Modal dialogs are useful when the user must provide some information before computation can continue. For example, the window used to configure a new resource was shown modally.&lt;br /&gt;
 &lt;br /&gt;
Now let's try to invoke our dialog. Generally such dialogs will pop-up in reaction to some user action like choosing a menu option or clicking on a button. We will use a button since this approach is really easy. Let's switch into the main frame - the one that was opened right after creating the new project - and add a box sizer and button: &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut04_004.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now we have to create an action for the button-click event. The easiest way is to double-click the button in the editor. wxSmith will automatically add a new event handler function:&lt;br /&gt;
&lt;br /&gt;
 void Tutorial_4Frame::OnButton1Click(wxCommandEvent&amp;amp; event)&lt;br /&gt;
 {&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
If you don't see this code, scroll down to the end of the .cpp file.&lt;br /&gt;
&lt;br /&gt;
In this frame, let's put the code to invoke our dialog: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
void Tutorial_4Frame::OnButton1Click(wxCommandEvent&amp;amp; event)&lt;br /&gt;
{&lt;br /&gt;
    FirstDialog dialog(this);&lt;br /&gt;
    dialog.ShowModal();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the first added line, we create the dialog's object and declare that ''this'' window (the main frame) is the parent of dialog. In the second line, we show the dialog modally. The call to ShowModal(), which is a function (or method) of the dialog, blocks everything else until the dialog is closed. &lt;br /&gt;
&lt;br /&gt;
There's one more thing we need to add before our application will compile. Jump to the beginning of the file and add the following code after the first group of  other includes:&lt;br /&gt;
&lt;br /&gt;
 #include &amp;quot;FirstDialog.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Note that you should '''not''' add it inside code which looks like this: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//(*InternalHeaders(Tutorial_4Frame)&lt;br /&gt;
#include &amp;lt;wx/intl.h&amp;gt;&lt;br /&gt;
#include &amp;lt;wx/string.h&amp;gt;&lt;br /&gt;
//*)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is a block of code that is automatically generated by wxSmith. Every block starts with a //(*BlockName comment and ends with a //*). You may find other similar blocks in both header and source files. If you change their content, all changes will be lost next time you change something in the editor. These comments and everything inside them belong to wxSmith, so don't mess with them.&lt;br /&gt;
&lt;br /&gt;
To sum up, the headers section should look like this: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#include &amp;quot;wx_pch.h&amp;quot;&lt;br /&gt;
#include &amp;quot;Tutorial_4Main.h&amp;quot;&lt;br /&gt;
#include &amp;lt;wx/msgdlg.h&amp;gt;&lt;br /&gt;
#include &amp;quot;FirstDialog.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
//(*InternalHeaders(Tutorial_4Frame)&lt;br /&gt;
#include &amp;lt;wx/intl.h&amp;gt;&lt;br /&gt;
#include &amp;lt;wx/string.h&amp;gt;&lt;br /&gt;
//*)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we can compile and run our application. If you click the button on the main window, this dialog will pop-up:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut04_005.png]]&lt;br /&gt;
&lt;br /&gt;
== Using Modeless Dialogs and Frame Windows ==&lt;br /&gt;
&lt;br /&gt;
Another way to show a window is as a modeless window. In such cases, the new window does not block other windows in the application and two (or more) windows can cooperate in one application. &lt;br /&gt;
Before we add new code into our application there's one more thing you should know. Each window may exist only as long as its object (the instance of the resource's c++ class) exists. So we cannot use the same approach as in the case of a modal dialog. In modal mode, an object was created as a local variable of the event handler by the simple declaration statement&lt;br /&gt;
&lt;br /&gt;
 FirstDialog dialog(this);&lt;br /&gt;
&lt;br /&gt;
We could do this only because the ShowModal method was blocking as long as the dialog was shown. Now with a wxFrame, which does not have the ShowModal possibility, we will have to create objects using the '''new''' operator of C++ because the objects must exist after leaving the handler function and also because windows not using modal mode will delete such objects automatically when the window is closed.&lt;br /&gt;
 &lt;br /&gt;
To allow creating the FirstFrame class we should add #include &amp;quot;FirstFrame.h&amp;quot; into the list of includes just as in the case of FirstDialog: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#include &amp;quot;wx_pch.h&amp;quot;&lt;br /&gt;
#include &amp;quot;Tutorial_4Main.h&amp;quot;&lt;br /&gt;
#include &amp;lt;wx/msgdlg.h&amp;gt;&lt;br /&gt;
#include &amp;quot;FirstDialog.h&amp;quot;&lt;br /&gt;
#include &amp;quot;FirstFrame.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
//(*InternalHeaders(Tutorial_4Frame)&lt;br /&gt;
#include &amp;lt;wx/intl.h&amp;gt;&lt;br /&gt;
#include &amp;lt;wx/string.h&amp;gt;&lt;br /&gt;
//*)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now let's add two more buttons to the main frame: &lt;br /&gt;
*Add new dialog &lt;br /&gt;
*Add new frame &lt;br /&gt;
&lt;br /&gt;
We can also name the first button to show what it does:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut04_006.png]]&lt;br /&gt;
&lt;br /&gt;
Now let's add a handler to the ''Add new dialog'' button:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
void Tutorial_4Frame::OnButton2Click(wxCommandEvent&amp;amp; event)&lt;br /&gt;
{&lt;br /&gt;
    FirstDialog* dlg = new FirstDialog(this);&lt;br /&gt;
    dlg-&amp;gt;Show();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Analogously, we can write the code for FirstFrame:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
void Tutorial_4Frame::OnButton3Click(wxCommandEvent&amp;amp; event)&lt;br /&gt;
{&lt;br /&gt;
    FirstFrame* frm = new FirstFrame(this);&lt;br /&gt;
    frm-&amp;gt;Show();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now each time we click the ''Add new dialog'' or ''Add new frame'' button, a new window shows up.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is the end of this tutorial. I hope that you learned some new and useful things. We have covered the use of two of the four things you can add to your project by using the wxSmith item on the Code::Blocks main menu. In the next tutorial, I'll show how to use another of the four, namely the wxPanel.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;'''[[WxSmith tutorial: Building more complex window|Previous]] | [[WxSmith tutorials|Index]] | [[WxSmith tutorial: Using wxPanel resources|Next]]'''&amp;lt;/center&amp;gt;&lt;/div&gt;</summary>
		<author><name>Chatumao</name></author>
	</entry>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=WxSmith_tutorial:_Building_more_complex_window&amp;diff=7574</id>
		<title>WxSmith tutorial: Building more complex window</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=WxSmith_tutorial:_Building_more_complex_window&amp;diff=7574"/>
		<updated>2013-05-12T13:15:56Z</updated>

		<summary type="html">&lt;p&gt;Chatumao: /* Building a More Complex Window */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:wxSmith Documentation]]&lt;br /&gt;
= Building a More Complex Window =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this tutorial, we will build a moderately complex form or window. Most of the complexity comes from the use of sizers, but their use is the key to making the same program work nicely on multiple operating systems.  Although the process may look complicated when you are new to wxSmith, after writing a few applications you will probably easily build resources with at least this much complexity, so don't get scared. I work with wxSmith almost every day; that's the best way to find bugs and to get ideas for improvements. As it's creator, that's my job. Although the process may look complex at first, I can assure you that you can quickly get the hang of it.&lt;br /&gt;
 &lt;br /&gt;
As I'm writing the beginning of this tutorial, I'm also beginning to write the application to illustrate it. I'll describe what I do as I go. Probably I'll make a mistake or two or at least forget to set some property, so the window won't work quite right. We'll learn to recognize the causes of certain misbehaviors of the window and to fix the problems. &lt;br /&gt;
&lt;br /&gt;
We will start with an empty frame - if you have read the previous tutorials you should be able to create one without problems. (Don't forget to put in the Close() statement.)&lt;br /&gt;
 &lt;br /&gt;
My idea for an example is something to manage a collection of CD-ROMs. Lest you be disappointed, let me say at the outset that we will develop only the form for the main window of the program; we will not do any database programming to make the application actually work.  &lt;br /&gt;
So what should the main window look like? On the left side of the window, I want to have a list of CD-ROMs. When I click on one, I want details about that CD to show up on the right side of the window. So basically we have two regions in our window: one with the list and one with the details of the CD selected from the list.&lt;br /&gt;
&lt;br /&gt;
I will use sizers because the application should run on various platforms – Linux, Mac OS X, or MS Windows – without any re-writing and the main window should be resizable. That is, as the user changes the size of the main window, the size of the space available for the list should change and the spacing of the items in the details should adjust to make an aesthetically pleasing window.&lt;br /&gt;
&lt;br /&gt;
== Building the skeleton ==&lt;br /&gt;
&lt;br /&gt;
In the first tutorial, we added an extra wxPanel into the frame to make the background better. Let's do the same thing here: &lt;br /&gt;
&lt;br /&gt;
* First add a wxBoxSizer directly into the window&lt;br /&gt;
* Add a wxPanel into that sizer&lt;br /&gt;
* Set the size of border to 0 to make the panel cover the entire window.&lt;br /&gt;
&lt;br /&gt;
Now we should have this result:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut03_001.png]]&lt;br /&gt;
&lt;br /&gt;
Now let's add a wxBoxSizer into the panel. This sizer will manage our two main regions. After that sizer is added, the tree structure should look like this:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut03_002.png]]&lt;br /&gt;
&lt;br /&gt;
Now we can start filling those two regions - each one can have only one component in it – but we want a number of them. So what do we do? We put one sizer in each region, and then we can put a number of items in each sizer. In such situations I usually use a wxStaticBoxSizer because in it we can name the region. So let's add two wxStaticBoxSizer-s into the window, one into each region. Be careful while adding the second one lest you add it into the first region. To add the second sizer properly, you must click on the border surrounding the first one, as in the picture. Remember that the parent for a new item is always the item totally covered with blue. The screen should look like this when you drop the second sizer:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut03_003.png]]&lt;br /&gt;
&lt;br /&gt;
The window is small now,  but it will change when we will add some components into the regions.&lt;br /&gt;
&lt;br /&gt;
== Building the '''List of CDs''' region: Orientation, Proportion, Expansion ==&lt;br /&gt;
&lt;br /&gt;
Now let's add some components items which will show a list of CDs. We can use a wxListBox here:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut03_004.png]]&lt;br /&gt;
&lt;br /&gt;
The list is rather small so let's resize it using drag-handles to something wider and higher:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut03_005.png]]&lt;br /&gt;
&lt;br /&gt;
That's progress, but the second sizer did not resize. That tells us that we didn't turn on its '''Expand''' flag. To do this, click on the second sizer and check its Expand property:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut03_006.png]]&lt;br /&gt;
&lt;br /&gt;
Now we can change the labels of the regions since they are fully visible now. To do this, click on each region's sizer and change the '''Label''' property:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut03_007.png]]&lt;br /&gt;
&lt;br /&gt;
We would like to have the ability to add a CD and delete a selected CD, so we will insert two buttons for this purpose into the left region. To add a button, click on it on the Standard tab and then add it into the sizer. Note that wxSmith will not let us (erroneously) select the wxListBox as a place to put the button; the ListBox cannot have children, so wxSmith will try to add new items before it or after it. After adding the button we would have such a result:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut03_008.png]]&lt;br /&gt;
&lt;br /&gt;
Hmm, I want the button to be under the list, not next to it. The wxStaticBoxSizer aligned components as we had told it to do; by default it aligns them in a horizontal line. To change the direction to vertical, you can change the '''Orientation''' property of wxStaticBoxSizer. But before we change it let's anticipate one more thing. I would like to have two buttons instead of only one and I'd like them to be aligned'' horizontally''. Since wxStaticBox will be changed to vertical mode, we will have to use yet another sizer just for the buttons. So let's add a wxBoxSizer right after the list and before the button:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut03_009.png]]&lt;br /&gt;
&lt;br /&gt;
Now let's change the '''Orientation''' of the wxStaticBoxSizer to vertical. After changing we have following result:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut03_010.png]]&lt;br /&gt;
&lt;br /&gt;
We can see that something is badly wrong here. The wxBoxSizer is abnormally stretched; and if we scroll the editor, we can see that the same goes for the button. We said in a previous tutorial that wxBoxSizer and wxStaticBoxSizer are trying to keep everything the same size  in one direction. That is exactly what happened here. wxStaticBoxSizer used the tallest item (the list of CDs) and applied this height into all managed items. How can we disable this behavior? By setting the '''Proportion''' property of both wxBoxSizer and wxButton to 0. This will notify the sizer that those items shouldn't be used in height calculations:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut03_011.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now let's move the button into the wxBoxSizer - you can very easily do it by clicking on the button and dragging it into the sizer. After that we can add the second button next to the first one:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut03_012.png]]&lt;br /&gt;
&lt;br /&gt;
Now we can see that the list doesn't have the '''Expand''' property set (otherwise it would be almost as wide as the region. Go back and check it.&lt;br /&gt;
&lt;br /&gt;
Now I'd like to see how resource currently looks in the application. We could by simply running it (F9) or by pressing the preview button on the right part of the wxSmith editor:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut03_013.png]]&lt;br /&gt;
&lt;br /&gt;
(If you run the application you will see that there's a menu and statusbar. On the preview they won't show up; wxSmith still misses a few features.&lt;br /&gt;
&lt;br /&gt;
Our window looks good, not perfect but let's leave some polishing for later and fill the CD details region.&lt;br /&gt;
&lt;br /&gt;
== The '''CD details''' region: wxFlexGridSizer, wxChoice, wxDatePickerCtrl  ==&lt;br /&gt;
&lt;br /&gt;
Inside CD details I'd like to have a description of the CD:&lt;br /&gt;
* Type (Music/Program/Backup/Other)&lt;br /&gt;
* Title&lt;br /&gt;
* Artist/Author&lt;br /&gt;
* Date of release&lt;br /&gt;
* Description&lt;br /&gt;
&lt;br /&gt;
For such a list we would need some type of grid sizer. Ok, but the region has a wxStaticBoxSizer which aligns items only in one line. To overcome this limitation we can just add another sizer into the wxStaticBoxSizer and use the new one as the grid. From the two available sizers I suggest wxFlexGridSizer (wxGridSizer would force all cells to have same size which wouldn't look good because the row with descriptions may need some more space than the others). So let's add the new sizer:&lt;br /&gt;
* Add wxFlexGridSizer into wxStaticBoxSizer&lt;br /&gt;
* Check the '''Expand''' property of the new item&lt;br /&gt;
* Set '''Border Size''' to 0 to avoid some unwanted border.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Data presented here should be shown in two columns - the first for the label and the second for the value, so let's change the '''Cols''' property to 2. And now it's time to add the content. For labels we will use wxStaticText and for the value we will use different items:&lt;br /&gt;
* wxChoice for Type&lt;br /&gt;
* wxTextCtrl for Title, Artist/Author and Description&lt;br /&gt;
* wxDatePickerCtrl for Date of release&lt;br /&gt;
&lt;br /&gt;
After adding the items we should have the following view:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut03_014.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(Back in 2006, BYO had problems with wxDatePickerCtrl and had to replace it with wxCalendarCtrl. By the time of this revision in 2012, there was no problem. Clicking on this control drops down a calendar so the window looks rather similar to what wxCalendarCtrl gives. The remaining illustrations are BYO's using wxCalendarCtrl.)&lt;br /&gt;
&lt;br /&gt;
Now when we build and run we have this screen:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut03_015.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
It looks like we have a few things to do now:&lt;br /&gt;
* First is to check the '''Expand''' property for the first region since (it didn't expand when the second region increased height)&lt;br /&gt;
* Second is to set proper labels for values in the '''CD details''' region&lt;br /&gt;
* Third is to check the '''Expand''' property for all items with values in that region &lt;br /&gt;
* Fourth is to adjust items used to edit values in '''CD details''' region&lt;br /&gt;
&lt;br /&gt;
The first three tasks are quite easy and I'll leave them to you.&lt;br /&gt;
&lt;br /&gt;
The fourth task will require a few new things so I'll describe it better:&lt;br /&gt;
&lt;br /&gt;
First let's remove the word &amp;quot;text&amp;quot; from text boxes - it's set by default but it would be better to have empty text by default. Text can be changed by modifying the '''Text''' property so you should do this very quickly.&lt;br /&gt;
&lt;br /&gt;
Now we have to set some values which could be chosen from the wxChoice control labeled '''Type'''. It is done by editing the items in the  '''Choices''' property of wxChoice. On that line, there's a button on the right side. When you click it, a new window will pop-up where you can enter choices:&lt;br /&gt;
&lt;br /&gt;
 Music&lt;br /&gt;
 Program&lt;br /&gt;
 Backup&lt;br /&gt;
 Other&lt;br /&gt;
&lt;br /&gt;
== Making a Window Resize ==&lt;br /&gt;
&lt;br /&gt;
We have the first version of our window. But it's not the end of our work. If we want it to be user-friendly, it should be able to resize. We can check it by either showing the preview or building and running the application. The latter route is more reliable, so let's use it. When I tried resizing it, it looked like this:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut03_016.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can see two wrong things in this window:&lt;br /&gt;
* The regions did not expand vertically and stay centered&lt;br /&gt;
* The content of the second region did not react for the resize&lt;br /&gt;
&lt;br /&gt;
The first problem should be caused by some missing '''Expand''' property so let's find it.&lt;br /&gt;
&lt;br /&gt;
First we should check if the regions have the '''Expand''' property set; yes, they do, so this is not the problem. Generally in such situations we should continue checking in the parent item. In this case it is a wxBoxSizer which always expands. Next there is a wxPanel, which we used to make a nice background, and voilà: this one is missing the '''Expand''' property. So let's check it and test the result again. It works fine. &lt;br /&gt;
&lt;br /&gt;
Now the second issue. Content inside the '''CD details''' pane was based on wxFlexGridSizer. If you look into the previous tutorial you may find out that this sizer has a special property called '''Growable cols'''. Using this property we can set columns which should resize. I'd like the column with values to grow; we don't need more space for labels. So let's set '''Growable cols''' to '''&amp;quot;1&amp;quot;''' (indexes are 0-based). Note that you may quickly find the wxFlexGridSizer by looking into the resource tree - we have only one such sizer in our project.&lt;br /&gt;
&lt;br /&gt;
Now we have a better result:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut03_017.png]]&lt;br /&gt;
&lt;br /&gt;
== Finishing Touches ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
As I look at our window, I see that I left undone a few things in the first region. The buttons don't have new labels, and there's to much space between them and the list, so we can update those things right now.&lt;br /&gt;
&lt;br /&gt;
As usual I'll leave changing the Labels to you - those buttons should be called '''Add''' and '''Delete'''. &lt;br /&gt;
&lt;br /&gt;
Now let's remove the wasted space. The space is added because each item inside a sizer may have an extra border. By default it's set to 5 pixels, so if we remove the border around buttons we would have more free space. But then the buttons won't have any space between them.&lt;br /&gt;
&lt;br /&gt;
To overcome this problem we could use another property related to Border and also called Border  but distinguished by a little square in the left margin. In the square is + mark.  By clicking on the + we expand the line and can then check the borders we do not want.  So if we remove the top/bottom/left edge borders of the first button and the top/bottom/right edge borders of the second button we remove the extra space but the buttons will still have some gap between them. Here is how the property should look for the first button: &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut03_018.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here we reach the end of this tutorial. Of course the window we've built need not be it's final version. For example, we could add a list to record who borrowed the CD from us and when and who has it now. We could add some searching and so on. But this tutorial has gone on long enough, and I'll leave those upgrades to you. I hope that you've learned something new, interesting and useful here.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;'''[[Wxsmith tutorial: Working with items|Previous]] | [[WxSmith tutorials|Index]] | [[WxSmith tutorial: Working with multiple resources|Next]]'''&amp;lt;/center&amp;gt;&lt;/div&gt;</summary>
		<author><name>Chatumao</name></author>
	</entry>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=Wxsmith_tutorial:_Working_with_items&amp;diff=7573</id>
		<title>Wxsmith tutorial: Working with items</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=Wxsmith_tutorial:_Working_with_items&amp;diff=7573"/>
		<updated>2013-05-12T12:51:23Z</updated>

		<summary type="html">&lt;p&gt;Chatumao: /* wxStdDialogButtonSizer */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:wxSmith Documentation]]&lt;br /&gt;
= Working with Menus and Components =&lt;br /&gt;
&lt;br /&gt;
In the [[wxSmith tutorial: Hello world|previous tutorial]] we learned how to create a small application using wxWidgets. We created a window with a few components inside. In this tutorial, we will first see how to use the menu bar at the top of the main window and then focus on sizers and wxWidgets components which can be put on a form or window. &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''A Note on Terminology'''&lt;br /&gt;
&lt;br /&gt;
BYO, the creator of wxSmith and original author of these tutorials, wrote &amp;quot;Each resource in wxSmith is made of items. All your buttons, text boxes, lists etc are items. Also some more abstract things like sizers, spacers (used to add empty space), menu entries or even timers are also called items in wxSmith. So basically anything that's inside the resource may be called an item. I'll also use the term component since it reflects the valid meaning too.&amp;quot; &lt;br /&gt;
&lt;br /&gt;
In fact, the word &amp;quot;item&amp;quot; is not found in the index of the Julian Smart and Kevin Hock book ''Cross-Platform GUI Programming with wxWidgets.'' The word is used in the book specifically for the elements of the drop-down lists of choice boxes, combo boxes, and other members of the class wxControlWithItems. In the revision of these tutorials, the word &amp;quot;item&amp;quot; is therefore generally being reserved for items in these lists and for items in a menu. Otherwise, the word &amp;quot;item&amp;quot; is generally being replaced by &amp;quot;component&amp;quot;, &amp;quot;widget&amp;quot;, or &amp;quot;control&amp;quot; as seems appropriate, though of course, it is also occasionally used with no special technical meaning. Also, BYO often uses the word &amp;quot;resource&amp;quot; to refer to a form or window. Smart and Hock use word the &amp;quot;resource&amp;quot; sparingly, mainly in the context of &amp;quot;resource files&amp;quot;.  The word seems overworked and needlessly abstract, so when what is intended is a form or window, the revisions will use one of those words, with no sharp distinction between them.   &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Note that all screenshots presented here were made on Linux but they should not be very different from the windows ones.&lt;br /&gt;
&lt;br /&gt;
== Working with Menus ==&lt;br /&gt;
&lt;br /&gt;
Following the directions given in Tutorial 1, start a new Code::Blocks project; call it Tutorial_2. Remember to add &amp;quot;event.Skip(TRUE);&amp;quot; at the appropriate place in the code, as explained in Tutorial 1. &lt;br /&gt;
&lt;br /&gt;
Build and run the program. You will see that it has two items on the main menu. We will add one more, Jump, at the top level and under it two more, Back and Out. Back will do nothing, but we will make Out close the program.&lt;br /&gt;
&lt;br /&gt;
Click on the “Tutorial_2frame.wxs” tab of the Editor window.  Just below the words “Tutorial_2framw.wxs” is a panel with two square icons.  Double left click on the leftmost one, which shows the word ''File'' suggestive of a menu.  Up comes the menu inspector window shown below.&lt;br /&gt;
&lt;br /&gt;
[[Image:1i.png]]  &lt;br /&gt;
   &lt;br /&gt;
Click on the various menu items shown and note how the content of the fields shown on the right side of the window are filled in.  Then click on the New button (in the lower right part of the window) to add the three additional menu items mentioned above, namely Jump at the top level and under it Back and Out. It does not matter where the items first appear; you use the arrow keys just above the “New” and “Delete” buttons to move around the item you have selected.  For the “Id” field of the “Out” item, put idMenuOut. You should make the menu inspector window look like this:&lt;br /&gt;
&lt;br /&gt;
[[Image:1j.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When you have the menu items properly arranged, click OK.   &lt;br /&gt;
&lt;br /&gt;
When you now build and run, you will see the new menu.  But clicking Jump | Out  does not close the program as desired because we have not programmed the response to that event.  To do so, we want to make wxSmith set up the frame for the routine which will be called when the menu item “Out” is clicked.  Go to the Management pane, Resources tab and persistently click on the little right-pointing triangles until the “Out” item can be seen, as in the screen shot below.&lt;br /&gt;
&lt;br /&gt;
[[Image:1k.png]]&lt;br /&gt;
&lt;br /&gt;
      &lt;br /&gt;
Click on the word “Out” and then on the {} icon in the panel below the Management pane. That will cause the pane below to show the words “EVT_MENU     --None--” . Click on the word “None” or the down arrow at the right end of the field; a menu drops down.  Pick the item  “-- Add New Handler --”, accept the suggested name (OnMenu3Selected), and over in the editor, the frame of our handler has been written, as shown below.  We have only to write the code, which will be simply “Close();”.&lt;br /&gt;
&lt;br /&gt;
[[Image:1l.png]]&lt;br /&gt;
&lt;br /&gt;
Now we can “Build and run”, drop down our menu, click on “Out”, and the program closes, as desired.&lt;br /&gt;
&lt;br /&gt;
== Windows and Components ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Each window in wxSmith is made of components. All your buttons, text boxes, lists, and so on are components. Also some more abstract things like sizers, spacers (used to add empty space), menu entries or even timers are also components.&lt;br /&gt;
&lt;br /&gt;
Every window has a root component. For a dialog window, it would be a wxDialog component; for a frame window, it would be wxFrame component; for a panel it would be a wxPanel component. In the [[wxSmith tutorial: Hello world|previous tutorial]] you probably noticed that some components may have &amp;quot;children&amp;quot;. For example, sizers had components inside their boxes. In this tutorial, you have seen sub-menu items inside main-menu items. The term &amp;quot;children&amp;quot; suggests the idea of a family tree, and indeed precisely such a tree structure is directly represented in the resource browser, as shown in the example below.&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_008.png]]&lt;br /&gt;
&lt;br /&gt;
In the picture above, you will see an example of such a tree. wxFontFaceEditorDlg is the currently opened form with a root component of type wxDialog. We can see that this resource consists of a few sizers and buttons, one text area and some spacers. It's definitely a fairly simple form. For more complicated forms, there could be more than 100 components. The tree (or Resource) browser can be very helpful for locating the code connected with a component; clicking on the component in the browser brings up its code in the editor.&lt;br /&gt;
&lt;br /&gt;
Each component has its properties - these are usually some values which describe the component. Some of them may affect the way component looks, some may change the component's behavior, and some may be dedicated to programming facilities. You will also find that there are some properties -- such as position and size -- common to many components.&lt;br /&gt;
&lt;br /&gt;
wxSmith allows you to edit components inside the properties browser (the window which is usually under the resource browser). If you select a component either by  clicking on it in the resource browser or by clicking on it inside the editor, the properties editor switches to edit its properties. Here's an example of the property browser:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_009.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can also use the Quick-Properties panel available after pressing the &amp;quot;Q&amp;quot; button on the right side of the editor:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_010.png]]&lt;br /&gt;
&lt;br /&gt;
The purpose of this panel is to provide most common properties in user-friendly way. It hasn't proven as useful as I had hoped, and you will probably find it helpful only while adjusting sizer-related settings.&lt;br /&gt;
&lt;br /&gt;
The last and the easiest way to work on a component is directly in the editor. You can grab drag boxes and change the component's size. You can also change its position by simply dragging it to another place.&lt;br /&gt;
&lt;br /&gt;
=== Excercise with Components ===&lt;br /&gt;
&lt;br /&gt;
Enough generalities; let's play with components. We can continue with the project started at the beginning of this tutorial. First let's add wxFlexGridSizer into our window. Like all sizers, it is located in Layout tab. (You'll remember how to add components from the [[wxSmith tutorial: Hello world|previous tutorial]]). Now let's add the following components into the sizer in the order given: wxButton, wxStaticText, wxTextCtrl, wxRadioButton and wxCheckBox. They can all be found on the Standard tab. The result should look like this:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_011.png]]&lt;br /&gt;
&lt;br /&gt;
In this picture, components I've selected have a light red border.&lt;br /&gt;
&lt;br /&gt;
Now that we have our playground, let's change some components. First, let's change the label and color of the button. To do so, click on the button and move to the properties browser. &amp;quot;Label&amp;quot; is the first property, and it's quite easy to change. Just click on the word &amp;quot;Label&amp;quot; on the right and type new text.&lt;br /&gt;
&lt;br /&gt;
Color is little bit harder to find. Usually components have two colors - Background and Foreground color. Background, as the name implies, is used to fill the component's background. Foreground, on the other hand, is used to paint some content onto the background. Note that there's no strict interpretation of these colors so you should experiment to find out their meaning. In wxButton, Background is what we want.&lt;br /&gt;
So let's find the Background property. It's value can be changed by using combobox:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_012.png]]&lt;br /&gt;
&lt;br /&gt;
On the list you may find a set of predefined system colors. When you choose one of them, they will be read from the current system settings making your application compatible with the system theme. There are also two special entries - Default (which means that we do not want to set our color) and Custom. When you select Custom, wxSmith will open a color dialog where you can choose any color you like. I have chosen light green, and here's the result:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_013.png]]&lt;br /&gt;
&lt;br /&gt;
There are also other properties we could talk about, but the best way to learn them is to play with them, so I leave those discoveries to you.&lt;br /&gt;
&lt;br /&gt;
Now let's use the mouse.&lt;br /&gt;
&lt;br /&gt;
The selected component will have eight black boxes -- drag handles -- around it. These boxes can be used to change the size of the component. You will easily notice when the mouse is over a handle because the cursor changes. Let's resize the wxTextCtrl (edit box):&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_014.png]]&lt;br /&gt;
&lt;br /&gt;
You may see that resizing the component will also change properties in the browser - '''Default Size''' is unchecked now and '''Width''' and '''Height''' are set to required values. There's another property which seems to be untouched - '''Size in Dialog Units''', which is also related to size. I'll explain it a bit.&lt;br /&gt;
&lt;br /&gt;
Usually when you must specify a size (or other size-related things) you provide a value in pixels. Alternatively you can specify values in a unit called a '''Dialog Unit'''. A '''Dialog Unit''' is usually a little bit bigger than one pixel and it's size depends on the size of the current font (actually it's the size of the font of some component's parent which has a font). This is useful when you want some values to be proportional to the size of text presented in the window. &lt;br /&gt;
&lt;br /&gt;
If you check '''Size in Dialog Units'', wxSmith will take care of it and sizes will be calculated in Dialog Units instead of pixels (although, naturally, you will still be able to resize components).&lt;br /&gt;
&lt;br /&gt;
Now let's change the position of the radio box. &amp;quot;But, wait,&amp;quot; you may say, &amp;quot;I thought you said that the sizer is responsible for the positioning.&amp;quot; That's right. We have limited possibilities to change position. Inside one sizer we can only reorder components; for more complex forms we can also move a component between two sizers or to areas where sizers do not apply. So, back to our example, let's move the radio box to position it right after the button. To do so, click on the radio button and drag it onto the button. When you start dragging, you will notice that the area of the sizer changes color to blue. This color change is an aid to show you what will be the new position of the dragged component. When you move the cursor onto the button, half of the button will become light-blue. When the left half is highlighted, the dragged component will be added before it. When the right half is highlighted, dragged component will be added after it. And when there's no highlighted component, the new component will be added as the last child of the parent:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_015.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When you drop the component, it will change it's position. Note that all the components after the new position also shift. That happens because the default setting of the wxFlexGridSizer allows only 3 components in one row (this can be changed in property browser) so the components just adapted to the new order.&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_016.png]]&lt;br /&gt;
&lt;br /&gt;
==Sizers== &lt;br /&gt;
&lt;br /&gt;
Now let's learn a little bit about components available in wxSmith. I'll describe all supported sizers and a few important components from the Standard palette. Let's start with sizers.&lt;br /&gt;
&lt;br /&gt;
We already know that sizers are responsible for automatically setting the position and size of some components. But how do they do that? Well, it depends on which sizer has been used. So what are the rules? The generic rule is that the sizer tries to use all its available space and place the components it manages in such way that they do not overlap. If the area available to the sizer is too small, it requests a bigger area, so you can be sure that no component will fall out of the window. (Unfortunately, you cannot be sure that after such adjustments the window will be small enough to fit on the screen, so be careful about that.) Another rule which should be mentioned here is that sizers automatically set-up the minimum size required by the window. Basically when you edit a window using sizers, you should be aware that you edit the smallest layout and without some tricks, you won't be able to resize the window to something smaller.&lt;br /&gt;
&lt;br /&gt;
Here are descriptions of all sizers available in wxSmith:&lt;br /&gt;
&lt;br /&gt;
=== wxBoxSizer ===&lt;br /&gt;
&lt;br /&gt;
wxBoxSizer is the most basic sizer available in wxWidgets. It's purpose is to align components in one line - one next to another - either horizontally or vertically. This sizer also tries to keep some proportions between components - for a horizontal sizer you can set factors which will keep proportionality of widths and the height of the sizer area will be equal to the height of the tallest component. Similarly, vertical sizers keep heights proportional and the width will be taken from the widest component. You specify whether the sizer is to be horizontal or vertical in the sizer's property browser.&lt;br /&gt;
&lt;br /&gt;
Here are examples of layout using box sizers (the first one is the horizontal one, the second is vertical one):&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_002.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In that example you may see that all components have the same width and height.&lt;br /&gt;
&lt;br /&gt;
But let's assume that we want Button2 to be two times wider that Button1 and Button3 to be three times wider than Button1. This can be easily done by using the Proportion property of managed components. By default, the value of all components is set to 1 so they have equal size. Changing the Proportion of second button to 2 would mean that it should be 2 times wider than the first or third one.&lt;br /&gt;
&lt;br /&gt;
Generally you can set any value you want here. One common technique is to set percentage values - for example setting proportions to values 20, 30 and 50 would mean that the first button should occupy 20% of the space, the second one 30% and the third one 50%. The special value 0 means that this component should be skipped in proportion calculations and it won't automatically adjust it's size when the main window is resized.&lt;br /&gt;
&lt;br /&gt;
So if we want to get 1:2:3 proportions, we set 1 for Button1, 2 for Button2 and 3 for Button3. And here is the result:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_003.png]]&lt;br /&gt;
&lt;br /&gt;
Also note that if you create a resizable window and resize it, those 3 buttons will automatically grow and keep proportions. If you set the Proportion property for some component to 0, it won't change size as the user changes the size of the window. &lt;br /&gt;
&lt;br /&gt;
The other dimension which is not controlled by the &amp;quot;Proportion&amp;quot; property may be controlled using the &amp;quot;Expand&amp;quot; and &amp;quot;Shaped&amp;quot; properties. They are simple checkboxes. If you check the first one, the component will expand it's width/height and will get the size of the biggest component managed by the same sizer. Selecting &amp;quot;Shaped&amp;quot; will also make the component resize but such components will try to keep the initial proportion between width and height so it doesn't have to use all available space. The effect of the &amp;quot;Expand&amp;quot; and &amp;quot;Shaped&amp;quot; properties can be seen when components differ in width or height; here's an example:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_004.png]]&lt;br /&gt;
&lt;br /&gt;
In this example, the first button is the biggest of the three. Its size will be used to adjust the sizes of the other buttons. The second one has its &amp;quot;Expand&amp;quot; property checked, and the third one does not. What can be seen here is that the third button expanded in only one dimension (the one managed by &amp;quot;Proportion&amp;quot; property), the second dimension was left untouched.&lt;br /&gt;
&lt;br /&gt;
You may also note that when a component does not fill its available area, it is centered. That's default behavior which can be changed. In the properties of components managed by sizer you will find properties called '''Horizontal align''' and '''Vertical align'''. Using these properties you can select where the component should be located when it's smaller that its available area.&lt;br /&gt;
&lt;br /&gt;
=== wxStaticBoxSizer ===&lt;br /&gt;
&lt;br /&gt;
This sizer is similar to wxBoxSizer with one exception: it adds an extra static box around managed components:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_005.png]]&lt;br /&gt;
&lt;br /&gt;
=== wxGridSizer ===&lt;br /&gt;
&lt;br /&gt;
This sizer is a little bit more advanced than wxBoxSizer because it aligns components on a grid, not on one line. You can specify the number of columns or number of rows in properties &amp;quot;Cols&amp;quot; and &amp;quot;Rows&amp;quot;. The default number of columns is set to 3 and number of rows is set to 0. When 0 is used, it means that sizer should automatically calculate this value to keep all managed components inside.&lt;br /&gt;
&lt;br /&gt;
This sizer makes an important assumption: all cells must have the same width and all must have the same height.  This means that the tallest managed component will set the height of all rows and the widest one will set the widths of all columns. If an component won't use the whole cell, it will be surrounded by empty space. (If you don't like this assumption, look at the wxFlexGridSizer.)&lt;br /&gt;
&lt;br /&gt;
Among the properties of a wxGridSizer you can also find horizontal and vertical spacings. These values set the spacing added between components. The result of using them is similar to using borders around managed components but with borders you would have to set borders for all components separately.&lt;br /&gt;
&lt;br /&gt;
In the case of wxGridSizer, the &amp;quot;Proportion&amp;quot; value is not used. But you may use &amp;quot;Expand&amp;quot;, &amp;quot;Shaped&amp;quot; or placement properties to adjust the result.&lt;br /&gt;
&lt;br /&gt;
Here's an example of a grid sizer:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_006.png]]&lt;br /&gt;
&lt;br /&gt;
=== wxFlexGridSizer ===&lt;br /&gt;
&lt;br /&gt;
This is a very useful one. It works similarly to wxGridSizer; but it does not force all columns to have the same width nor all rows to have the same height. Also not all columns resize when there's more space available for the sizer. Comparing to wxGridSizer you will find two extra properties here: &amp;quot;Growable cols&amp;quot; and &amp;quot;Growable rows&amp;quot;. In these properties you may provide a list of columns / rows which should automatically resize by providing a list of numbers separated using comma (,). The numbers should start from 0, so if you would like the second and third column to resize, put &amp;quot;1,2&amp;quot; into &amp;quot;Growable cols&amp;quot;. This property is very useful to handle resizing of the window.&lt;br /&gt;
&lt;br /&gt;
Unfortunately you won't be able to set proportions other that 1:1 The &amp;quot;Proportion&amp;quot; property is also not used in this sizer.&lt;br /&gt;
&lt;br /&gt;
=== wxStdDialogButtonSizer ===&lt;br /&gt;
&lt;br /&gt;
This is a specialized sizer with one purpose - to provide a set of standard buttons with respect to the platform's look and feel. This sizer has a predefined list of components which it can handle - all are buttons and you can manage them using the sizer's properties. You cannot add your custom components into this sizer.&lt;br /&gt;
&lt;br /&gt;
Each button on this sizer has two properties in the sizer - whether the button should be enabled (for example wxID_OK for OK button) and its label. Note that labels for most buttons will be generated automatically and wxWidgets will skip them when it can read them from the system settings. For example, on Linux only the Context Help button does not have a system-supplied label. It is also very probable that labels will be provided with language-specific strings (depending on the current system language). Not all configurations of buttons are valid - they won't break the application but buttons will overlap (for example Yes and OK).&lt;br /&gt;
&lt;br /&gt;
Here is an example of this sizer. My system is set up in Polish, so the labels are automatically in Polish.  They mean: Help, Cancel, Apply and OK.&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_007.png]]&lt;br /&gt;
&lt;br /&gt;
This screenshot was taken on a Linux box. You may see that the buttons have an extra image which is not available for standard buttons. With such a layout, users of the application will feel more comfortable, and such 'small' things make users say that the GUI was designed very well. On MS Windows, the sizer would have the same buttons but without images and they would be in a different order - the one that is used on windows by default.&lt;br /&gt;
&lt;br /&gt;
All of the above sizers can be found on the &amp;quot;Layout&amp;quot; tab. You can find two other components there which are not sizers but can be used for layout purposes. &lt;br /&gt;
&lt;br /&gt;
The first one is Spacer. It can be added to other sizers when you simply need some empty space instead of any particular component. Spacers have only width and height.&lt;br /&gt;
&lt;br /&gt;
The second one is wxSplitterWindow. When you use this component, you can add one or two child components into it and they will be separated with a dividing line (it's called a sash in wxWidgets). On the application you can drag it to dynamically adjust the size of managed components.&lt;br /&gt;
&lt;br /&gt;
Now that we know something about sizers let's turn to other components.&lt;br /&gt;
&lt;br /&gt;
== Especially Useful Standard Components ==&lt;br /&gt;
&lt;br /&gt;
wxWidgets provides all standard graphical components like static text, buttons, edit boxes, combo boxes, and so on. All are supported in wxSmith, so you can build a nice working environment. I'll briefly describe the components that are really useful in standard applications.&lt;br /&gt;
&lt;br /&gt;
=== wxButton ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_017.png]]&lt;br /&gt;
&lt;br /&gt;
This is standard button, a very common component. Its purpose is to run some piece of code when the user clicks on it. That's it.&lt;br /&gt;
&lt;br /&gt;
=== wxStaticText ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_018.png]]&lt;br /&gt;
&lt;br /&gt;
This component only shows user-defined text on the window. It doesn't generate any events.&lt;br /&gt;
&lt;br /&gt;
=== wxTextCtrl ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_019.png]]&lt;br /&gt;
&lt;br /&gt;
This component let's the user enter some text. It's basic functionality allows entering one-line text. After changing its properties, it may become a more advanced multiline editor with support for different fonts, colors and text styles.&lt;br /&gt;
&lt;br /&gt;
=== wxPanel ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_020.png]]&lt;br /&gt;
&lt;br /&gt;
Although this component may be a separate window, it is most commonly added as a comoponent in a parent window. It is particularly useful as a background for other components. It has a few functionalities - it can be used as background in notebooks and it may be a place where you put components without sizers. But it also has a few drawbacks - wxWidgets tends to do some tricks with wxPanel's size so it's not always possible to set the size we really want.&lt;br /&gt;
&lt;br /&gt;
=== wxChoice ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_021.png]]&lt;br /&gt;
&lt;br /&gt;
This component provides a drop-down list with available options. It works similarly to wxComboBox but the user cannot enter values. It can be used in situations when the user should use one of several available options. An event is generated when the user changes the selected component.&lt;br /&gt;
&lt;br /&gt;
=== wxComboBox ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_022.png]]&lt;br /&gt;
&lt;br /&gt;
This component provides a drop-down list similar to that of wxChoice. In the case of this component, the user can select one of the available values or enter his own if the component is not in a Read-Only state. A very good example of its usage is to provide some text entry with a stored list of previously entered values (like in search boxes). Like wxChoice, changing the selection generates an event. Additionally, changing the text and pressing enter also generates events. Tutorial 9 will illustrate its use. &lt;br /&gt;
&lt;br /&gt;
=== wxListBox ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_023.png]]&lt;br /&gt;
&lt;br /&gt;
This component provides a list where you can select one or more components. Changing the component or double-clicking on it generates an event.&lt;br /&gt;
&lt;br /&gt;
=== wxNotebook ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_024.png]]&lt;br /&gt;
&lt;br /&gt;
Notebook is very useful for complex resources since it groups content under tabs. Additionally, wxChoicebook and wxCombobook are also available but are not described here. Changing the selected notebook generates two events: one when the page starts to change (before change) and one when the page is finished changing (after change).&lt;br /&gt;
&lt;br /&gt;
=== wxCheckBox ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_025.png]]&lt;br /&gt;
&lt;br /&gt;
Check boxes may be used to map boolean values. Additionally, 2-state boxes can also be generated (with values: yes/no/unspecified). Changing the value emits an event.&lt;br /&gt;
&lt;br /&gt;
=== wxRadioBox ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_026.png]]&lt;br /&gt;
&lt;br /&gt;
Radio box works similarly to check boxes. The difference is that only one radiobox in a group can be selected. Groups may be defined by using wxRB_GROUP style. A radiobox which has this style set starts a new group. Changing the selected radiobox emits an event.&lt;br /&gt;
&lt;br /&gt;
=== wxGauge ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_027.png]]&lt;br /&gt;
&lt;br /&gt;
This component, also called a Progress Bar, can be used to show the progress of some operation. It's very useful when doing some calculation intensive operations. It can prevent users from getting frustrated when they do not see anything happening on the screen but only a window which seems hung.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt; * * * * &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
That's the end of this tutorial. We will get more experience with these subjects in the following tutorials. But you can also learn a lot by experimenting: add components, change properties, resize, move. You may try adding sizers into other sizers, a very useful technique absolutely required for more complex forms. Join me for the next tutorial!&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;'''[[WxSmith tutorial: Hello world|Previous]] | [[WxSmith tutorials|Index]] | [[WxSmith tutorial: Building more complex window|Next]]'''&amp;lt;/center&amp;gt;&lt;/div&gt;</summary>
		<author><name>Chatumao</name></author>
	</entry>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=Wxsmith_tutorial:_Working_with_items&amp;diff=7572</id>
		<title>Wxsmith tutorial: Working with items</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=Wxsmith_tutorial:_Working_with_items&amp;diff=7572"/>
		<updated>2013-05-12T12:47:28Z</updated>

		<summary type="html">&lt;p&gt;Chatumao: /* wxGridSizer */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:wxSmith Documentation]]&lt;br /&gt;
= Working with Menus and Components =&lt;br /&gt;
&lt;br /&gt;
In the [[wxSmith tutorial: Hello world|previous tutorial]] we learned how to create a small application using wxWidgets. We created a window with a few components inside. In this tutorial, we will first see how to use the menu bar at the top of the main window and then focus on sizers and wxWidgets components which can be put on a form or window. &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''A Note on Terminology'''&lt;br /&gt;
&lt;br /&gt;
BYO, the creator of wxSmith and original author of these tutorials, wrote &amp;quot;Each resource in wxSmith is made of items. All your buttons, text boxes, lists etc are items. Also some more abstract things like sizers, spacers (used to add empty space), menu entries or even timers are also called items in wxSmith. So basically anything that's inside the resource may be called an item. I'll also use the term component since it reflects the valid meaning too.&amp;quot; &lt;br /&gt;
&lt;br /&gt;
In fact, the word &amp;quot;item&amp;quot; is not found in the index of the Julian Smart and Kevin Hock book ''Cross-Platform GUI Programming with wxWidgets.'' The word is used in the book specifically for the elements of the drop-down lists of choice boxes, combo boxes, and other members of the class wxControlWithItems. In the revision of these tutorials, the word &amp;quot;item&amp;quot; is therefore generally being reserved for items in these lists and for items in a menu. Otherwise, the word &amp;quot;item&amp;quot; is generally being replaced by &amp;quot;component&amp;quot;, &amp;quot;widget&amp;quot;, or &amp;quot;control&amp;quot; as seems appropriate, though of course, it is also occasionally used with no special technical meaning. Also, BYO often uses the word &amp;quot;resource&amp;quot; to refer to a form or window. Smart and Hock use word the &amp;quot;resource&amp;quot; sparingly, mainly in the context of &amp;quot;resource files&amp;quot;.  The word seems overworked and needlessly abstract, so when what is intended is a form or window, the revisions will use one of those words, with no sharp distinction between them.   &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Note that all screenshots presented here were made on Linux but they should not be very different from the windows ones.&lt;br /&gt;
&lt;br /&gt;
== Working with Menus ==&lt;br /&gt;
&lt;br /&gt;
Following the directions given in Tutorial 1, start a new Code::Blocks project; call it Tutorial_2. Remember to add &amp;quot;event.Skip(TRUE);&amp;quot; at the appropriate place in the code, as explained in Tutorial 1. &lt;br /&gt;
&lt;br /&gt;
Build and run the program. You will see that it has two items on the main menu. We will add one more, Jump, at the top level and under it two more, Back and Out. Back will do nothing, but we will make Out close the program.&lt;br /&gt;
&lt;br /&gt;
Click on the “Tutorial_2frame.wxs” tab of the Editor window.  Just below the words “Tutorial_2framw.wxs” is a panel with two square icons.  Double left click on the leftmost one, which shows the word ''File'' suggestive of a menu.  Up comes the menu inspector window shown below.&lt;br /&gt;
&lt;br /&gt;
[[Image:1i.png]]  &lt;br /&gt;
   &lt;br /&gt;
Click on the various menu items shown and note how the content of the fields shown on the right side of the window are filled in.  Then click on the New button (in the lower right part of the window) to add the three additional menu items mentioned above, namely Jump at the top level and under it Back and Out. It does not matter where the items first appear; you use the arrow keys just above the “New” and “Delete” buttons to move around the item you have selected.  For the “Id” field of the “Out” item, put idMenuOut. You should make the menu inspector window look like this:&lt;br /&gt;
&lt;br /&gt;
[[Image:1j.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When you have the menu items properly arranged, click OK.   &lt;br /&gt;
&lt;br /&gt;
When you now build and run, you will see the new menu.  But clicking Jump | Out  does not close the program as desired because we have not programmed the response to that event.  To do so, we want to make wxSmith set up the frame for the routine which will be called when the menu item “Out” is clicked.  Go to the Management pane, Resources tab and persistently click on the little right-pointing triangles until the “Out” item can be seen, as in the screen shot below.&lt;br /&gt;
&lt;br /&gt;
[[Image:1k.png]]&lt;br /&gt;
&lt;br /&gt;
      &lt;br /&gt;
Click on the word “Out” and then on the {} icon in the panel below the Management pane. That will cause the pane below to show the words “EVT_MENU     --None--” . Click on the word “None” or the down arrow at the right end of the field; a menu drops down.  Pick the item  “-- Add New Handler --”, accept the suggested name (OnMenu3Selected), and over in the editor, the frame of our handler has been written, as shown below.  We have only to write the code, which will be simply “Close();”.&lt;br /&gt;
&lt;br /&gt;
[[Image:1l.png]]&lt;br /&gt;
&lt;br /&gt;
Now we can “Build and run”, drop down our menu, click on “Out”, and the program closes, as desired.&lt;br /&gt;
&lt;br /&gt;
== Windows and Components ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Each window in wxSmith is made of components. All your buttons, text boxes, lists, and so on are components. Also some more abstract things like sizers, spacers (used to add empty space), menu entries or even timers are also components.&lt;br /&gt;
&lt;br /&gt;
Every window has a root component. For a dialog window, it would be a wxDialog component; for a frame window, it would be wxFrame component; for a panel it would be a wxPanel component. In the [[wxSmith tutorial: Hello world|previous tutorial]] you probably noticed that some components may have &amp;quot;children&amp;quot;. For example, sizers had components inside their boxes. In this tutorial, you have seen sub-menu items inside main-menu items. The term &amp;quot;children&amp;quot; suggests the idea of a family tree, and indeed precisely such a tree structure is directly represented in the resource browser, as shown in the example below.&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_008.png]]&lt;br /&gt;
&lt;br /&gt;
In the picture above, you will see an example of such a tree. wxFontFaceEditorDlg is the currently opened form with a root component of type wxDialog. We can see that this resource consists of a few sizers and buttons, one text area and some spacers. It's definitely a fairly simple form. For more complicated forms, there could be more than 100 components. The tree (or Resource) browser can be very helpful for locating the code connected with a component; clicking on the component in the browser brings up its code in the editor.&lt;br /&gt;
&lt;br /&gt;
Each component has its properties - these are usually some values which describe the component. Some of them may affect the way component looks, some may change the component's behavior, and some may be dedicated to programming facilities. You will also find that there are some properties -- such as position and size -- common to many components.&lt;br /&gt;
&lt;br /&gt;
wxSmith allows you to edit components inside the properties browser (the window which is usually under the resource browser). If you select a component either by  clicking on it in the resource browser or by clicking on it inside the editor, the properties editor switches to edit its properties. Here's an example of the property browser:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_009.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can also use the Quick-Properties panel available after pressing the &amp;quot;Q&amp;quot; button on the right side of the editor:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_010.png]]&lt;br /&gt;
&lt;br /&gt;
The purpose of this panel is to provide most common properties in user-friendly way. It hasn't proven as useful as I had hoped, and you will probably find it helpful only while adjusting sizer-related settings.&lt;br /&gt;
&lt;br /&gt;
The last and the easiest way to work on a component is directly in the editor. You can grab drag boxes and change the component's size. You can also change its position by simply dragging it to another place.&lt;br /&gt;
&lt;br /&gt;
=== Excercise with Components ===&lt;br /&gt;
&lt;br /&gt;
Enough generalities; let's play with components. We can continue with the project started at the beginning of this tutorial. First let's add wxFlexGridSizer into our window. Like all sizers, it is located in Layout tab. (You'll remember how to add components from the [[wxSmith tutorial: Hello world|previous tutorial]]). Now let's add the following components into the sizer in the order given: wxButton, wxStaticText, wxTextCtrl, wxRadioButton and wxCheckBox. They can all be found on the Standard tab. The result should look like this:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_011.png]]&lt;br /&gt;
&lt;br /&gt;
In this picture, components I've selected have a light red border.&lt;br /&gt;
&lt;br /&gt;
Now that we have our playground, let's change some components. First, let's change the label and color of the button. To do so, click on the button and move to the properties browser. &amp;quot;Label&amp;quot; is the first property, and it's quite easy to change. Just click on the word &amp;quot;Label&amp;quot; on the right and type new text.&lt;br /&gt;
&lt;br /&gt;
Color is little bit harder to find. Usually components have two colors - Background and Foreground color. Background, as the name implies, is used to fill the component's background. Foreground, on the other hand, is used to paint some content onto the background. Note that there's no strict interpretation of these colors so you should experiment to find out their meaning. In wxButton, Background is what we want.&lt;br /&gt;
So let's find the Background property. It's value can be changed by using combobox:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_012.png]]&lt;br /&gt;
&lt;br /&gt;
On the list you may find a set of predefined system colors. When you choose one of them, they will be read from the current system settings making your application compatible with the system theme. There are also two special entries - Default (which means that we do not want to set our color) and Custom. When you select Custom, wxSmith will open a color dialog where you can choose any color you like. I have chosen light green, and here's the result:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_013.png]]&lt;br /&gt;
&lt;br /&gt;
There are also other properties we could talk about, but the best way to learn them is to play with them, so I leave those discoveries to you.&lt;br /&gt;
&lt;br /&gt;
Now let's use the mouse.&lt;br /&gt;
&lt;br /&gt;
The selected component will have eight black boxes -- drag handles -- around it. These boxes can be used to change the size of the component. You will easily notice when the mouse is over a handle because the cursor changes. Let's resize the wxTextCtrl (edit box):&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_014.png]]&lt;br /&gt;
&lt;br /&gt;
You may see that resizing the component will also change properties in the browser - '''Default Size''' is unchecked now and '''Width''' and '''Height''' are set to required values. There's another property which seems to be untouched - '''Size in Dialog Units''', which is also related to size. I'll explain it a bit.&lt;br /&gt;
&lt;br /&gt;
Usually when you must specify a size (or other size-related things) you provide a value in pixels. Alternatively you can specify values in a unit called a '''Dialog Unit'''. A '''Dialog Unit''' is usually a little bit bigger than one pixel and it's size depends on the size of the current font (actually it's the size of the font of some component's parent which has a font). This is useful when you want some values to be proportional to the size of text presented in the window. &lt;br /&gt;
&lt;br /&gt;
If you check '''Size in Dialog Units'', wxSmith will take care of it and sizes will be calculated in Dialog Units instead of pixels (although, naturally, you will still be able to resize components).&lt;br /&gt;
&lt;br /&gt;
Now let's change the position of the radio box. &amp;quot;But, wait,&amp;quot; you may say, &amp;quot;I thought you said that the sizer is responsible for the positioning.&amp;quot; That's right. We have limited possibilities to change position. Inside one sizer we can only reorder components; for more complex forms we can also move a component between two sizers or to areas where sizers do not apply. So, back to our example, let's move the radio box to position it right after the button. To do so, click on the radio button and drag it onto the button. When you start dragging, you will notice that the area of the sizer changes color to blue. This color change is an aid to show you what will be the new position of the dragged component. When you move the cursor onto the button, half of the button will become light-blue. When the left half is highlighted, the dragged component will be added before it. When the right half is highlighted, dragged component will be added after it. And when there's no highlighted component, the new component will be added as the last child of the parent:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_015.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When you drop the component, it will change it's position. Note that all the components after the new position also shift. That happens because the default setting of the wxFlexGridSizer allows only 3 components in one row (this can be changed in property browser) so the components just adapted to the new order.&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_016.png]]&lt;br /&gt;
&lt;br /&gt;
==Sizers== &lt;br /&gt;
&lt;br /&gt;
Now let's learn a little bit about components available in wxSmith. I'll describe all supported sizers and a few important components from the Standard palette. Let's start with sizers.&lt;br /&gt;
&lt;br /&gt;
We already know that sizers are responsible for automatically setting the position and size of some components. But how do they do that? Well, it depends on which sizer has been used. So what are the rules? The generic rule is that the sizer tries to use all its available space and place the components it manages in such way that they do not overlap. If the area available to the sizer is too small, it requests a bigger area, so you can be sure that no component will fall out of the window. (Unfortunately, you cannot be sure that after such adjustments the window will be small enough to fit on the screen, so be careful about that.) Another rule which should be mentioned here is that sizers automatically set-up the minimum size required by the window. Basically when you edit a window using sizers, you should be aware that you edit the smallest layout and without some tricks, you won't be able to resize the window to something smaller.&lt;br /&gt;
&lt;br /&gt;
Here are descriptions of all sizers available in wxSmith:&lt;br /&gt;
&lt;br /&gt;
=== wxBoxSizer ===&lt;br /&gt;
&lt;br /&gt;
wxBoxSizer is the most basic sizer available in wxWidgets. It's purpose is to align components in one line - one next to another - either horizontally or vertically. This sizer also tries to keep some proportions between components - for a horizontal sizer you can set factors which will keep proportionality of widths and the height of the sizer area will be equal to the height of the tallest component. Similarly, vertical sizers keep heights proportional and the width will be taken from the widest component. You specify whether the sizer is to be horizontal or vertical in the sizer's property browser.&lt;br /&gt;
&lt;br /&gt;
Here are examples of layout using box sizers (the first one is the horizontal one, the second is vertical one):&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_002.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In that example you may see that all components have the same width and height.&lt;br /&gt;
&lt;br /&gt;
But let's assume that we want Button2 to be two times wider that Button1 and Button3 to be three times wider than Button1. This can be easily done by using the Proportion property of managed components. By default, the value of all components is set to 1 so they have equal size. Changing the Proportion of second button to 2 would mean that it should be 2 times wider than the first or third one.&lt;br /&gt;
&lt;br /&gt;
Generally you can set any value you want here. One common technique is to set percentage values - for example setting proportions to values 20, 30 and 50 would mean that the first button should occupy 20% of the space, the second one 30% and the third one 50%. The special value 0 means that this component should be skipped in proportion calculations and it won't automatically adjust it's size when the main window is resized.&lt;br /&gt;
&lt;br /&gt;
So if we want to get 1:2:3 proportions, we set 1 for Button1, 2 for Button2 and 3 for Button3. And here is the result:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_003.png]]&lt;br /&gt;
&lt;br /&gt;
Also note that if you create a resizable window and resize it, those 3 buttons will automatically grow and keep proportions. If you set the Proportion property for some component to 0, it won't change size as the user changes the size of the window. &lt;br /&gt;
&lt;br /&gt;
The other dimension which is not controlled by the &amp;quot;Proportion&amp;quot; property may be controlled using the &amp;quot;Expand&amp;quot; and &amp;quot;Shaped&amp;quot; properties. They are simple checkboxes. If you check the first one, the component will expand it's width/height and will get the size of the biggest component managed by the same sizer. Selecting &amp;quot;Shaped&amp;quot; will also make the component resize but such components will try to keep the initial proportion between width and height so it doesn't have to use all available space. The effect of the &amp;quot;Expand&amp;quot; and &amp;quot;Shaped&amp;quot; properties can be seen when components differ in width or height; here's an example:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_004.png]]&lt;br /&gt;
&lt;br /&gt;
In this example, the first button is the biggest of the three. Its size will be used to adjust the sizes of the other buttons. The second one has its &amp;quot;Expand&amp;quot; property checked, and the third one does not. What can be seen here is that the third button expanded in only one dimension (the one managed by &amp;quot;Proportion&amp;quot; property), the second dimension was left untouched.&lt;br /&gt;
&lt;br /&gt;
You may also note that when a component does not fill its available area, it is centered. That's default behavior which can be changed. In the properties of components managed by sizer you will find properties called '''Horizontal align''' and '''Vertical align'''. Using these properties you can select where the component should be located when it's smaller that its available area.&lt;br /&gt;
&lt;br /&gt;
=== wxStaticBoxSizer ===&lt;br /&gt;
&lt;br /&gt;
This sizer is similar to wxBoxSizer with one exception: it adds an extra static box around managed components:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_005.png]]&lt;br /&gt;
&lt;br /&gt;
=== wxGridSizer ===&lt;br /&gt;
&lt;br /&gt;
This sizer is a little bit more advanced than wxBoxSizer because it aligns components on a grid, not on one line. You can specify the number of columns or number of rows in properties &amp;quot;Cols&amp;quot; and &amp;quot;Rows&amp;quot;. The default number of columns is set to 3 and number of rows is set to 0. When 0 is used, it means that sizer should automatically calculate this value to keep all managed components inside.&lt;br /&gt;
&lt;br /&gt;
This sizer makes an important assumption: all cells must have the same width and all must have the same height.  This means that the tallest managed component will set the height of all rows and the widest one will set the widths of all columns. If an component won't use the whole cell, it will be surrounded by empty space. (If you don't like this assumption, look at the wxFlexGridSizer.)&lt;br /&gt;
&lt;br /&gt;
Among the properties of a wxGridSizer you can also find horizontal and vertical spacings. These values set the spacing added between components. The result of using them is similar to using borders around managed components but with borders you would have to set borders for all components separately.&lt;br /&gt;
&lt;br /&gt;
In the case of wxGridSizer, the &amp;quot;Proportion&amp;quot; value is not used. But you may use &amp;quot;Expand&amp;quot;, &amp;quot;Shaped&amp;quot; or placement properties to adjust the result.&lt;br /&gt;
&lt;br /&gt;
Here's an example of a grid sizer:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_006.png]]&lt;br /&gt;
&lt;br /&gt;
=== wxFlexGridSizer ===&lt;br /&gt;
&lt;br /&gt;
This is a very useful one. It works similarly to wxGridSizer; but it does not force all columns to have the same width nor all rows to have the same height. Also not all columns resize when there's more space available for the sizer. Comparing to wxGridSizer you will find two extra properties here: &amp;quot;Growable cols&amp;quot; and &amp;quot;Growable rows&amp;quot;. In these properties you may provide a list of columns / rows which should automatically resize by providing a list of numbers separated using comma (,). The numbers should start from 0, so if you would like the second and third column to resize, put &amp;quot;1,2&amp;quot; into &amp;quot;Growable cols&amp;quot;. This property is very useful to handle resizing of the window.&lt;br /&gt;
&lt;br /&gt;
Unfortunately you won't be able to set proportions other that 1:1 The &amp;quot;Proportion&amp;quot; property is also not used in this sizer.&lt;br /&gt;
&lt;br /&gt;
=== wxStdDialogButtonSizer ===&lt;br /&gt;
&lt;br /&gt;
This is a specialized sizer with one purpose - to provide a set of standard buttons with respect to the platform's look and feel. This sizer has a predefined list of components which it can handle - all are buttons and you can manage them using the sizer's properties. You cannot add your custom components into this sizer.&lt;br /&gt;
&lt;br /&gt;
Each button on this sizer has two properties in the sizer - whether the button should be enabled (for example wxID_OK for OK button) and its label. Note that labels for most buttons will be generated automatically and wxWidgets will skip them when it can read them from system settings. For example, on Linux only the Context Help button does not have a system-supplied label. It is also very probable that labels will be provided with language-specific strings (depending on the current system language). Not all configurations of buttons are valid - they won't break the application but buttons will overlap (for example Yes and OK).&lt;br /&gt;
&lt;br /&gt;
Here is an example of this sizer. My system is set up in Polish, so the labels are automatically in Polish.  They mean: Help, Cancel, Apply and OK.&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_007.png]]&lt;br /&gt;
&lt;br /&gt;
This screenshot was taken on a Linux box. You may see that the buttons have an extra image which is not available for standard buttons. With such a layout, users of the application will feel more comfortable, and such 'small' things make users say that the GUI was designed very well. On MS Windows, the sizer would have the same buttons but without images and they would be in a different order - the one that is used on windows by default.&lt;br /&gt;
&lt;br /&gt;
All of the above sizers can be found on the &amp;quot;Layout&amp;quot; tab. You can find two other components there which are not sizers but can be used for layout purposes. &lt;br /&gt;
&lt;br /&gt;
The first one is Spacer. It can be added to other sizers when you simply need some empty space instead of any particular component. Spacers have only width and height.&lt;br /&gt;
&lt;br /&gt;
The second one is wxSplitterWindow. When you use this component, you can add one or two child components into it and they will be separated with a dividing line (it's called a sash in wxWidgets). On the application you can drag it to dynamically adjust the size of managed components.&lt;br /&gt;
&lt;br /&gt;
Now that we know something about sizers let's turn to other components.&lt;br /&gt;
&lt;br /&gt;
== Especially Useful Standard Components ==&lt;br /&gt;
&lt;br /&gt;
wxWidgets provides all standard graphical components like static text, buttons, edit boxes, combo boxes, and so on. All are supported in wxSmith, so you can build a nice working environment. I'll briefly describe the components that are really useful in standard applications.&lt;br /&gt;
&lt;br /&gt;
=== wxButton ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_017.png]]&lt;br /&gt;
&lt;br /&gt;
This is standard button, a very common component. Its purpose is to run some piece of code when the user clicks on it. That's it.&lt;br /&gt;
&lt;br /&gt;
=== wxStaticText ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_018.png]]&lt;br /&gt;
&lt;br /&gt;
This component only shows user-defined text on the window. It doesn't generate any events.&lt;br /&gt;
&lt;br /&gt;
=== wxTextCtrl ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_019.png]]&lt;br /&gt;
&lt;br /&gt;
This component let's the user enter some text. It's basic functionality allows entering one-line text. After changing its properties, it may become a more advanced multiline editor with support for different fonts, colors and text styles.&lt;br /&gt;
&lt;br /&gt;
=== wxPanel ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_020.png]]&lt;br /&gt;
&lt;br /&gt;
Although this component may be a separate window, it is most commonly added as a comoponent in a parent window. It is particularly useful as a background for other components. It has a few functionalities - it can be used as background in notebooks and it may be a place where you put components without sizers. But it also has a few drawbacks - wxWidgets tends to do some tricks with wxPanel's size so it's not always possible to set the size we really want.&lt;br /&gt;
&lt;br /&gt;
=== wxChoice ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_021.png]]&lt;br /&gt;
&lt;br /&gt;
This component provides a drop-down list with available options. It works similarly to wxComboBox but the user cannot enter values. It can be used in situations when the user should use one of several available options. An event is generated when the user changes the selected component.&lt;br /&gt;
&lt;br /&gt;
=== wxComboBox ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_022.png]]&lt;br /&gt;
&lt;br /&gt;
This component provides a drop-down list similar to that of wxChoice. In the case of this component, the user can select one of the available values or enter his own if the component is not in a Read-Only state. A very good example of its usage is to provide some text entry with a stored list of previously entered values (like in search boxes). Like wxChoice, changing the selection generates an event. Additionally, changing the text and pressing enter also generates events. Tutorial 9 will illustrate its use. &lt;br /&gt;
&lt;br /&gt;
=== wxListBox ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_023.png]]&lt;br /&gt;
&lt;br /&gt;
This component provides a list where you can select one or more components. Changing the component or double-clicking on it generates an event.&lt;br /&gt;
&lt;br /&gt;
=== wxNotebook ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_024.png]]&lt;br /&gt;
&lt;br /&gt;
Notebook is very useful for complex resources since it groups content under tabs. Additionally, wxChoicebook and wxCombobook are also available but are not described here. Changing the selected notebook generates two events: one when the page starts to change (before change) and one when the page is finished changing (after change).&lt;br /&gt;
&lt;br /&gt;
=== wxCheckBox ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_025.png]]&lt;br /&gt;
&lt;br /&gt;
Check boxes may be used to map boolean values. Additionally, 2-state boxes can also be generated (with values: yes/no/unspecified). Changing the value emits an event.&lt;br /&gt;
&lt;br /&gt;
=== wxRadioBox ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_026.png]]&lt;br /&gt;
&lt;br /&gt;
Radio box works similarly to check boxes. The difference is that only one radiobox in a group can be selected. Groups may be defined by using wxRB_GROUP style. A radiobox which has this style set starts a new group. Changing the selected radiobox emits an event.&lt;br /&gt;
&lt;br /&gt;
=== wxGauge ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_027.png]]&lt;br /&gt;
&lt;br /&gt;
This component, also called a Progress Bar, can be used to show the progress of some operation. It's very useful when doing some calculation intensive operations. It can prevent users from getting frustrated when they do not see anything happening on the screen but only a window which seems hung.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt; * * * * &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
That's the end of this tutorial. We will get more experience with these subjects in the following tutorials. But you can also learn a lot by experimenting: add components, change properties, resize, move. You may try adding sizers into other sizers, a very useful technique absolutely required for more complex forms. Join me for the next tutorial!&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;'''[[WxSmith tutorial: Hello world|Previous]] | [[WxSmith tutorials|Index]] | [[WxSmith tutorial: Building more complex window|Next]]'''&amp;lt;/center&amp;gt;&lt;/div&gt;</summary>
		<author><name>Chatumao</name></author>
	</entry>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=Wxsmith_tutorial:_Working_with_items&amp;diff=7571</id>
		<title>Wxsmith tutorial: Working with items</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=Wxsmith_tutorial:_Working_with_items&amp;diff=7571"/>
		<updated>2013-05-12T12:41:44Z</updated>

		<summary type="html">&lt;p&gt;Chatumao: /* wxBoxSizer */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:wxSmith Documentation]]&lt;br /&gt;
= Working with Menus and Components =&lt;br /&gt;
&lt;br /&gt;
In the [[wxSmith tutorial: Hello world|previous tutorial]] we learned how to create a small application using wxWidgets. We created a window with a few components inside. In this tutorial, we will first see how to use the menu bar at the top of the main window and then focus on sizers and wxWidgets components which can be put on a form or window. &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''A Note on Terminology'''&lt;br /&gt;
&lt;br /&gt;
BYO, the creator of wxSmith and original author of these tutorials, wrote &amp;quot;Each resource in wxSmith is made of items. All your buttons, text boxes, lists etc are items. Also some more abstract things like sizers, spacers (used to add empty space), menu entries or even timers are also called items in wxSmith. So basically anything that's inside the resource may be called an item. I'll also use the term component since it reflects the valid meaning too.&amp;quot; &lt;br /&gt;
&lt;br /&gt;
In fact, the word &amp;quot;item&amp;quot; is not found in the index of the Julian Smart and Kevin Hock book ''Cross-Platform GUI Programming with wxWidgets.'' The word is used in the book specifically for the elements of the drop-down lists of choice boxes, combo boxes, and other members of the class wxControlWithItems. In the revision of these tutorials, the word &amp;quot;item&amp;quot; is therefore generally being reserved for items in these lists and for items in a menu. Otherwise, the word &amp;quot;item&amp;quot; is generally being replaced by &amp;quot;component&amp;quot;, &amp;quot;widget&amp;quot;, or &amp;quot;control&amp;quot; as seems appropriate, though of course, it is also occasionally used with no special technical meaning. Also, BYO often uses the word &amp;quot;resource&amp;quot; to refer to a form or window. Smart and Hock use word the &amp;quot;resource&amp;quot; sparingly, mainly in the context of &amp;quot;resource files&amp;quot;.  The word seems overworked and needlessly abstract, so when what is intended is a form or window, the revisions will use one of those words, with no sharp distinction between them.   &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Note that all screenshots presented here were made on Linux but they should not be very different from the windows ones.&lt;br /&gt;
&lt;br /&gt;
== Working with Menus ==&lt;br /&gt;
&lt;br /&gt;
Following the directions given in Tutorial 1, start a new Code::Blocks project; call it Tutorial_2. Remember to add &amp;quot;event.Skip(TRUE);&amp;quot; at the appropriate place in the code, as explained in Tutorial 1. &lt;br /&gt;
&lt;br /&gt;
Build and run the program. You will see that it has two items on the main menu. We will add one more, Jump, at the top level and under it two more, Back and Out. Back will do nothing, but we will make Out close the program.&lt;br /&gt;
&lt;br /&gt;
Click on the “Tutorial_2frame.wxs” tab of the Editor window.  Just below the words “Tutorial_2framw.wxs” is a panel with two square icons.  Double left click on the leftmost one, which shows the word ''File'' suggestive of a menu.  Up comes the menu inspector window shown below.&lt;br /&gt;
&lt;br /&gt;
[[Image:1i.png]]  &lt;br /&gt;
   &lt;br /&gt;
Click on the various menu items shown and note how the content of the fields shown on the right side of the window are filled in.  Then click on the New button (in the lower right part of the window) to add the three additional menu items mentioned above, namely Jump at the top level and under it Back and Out. It does not matter where the items first appear; you use the arrow keys just above the “New” and “Delete” buttons to move around the item you have selected.  For the “Id” field of the “Out” item, put idMenuOut. You should make the menu inspector window look like this:&lt;br /&gt;
&lt;br /&gt;
[[Image:1j.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When you have the menu items properly arranged, click OK.   &lt;br /&gt;
&lt;br /&gt;
When you now build and run, you will see the new menu.  But clicking Jump | Out  does not close the program as desired because we have not programmed the response to that event.  To do so, we want to make wxSmith set up the frame for the routine which will be called when the menu item “Out” is clicked.  Go to the Management pane, Resources tab and persistently click on the little right-pointing triangles until the “Out” item can be seen, as in the screen shot below.&lt;br /&gt;
&lt;br /&gt;
[[Image:1k.png]]&lt;br /&gt;
&lt;br /&gt;
      &lt;br /&gt;
Click on the word “Out” and then on the {} icon in the panel below the Management pane. That will cause the pane below to show the words “EVT_MENU     --None--” . Click on the word “None” or the down arrow at the right end of the field; a menu drops down.  Pick the item  “-- Add New Handler --”, accept the suggested name (OnMenu3Selected), and over in the editor, the frame of our handler has been written, as shown below.  We have only to write the code, which will be simply “Close();”.&lt;br /&gt;
&lt;br /&gt;
[[Image:1l.png]]&lt;br /&gt;
&lt;br /&gt;
Now we can “Build and run”, drop down our menu, click on “Out”, and the program closes, as desired.&lt;br /&gt;
&lt;br /&gt;
== Windows and Components ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Each window in wxSmith is made of components. All your buttons, text boxes, lists, and so on are components. Also some more abstract things like sizers, spacers (used to add empty space), menu entries or even timers are also components.&lt;br /&gt;
&lt;br /&gt;
Every window has a root component. For a dialog window, it would be a wxDialog component; for a frame window, it would be wxFrame component; for a panel it would be a wxPanel component. In the [[wxSmith tutorial: Hello world|previous tutorial]] you probably noticed that some components may have &amp;quot;children&amp;quot;. For example, sizers had components inside their boxes. In this tutorial, you have seen sub-menu items inside main-menu items. The term &amp;quot;children&amp;quot; suggests the idea of a family tree, and indeed precisely such a tree structure is directly represented in the resource browser, as shown in the example below.&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_008.png]]&lt;br /&gt;
&lt;br /&gt;
In the picture above, you will see an example of such a tree. wxFontFaceEditorDlg is the currently opened form with a root component of type wxDialog. We can see that this resource consists of a few sizers and buttons, one text area and some spacers. It's definitely a fairly simple form. For more complicated forms, there could be more than 100 components. The tree (or Resource) browser can be very helpful for locating the code connected with a component; clicking on the component in the browser brings up its code in the editor.&lt;br /&gt;
&lt;br /&gt;
Each component has its properties - these are usually some values which describe the component. Some of them may affect the way component looks, some may change the component's behavior, and some may be dedicated to programming facilities. You will also find that there are some properties -- such as position and size -- common to many components.&lt;br /&gt;
&lt;br /&gt;
wxSmith allows you to edit components inside the properties browser (the window which is usually under the resource browser). If you select a component either by  clicking on it in the resource browser or by clicking on it inside the editor, the properties editor switches to edit its properties. Here's an example of the property browser:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_009.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can also use the Quick-Properties panel available after pressing the &amp;quot;Q&amp;quot; button on the right side of the editor:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_010.png]]&lt;br /&gt;
&lt;br /&gt;
The purpose of this panel is to provide most common properties in user-friendly way. It hasn't proven as useful as I had hoped, and you will probably find it helpful only while adjusting sizer-related settings.&lt;br /&gt;
&lt;br /&gt;
The last and the easiest way to work on a component is directly in the editor. You can grab drag boxes and change the component's size. You can also change its position by simply dragging it to another place.&lt;br /&gt;
&lt;br /&gt;
=== Excercise with Components ===&lt;br /&gt;
&lt;br /&gt;
Enough generalities; let's play with components. We can continue with the project started at the beginning of this tutorial. First let's add wxFlexGridSizer into our window. Like all sizers, it is located in Layout tab. (You'll remember how to add components from the [[wxSmith tutorial: Hello world|previous tutorial]]). Now let's add the following components into the sizer in the order given: wxButton, wxStaticText, wxTextCtrl, wxRadioButton and wxCheckBox. They can all be found on the Standard tab. The result should look like this:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_011.png]]&lt;br /&gt;
&lt;br /&gt;
In this picture, components I've selected have a light red border.&lt;br /&gt;
&lt;br /&gt;
Now that we have our playground, let's change some components. First, let's change the label and color of the button. To do so, click on the button and move to the properties browser. &amp;quot;Label&amp;quot; is the first property, and it's quite easy to change. Just click on the word &amp;quot;Label&amp;quot; on the right and type new text.&lt;br /&gt;
&lt;br /&gt;
Color is little bit harder to find. Usually components have two colors - Background and Foreground color. Background, as the name implies, is used to fill the component's background. Foreground, on the other hand, is used to paint some content onto the background. Note that there's no strict interpretation of these colors so you should experiment to find out their meaning. In wxButton, Background is what we want.&lt;br /&gt;
So let's find the Background property. It's value can be changed by using combobox:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_012.png]]&lt;br /&gt;
&lt;br /&gt;
On the list you may find a set of predefined system colors. When you choose one of them, they will be read from the current system settings making your application compatible with the system theme. There are also two special entries - Default (which means that we do not want to set our color) and Custom. When you select Custom, wxSmith will open a color dialog where you can choose any color you like. I have chosen light green, and here's the result:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_013.png]]&lt;br /&gt;
&lt;br /&gt;
There are also other properties we could talk about, but the best way to learn them is to play with them, so I leave those discoveries to you.&lt;br /&gt;
&lt;br /&gt;
Now let's use the mouse.&lt;br /&gt;
&lt;br /&gt;
The selected component will have eight black boxes -- drag handles -- around it. These boxes can be used to change the size of the component. You will easily notice when the mouse is over a handle because the cursor changes. Let's resize the wxTextCtrl (edit box):&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_014.png]]&lt;br /&gt;
&lt;br /&gt;
You may see that resizing the component will also change properties in the browser - '''Default Size''' is unchecked now and '''Width''' and '''Height''' are set to required values. There's another property which seems to be untouched - '''Size in Dialog Units''', which is also related to size. I'll explain it a bit.&lt;br /&gt;
&lt;br /&gt;
Usually when you must specify a size (or other size-related things) you provide a value in pixels. Alternatively you can specify values in a unit called a '''Dialog Unit'''. A '''Dialog Unit''' is usually a little bit bigger than one pixel and it's size depends on the size of the current font (actually it's the size of the font of some component's parent which has a font). This is useful when you want some values to be proportional to the size of text presented in the window. &lt;br /&gt;
&lt;br /&gt;
If you check '''Size in Dialog Units'', wxSmith will take care of it and sizes will be calculated in Dialog Units instead of pixels (although, naturally, you will still be able to resize components).&lt;br /&gt;
&lt;br /&gt;
Now let's change the position of the radio box. &amp;quot;But, wait,&amp;quot; you may say, &amp;quot;I thought you said that the sizer is responsible for the positioning.&amp;quot; That's right. We have limited possibilities to change position. Inside one sizer we can only reorder components; for more complex forms we can also move a component between two sizers or to areas where sizers do not apply. So, back to our example, let's move the radio box to position it right after the button. To do so, click on the radio button and drag it onto the button. When you start dragging, you will notice that the area of the sizer changes color to blue. This color change is an aid to show you what will be the new position of the dragged component. When you move the cursor onto the button, half of the button will become light-blue. When the left half is highlighted, the dragged component will be added before it. When the right half is highlighted, dragged component will be added after it. And when there's no highlighted component, the new component will be added as the last child of the parent:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_015.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When you drop the component, it will change it's position. Note that all the components after the new position also shift. That happens because the default setting of the wxFlexGridSizer allows only 3 components in one row (this can be changed in property browser) so the components just adapted to the new order.&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_016.png]]&lt;br /&gt;
&lt;br /&gt;
==Sizers== &lt;br /&gt;
&lt;br /&gt;
Now let's learn a little bit about components available in wxSmith. I'll describe all supported sizers and a few important components from the Standard palette. Let's start with sizers.&lt;br /&gt;
&lt;br /&gt;
We already know that sizers are responsible for automatically setting the position and size of some components. But how do they do that? Well, it depends on which sizer has been used. So what are the rules? The generic rule is that the sizer tries to use all its available space and place the components it manages in such way that they do not overlap. If the area available to the sizer is too small, it requests a bigger area, so you can be sure that no component will fall out of the window. (Unfortunately, you cannot be sure that after such adjustments the window will be small enough to fit on the screen, so be careful about that.) Another rule which should be mentioned here is that sizers automatically set-up the minimum size required by the window. Basically when you edit a window using sizers, you should be aware that you edit the smallest layout and without some tricks, you won't be able to resize the window to something smaller.&lt;br /&gt;
&lt;br /&gt;
Here are descriptions of all sizers available in wxSmith:&lt;br /&gt;
&lt;br /&gt;
=== wxBoxSizer ===&lt;br /&gt;
&lt;br /&gt;
wxBoxSizer is the most basic sizer available in wxWidgets. It's purpose is to align components in one line - one next to another - either horizontally or vertically. This sizer also tries to keep some proportions between components - for a horizontal sizer you can set factors which will keep proportionality of widths and the height of the sizer area will be equal to the height of the tallest component. Similarly, vertical sizers keep heights proportional and the width will be taken from the widest component. You specify whether the sizer is to be horizontal or vertical in the sizer's property browser.&lt;br /&gt;
&lt;br /&gt;
Here are examples of layout using box sizers (the first one is the horizontal one, the second is vertical one):&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_002.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In that example you may see that all components have the same width and height.&lt;br /&gt;
&lt;br /&gt;
But let's assume that we want Button2 to be two times wider that Button1 and Button3 to be three times wider than Button1. This can be easily done by using the Proportion property of managed components. By default, the value of all components is set to 1 so they have equal size. Changing the Proportion of second button to 2 would mean that it should be 2 times wider than the first or third one.&lt;br /&gt;
&lt;br /&gt;
Generally you can set any value you want here. One common technique is to set percentage values - for example setting proportions to values 20, 30 and 50 would mean that the first button should occupy 20% of the space, the second one 30% and the third one 50%. The special value 0 means that this component should be skipped in proportion calculations and it won't automatically adjust it's size when the main window is resized.&lt;br /&gt;
&lt;br /&gt;
So if we want to get 1:2:3 proportions, we set 1 for Button1, 2 for Button2 and 3 for Button3. And here is the result:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_003.png]]&lt;br /&gt;
&lt;br /&gt;
Also note that if you create a resizable window and resize it, those 3 buttons will automatically grow and keep proportions. If you set the Proportion property for some component to 0, it won't change size as the user changes the size of the window. &lt;br /&gt;
&lt;br /&gt;
The other dimension which is not controlled by the &amp;quot;Proportion&amp;quot; property may be controlled using the &amp;quot;Expand&amp;quot; and &amp;quot;Shaped&amp;quot; properties. They are simple checkboxes. If you check the first one, the component will expand it's width/height and will get the size of the biggest component managed by the same sizer. Selecting &amp;quot;Shaped&amp;quot; will also make the component resize but such components will try to keep the initial proportion between width and height so it doesn't have to use all available space. The effect of the &amp;quot;Expand&amp;quot; and &amp;quot;Shaped&amp;quot; properties can be seen when components differ in width or height; here's an example:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_004.png]]&lt;br /&gt;
&lt;br /&gt;
In this example, the first button is the biggest of the three. Its size will be used to adjust the sizes of the other buttons. The second one has its &amp;quot;Expand&amp;quot; property checked, and the third one does not. What can be seen here is that the third button expanded in only one dimension (the one managed by &amp;quot;Proportion&amp;quot; property), the second dimension was left untouched.&lt;br /&gt;
&lt;br /&gt;
You may also note that when a component does not fill its available area, it is centered. That's default behavior which can be changed. In the properties of components managed by sizer you will find properties called '''Horizontal align''' and '''Vertical align'''. Using these properties you can select where the component should be located when it's smaller that its available area.&lt;br /&gt;
&lt;br /&gt;
=== wxStaticBoxSizer ===&lt;br /&gt;
&lt;br /&gt;
This sizer is similar to wxBoxSizer with one exception: it adds an extra static box around managed components:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_005.png]]&lt;br /&gt;
&lt;br /&gt;
=== wxGridSizer ===&lt;br /&gt;
&lt;br /&gt;
This sizer is a little bit more advanced than wxBoxSizer because it aligns components on a grid, not on one line. You can specify the number of columns or number of rows in properties &amp;quot;Cols&amp;quot; and &amp;quot;Rows&amp;quot;. The default number of columns is set to 3 and number of rows is set to 0. When 0 is used, it means that sizer should automatically calculate this value to keep all managed components inside.&lt;br /&gt;
&lt;br /&gt;
This sizer makes an important assumption: all cells must have the same width and all must have the same height.  This means that the tallest managed component will set the height of all rows and the widest one will set the widths of all columns. If an component won't use the whole cell, it will be surrounded by empty space. (If you don't like this assumption, look at the wxFlexGridSizer.)&lt;br /&gt;
&lt;br /&gt;
Among the properties of a wxGridsizer you can also find horizontal and vertical spacings. These values set the spacing added between components. The result of using them is similar to using borders around managed components but with borders you would have to set borders for all components separately.&lt;br /&gt;
&lt;br /&gt;
In the case of wxGridSizer, the &amp;quot;Proportion&amp;quot; value is not used. But you may use &amp;quot;Expand&amp;quot;, &amp;quot;Shaped&amp;quot; or placement properties to adjust the result.&lt;br /&gt;
&lt;br /&gt;
Here's an example of a grid sizer:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_006.png]]&lt;br /&gt;
&lt;br /&gt;
=== wxFlexGridSizer ===&lt;br /&gt;
&lt;br /&gt;
This is a very useful one. It works similarly to wxGridSizer; but it does not force all columns to have the same width nor all rows to have the same height. Also not all columns resize when there's more space available for the sizer. Comparing to wxGridSizer you will find two extra properties here: &amp;quot;Growable cols&amp;quot; and &amp;quot;Growable rows&amp;quot;. In these properties you may provide a list of columns / rows which should automatically resize by providing a list of numbers separated using comma (,). The numbers should start from 0, so if you would like the second and third column to resize, put &amp;quot;1,2&amp;quot; into &amp;quot;Growable cols&amp;quot;. This property is very useful to handle resizing of the window.&lt;br /&gt;
&lt;br /&gt;
Unfortunately you won't be able to set proportions other that 1:1 The &amp;quot;Proportion&amp;quot; property is also not used in this sizer.&lt;br /&gt;
&lt;br /&gt;
=== wxStdDialogButtonSizer ===&lt;br /&gt;
&lt;br /&gt;
This is a specialized sizer with one purpose - to provide a set of standard buttons with respect to the platform's look and feel. This sizer has a predefined list of components which it can handle - all are buttons and you can manage them using the sizer's properties. You cannot add your custom components into this sizer.&lt;br /&gt;
&lt;br /&gt;
Each button on this sizer has two properties in the sizer - whether the button should be enabled (for example wxID_OK for OK button) and its label. Note that labels for most buttons will be generated automatically and wxWidgets will skip them when it can read them from system settings. For example, on Linux only the Context Help button does not have a system-supplied label. It is also very probable that labels will be provided with language-specific strings (depending on the current system language). Not all configurations of buttons are valid - they won't break the application but buttons will overlap (for example Yes and OK).&lt;br /&gt;
&lt;br /&gt;
Here is an example of this sizer. My system is set up in Polish, so the labels are automatically in Polish.  They mean: Help, Cancel, Apply and OK.&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_007.png]]&lt;br /&gt;
&lt;br /&gt;
This screenshot was taken on a Linux box. You may see that the buttons have an extra image which is not available for standard buttons. With such a layout, users of the application will feel more comfortable, and such 'small' things make users say that the GUI was designed very well. On MS Windows, the sizer would have the same buttons but without images and they would be in a different order - the one that is used on windows by default.&lt;br /&gt;
&lt;br /&gt;
All of the above sizers can be found on the &amp;quot;Layout&amp;quot; tab. You can find two other components there which are not sizers but can be used for layout purposes. &lt;br /&gt;
&lt;br /&gt;
The first one is Spacer. It can be added to other sizers when you simply need some empty space instead of any particular component. Spacers have only width and height.&lt;br /&gt;
&lt;br /&gt;
The second one is wxSplitterWindow. When you use this component, you can add one or two child components into it and they will be separated with a dividing line (it's called a sash in wxWidgets). On the application you can drag it to dynamically adjust the size of managed components.&lt;br /&gt;
&lt;br /&gt;
Now that we know something about sizers let's turn to other components.&lt;br /&gt;
&lt;br /&gt;
== Especially Useful Standard Components ==&lt;br /&gt;
&lt;br /&gt;
wxWidgets provides all standard graphical components like static text, buttons, edit boxes, combo boxes, and so on. All are supported in wxSmith, so you can build a nice working environment. I'll briefly describe the components that are really useful in standard applications.&lt;br /&gt;
&lt;br /&gt;
=== wxButton ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_017.png]]&lt;br /&gt;
&lt;br /&gt;
This is standard button, a very common component. Its purpose is to run some piece of code when the user clicks on it. That's it.&lt;br /&gt;
&lt;br /&gt;
=== wxStaticText ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_018.png]]&lt;br /&gt;
&lt;br /&gt;
This component only shows user-defined text on the window. It doesn't generate any events.&lt;br /&gt;
&lt;br /&gt;
=== wxTextCtrl ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_019.png]]&lt;br /&gt;
&lt;br /&gt;
This component let's the user enter some text. It's basic functionality allows entering one-line text. After changing its properties, it may become a more advanced multiline editor with support for different fonts, colors and text styles.&lt;br /&gt;
&lt;br /&gt;
=== wxPanel ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_020.png]]&lt;br /&gt;
&lt;br /&gt;
Although this component may be a separate window, it is most commonly added as a comoponent in a parent window. It is particularly useful as a background for other components. It has a few functionalities - it can be used as background in notebooks and it may be a place where you put components without sizers. But it also has a few drawbacks - wxWidgets tends to do some tricks with wxPanel's size so it's not always possible to set the size we really want.&lt;br /&gt;
&lt;br /&gt;
=== wxChoice ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_021.png]]&lt;br /&gt;
&lt;br /&gt;
This component provides a drop-down list with available options. It works similarly to wxComboBox but the user cannot enter values. It can be used in situations when the user should use one of several available options. An event is generated when the user changes the selected component.&lt;br /&gt;
&lt;br /&gt;
=== wxComboBox ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_022.png]]&lt;br /&gt;
&lt;br /&gt;
This component provides a drop-down list similar to that of wxChoice. In the case of this component, the user can select one of the available values or enter his own if the component is not in a Read-Only state. A very good example of its usage is to provide some text entry with a stored list of previously entered values (like in search boxes). Like wxChoice, changing the selection generates an event. Additionally, changing the text and pressing enter also generates events. Tutorial 9 will illustrate its use. &lt;br /&gt;
&lt;br /&gt;
=== wxListBox ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_023.png]]&lt;br /&gt;
&lt;br /&gt;
This component provides a list where you can select one or more components. Changing the component or double-clicking on it generates an event.&lt;br /&gt;
&lt;br /&gt;
=== wxNotebook ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_024.png]]&lt;br /&gt;
&lt;br /&gt;
Notebook is very useful for complex resources since it groups content under tabs. Additionally, wxChoicebook and wxCombobook are also available but are not described here. Changing the selected notebook generates two events: one when the page starts to change (before change) and one when the page is finished changing (after change).&lt;br /&gt;
&lt;br /&gt;
=== wxCheckBox ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_025.png]]&lt;br /&gt;
&lt;br /&gt;
Check boxes may be used to map boolean values. Additionally, 2-state boxes can also be generated (with values: yes/no/unspecified). Changing the value emits an event.&lt;br /&gt;
&lt;br /&gt;
=== wxRadioBox ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_026.png]]&lt;br /&gt;
&lt;br /&gt;
Radio box works similarly to check boxes. The difference is that only one radiobox in a group can be selected. Groups may be defined by using wxRB_GROUP style. A radiobox which has this style set starts a new group. Changing the selected radiobox emits an event.&lt;br /&gt;
&lt;br /&gt;
=== wxGauge ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_027.png]]&lt;br /&gt;
&lt;br /&gt;
This component, also called a Progress Bar, can be used to show the progress of some operation. It's very useful when doing some calculation intensive operations. It can prevent users from getting frustrated when they do not see anything happening on the screen but only a window which seems hung.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt; * * * * &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
That's the end of this tutorial. We will get more experience with these subjects in the following tutorials. But you can also learn a lot by experimenting: add components, change properties, resize, move. You may try adding sizers into other sizers, a very useful technique absolutely required for more complex forms. Join me for the next tutorial!&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;'''[[WxSmith tutorial: Hello world|Previous]] | [[WxSmith tutorials|Index]] | [[WxSmith tutorial: Building more complex window|Next]]'''&amp;lt;/center&amp;gt;&lt;/div&gt;</summary>
		<author><name>Chatumao</name></author>
	</entry>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=Wxsmith_tutorial:_Working_with_items&amp;diff=7568</id>
		<title>Wxsmith tutorial: Working with items</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=Wxsmith_tutorial:_Working_with_items&amp;diff=7568"/>
		<updated>2013-04-29T10:31:00Z</updated>

		<summary type="html">&lt;p&gt;Chatumao: /* wxBoxSizer */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:wxSmith Documentation]]&lt;br /&gt;
= Working with Menus and Components =&lt;br /&gt;
&lt;br /&gt;
In the [[wxSmith tutorial: Hello world|previous tutorial]] we learned how to create a small application using wxWidgets. We created a window with a few components inside. In this tutorial, we will first see how to use the menu bar at the top of the main window and then focus on sizers and wxWidgets components which can be put on a form or window. &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''A Note on Terminology'''&lt;br /&gt;
&lt;br /&gt;
BYO, the creator of wxSmith and original author of these tutorials, wrote &amp;quot;Each resource in wxSmith is made of items. All your buttons, text boxes, lists etc are items. Also some more abstract things like sizers, spacers (used to add empty space), menu entries or even timers are also called items in wxSmith. So basically anything that's inside the resource may be called an item. I'll also use the term component since it reflects the valid meaning too.&amp;quot; &lt;br /&gt;
&lt;br /&gt;
In fact, the word &amp;quot;item&amp;quot; is not found in the index of the Julian Smart and Kevin Hock book ''Cross-Platform GUI Programming with wxWidgets.'' The word is used in the book specifically for the elements of the drop-down lists of choice boxes, combo boxes, and other members of the class wxControlWithItems. In the revision of these tutorials, the word &amp;quot;item&amp;quot; is therefore generally being reserved for items in these lists and for items in a menu. Otherwise, the word &amp;quot;item&amp;quot; is generally being replaced by &amp;quot;component&amp;quot;, &amp;quot;widget&amp;quot;, or &amp;quot;control&amp;quot; as seems appropriate, though of course, it is also occasionally used with no special technical meaning. Also, BYO often uses the word &amp;quot;resource&amp;quot; to refer to a form or window. Smart and Hock use word the &amp;quot;resource&amp;quot; sparingly, mainly in the context of &amp;quot;resource files&amp;quot;.  The word seems overworked and needlessly abstract, so when what is intended is a form or window, the revisions will use one of those words, with no sharp distinction between them.   &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Note that all screenshots presented here were made on Linux but they should not be very different from the windows ones.&lt;br /&gt;
&lt;br /&gt;
== Working with Menus ==&lt;br /&gt;
&lt;br /&gt;
Following the directions given in Tutorial 1, start a new Code::Blocks project; call it Tutorial_2. Remember to add &amp;quot;event.Skip(TRUE);&amp;quot; at the appropriate place in the code, as explained in Tutorial 1. &lt;br /&gt;
&lt;br /&gt;
Build and run the program. You will see that it has two items on the main menu. We will add one more, Jump, at the top level and under it two more, Back and Out. Back will do nothing, but we will make Out close the program.&lt;br /&gt;
&lt;br /&gt;
Click on the “Tutorial_2frame.wxs” tab of the Editor window.  Just below the words “Tutorial_2framw.wxs” is a panel with two square icons.  Double left click on the leftmost one, which shows the word ''File'' suggestive of a menu.  Up comes the menu inspector window shown below.&lt;br /&gt;
&lt;br /&gt;
[[Image:1i.png]]  &lt;br /&gt;
   &lt;br /&gt;
Click on the various menu items shown and note how the content of the fields shown on the right side of the window are filled in.  Then click on the New button (in the lower right part of the window) to add the three additional menu items mentioned above, namely Jump at the top level and under it Back and Out. It does not matter where the items first appear; you use the arrow keys just above the “New” and “Delete” buttons to move around the item you have selected.  For the “Id” field of the “Out” item, put idMenuOut. You should make the menu inspector window look like this:&lt;br /&gt;
&lt;br /&gt;
[[Image:1j.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When you have the menu items properly arranged, click OK.   &lt;br /&gt;
&lt;br /&gt;
When you now build and run, you will see the new menu.  But clicking Jump | Out  does not close the program as desired because we have not programmed the response to that event.  To do so, we want to make wxSmith set up the frame for the routine which will be called when the menu item “Out” is clicked.  Go to the Management pane, Resources tab and persistently click on the little right-pointing triangles until the “Out” item can be seen, as in the screen shot below.&lt;br /&gt;
&lt;br /&gt;
[[Image:1k.png]]&lt;br /&gt;
&lt;br /&gt;
      &lt;br /&gt;
Click on the word “Out” and then on the {} icon in the panel below the Management pane. That will cause the pane below to show the words “EVT_MENU     --None--” . Click on the word “None” or the down arrow at the right end of the field; a menu drops down.  Pick the item  “-- Add New Handler --”, accept the suggested name (OnMenu3Selected), and over in the editor, the frame of our handler has been written, as shown below.  We have only to write the code, which will be simply “Close();”.&lt;br /&gt;
&lt;br /&gt;
[[Image:1l.png]]&lt;br /&gt;
&lt;br /&gt;
Now we can “Build and run”, drop down our menu, click on “Out”, and the program closes, as desired.&lt;br /&gt;
&lt;br /&gt;
== Windows and Components ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Each window in wxSmith is made of components. All your buttons, text boxes, lists, and so on are components. Also some more abstract things like sizers, spacers (used to add empty space), menu entries or even timers are also components.&lt;br /&gt;
&lt;br /&gt;
Every window has a root component. For a dialog window, it would be a wxDialog component; for a frame window, it would be wxFrame component; for a panel it would be a wxPanel component. In the [[wxSmith tutorial: Hello world|previous tutorial]] you probably noticed that some components may have &amp;quot;children&amp;quot;. For example, sizers had components inside their boxes. In this tutorial, you have seen sub-menu items inside main-menu items. The term &amp;quot;children&amp;quot; suggests the idea of a family tree, and indeed precisely such a tree structure is directly represented in the resource browser, as shown in the example below.&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_008.png]]&lt;br /&gt;
&lt;br /&gt;
In the picture above, you will see an example of such a tree. wxFontFaceEditorDlg is the currently opened form with a root component of type wxDialog. We can see that this resource consists of a few sizers and buttons, one text area and some spacers. It's definitely a fairly simple form. For more complicated forms, there could be more than 100 components. The tree (or Resource) browser can be very helpful for locating the code connected with a component; clicking on the component in the browser brings up its code in the editor.&lt;br /&gt;
&lt;br /&gt;
Each component has its properties - these are usually some values which describe the component. Some of them may affect the way component looks, some may change the component's behavior, and some may be dedicated to programming facilities. You will also find that there are some properties -- such as position and size -- common to many components.&lt;br /&gt;
&lt;br /&gt;
wxSmith allows you to edit components inside the properties browser (the window which is usually under the resource browser). If you select a component either by  clicking on it in the resource browser or by clicking on it inside the editor, the properties editor switches to edit its properties. Here's an example of the property browser:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_009.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can also use the Quick-Properties panel available after pressing the &amp;quot;Q&amp;quot; button on the right side of the editor:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_010.png]]&lt;br /&gt;
&lt;br /&gt;
The purpose of this panel is to provide most common properties in user-friendly way. It hasn't proven as useful as I had hoped, and you will probably find it helpful only while adjusting sizer-related settings.&lt;br /&gt;
&lt;br /&gt;
The last and the easiest way to work on a component is directly in the editor. You can grab drag boxes and change the component's size. You can also change its position by simply dragging it to another place.&lt;br /&gt;
&lt;br /&gt;
=== Excercise with Components ===&lt;br /&gt;
&lt;br /&gt;
Enough generalities; let's play with components. We can continue with the project started at the beginning of this tutorial. First let's add wxFlexGridSizer into our window. Like all sizers, it is located in Layout tab. (You'll remember how to add components from the [[wxSmith tutorial: Hello world|previous tutorial]]). Now let's add the following components into the sizer in the order given: wxButton, wxStaticText, wxTextCtrl, wxRadioButton and wxCheckBox. They can all be found on the Standard tab. The result should look like this:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_011.png]]&lt;br /&gt;
&lt;br /&gt;
In this picture, components I've selected have a light red border.&lt;br /&gt;
&lt;br /&gt;
Now that we have our playground, let's change some components. First, let's change the label and color of the button. To do so, click on the button and move to the properties browser. &amp;quot;Label&amp;quot; is the first property, and it's quite easy to change. Just click on the word &amp;quot;Label&amp;quot; on the right and type new text.&lt;br /&gt;
&lt;br /&gt;
Color is little bit harder to find. Usually components have two colors - Background and Foreground color. Background, as the name implies, is used to fill the component's background. Foreground, on the other hand, is used to paint some content onto the background. Note that there's no strict interpretation of these colors so you should experiment to find out their meaning. In wxButton, Background is what we want.&lt;br /&gt;
So let's find the Background property. It's value can be changed by using combobox:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_012.png]]&lt;br /&gt;
&lt;br /&gt;
On the list you may find a set of predefined system colors. When you choose one of them, they will be read from the current system settings making your application compatible with the system theme. There are also two special entries - Default (which means that we do not want to set our color) and Custom. When you select Custom, wxSmith will open a color dialog where you can choose any color you like. I have chosen light green, and here's the result:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_013.png]]&lt;br /&gt;
&lt;br /&gt;
There are also other properties we could talk about, but the best way to learn them is to play with them, so I leave those discoveries to you.&lt;br /&gt;
&lt;br /&gt;
Now let's use the mouse.&lt;br /&gt;
&lt;br /&gt;
The selected component will have eight black boxes -- drag handles -- around it. These boxes can be used to change the size of the component. You will easily notice when the mouse is over a handle because the cursor changes. Let's resize the wxTextCtrl (edit box):&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_014.png]]&lt;br /&gt;
&lt;br /&gt;
You may see that resizing the component will also change properties in the browser - '''Default Size''' is unchecked now and '''Width''' and '''Height''' are set to required values. There's another property which seems to be untouched - '''Size in Dialog Units''', which is also related to size. I'll explain it a bit.&lt;br /&gt;
&lt;br /&gt;
Usually when you must specify a size (or other size-related things) you provide a value in pixels. Alternatively you can specify values in a unit called a '''Dialog Unit'''. A '''Dialog Unit''' is usually a little bit bigger than one pixel and it's size depends on the size of the current font (actually it's the size of the font of some component's parent which has a font). This is useful when you want some values to be proportional to the size of text presented in the window. &lt;br /&gt;
&lt;br /&gt;
If you check '''Size in Dialog Units'', wxSmith will take care of it and sizes will be calculated in Dialog Units instead of pixels (although, naturally, you will still be able to resize components).&lt;br /&gt;
&lt;br /&gt;
Now let's change the position of the radio box. &amp;quot;But, wait,&amp;quot; you may say, &amp;quot;I thought you said that the sizer is responsible for the positioning.&amp;quot; That's right. We have limited possibilities to change position. Inside one sizer we can only reorder components; for more complex forms we can also move a component between two sizers or to areas where sizers do not apply. So, back to our example, let's move the radio box to position it right after the button. To do so, click on the radio button and drag it onto the button. When you start dragging, you will notice that the area of the sizer changes color to blue. This color change is an aid to show you what will be the new position of the dragged component. When you move the cursor onto the button, half of the button will become light-blue. When the left half is highlighted, the dragged component will be added before it. When the right half is highlighted, dragged component will be added after it. And when there's no highlighted component, the new component will be added as the last child of the parent:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_015.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When you drop the component, it will change it's position. Note that all the components after the new position also shift. That happens because the default setting of the wxFlexGridSizer allows only 3 components in one row (this can be changed in property browser) so the components just adapted to the new order.&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_016.png]]&lt;br /&gt;
&lt;br /&gt;
==Sizers== &lt;br /&gt;
&lt;br /&gt;
Now let's learn a little bit about components available in wxSmith. I'll describe all supported sizers and a few important components from the Standard palette. Let's start with sizers.&lt;br /&gt;
&lt;br /&gt;
We already know that sizers are responsible for automatically setting the position and size of some components. But how do they do that? Well, it depends on which sizer has been used. So what are the rules? The generic rule is that the sizer tries to use all its available space and place the components it manages in such way that they do not overlap. If the area available to the sizer is too small, it requests a bigger area, so you can be sure that no component will fall out of the window. (Unfortunately, you cannot be sure that after such adjustments the window will be small enough to fit on the screen, so be careful about that.) Another rule which should be mentioned here is that sizers automatically set-up the minimum size required by the window. Basically when you edit a window using sizers, you should be aware that you edit the smallest layout and without some tricks, you won't be able to resize the window to something smaller.&lt;br /&gt;
&lt;br /&gt;
Here are descriptions of all sizers available in wxSmith:&lt;br /&gt;
&lt;br /&gt;
=== wxBoxSizer ===&lt;br /&gt;
&lt;br /&gt;
wxBoxSizer is the most basic sizer available in wxWidgets. It's purpose is to align components in one line - one next to another - either horizontally or vertically. This sizer also tries to keep some proportions between components - for a horizontal sizer you can set factors which will keep proportionality of widths and the height of the sizer area will be equal to the height of the tallest component. Similarly, vertical sizers keep heights proportional and the width will be taken from the widest component. You specify whether the sizer is to be horizontal or vertical in the sizer's property browser.&lt;br /&gt;
&lt;br /&gt;
Here are examples of layout using box sizers (the first one is the horizontal one, the second is vertical one):&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_002.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In that example you may see that all components have the same width and height.&lt;br /&gt;
&lt;br /&gt;
But let's assume that we want Button2 to be two times wider that Button1 and Button3 to be three times wider than Button1. This can be easily done by using the Proportion property of managed components. By default, the value of all components is set to 1 so they have equal size. Changing the Proportion of second button to 2 would mean that it should be 2 times wider that the first or third one.&lt;br /&gt;
&lt;br /&gt;
Generally you can set any value you want here. One common technique is to set percentage values - for example setting proportions to values 20, 30 and 50 would mean that the first button should occupy 20% of the space, the second one 30% and the third one 50%. The special value 0 means that this component should be skipped in proportion calculations and it won't automatically adjust it's size when the main window is resized.&lt;br /&gt;
&lt;br /&gt;
So if we want to get 1:2:3 proportions, we set 1 for Button1, 2 for Button2 and 3 for Button3. And here is the result:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_003.png]]&lt;br /&gt;
&lt;br /&gt;
Also note that if you create a resizable window and resize it, those 3 buttons will automatically grow and keep proportions. If you set the Proportion property for some component to 0, it won't change size as the user changes the size of the window. &lt;br /&gt;
&lt;br /&gt;
The other dimension which is not controlled by Proportion property may be controlled using the &amp;quot;Expand&amp;quot; and &amp;quot;Shaped&amp;quot; properties. They are simple checkboxes. If you check the first one, the component will expand it's width/height and will get the size of the biggest component managed by the same sizer. Selecting &amp;quot;Shaped&amp;quot; will also make the component resize but such components will try to keep the initial proportion between width and height so it doesn't have to use all available space. The effect of the &amp;quot;Expand&amp;quot; and &amp;quot;Shaped&amp;quot; properties can be seen when components differ in width or height; here's an example:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_004.png]]&lt;br /&gt;
&lt;br /&gt;
In this example, the first button is the biggest of the three. Its size will be used to adjust the sizes of the other buttons. The second one has its &amp;quot;Expand&amp;quot; property checked, and the third one does not. What can be seen here is that the third button expanded in only one dimension (the one managed by &amp;quot;Proportion&amp;quot; property), the second dimension was left untouched.&lt;br /&gt;
&lt;br /&gt;
You may also note that when a component does not fill its available area, it is centered. That's default behavior which can be changed. In the properties of components managed by sizer you will find properties called '''Horizontal align''' and '''Vertical align'''. Using these properties you can select where the component should be located when it's smaller that its available area.&lt;br /&gt;
&lt;br /&gt;
=== wxStaticBoxSizer ===&lt;br /&gt;
&lt;br /&gt;
This sizer is similar to wxBoxSizer with one exception: it adds an extra static box around managed components:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_005.png]]&lt;br /&gt;
&lt;br /&gt;
=== wxGridSizer ===&lt;br /&gt;
&lt;br /&gt;
This sizer is a little bit more advanced than wxBoxSizer because it aligns components on a grid, not on one line. You can specify the number of columns or number of rows in properties &amp;quot;Cols&amp;quot; and &amp;quot;Rows&amp;quot;. The default number of columns is set to 3 and number of rows is set to 0. When 0 is used, it means that sizer should automatically calculate this value to keep all managed components inside.&lt;br /&gt;
&lt;br /&gt;
This sizer makes an important assumption: all cells must have the same width and all must have the same height.  This means that the tallest managed component will set the height of all rows and the widest one will set the widths of all columns. If an component won't use the whole cell, it will be surrounded by empty space. (If you don't like this assumption, look at the wxFlexGridSizer.)&lt;br /&gt;
&lt;br /&gt;
Among the properties of a wxGridsizer you can also find horizontal and vertical spacings. These values set the spacing added between components. The result of using them is similar to using borders around managed components but with borders you would have to set borders for all components separately.&lt;br /&gt;
&lt;br /&gt;
In the case of wxGridSizer, the &amp;quot;Proportion&amp;quot; value is not used. But you may use &amp;quot;Expand&amp;quot;, &amp;quot;Shaped&amp;quot; or placement properties to adjust the result.&lt;br /&gt;
&lt;br /&gt;
Here's an example of a grid sizer:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_006.png]]&lt;br /&gt;
&lt;br /&gt;
=== wxFlexGridSizer ===&lt;br /&gt;
&lt;br /&gt;
This is a very useful one. It works similarly to wxGridSizer; but it does not force all columns to have the same width nor all rows to have the same height. Also not all columns resize when there's more space available for the sizer. Comparing to wxGridSizer you will find two extra properties here: &amp;quot;Growable cols&amp;quot; and &amp;quot;Growable rows&amp;quot;. In these properties you may provide a list of columns / rows which should automatically resize by providing a list of numbers separated using comma (,). The numbers should start from 0, so if you would like the second and third column to resize, put &amp;quot;1,2&amp;quot; into &amp;quot;Growable cols&amp;quot;. This property is very useful to handle resizing of the window.&lt;br /&gt;
&lt;br /&gt;
Unfortunately you won't be able to set proportions other that 1:1 The &amp;quot;Proportion&amp;quot; property is also not used in this sizer.&lt;br /&gt;
&lt;br /&gt;
=== wxStdDialogButtonSizer ===&lt;br /&gt;
&lt;br /&gt;
This is a specialized sizer with one purpose - to provide a set of standard buttons with respect to the platform's look and feel. This sizer has a predefined list of components which it can handle - all are buttons and you can manage them using the sizer's properties. You cannot add your custom components into this sizer.&lt;br /&gt;
&lt;br /&gt;
Each button on this sizer has two properties in the sizer - whether the button should be enabled (for example wxID_OK for OK button) and its label. Note that labels for most buttons will be generated automatically and wxWidgets will skip them when it can read them from system settings. For example, on Linux only the Context Help button does not have a system-supplied label. It is also very probable that labels will be provided with language-specific strings (depending on the current system language). Not all configurations of buttons are valid - they won't break the application but buttons will overlap (for example Yes and OK).&lt;br /&gt;
&lt;br /&gt;
Here is an example of this sizer. My system is set up in Polish, so the labels are automatically in Polish.  They mean: Help, Cancel, Apply and OK.&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_007.png]]&lt;br /&gt;
&lt;br /&gt;
This screenshot was taken on a Linux box. You may see that the buttons have an extra image which is not available for standard buttons. With such a layout, users of the application will feel more comfortable, and such 'small' things make users say that the GUI was designed very well. On MS Windows, the sizer would have the same buttons but without images and they would be in a different order - the one that is used on windows by default.&lt;br /&gt;
&lt;br /&gt;
All of the above sizers can be found on the &amp;quot;Layout&amp;quot; tab. You can find two other components there which are not sizers but can be used for layout purposes. &lt;br /&gt;
&lt;br /&gt;
The first one is Spacer. It can be added to other sizers when you simply need some empty space instead of any particular component. Spacers have only width and height.&lt;br /&gt;
&lt;br /&gt;
The second one is wxSplitterWindow. When you use this component, you can add one or two child components into it and they will be separated with a dividing line (it's called a sash in wxWidgets). On the application you can drag it to dynamically adjust the size of managed components.&lt;br /&gt;
&lt;br /&gt;
Now that we know something about sizers let's turn to other components.&lt;br /&gt;
&lt;br /&gt;
== Especially Useful Standard Components ==&lt;br /&gt;
&lt;br /&gt;
wxWidgets provides all standard graphical components like static text, buttons, edit boxes, combo boxes, and so on. All are supported in wxSmith, so you can build a nice working environment. I'll briefly describe the components that are really useful in standard applications.&lt;br /&gt;
&lt;br /&gt;
=== wxButton ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_017.png]]&lt;br /&gt;
&lt;br /&gt;
This is standard button, a very common component. Its purpose is to run some piece of code when the user clicks on it. That's it.&lt;br /&gt;
&lt;br /&gt;
=== wxStaticText ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_018.png]]&lt;br /&gt;
&lt;br /&gt;
This component only shows user-defined text on the window. It doesn't generate any events.&lt;br /&gt;
&lt;br /&gt;
=== wxTextCtrl ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_019.png]]&lt;br /&gt;
&lt;br /&gt;
This component let's the user enter some text. It's basic functionality allows entering one-line text. After changing its properties, it may become a more advanced multiline editor with support for different fonts, colors and text styles.&lt;br /&gt;
&lt;br /&gt;
=== wxPanel ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_020.png]]&lt;br /&gt;
&lt;br /&gt;
Although this component may be a separate window, it is most commonly added as a comoponent in a parent window. It is particularly useful as a background for other components. It has a few functionalities - it can be used as background in notebooks and it may be a place where you put components without sizers. But it also has a few drawbacks - wxWidgets tends to do some tricks with wxPanel's size so it's not always possible to set the size we really want.&lt;br /&gt;
&lt;br /&gt;
=== wxChoice ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_021.png]]&lt;br /&gt;
&lt;br /&gt;
This component provides a drop-down list with available options. It works similarly to wxComboBox but the user cannot enter values. It can be used in situations when the user should use one of several available options. An event is generated when the user changes the selected component.&lt;br /&gt;
&lt;br /&gt;
=== wxComboBox ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_022.png]]&lt;br /&gt;
&lt;br /&gt;
This component provides a drop-down list similar to that of wxChoice. In the case of this component, the user can select one of the available values or enter his own if the component is not in a Read-Only state. A very good example of its usage is to provide some text entry with a stored list of previously entered values (like in search boxes). Like wxChoice, changing the selection generates an event. Additionally, changing the text and pressing enter also generates events. Tutorial 9 will illustrate its use. &lt;br /&gt;
&lt;br /&gt;
=== wxListBox ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_023.png]]&lt;br /&gt;
&lt;br /&gt;
This component provides a list where you can select one or more components. Changing the component or double-clicking on it generates an event.&lt;br /&gt;
&lt;br /&gt;
=== wxNotebook ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_024.png]]&lt;br /&gt;
&lt;br /&gt;
Notebook is very useful for complex resources since it groups content under tabs. Additionally, wxChoicebook and wxCombobook are also available but are not described here. Changing the selected notebook generates two events: one when the page starts to change (before change) and one when the page is finished changing (after change).&lt;br /&gt;
&lt;br /&gt;
=== wxCheckBox ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_025.png]]&lt;br /&gt;
&lt;br /&gt;
Check boxes may be used to map boolean values. Additionally, 2-state boxes can also be generated (with values: yes/no/unspecified). Changing the value emits an event.&lt;br /&gt;
&lt;br /&gt;
=== wxRadioBox ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_026.png]]&lt;br /&gt;
&lt;br /&gt;
Radio box works similarly to check boxes. The difference is that only one radiobox in a group can be selected. Groups may be defined by using wxRB_GROUP style. A radiobox which has this style set starts a new group. Changing the selected radiobox emits an event.&lt;br /&gt;
&lt;br /&gt;
=== wxGauge ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_027.png]]&lt;br /&gt;
&lt;br /&gt;
This component, also called a Progress Bar, can be used to show the progress of some operation. It's very useful when doing some calculation intensive operations. It can prevent users from getting frustrated when they do not see anything happening on the screen but only a window which seems hung.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt; * * * * &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
That's the end of this tutorial. We will get more experience with these subjects in the following tutorials. But you can also learn a lot by experimenting: add components, change properties, resize, move. You may try adding sizers into other sizers, a very useful technique absolutely required for more complex forms. Join me for the next tutorial!&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;'''[[WxSmith tutorial: Hello world|Previous]] | [[WxSmith tutorials|Index]] | [[WxSmith tutorial: Building more complex window|Next]]'''&amp;lt;/center&amp;gt;&lt;/div&gt;</summary>
		<author><name>Chatumao</name></author>
	</entry>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=Wxsmith_tutorial:_Working_with_items&amp;diff=7567</id>
		<title>Wxsmith tutorial: Working with items</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=Wxsmith_tutorial:_Working_with_items&amp;diff=7567"/>
		<updated>2013-04-29T10:28:49Z</updated>

		<summary type="html">&lt;p&gt;Chatumao: /* wxBoxSizer */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:wxSmith Documentation]]&lt;br /&gt;
= Working with Menus and Components =&lt;br /&gt;
&lt;br /&gt;
In the [[wxSmith tutorial: Hello world|previous tutorial]] we learned how to create a small application using wxWidgets. We created a window with a few components inside. In this tutorial, we will first see how to use the menu bar at the top of the main window and then focus on sizers and wxWidgets components which can be put on a form or window. &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''A Note on Terminology'''&lt;br /&gt;
&lt;br /&gt;
BYO, the creator of wxSmith and original author of these tutorials, wrote &amp;quot;Each resource in wxSmith is made of items. All your buttons, text boxes, lists etc are items. Also some more abstract things like sizers, spacers (used to add empty space), menu entries or even timers are also called items in wxSmith. So basically anything that's inside the resource may be called an item. I'll also use the term component since it reflects the valid meaning too.&amp;quot; &lt;br /&gt;
&lt;br /&gt;
In fact, the word &amp;quot;item&amp;quot; is not found in the index of the Julian Smart and Kevin Hock book ''Cross-Platform GUI Programming with wxWidgets.'' The word is used in the book specifically for the elements of the drop-down lists of choice boxes, combo boxes, and other members of the class wxControlWithItems. In the revision of these tutorials, the word &amp;quot;item&amp;quot; is therefore generally being reserved for items in these lists and for items in a menu. Otherwise, the word &amp;quot;item&amp;quot; is generally being replaced by &amp;quot;component&amp;quot;, &amp;quot;widget&amp;quot;, or &amp;quot;control&amp;quot; as seems appropriate, though of course, it is also occasionally used with no special technical meaning. Also, BYO often uses the word &amp;quot;resource&amp;quot; to refer to a form or window. Smart and Hock use word the &amp;quot;resource&amp;quot; sparingly, mainly in the context of &amp;quot;resource files&amp;quot;.  The word seems overworked and needlessly abstract, so when what is intended is a form or window, the revisions will use one of those words, with no sharp distinction between them.   &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Note that all screenshots presented here were made on Linux but they should not be very different from the windows ones.&lt;br /&gt;
&lt;br /&gt;
== Working with Menus ==&lt;br /&gt;
&lt;br /&gt;
Following the directions given in Tutorial 1, start a new Code::Blocks project; call it Tutorial_2. Remember to add &amp;quot;event.Skip(TRUE);&amp;quot; at the appropriate place in the code, as explained in Tutorial 1. &lt;br /&gt;
&lt;br /&gt;
Build and run the program. You will see that it has two items on the main menu. We will add one more, Jump, at the top level and under it two more, Back and Out. Back will do nothing, but we will make Out close the program.&lt;br /&gt;
&lt;br /&gt;
Click on the “Tutorial_2frame.wxs” tab of the Editor window.  Just below the words “Tutorial_2framw.wxs” is a panel with two square icons.  Double left click on the leftmost one, which shows the word ''File'' suggestive of a menu.  Up comes the menu inspector window shown below.&lt;br /&gt;
&lt;br /&gt;
[[Image:1i.png]]  &lt;br /&gt;
   &lt;br /&gt;
Click on the various menu items shown and note how the content of the fields shown on the right side of the window are filled in.  Then click on the New button (in the lower right part of the window) to add the three additional menu items mentioned above, namely Jump at the top level and under it Back and Out. It does not matter where the items first appear; you use the arrow keys just above the “New” and “Delete” buttons to move around the item you have selected.  For the “Id” field of the “Out” item, put idMenuOut. You should make the menu inspector window look like this:&lt;br /&gt;
&lt;br /&gt;
[[Image:1j.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When you have the menu items properly arranged, click OK.   &lt;br /&gt;
&lt;br /&gt;
When you now build and run, you will see the new menu.  But clicking Jump | Out  does not close the program as desired because we have not programmed the response to that event.  To do so, we want to make wxSmith set up the frame for the routine which will be called when the menu item “Out” is clicked.  Go to the Management pane, Resources tab and persistently click on the little right-pointing triangles until the “Out” item can be seen, as in the screen shot below.&lt;br /&gt;
&lt;br /&gt;
[[Image:1k.png]]&lt;br /&gt;
&lt;br /&gt;
      &lt;br /&gt;
Click on the word “Out” and then on the {} icon in the panel below the Management pane. That will cause the pane below to show the words “EVT_MENU     --None--” . Click on the word “None” or the down arrow at the right end of the field; a menu drops down.  Pick the item  “-- Add New Handler --”, accept the suggested name (OnMenu3Selected), and over in the editor, the frame of our handler has been written, as shown below.  We have only to write the code, which will be simply “Close();”.&lt;br /&gt;
&lt;br /&gt;
[[Image:1l.png]]&lt;br /&gt;
&lt;br /&gt;
Now we can “Build and run”, drop down our menu, click on “Out”, and the program closes, as desired.&lt;br /&gt;
&lt;br /&gt;
== Windows and Components ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Each window in wxSmith is made of components. All your buttons, text boxes, lists, and so on are components. Also some more abstract things like sizers, spacers (used to add empty space), menu entries or even timers are also components.&lt;br /&gt;
&lt;br /&gt;
Every window has a root component. For a dialog window, it would be a wxDialog component; for a frame window, it would be wxFrame component; for a panel it would be a wxPanel component. In the [[wxSmith tutorial: Hello world|previous tutorial]] you probably noticed that some components may have &amp;quot;children&amp;quot;. For example, sizers had components inside their boxes. In this tutorial, you have seen sub-menu items inside main-menu items. The term &amp;quot;children&amp;quot; suggests the idea of a family tree, and indeed precisely such a tree structure is directly represented in the resource browser, as shown in the example below.&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_008.png]]&lt;br /&gt;
&lt;br /&gt;
In the picture above, you will see an example of such a tree. wxFontFaceEditorDlg is the currently opened form with a root component of type wxDialog. We can see that this resource consists of a few sizers and buttons, one text area and some spacers. It's definitely a fairly simple form. For more complicated forms, there could be more than 100 components. The tree (or Resource) browser can be very helpful for locating the code connected with a component; clicking on the component in the browser brings up its code in the editor.&lt;br /&gt;
&lt;br /&gt;
Each component has its properties - these are usually some values which describe the component. Some of them may affect the way component looks, some may change the component's behavior, and some may be dedicated to programming facilities. You will also find that there are some properties -- such as position and size -- common to many components.&lt;br /&gt;
&lt;br /&gt;
wxSmith allows you to edit components inside the properties browser (the window which is usually under the resource browser). If you select a component either by  clicking on it in the resource browser or by clicking on it inside the editor, the properties editor switches to edit its properties. Here's an example of the property browser:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_009.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can also use the Quick-Properties panel available after pressing the &amp;quot;Q&amp;quot; button on the right side of the editor:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_010.png]]&lt;br /&gt;
&lt;br /&gt;
The purpose of this panel is to provide most common properties in user-friendly way. It hasn't proven as useful as I had hoped, and you will probably find it helpful only while adjusting sizer-related settings.&lt;br /&gt;
&lt;br /&gt;
The last and the easiest way to work on a component is directly in the editor. You can grab drag boxes and change the component's size. You can also change its position by simply dragging it to another place.&lt;br /&gt;
&lt;br /&gt;
=== Excercise with Components ===&lt;br /&gt;
&lt;br /&gt;
Enough generalities; let's play with components. We can continue with the project started at the beginning of this tutorial. First let's add wxFlexGridSizer into our window. Like all sizers, it is located in Layout tab. (You'll remember how to add components from the [[wxSmith tutorial: Hello world|previous tutorial]]). Now let's add the following components into the sizer in the order given: wxButton, wxStaticText, wxTextCtrl, wxRadioButton and wxCheckBox. They can all be found on the Standard tab. The result should look like this:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_011.png]]&lt;br /&gt;
&lt;br /&gt;
In this picture, components I've selected have a light red border.&lt;br /&gt;
&lt;br /&gt;
Now that we have our playground, let's change some components. First, let's change the label and color of the button. To do so, click on the button and move to the properties browser. &amp;quot;Label&amp;quot; is the first property, and it's quite easy to change. Just click on the word &amp;quot;Label&amp;quot; on the right and type new text.&lt;br /&gt;
&lt;br /&gt;
Color is little bit harder to find. Usually components have two colors - Background and Foreground color. Background, as the name implies, is used to fill the component's background. Foreground, on the other hand, is used to paint some content onto the background. Note that there's no strict interpretation of these colors so you should experiment to find out their meaning. In wxButton, Background is what we want.&lt;br /&gt;
So let's find the Background property. It's value can be changed by using combobox:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_012.png]]&lt;br /&gt;
&lt;br /&gt;
On the list you may find a set of predefined system colors. When you choose one of them, they will be read from the current system settings making your application compatible with the system theme. There are also two special entries - Default (which means that we do not want to set our color) and Custom. When you select Custom, wxSmith will open a color dialog where you can choose any color you like. I have chosen light green, and here's the result:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_013.png]]&lt;br /&gt;
&lt;br /&gt;
There are also other properties we could talk about, but the best way to learn them is to play with them, so I leave those discoveries to you.&lt;br /&gt;
&lt;br /&gt;
Now let's use the mouse.&lt;br /&gt;
&lt;br /&gt;
The selected component will have eight black boxes -- drag handles -- around it. These boxes can be used to change the size of the component. You will easily notice when the mouse is over a handle because the cursor changes. Let's resize the wxTextCtrl (edit box):&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_014.png]]&lt;br /&gt;
&lt;br /&gt;
You may see that resizing the component will also change properties in the browser - '''Default Size''' is unchecked now and '''Width''' and '''Height''' are set to required values. There's another property which seems to be untouched - '''Size in Dialog Units''', which is also related to size. I'll explain it a bit.&lt;br /&gt;
&lt;br /&gt;
Usually when you must specify a size (or other size-related things) you provide a value in pixels. Alternatively you can specify values in a unit called a '''Dialog Unit'''. A '''Dialog Unit''' is usually a little bit bigger than one pixel and it's size depends on the size of the current font (actually it's the size of the font of some component's parent which has a font). This is useful when you want some values to be proportional to the size of text presented in the window. &lt;br /&gt;
&lt;br /&gt;
If you check '''Size in Dialog Units'', wxSmith will take care of it and sizes will be calculated in Dialog Units instead of pixels (although, naturally, you will still be able to resize components).&lt;br /&gt;
&lt;br /&gt;
Now let's change the position of the radio box. &amp;quot;But, wait,&amp;quot; you may say, &amp;quot;I thought you said that the sizer is responsible for the positioning.&amp;quot; That's right. We have limited possibilities to change position. Inside one sizer we can only reorder components; for more complex forms we can also move a component between two sizers or to areas where sizers do not apply. So, back to our example, let's move the radio box to position it right after the button. To do so, click on the radio button and drag it onto the button. When you start dragging, you will notice that the area of the sizer changes color to blue. This color change is an aid to show you what will be the new position of the dragged component. When you move the cursor onto the button, half of the button will become light-blue. When the left half is highlighted, the dragged component will be added before it. When the right half is highlighted, dragged component will be added after it. And when there's no highlighted component, the new component will be added as the last child of the parent:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_015.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When you drop the component, it will change it's position. Note that all the components after the new position also shift. That happens because the default setting of the wxFlexGridSizer allows only 3 components in one row (this can be changed in property browser) so the components just adapted to the new order.&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_016.png]]&lt;br /&gt;
&lt;br /&gt;
==Sizers== &lt;br /&gt;
&lt;br /&gt;
Now let's learn a little bit about components available in wxSmith. I'll describe all supported sizers and a few important components from the Standard palette. Let's start with sizers.&lt;br /&gt;
&lt;br /&gt;
We already know that sizers are responsible for automatically setting the position and size of some components. But how do they do that? Well, it depends on which sizer has been used. So what are the rules? The generic rule is that the sizer tries to use all its available space and place the components it manages in such way that they do not overlap. If the area available to the sizer is too small, it requests a bigger area, so you can be sure that no component will fall out of the window. (Unfortunately, you cannot be sure that after such adjustments the window will be small enough to fit on the screen, so be careful about that.) Another rule which should be mentioned here is that sizers automatically set-up the minimum size required by the window. Basically when you edit a window using sizers, you should be aware that you edit the smallest layout and without some tricks, you won't be able to resize the window to something smaller.&lt;br /&gt;
&lt;br /&gt;
Here are descriptions of all sizers available in wxSmith:&lt;br /&gt;
&lt;br /&gt;
=== wxBoxSizer ===&lt;br /&gt;
&lt;br /&gt;
wxBoxSizer is the most basic sizer available in wxWidgets. It's purpose is to align components in one line - one next to another - either horizontally or vertically. This sizer also tries to keep some proportions between components - for a horizontal sizer you can set factors which will keep proportionality of widths and the height of the sizer area will be equal to the height of the tallest component. Similarly, vertical sizers keep heights proportional and the width will be taken from the widest component. You specify whether the sizer is to be horizontal or vertical in the sizer's property browser.&lt;br /&gt;
&lt;br /&gt;
Here are examples of layout using box sizers (the first one is the horizontal one, the second is vertical one):&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_002.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In that example you may see that all components have the same width and height.&lt;br /&gt;
&lt;br /&gt;
But let's assume that we want Button2 to be two times wider that Button1 and Button3 to be three times wider than Button1. This can be easily done by using the Proportion property of managed components. By default, the value of all components is set to 1 so they have equal size. Changing the Proportion of second button to 2 would mean that it should be 2 times wider that the first or third one.&lt;br /&gt;
&lt;br /&gt;
Generally you can set any value you want here. One common technique is to set percentage values - for example setting proportions to values 20, 30 and 50 would mean that the first button should occupy 20% of the space, the second one 30% and the third one 50%. The special value 0 means that this component should be skipped in proportion calculations and it will won't automatically adjust it's size when the main window is resized.&lt;br /&gt;
&lt;br /&gt;
So if we want to get 1:2:3 proportions, we set 1 for Button1, 2 for Button2 and 3 for Button3. And here is the result:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_003.png]]&lt;br /&gt;
&lt;br /&gt;
Also note that if you create a resizable window and resize it, those 3 buttons will automatically grow and keep proportions. If you set the Proportion property for some component to 0, it won't change size as the user changes the size of the window. &lt;br /&gt;
&lt;br /&gt;
The other dimension which is not controlled by Proportion property may be controlled using the &amp;quot;Expand&amp;quot; and &amp;quot;Shaped&amp;quot; properties. They are simple checkboxes. If you check the first one, the component will expand it's width/height and will get the size of the biggest component managed by the same sizer. Selecting &amp;quot;Shaped&amp;quot; will also make the component resize but such components will try to keep the initial proportion between width and height so it doesn't have to use all available space. The effect of the &amp;quot;Expand&amp;quot; and &amp;quot;Shaped&amp;quot; properties can be seen when components differ in width or height; here's an example:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_004.png]]&lt;br /&gt;
&lt;br /&gt;
In this example, the first button is the biggest of the three. Its size will be used to adjust the sizes of the other buttons. The second one has its &amp;quot;Expand&amp;quot; property checked, and the third one does not. What can be seen here is that the third button expanded in only one dimension (the one managed by &amp;quot;Proportion&amp;quot; property), the second dimension was left untouched.&lt;br /&gt;
&lt;br /&gt;
You may also note that when a component does not fill its available area, it is centered. That's default behavior which can be changed. In the properties of components managed by sizer you will find properties called '''Horizontal align''' and '''Vertical align'''. Using these properties you can select where the component should be located when it's smaller that its available area.&lt;br /&gt;
&lt;br /&gt;
=== wxStaticBoxSizer ===&lt;br /&gt;
&lt;br /&gt;
This sizer is similar to wxBoxSizer with one exception: it adds an extra static box around managed components:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_005.png]]&lt;br /&gt;
&lt;br /&gt;
=== wxGridSizer ===&lt;br /&gt;
&lt;br /&gt;
This sizer is a little bit more advanced than wxBoxSizer because it aligns components on a grid, not on one line. You can specify the number of columns or number of rows in properties &amp;quot;Cols&amp;quot; and &amp;quot;Rows&amp;quot;. The default number of columns is set to 3 and number of rows is set to 0. When 0 is used, it means that sizer should automatically calculate this value to keep all managed components inside.&lt;br /&gt;
&lt;br /&gt;
This sizer makes an important assumption: all cells must have the same width and all must have the same height.  This means that the tallest managed component will set the height of all rows and the widest one will set the widths of all columns. If an component won't use the whole cell, it will be surrounded by empty space. (If you don't like this assumption, look at the wxFlexGridSizer.)&lt;br /&gt;
&lt;br /&gt;
Among the properties of a wxGridsizer you can also find horizontal and vertical spacings. These values set the spacing added between components. The result of using them is similar to using borders around managed components but with borders you would have to set borders for all components separately.&lt;br /&gt;
&lt;br /&gt;
In the case of wxGridSizer, the &amp;quot;Proportion&amp;quot; value is not used. But you may use &amp;quot;Expand&amp;quot;, &amp;quot;Shaped&amp;quot; or placement properties to adjust the result.&lt;br /&gt;
&lt;br /&gt;
Here's an example of a grid sizer:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_006.png]]&lt;br /&gt;
&lt;br /&gt;
=== wxFlexGridSizer ===&lt;br /&gt;
&lt;br /&gt;
This is a very useful one. It works similarly to wxGridSizer; but it does not force all columns to have the same width nor all rows to have the same height. Also not all columns resize when there's more space available for the sizer. Comparing to wxGridSizer you will find two extra properties here: &amp;quot;Growable cols&amp;quot; and &amp;quot;Growable rows&amp;quot;. In these properties you may provide a list of columns / rows which should automatically resize by providing a list of numbers separated using comma (,). The numbers should start from 0, so if you would like the second and third column to resize, put &amp;quot;1,2&amp;quot; into &amp;quot;Growable cols&amp;quot;. This property is very useful to handle resizing of the window.&lt;br /&gt;
&lt;br /&gt;
Unfortunately you won't be able to set proportions other that 1:1 The &amp;quot;Proportion&amp;quot; property is also not used in this sizer.&lt;br /&gt;
&lt;br /&gt;
=== wxStdDialogButtonSizer ===&lt;br /&gt;
&lt;br /&gt;
This is a specialized sizer with one purpose - to provide a set of standard buttons with respect to the platform's look and feel. This sizer has a predefined list of components which it can handle - all are buttons and you can manage them using the sizer's properties. You cannot add your custom components into this sizer.&lt;br /&gt;
&lt;br /&gt;
Each button on this sizer has two properties in the sizer - whether the button should be enabled (for example wxID_OK for OK button) and its label. Note that labels for most buttons will be generated automatically and wxWidgets will skip them when it can read them from system settings. For example, on Linux only the Context Help button does not have a system-supplied label. It is also very probable that labels will be provided with language-specific strings (depending on the current system language). Not all configurations of buttons are valid - they won't break the application but buttons will overlap (for example Yes and OK).&lt;br /&gt;
&lt;br /&gt;
Here is an example of this sizer. My system is set up in Polish, so the labels are automatically in Polish.  They mean: Help, Cancel, Apply and OK.&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_007.png]]&lt;br /&gt;
&lt;br /&gt;
This screenshot was taken on a Linux box. You may see that the buttons have an extra image which is not available for standard buttons. With such a layout, users of the application will feel more comfortable, and such 'small' things make users say that the GUI was designed very well. On MS Windows, the sizer would have the same buttons but without images and they would be in a different order - the one that is used on windows by default.&lt;br /&gt;
&lt;br /&gt;
All of the above sizers can be found on the &amp;quot;Layout&amp;quot; tab. You can find two other components there which are not sizers but can be used for layout purposes. &lt;br /&gt;
&lt;br /&gt;
The first one is Spacer. It can be added to other sizers when you simply need some empty space instead of any particular component. Spacers have only width and height.&lt;br /&gt;
&lt;br /&gt;
The second one is wxSplitterWindow. When you use this component, you can add one or two child components into it and they will be separated with a dividing line (it's called a sash in wxWidgets). On the application you can drag it to dynamically adjust the size of managed components.&lt;br /&gt;
&lt;br /&gt;
Now that we know something about sizers let's turn to other components.&lt;br /&gt;
&lt;br /&gt;
== Especially Useful Standard Components ==&lt;br /&gt;
&lt;br /&gt;
wxWidgets provides all standard graphical components like static text, buttons, edit boxes, combo boxes, and so on. All are supported in wxSmith, so you can build a nice working environment. I'll briefly describe the components that are really useful in standard applications.&lt;br /&gt;
&lt;br /&gt;
=== wxButton ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_017.png]]&lt;br /&gt;
&lt;br /&gt;
This is standard button, a very common component. Its purpose is to run some piece of code when the user clicks on it. That's it.&lt;br /&gt;
&lt;br /&gt;
=== wxStaticText ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_018.png]]&lt;br /&gt;
&lt;br /&gt;
This component only shows user-defined text on the window. It doesn't generate any events.&lt;br /&gt;
&lt;br /&gt;
=== wxTextCtrl ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_019.png]]&lt;br /&gt;
&lt;br /&gt;
This component let's the user enter some text. It's basic functionality allows entering one-line text. After changing its properties, it may become a more advanced multiline editor with support for different fonts, colors and text styles.&lt;br /&gt;
&lt;br /&gt;
=== wxPanel ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_020.png]]&lt;br /&gt;
&lt;br /&gt;
Although this component may be a separate window, it is most commonly added as a comoponent in a parent window. It is particularly useful as a background for other components. It has a few functionalities - it can be used as background in notebooks and it may be a place where you put components without sizers. But it also has a few drawbacks - wxWidgets tends to do some tricks with wxPanel's size so it's not always possible to set the size we really want.&lt;br /&gt;
&lt;br /&gt;
=== wxChoice ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_021.png]]&lt;br /&gt;
&lt;br /&gt;
This component provides a drop-down list with available options. It works similarly to wxComboBox but the user cannot enter values. It can be used in situations when the user should use one of several available options. An event is generated when the user changes the selected component.&lt;br /&gt;
&lt;br /&gt;
=== wxComboBox ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_022.png]]&lt;br /&gt;
&lt;br /&gt;
This component provides a drop-down list similar to that of wxChoice. In the case of this component, the user can select one of the available values or enter his own if the component is not in a Read-Only state. A very good example of its usage is to provide some text entry with a stored list of previously entered values (like in search boxes). Like wxChoice, changing the selection generates an event. Additionally, changing the text and pressing enter also generates events. Tutorial 9 will illustrate its use. &lt;br /&gt;
&lt;br /&gt;
=== wxListBox ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_023.png]]&lt;br /&gt;
&lt;br /&gt;
This component provides a list where you can select one or more components. Changing the component or double-clicking on it generates an event.&lt;br /&gt;
&lt;br /&gt;
=== wxNotebook ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_024.png]]&lt;br /&gt;
&lt;br /&gt;
Notebook is very useful for complex resources since it groups content under tabs. Additionally, wxChoicebook and wxCombobook are also available but are not described here. Changing the selected notebook generates two events: one when the page starts to change (before change) and one when the page is finished changing (after change).&lt;br /&gt;
&lt;br /&gt;
=== wxCheckBox ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_025.png]]&lt;br /&gt;
&lt;br /&gt;
Check boxes may be used to map boolean values. Additionally, 2-state boxes can also be generated (with values: yes/no/unspecified). Changing the value emits an event.&lt;br /&gt;
&lt;br /&gt;
=== wxRadioBox ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_026.png]]&lt;br /&gt;
&lt;br /&gt;
Radio box works similarly to check boxes. The difference is that only one radiobox in a group can be selected. Groups may be defined by using wxRB_GROUP style. A radiobox which has this style set starts a new group. Changing the selected radiobox emits an event.&lt;br /&gt;
&lt;br /&gt;
=== wxGauge ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_027.png]]&lt;br /&gt;
&lt;br /&gt;
This component, also called a Progress Bar, can be used to show the progress of some operation. It's very useful when doing some calculation intensive operations. It can prevent users from getting frustrated when they do not see anything happening on the screen but only a window which seems hung.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt; * * * * &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
That's the end of this tutorial. We will get more experience with these subjects in the following tutorials. But you can also learn a lot by experimenting: add components, change properties, resize, move. You may try adding sizers into other sizers, a very useful technique absolutely required for more complex forms. Join me for the next tutorial!&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;'''[[WxSmith tutorial: Hello world|Previous]] | [[WxSmith tutorials|Index]] | [[WxSmith tutorial: Building more complex window|Next]]'''&amp;lt;/center&amp;gt;&lt;/div&gt;</summary>
		<author><name>Chatumao</name></author>
	</entry>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=Wxsmith_tutorial:_Working_with_items&amp;diff=7566</id>
		<title>Wxsmith tutorial: Working with items</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=Wxsmith_tutorial:_Working_with_items&amp;diff=7566"/>
		<updated>2013-04-29T10:25:11Z</updated>

		<summary type="html">&lt;p&gt;Chatumao: /* Excercise with Components */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:wxSmith Documentation]]&lt;br /&gt;
= Working with Menus and Components =&lt;br /&gt;
&lt;br /&gt;
In the [[wxSmith tutorial: Hello world|previous tutorial]] we learned how to create a small application using wxWidgets. We created a window with a few components inside. In this tutorial, we will first see how to use the menu bar at the top of the main window and then focus on sizers and wxWidgets components which can be put on a form or window. &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''A Note on Terminology'''&lt;br /&gt;
&lt;br /&gt;
BYO, the creator of wxSmith and original author of these tutorials, wrote &amp;quot;Each resource in wxSmith is made of items. All your buttons, text boxes, lists etc are items. Also some more abstract things like sizers, spacers (used to add empty space), menu entries or even timers are also called items in wxSmith. So basically anything that's inside the resource may be called an item. I'll also use the term component since it reflects the valid meaning too.&amp;quot; &lt;br /&gt;
&lt;br /&gt;
In fact, the word &amp;quot;item&amp;quot; is not found in the index of the Julian Smart and Kevin Hock book ''Cross-Platform GUI Programming with wxWidgets.'' The word is used in the book specifically for the elements of the drop-down lists of choice boxes, combo boxes, and other members of the class wxControlWithItems. In the revision of these tutorials, the word &amp;quot;item&amp;quot; is therefore generally being reserved for items in these lists and for items in a menu. Otherwise, the word &amp;quot;item&amp;quot; is generally being replaced by &amp;quot;component&amp;quot;, &amp;quot;widget&amp;quot;, or &amp;quot;control&amp;quot; as seems appropriate, though of course, it is also occasionally used with no special technical meaning. Also, BYO often uses the word &amp;quot;resource&amp;quot; to refer to a form or window. Smart and Hock use word the &amp;quot;resource&amp;quot; sparingly, mainly in the context of &amp;quot;resource files&amp;quot;.  The word seems overworked and needlessly abstract, so when what is intended is a form or window, the revisions will use one of those words, with no sharp distinction between them.   &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Note that all screenshots presented here were made on Linux but they should not be very different from the windows ones.&lt;br /&gt;
&lt;br /&gt;
== Working with Menus ==&lt;br /&gt;
&lt;br /&gt;
Following the directions given in Tutorial 1, start a new Code::Blocks project; call it Tutorial_2. Remember to add &amp;quot;event.Skip(TRUE);&amp;quot; at the appropriate place in the code, as explained in Tutorial 1. &lt;br /&gt;
&lt;br /&gt;
Build and run the program. You will see that it has two items on the main menu. We will add one more, Jump, at the top level and under it two more, Back and Out. Back will do nothing, but we will make Out close the program.&lt;br /&gt;
&lt;br /&gt;
Click on the “Tutorial_2frame.wxs” tab of the Editor window.  Just below the words “Tutorial_2framw.wxs” is a panel with two square icons.  Double left click on the leftmost one, which shows the word ''File'' suggestive of a menu.  Up comes the menu inspector window shown below.&lt;br /&gt;
&lt;br /&gt;
[[Image:1i.png]]  &lt;br /&gt;
   &lt;br /&gt;
Click on the various menu items shown and note how the content of the fields shown on the right side of the window are filled in.  Then click on the New button (in the lower right part of the window) to add the three additional menu items mentioned above, namely Jump at the top level and under it Back and Out. It does not matter where the items first appear; you use the arrow keys just above the “New” and “Delete” buttons to move around the item you have selected.  For the “Id” field of the “Out” item, put idMenuOut. You should make the menu inspector window look like this:&lt;br /&gt;
&lt;br /&gt;
[[Image:1j.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When you have the menu items properly arranged, click OK.   &lt;br /&gt;
&lt;br /&gt;
When you now build and run, you will see the new menu.  But clicking Jump | Out  does not close the program as desired because we have not programmed the response to that event.  To do so, we want to make wxSmith set up the frame for the routine which will be called when the menu item “Out” is clicked.  Go to the Management pane, Resources tab and persistently click on the little right-pointing triangles until the “Out” item can be seen, as in the screen shot below.&lt;br /&gt;
&lt;br /&gt;
[[Image:1k.png]]&lt;br /&gt;
&lt;br /&gt;
      &lt;br /&gt;
Click on the word “Out” and then on the {} icon in the panel below the Management pane. That will cause the pane below to show the words “EVT_MENU     --None--” . Click on the word “None” or the down arrow at the right end of the field; a menu drops down.  Pick the item  “-- Add New Handler --”, accept the suggested name (OnMenu3Selected), and over in the editor, the frame of our handler has been written, as shown below.  We have only to write the code, which will be simply “Close();”.&lt;br /&gt;
&lt;br /&gt;
[[Image:1l.png]]&lt;br /&gt;
&lt;br /&gt;
Now we can “Build and run”, drop down our menu, click on “Out”, and the program closes, as desired.&lt;br /&gt;
&lt;br /&gt;
== Windows and Components ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Each window in wxSmith is made of components. All your buttons, text boxes, lists, and so on are components. Also some more abstract things like sizers, spacers (used to add empty space), menu entries or even timers are also components.&lt;br /&gt;
&lt;br /&gt;
Every window has a root component. For a dialog window, it would be a wxDialog component; for a frame window, it would be wxFrame component; for a panel it would be a wxPanel component. In the [[wxSmith tutorial: Hello world|previous tutorial]] you probably noticed that some components may have &amp;quot;children&amp;quot;. For example, sizers had components inside their boxes. In this tutorial, you have seen sub-menu items inside main-menu items. The term &amp;quot;children&amp;quot; suggests the idea of a family tree, and indeed precisely such a tree structure is directly represented in the resource browser, as shown in the example below.&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_008.png]]&lt;br /&gt;
&lt;br /&gt;
In the picture above, you will see an example of such a tree. wxFontFaceEditorDlg is the currently opened form with a root component of type wxDialog. We can see that this resource consists of a few sizers and buttons, one text area and some spacers. It's definitely a fairly simple form. For more complicated forms, there could be more than 100 components. The tree (or Resource) browser can be very helpful for locating the code connected with a component; clicking on the component in the browser brings up its code in the editor.&lt;br /&gt;
&lt;br /&gt;
Each component has its properties - these are usually some values which describe the component. Some of them may affect the way component looks, some may change the component's behavior, and some may be dedicated to programming facilities. You will also find that there are some properties -- such as position and size -- common to many components.&lt;br /&gt;
&lt;br /&gt;
wxSmith allows you to edit components inside the properties browser (the window which is usually under the resource browser). If you select a component either by  clicking on it in the resource browser or by clicking on it inside the editor, the properties editor switches to edit its properties. Here's an example of the property browser:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_009.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can also use the Quick-Properties panel available after pressing the &amp;quot;Q&amp;quot; button on the right side of the editor:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_010.png]]&lt;br /&gt;
&lt;br /&gt;
The purpose of this panel is to provide most common properties in user-friendly way. It hasn't proven as useful as I had hoped, and you will probably find it helpful only while adjusting sizer-related settings.&lt;br /&gt;
&lt;br /&gt;
The last and the easiest way to work on a component is directly in the editor. You can grab drag boxes and change the component's size. You can also change its position by simply dragging it to another place.&lt;br /&gt;
&lt;br /&gt;
=== Excercise with Components ===&lt;br /&gt;
&lt;br /&gt;
Enough generalities; let's play with components. We can continue with the project started at the beginning of this tutorial. First let's add wxFlexGridSizer into our window. Like all sizers, it is located in Layout tab. (You'll remember how to add components from the [[wxSmith tutorial: Hello world|previous tutorial]]). Now let's add the following components into the sizer in the order given: wxButton, wxStaticText, wxTextCtrl, wxRadioButton and wxCheckBox. They can all be found on the Standard tab. The result should look like this:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_011.png]]&lt;br /&gt;
&lt;br /&gt;
In this picture, components I've selected have a light red border.&lt;br /&gt;
&lt;br /&gt;
Now that we have our playground, let's change some components. First, let's change the label and color of the button. To do so, click on the button and move to the properties browser. &amp;quot;Label&amp;quot; is the first property, and it's quite easy to change. Just click on the word &amp;quot;Label&amp;quot; on the right and type new text.&lt;br /&gt;
&lt;br /&gt;
Color is little bit harder to find. Usually components have two colors - Background and Foreground color. Background, as the name implies, is used to fill the component's background. Foreground, on the other hand, is used to paint some content onto the background. Note that there's no strict interpretation of these colors so you should experiment to find out their meaning. In wxButton, Background is what we want.&lt;br /&gt;
So let's find the Background property. It's value can be changed by using combobox:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_012.png]]&lt;br /&gt;
&lt;br /&gt;
On the list you may find a set of predefined system colors. When you choose one of them, they will be read from the current system settings making your application compatible with the system theme. There are also two special entries - Default (which means that we do not want to set our color) and Custom. When you select Custom, wxSmith will open a color dialog where you can choose any color you like. I have chosen light green, and here's the result:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_013.png]]&lt;br /&gt;
&lt;br /&gt;
There are also other properties we could talk about, but the best way to learn them is to play with them, so I leave those discoveries to you.&lt;br /&gt;
&lt;br /&gt;
Now let's use the mouse.&lt;br /&gt;
&lt;br /&gt;
The selected component will have eight black boxes -- drag handles -- around it. These boxes can be used to change the size of the component. You will easily notice when the mouse is over a handle because the cursor changes. Let's resize the wxTextCtrl (edit box):&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_014.png]]&lt;br /&gt;
&lt;br /&gt;
You may see that resizing the component will also change properties in the browser - '''Default Size''' is unchecked now and '''Width''' and '''Height''' are set to required values. There's another property which seems to be untouched - '''Size in Dialog Units''', which is also related to size. I'll explain it a bit.&lt;br /&gt;
&lt;br /&gt;
Usually when you must specify a size (or other size-related things) you provide a value in pixels. Alternatively you can specify values in a unit called a '''Dialog Unit'''. A '''Dialog Unit''' is usually a little bit bigger than one pixel and it's size depends on the size of the current font (actually it's the size of the font of some component's parent which has a font). This is useful when you want some values to be proportional to the size of text presented in the window. &lt;br /&gt;
&lt;br /&gt;
If you check '''Size in Dialog Units'', wxSmith will take care of it and sizes will be calculated in Dialog Units instead of pixels (although, naturally, you will still be able to resize components).&lt;br /&gt;
&lt;br /&gt;
Now let's change the position of the radio box. &amp;quot;But, wait,&amp;quot; you may say, &amp;quot;I thought you said that the sizer is responsible for the positioning.&amp;quot; That's right. We have limited possibilities to change position. Inside one sizer we can only reorder components; for more complex forms we can also move a component between two sizers or to areas where sizers do not apply. So, back to our example, let's move the radio box to position it right after the button. To do so, click on the radio button and drag it onto the button. When you start dragging, you will notice that the area of the sizer changes color to blue. This color change is an aid to show you what will be the new position of the dragged component. When you move the cursor onto the button, half of the button will become light-blue. When the left half is highlighted, the dragged component will be added before it. When the right half is highlighted, dragged component will be added after it. And when there's no highlighted component, the new component will be added as the last child of the parent:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_015.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When you drop the component, it will change it's position. Note that all the components after the new position also shift. That happens because the default setting of the wxFlexGridSizer allows only 3 components in one row (this can be changed in property browser) so the components just adapted to the new order.&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_016.png]]&lt;br /&gt;
&lt;br /&gt;
==Sizers== &lt;br /&gt;
&lt;br /&gt;
Now let's learn a little bit about components available in wxSmith. I'll describe all supported sizers and a few important components from the Standard palette. Let's start with sizers.&lt;br /&gt;
&lt;br /&gt;
We already know that sizers are responsible for automatically setting the position and size of some components. But how do they do that? Well, it depends on which sizer has been used. So what are the rules? The generic rule is that the sizer tries to use all its available space and place the components it manages in such way that they do not overlap. If the area available to the sizer is too small, it requests a bigger area, so you can be sure that no component will fall out of the window. (Unfortunately, you cannot be sure that after such adjustments the window will be small enough to fit on the screen, so be careful about that.) Another rule which should be mentioned here is that sizers automatically set-up the minimum size required by the window. Basically when you edit a window using sizers, you should be aware that you edit the smallest layout and without some tricks, you won't be able to resize the window to something smaller.&lt;br /&gt;
&lt;br /&gt;
Here are descriptions of all sizers available in wxSmith:&lt;br /&gt;
&lt;br /&gt;
=== wxBoxSizer ===&lt;br /&gt;
&lt;br /&gt;
wxBoxSizer is the most basic sizer available in wxWidgets. It's purpose is to align components in one line - one next to another - either horizontally or vertically. This sizer also tries to keep some proportions between components - for a horizontal sizer you can set factors which will keep proportionality of widths and the height of the sizer area will be equal to the height of the tallest component. Similarly, vertical sizers keep heights proportional and the width will be taken as the widest component. You specify whether the sizer is to be horizontal or vertical in the sizer's property browser.&lt;br /&gt;
&lt;br /&gt;
Here are examples of layout using box sizers (the first one is the horizontal one, the second is vertical one):&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_002.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In that example you may see that all components have the same width and height.&lt;br /&gt;
&lt;br /&gt;
But let's assume that we want Button2 to be two times wider that Button1 and Button3 to be three times wider than Button1. This can be easily done by using the Proportion property of managed components. By default, the value of all components is set to 1 so they have equal size. Changing the Proportion of second button to 2 would mean that it should be 2 times wider that the first or third one.&lt;br /&gt;
&lt;br /&gt;
Generally you can set any value you want here. One common technique is to set percentage values - for example setting proportions to values 20, 30 and 50 would mean that the first button should occupy 20% of the space, the second one 30% and the third one 50%. The special value 0 means that this component should be skipped in proportion calculations and it will won't automatically adjust it's size when the main window is resized.&lt;br /&gt;
&lt;br /&gt;
So if we want to get 1:2:3 proportions, we set 1 for Button1, 2 for Button2 and 3 for Button3. And here is the result:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_003.png]]&lt;br /&gt;
&lt;br /&gt;
Also note that if you create a resizable window and resize it, those 3 buttons will automatically grow and keep proportions. If you set the Proportion property for some component to 0, it won't change size as the user changes the size of the window. &lt;br /&gt;
&lt;br /&gt;
The other dimension which is not controlled by Proportion property may be controlled using the &amp;quot;Expand&amp;quot; and &amp;quot;Shaped&amp;quot; properties. They are simple checkboxes. If you check the first one, the component will expand it's width/height and will get the size of the biggest component managed by the same sizer. Selecting &amp;quot;Shaped&amp;quot; will also make the component resize but such components will try to keep the initial proportion between width and height so it doesn't have to use all available space. The effect of the &amp;quot;Expand&amp;quot; and &amp;quot;Shaped&amp;quot; properties can be seen when components differ in width or height; here's an example:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_004.png]]&lt;br /&gt;
&lt;br /&gt;
In this example, the first button is the biggest of the three. Its size will be used to adjust the sizes of the other buttons. The second one has its &amp;quot;Expand&amp;quot; property checked, and the third one does not. What can be seen here is that the third button expanded in only one dimension (the one managed by &amp;quot;Proportion&amp;quot; property), the second dimension was left untouched.&lt;br /&gt;
&lt;br /&gt;
You may also note that when a component does not fill its available area, it is centered. That's default behavior which can be changed. In the properties of components managed by sizer you will find properties called '''Horizontal align''' and '''Vertical align'''. Using these properties you can select where the component should be located when it's smaller that its available area.&lt;br /&gt;
&lt;br /&gt;
=== wxStaticBoxSizer ===&lt;br /&gt;
&lt;br /&gt;
This sizer is similar to wxBoxSizer with one exception: it adds an extra static box around managed components:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_005.png]]&lt;br /&gt;
&lt;br /&gt;
=== wxGridSizer ===&lt;br /&gt;
&lt;br /&gt;
This sizer is a little bit more advanced than wxBoxSizer because it aligns components on a grid, not on one line. You can specify the number of columns or number of rows in properties &amp;quot;Cols&amp;quot; and &amp;quot;Rows&amp;quot;. The default number of columns is set to 3 and number of rows is set to 0. When 0 is used, it means that sizer should automatically calculate this value to keep all managed components inside.&lt;br /&gt;
&lt;br /&gt;
This sizer makes an important assumption: all cells must have the same width and all must have the same height.  This means that the tallest managed component will set the height of all rows and the widest one will set the widths of all columns. If an component won't use the whole cell, it will be surrounded by empty space. (If you don't like this assumption, look at the wxFlexGridSizer.)&lt;br /&gt;
&lt;br /&gt;
Among the properties of a wxGridsizer you can also find horizontal and vertical spacings. These values set the spacing added between components. The result of using them is similar to using borders around managed components but with borders you would have to set borders for all components separately.&lt;br /&gt;
&lt;br /&gt;
In the case of wxGridSizer, the &amp;quot;Proportion&amp;quot; value is not used. But you may use &amp;quot;Expand&amp;quot;, &amp;quot;Shaped&amp;quot; or placement properties to adjust the result.&lt;br /&gt;
&lt;br /&gt;
Here's an example of a grid sizer:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_006.png]]&lt;br /&gt;
&lt;br /&gt;
=== wxFlexGridSizer ===&lt;br /&gt;
&lt;br /&gt;
This is a very useful one. It works similarly to wxGridSizer; but it does not force all columns to have the same width nor all rows to have the same height. Also not all columns resize when there's more space available for the sizer. Comparing to wxGridSizer you will find two extra properties here: &amp;quot;Growable cols&amp;quot; and &amp;quot;Growable rows&amp;quot;. In these properties you may provide a list of columns / rows which should automatically resize by providing a list of numbers separated using comma (,). The numbers should start from 0, so if you would like the second and third column to resize, put &amp;quot;1,2&amp;quot; into &amp;quot;Growable cols&amp;quot;. This property is very useful to handle resizing of the window.&lt;br /&gt;
&lt;br /&gt;
Unfortunately you won't be able to set proportions other that 1:1 The &amp;quot;Proportion&amp;quot; property is also not used in this sizer.&lt;br /&gt;
&lt;br /&gt;
=== wxStdDialogButtonSizer ===&lt;br /&gt;
&lt;br /&gt;
This is a specialized sizer with one purpose - to provide a set of standard buttons with respect to the platform's look and feel. This sizer has a predefined list of components which it can handle - all are buttons and you can manage them using the sizer's properties. You cannot add your custom components into this sizer.&lt;br /&gt;
&lt;br /&gt;
Each button on this sizer has two properties in the sizer - whether the button should be enabled (for example wxID_OK for OK button) and its label. Note that labels for most buttons will be generated automatically and wxWidgets will skip them when it can read them from system settings. For example, on Linux only the Context Help button does not have a system-supplied label. It is also very probable that labels will be provided with language-specific strings (depending on the current system language). Not all configurations of buttons are valid - they won't break the application but buttons will overlap (for example Yes and OK).&lt;br /&gt;
&lt;br /&gt;
Here is an example of this sizer. My system is set up in Polish, so the labels are automatically in Polish.  They mean: Help, Cancel, Apply and OK.&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_007.png]]&lt;br /&gt;
&lt;br /&gt;
This screenshot was taken on a Linux box. You may see that the buttons have an extra image which is not available for standard buttons. With such a layout, users of the application will feel more comfortable, and such 'small' things make users say that the GUI was designed very well. On MS Windows, the sizer would have the same buttons but without images and they would be in a different order - the one that is used on windows by default.&lt;br /&gt;
&lt;br /&gt;
All of the above sizers can be found on the &amp;quot;Layout&amp;quot; tab. You can find two other components there which are not sizers but can be used for layout purposes. &lt;br /&gt;
&lt;br /&gt;
The first one is Spacer. It can be added to other sizers when you simply need some empty space instead of any particular component. Spacers have only width and height.&lt;br /&gt;
&lt;br /&gt;
The second one is wxSplitterWindow. When you use this component, you can add one or two child components into it and they will be separated with a dividing line (it's called a sash in wxWidgets). On the application you can drag it to dynamically adjust the size of managed components.&lt;br /&gt;
&lt;br /&gt;
Now that we know something about sizers let's turn to other components.&lt;br /&gt;
&lt;br /&gt;
== Especially Useful Standard Components ==&lt;br /&gt;
&lt;br /&gt;
wxWidgets provides all standard graphical components like static text, buttons, edit boxes, combo boxes, and so on. All are supported in wxSmith, so you can build a nice working environment. I'll briefly describe the components that are really useful in standard applications.&lt;br /&gt;
&lt;br /&gt;
=== wxButton ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_017.png]]&lt;br /&gt;
&lt;br /&gt;
This is standard button, a very common component. Its purpose is to run some piece of code when the user clicks on it. That's it.&lt;br /&gt;
&lt;br /&gt;
=== wxStaticText ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_018.png]]&lt;br /&gt;
&lt;br /&gt;
This component only shows user-defined text on the window. It doesn't generate any events.&lt;br /&gt;
&lt;br /&gt;
=== wxTextCtrl ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_019.png]]&lt;br /&gt;
&lt;br /&gt;
This component let's the user enter some text. It's basic functionality allows entering one-line text. After changing its properties, it may become a more advanced multiline editor with support for different fonts, colors and text styles.&lt;br /&gt;
&lt;br /&gt;
=== wxPanel ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_020.png]]&lt;br /&gt;
&lt;br /&gt;
Although this component may be a separate window, it is most commonly added as a comoponent in a parent window. It is particularly useful as a background for other components. It has a few functionalities - it can be used as background in notebooks and it may be a place where you put components without sizers. But it also has a few drawbacks - wxWidgets tends to do some tricks with wxPanel's size so it's not always possible to set the size we really want.&lt;br /&gt;
&lt;br /&gt;
=== wxChoice ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_021.png]]&lt;br /&gt;
&lt;br /&gt;
This component provides a drop-down list with available options. It works similarly to wxComboBox but the user cannot enter values. It can be used in situations when the user should use one of several available options. An event is generated when the user changes the selected component.&lt;br /&gt;
&lt;br /&gt;
=== wxComboBox ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_022.png]]&lt;br /&gt;
&lt;br /&gt;
This component provides a drop-down list similar to that of wxChoice. In the case of this component, the user can select one of the available values or enter his own if the component is not in a Read-Only state. A very good example of its usage is to provide some text entry with a stored list of previously entered values (like in search boxes). Like wxChoice, changing the selection generates an event. Additionally, changing the text and pressing enter also generates events. Tutorial 9 will illustrate its use. &lt;br /&gt;
&lt;br /&gt;
=== wxListBox ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_023.png]]&lt;br /&gt;
&lt;br /&gt;
This component provides a list where you can select one or more components. Changing the component or double-clicking on it generates an event.&lt;br /&gt;
&lt;br /&gt;
=== wxNotebook ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_024.png]]&lt;br /&gt;
&lt;br /&gt;
Notebook is very useful for complex resources since it groups content under tabs. Additionally, wxChoicebook and wxCombobook are also available but are not described here. Changing the selected notebook generates two events: one when the page starts to change (before change) and one when the page is finished changing (after change).&lt;br /&gt;
&lt;br /&gt;
=== wxCheckBox ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_025.png]]&lt;br /&gt;
&lt;br /&gt;
Check boxes may be used to map boolean values. Additionally, 2-state boxes can also be generated (with values: yes/no/unspecified). Changing the value emits an event.&lt;br /&gt;
&lt;br /&gt;
=== wxRadioBox ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_026.png]]&lt;br /&gt;
&lt;br /&gt;
Radio box works similarly to check boxes. The difference is that only one radiobox in a group can be selected. Groups may be defined by using wxRB_GROUP style. A radiobox which has this style set starts a new group. Changing the selected radiobox emits an event.&lt;br /&gt;
&lt;br /&gt;
=== wxGauge ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_027.png]]&lt;br /&gt;
&lt;br /&gt;
This component, also called a Progress Bar, can be used to show the progress of some operation. It's very useful when doing some calculation intensive operations. It can prevent users from getting frustrated when they do not see anything happening on the screen but only a window which seems hung.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt; * * * * &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
That's the end of this tutorial. We will get more experience with these subjects in the following tutorials. But you can also learn a lot by experimenting: add components, change properties, resize, move. You may try adding sizers into other sizers, a very useful technique absolutely required for more complex forms. Join me for the next tutorial!&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;'''[[WxSmith tutorial: Hello world|Previous]] | [[WxSmith tutorials|Index]] | [[WxSmith tutorial: Building more complex window|Next]]'''&amp;lt;/center&amp;gt;&lt;/div&gt;</summary>
		<author><name>Chatumao</name></author>
	</entry>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=Wxsmith_tutorial:_Working_with_items&amp;diff=7565</id>
		<title>Wxsmith tutorial: Working with items</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=Wxsmith_tutorial:_Working_with_items&amp;diff=7565"/>
		<updated>2013-04-29T10:18:39Z</updated>

		<summary type="html">&lt;p&gt;Chatumao: /* Excercise with Components */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:wxSmith Documentation]]&lt;br /&gt;
= Working with Menus and Components =&lt;br /&gt;
&lt;br /&gt;
In the [[wxSmith tutorial: Hello world|previous tutorial]] we learned how to create a small application using wxWidgets. We created a window with a few components inside. In this tutorial, we will first see how to use the menu bar at the top of the main window and then focus on sizers and wxWidgets components which can be put on a form or window. &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''A Note on Terminology'''&lt;br /&gt;
&lt;br /&gt;
BYO, the creator of wxSmith and original author of these tutorials, wrote &amp;quot;Each resource in wxSmith is made of items. All your buttons, text boxes, lists etc are items. Also some more abstract things like sizers, spacers (used to add empty space), menu entries or even timers are also called items in wxSmith. So basically anything that's inside the resource may be called an item. I'll also use the term component since it reflects the valid meaning too.&amp;quot; &lt;br /&gt;
&lt;br /&gt;
In fact, the word &amp;quot;item&amp;quot; is not found in the index of the Julian Smart and Kevin Hock book ''Cross-Platform GUI Programming with wxWidgets.'' The word is used in the book specifically for the elements of the drop-down lists of choice boxes, combo boxes, and other members of the class wxControlWithItems. In the revision of these tutorials, the word &amp;quot;item&amp;quot; is therefore generally being reserved for items in these lists and for items in a menu. Otherwise, the word &amp;quot;item&amp;quot; is generally being replaced by &amp;quot;component&amp;quot;, &amp;quot;widget&amp;quot;, or &amp;quot;control&amp;quot; as seems appropriate, though of course, it is also occasionally used with no special technical meaning. Also, BYO often uses the word &amp;quot;resource&amp;quot; to refer to a form or window. Smart and Hock use word the &amp;quot;resource&amp;quot; sparingly, mainly in the context of &amp;quot;resource files&amp;quot;.  The word seems overworked and needlessly abstract, so when what is intended is a form or window, the revisions will use one of those words, with no sharp distinction between them.   &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Note that all screenshots presented here were made on Linux but they should not be very different from the windows ones.&lt;br /&gt;
&lt;br /&gt;
== Working with Menus ==&lt;br /&gt;
&lt;br /&gt;
Following the directions given in Tutorial 1, start a new Code::Blocks project; call it Tutorial_2. Remember to add &amp;quot;event.Skip(TRUE);&amp;quot; at the appropriate place in the code, as explained in Tutorial 1. &lt;br /&gt;
&lt;br /&gt;
Build and run the program. You will see that it has two items on the main menu. We will add one more, Jump, at the top level and under it two more, Back and Out. Back will do nothing, but we will make Out close the program.&lt;br /&gt;
&lt;br /&gt;
Click on the “Tutorial_2frame.wxs” tab of the Editor window.  Just below the words “Tutorial_2framw.wxs” is a panel with two square icons.  Double left click on the leftmost one, which shows the word ''File'' suggestive of a menu.  Up comes the menu inspector window shown below.&lt;br /&gt;
&lt;br /&gt;
[[Image:1i.png]]  &lt;br /&gt;
   &lt;br /&gt;
Click on the various menu items shown and note how the content of the fields shown on the right side of the window are filled in.  Then click on the New button (in the lower right part of the window) to add the three additional menu items mentioned above, namely Jump at the top level and under it Back and Out. It does not matter where the items first appear; you use the arrow keys just above the “New” and “Delete” buttons to move around the item you have selected.  For the “Id” field of the “Out” item, put idMenuOut. You should make the menu inspector window look like this:&lt;br /&gt;
&lt;br /&gt;
[[Image:1j.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When you have the menu items properly arranged, click OK.   &lt;br /&gt;
&lt;br /&gt;
When you now build and run, you will see the new menu.  But clicking Jump | Out  does not close the program as desired because we have not programmed the response to that event.  To do so, we want to make wxSmith set up the frame for the routine which will be called when the menu item “Out” is clicked.  Go to the Management pane, Resources tab and persistently click on the little right-pointing triangles until the “Out” item can be seen, as in the screen shot below.&lt;br /&gt;
&lt;br /&gt;
[[Image:1k.png]]&lt;br /&gt;
&lt;br /&gt;
      &lt;br /&gt;
Click on the word “Out” and then on the {} icon in the panel below the Management pane. That will cause the pane below to show the words “EVT_MENU     --None--” . Click on the word “None” or the down arrow at the right end of the field; a menu drops down.  Pick the item  “-- Add New Handler --”, accept the suggested name (OnMenu3Selected), and over in the editor, the frame of our handler has been written, as shown below.  We have only to write the code, which will be simply “Close();”.&lt;br /&gt;
&lt;br /&gt;
[[Image:1l.png]]&lt;br /&gt;
&lt;br /&gt;
Now we can “Build and run”, drop down our menu, click on “Out”, and the program closes, as desired.&lt;br /&gt;
&lt;br /&gt;
== Windows and Components ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Each window in wxSmith is made of components. All your buttons, text boxes, lists, and so on are components. Also some more abstract things like sizers, spacers (used to add empty space), menu entries or even timers are also components.&lt;br /&gt;
&lt;br /&gt;
Every window has a root component. For a dialog window, it would be a wxDialog component; for a frame window, it would be wxFrame component; for a panel it would be a wxPanel component. In the [[wxSmith tutorial: Hello world|previous tutorial]] you probably noticed that some components may have &amp;quot;children&amp;quot;. For example, sizers had components inside their boxes. In this tutorial, you have seen sub-menu items inside main-menu items. The term &amp;quot;children&amp;quot; suggests the idea of a family tree, and indeed precisely such a tree structure is directly represented in the resource browser, as shown in the example below.&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_008.png]]&lt;br /&gt;
&lt;br /&gt;
In the picture above, you will see an example of such a tree. wxFontFaceEditorDlg is the currently opened form with a root component of type wxDialog. We can see that this resource consists of a few sizers and buttons, one text area and some spacers. It's definitely a fairly simple form. For more complicated forms, there could be more than 100 components. The tree (or Resource) browser can be very helpful for locating the code connected with a component; clicking on the component in the browser brings up its code in the editor.&lt;br /&gt;
&lt;br /&gt;
Each component has its properties - these are usually some values which describe the component. Some of them may affect the way component looks, some may change the component's behavior, and some may be dedicated to programming facilities. You will also find that there are some properties -- such as position and size -- common to many components.&lt;br /&gt;
&lt;br /&gt;
wxSmith allows you to edit components inside the properties browser (the window which is usually under the resource browser). If you select a component either by  clicking on it in the resource browser or by clicking on it inside the editor, the properties editor switches to edit its properties. Here's an example of the property browser:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_009.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can also use the Quick-Properties panel available after pressing the &amp;quot;Q&amp;quot; button on the right side of the editor:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_010.png]]&lt;br /&gt;
&lt;br /&gt;
The purpose of this panel is to provide most common properties in user-friendly way. It hasn't proven as useful as I had hoped, and you will probably find it helpful only while adjusting sizer-related settings.&lt;br /&gt;
&lt;br /&gt;
The last and the easiest way to work on a component is directly in the editor. You can grab drag boxes and change the component's size. You can also change its position by simply dragging it to another place.&lt;br /&gt;
&lt;br /&gt;
=== Excercise with Components ===&lt;br /&gt;
&lt;br /&gt;
Enough generalities; let's play with components. We can continue with the project started at the beginning of this tutorial. First let's add wxFlexGridSizer into our window. Like all sizers, it is located in Layout tab. (You'll remember how to add components from the [[wxSmith tutorial: Hello world|previous tutorial]]). Now let's add the following components into the sizer in the order given: wxButton, wxStaticText, wxTextCtrl, wxRadioButton and wxCheckBox. They can all be found on the Standard tab. The result should look like this:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_011.png]]&lt;br /&gt;
&lt;br /&gt;
In this picture, components I've selected have a light red border.&lt;br /&gt;
&lt;br /&gt;
Now that we have our playground, let's change some components. First, let's change the label and color of the button. To do so, click on the button and move to the properties browser. &amp;quot;Label&amp;quot; is the first property, and it's quite easy to change. Just click on the word &amp;quot;Label&amp;quot; on the right and type new text.&lt;br /&gt;
&lt;br /&gt;
Color is little bit harder to find. Usually components have two colors - Background and Foreground color. Background, as the name implies, is used to fill the component's background. Foreground, on the other hand, is used to paint some content onto the background. Note that there's no strict interpretation of these colors so you should experiment to find out their meaning. In wxButton, Background is what we want.&lt;br /&gt;
So let's find the Background property. It's value can be changed by using combobox:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_012.png]]&lt;br /&gt;
&lt;br /&gt;
On the list you may find a set of predefined system colors. When you choose one of them, they will be read from the current system settings making your application compatible with the system theme. There are also two special entries - Default (which means that we do not want to set our color) and Custom. When you select Custom, wxSmith will open a color dialog where you can choose any color you like. I have chosen light green, and here's the result:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_013.png]]&lt;br /&gt;
&lt;br /&gt;
There are also other properties we could talk about, but the best way to learn them is to play with them, so I leave those discoveries to you.&lt;br /&gt;
&lt;br /&gt;
Now let's use the mouse.&lt;br /&gt;
&lt;br /&gt;
The selected component will have eight black boxes -- drag handles -- around it. These boxes can be used to change the size of the component. You will easily notice when the mouse is over a handle because the cursor changes. Let's resize the wxTextCtrl (edit box):&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_014.png]]&lt;br /&gt;
&lt;br /&gt;
You may see that resizing the component will also change properties in the browser - '''Default Size''' is unchecked now and '''Width''' and '''Height''' are set to required values. There's another property which seems to be untouched - '''Size in Dialog Units''', which is also related to size. I'll explain it a bit.&lt;br /&gt;
&lt;br /&gt;
Usually when you must specify a size (or other size-related things) you provide a value in pixels. Alternatively you can specify values in a unit called a '''Dialog Unit'''. A '''Dialog Unit''' is usually a little bit bigger than one pixel and it's size depends on the size of the current font (actually it's the size of the font of some component's parent which has a font). This is useful when you want some values to be proportional to the size of text presented in the window. &lt;br /&gt;
&lt;br /&gt;
If you check '''Size in Dialog Units'', wxSmith will take care of it and sizes will be calculated in Dialog Units instead of pixels (although, naturally, you will still be able to resize components).&lt;br /&gt;
&lt;br /&gt;
Now let's change the position of the radio box. &amp;quot;But, wait,&amp;quot; you may say, &amp;quot;I thought you said that the sizer is responsible for the positioning.&amp;quot; That's right. We have limited possibilities to change position. Inside one sizer we can only reorder components; for more complex forms we can also move a component between two sizers or to areas where sizers do not apply. So, back to our example, let's move the radio box to position it right after the button. To do so, click on the radio button and drag it onto the button. When you start dragging, you will notice that the area of the sizer changes color to blue. This color change is a aid to show you what will be the new position of the dragged component. When you move the cursor onto the button, half of the button will become light-blue. When the left half is highlighted, the dragged component will be added before it. When the right half is highlighted, dragged component will be added after it. And when there's no highlighted component, the new component will be added as the last child of the parent:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_015.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When you drop the component, it will change it's position. Note that all the components after the new position also shift. That happens because the default setting of the wxFlexGridSizer allows only 3 components in one row (this can be changed in property browser) so the components just adapted to the new order.&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_016.png]]&lt;br /&gt;
&lt;br /&gt;
==Sizers== &lt;br /&gt;
&lt;br /&gt;
Now let's learn a little bit about components available in wxSmith. I'll describe all supported sizers and a few important components from the Standard palette. Let's start with sizers.&lt;br /&gt;
&lt;br /&gt;
We already know that sizers are responsible for automatically setting the position and size of some components. But how do they do that? Well, it depends on which sizer has been used. So what are the rules? The generic rule is that the sizer tries to use all its available space and place the components it manages in such way that they do not overlap. If the area available to the sizer is too small, it requests a bigger area, so you can be sure that no component will fall out of the window. (Unfortunately, you cannot be sure that after such adjustments the window will be small enough to fit on the screen, so be careful about that.) Another rule which should be mentioned here is that sizers automatically set-up the minimum size required by the window. Basically when you edit a window using sizers, you should be aware that you edit the smallest layout and without some tricks, you won't be able to resize the window to something smaller.&lt;br /&gt;
&lt;br /&gt;
Here are descriptions of all sizers available in wxSmith:&lt;br /&gt;
&lt;br /&gt;
=== wxBoxSizer ===&lt;br /&gt;
&lt;br /&gt;
wxBoxSizer is the most basic sizer available in wxWidgets. It's purpose is to align components in one line - one next to another - either horizontally or vertically. This sizer also tries to keep some proportions between components - for a horizontal sizer you can set factors which will keep proportionality of widths and the height of the sizer area will be equal to the height of the tallest component. Similarly, vertical sizers keep heights proportional and the width will be taken as the widest component. You specify whether the sizer is to be horizontal or vertical in the sizer's property browser.&lt;br /&gt;
&lt;br /&gt;
Here are examples of layout using box sizers (the first one is the horizontal one, the second is vertical one):&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_002.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In that example you may see that all components have the same width and height.&lt;br /&gt;
&lt;br /&gt;
But let's assume that we want Button2 to be two times wider that Button1 and Button3 to be three times wider than Button1. This can be easily done by using the Proportion property of managed components. By default, the value of all components is set to 1 so they have equal size. Changing the Proportion of second button to 2 would mean that it should be 2 times wider that the first or third one.&lt;br /&gt;
&lt;br /&gt;
Generally you can set any value you want here. One common technique is to set percentage values - for example setting proportions to values 20, 30 and 50 would mean that the first button should occupy 20% of the space, the second one 30% and the third one 50%. The special value 0 means that this component should be skipped in proportion calculations and it will won't automatically adjust it's size when the main window is resized.&lt;br /&gt;
&lt;br /&gt;
So if we want to get 1:2:3 proportions, we set 1 for Button1, 2 for Button2 and 3 for Button3. And here is the result:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_003.png]]&lt;br /&gt;
&lt;br /&gt;
Also note that if you create a resizable window and resize it, those 3 buttons will automatically grow and keep proportions. If you set the Proportion property for some component to 0, it won't change size as the user changes the size of the window. &lt;br /&gt;
&lt;br /&gt;
The other dimension which is not controlled by Proportion property may be controlled using the &amp;quot;Expand&amp;quot; and &amp;quot;Shaped&amp;quot; properties. They are simple checkboxes. If you check the first one, the component will expand it's width/height and will get the size of the biggest component managed by the same sizer. Selecting &amp;quot;Shaped&amp;quot; will also make the component resize but such components will try to keep the initial proportion between width and height so it doesn't have to use all available space. The effect of the &amp;quot;Expand&amp;quot; and &amp;quot;Shaped&amp;quot; properties can be seen when components differ in width or height; here's an example:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_004.png]]&lt;br /&gt;
&lt;br /&gt;
In this example, the first button is the biggest of the three. Its size will be used to adjust the sizes of the other buttons. The second one has its &amp;quot;Expand&amp;quot; property checked, and the third one does not. What can be seen here is that the third button expanded in only one dimension (the one managed by &amp;quot;Proportion&amp;quot; property), the second dimension was left untouched.&lt;br /&gt;
&lt;br /&gt;
You may also note that when a component does not fill its available area, it is centered. That's default behavior which can be changed. In the properties of components managed by sizer you will find properties called '''Horizontal align''' and '''Vertical align'''. Using these properties you can select where the component should be located when it's smaller that its available area.&lt;br /&gt;
&lt;br /&gt;
=== wxStaticBoxSizer ===&lt;br /&gt;
&lt;br /&gt;
This sizer is similar to wxBoxSizer with one exception: it adds an extra static box around managed components:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_005.png]]&lt;br /&gt;
&lt;br /&gt;
=== wxGridSizer ===&lt;br /&gt;
&lt;br /&gt;
This sizer is a little bit more advanced than wxBoxSizer because it aligns components on a grid, not on one line. You can specify the number of columns or number of rows in properties &amp;quot;Cols&amp;quot; and &amp;quot;Rows&amp;quot;. The default number of columns is set to 3 and number of rows is set to 0. When 0 is used, it means that sizer should automatically calculate this value to keep all managed components inside.&lt;br /&gt;
&lt;br /&gt;
This sizer makes an important assumption: all cells must have the same width and all must have the same height.  This means that the tallest managed component will set the height of all rows and the widest one will set the widths of all columns. If an component won't use the whole cell, it will be surrounded by empty space. (If you don't like this assumption, look at the wxFlexGridSizer.)&lt;br /&gt;
&lt;br /&gt;
Among the properties of a wxGridsizer you can also find horizontal and vertical spacings. These values set the spacing added between components. The result of using them is similar to using borders around managed components but with borders you would have to set borders for all components separately.&lt;br /&gt;
&lt;br /&gt;
In the case of wxGridSizer, the &amp;quot;Proportion&amp;quot; value is not used. But you may use &amp;quot;Expand&amp;quot;, &amp;quot;Shaped&amp;quot; or placement properties to adjust the result.&lt;br /&gt;
&lt;br /&gt;
Here's an example of a grid sizer:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_006.png]]&lt;br /&gt;
&lt;br /&gt;
=== wxFlexGridSizer ===&lt;br /&gt;
&lt;br /&gt;
This is a very useful one. It works similarly to wxGridSizer; but it does not force all columns to have the same width nor all rows to have the same height. Also not all columns resize when there's more space available for the sizer. Comparing to wxGridSizer you will find two extra properties here: &amp;quot;Growable cols&amp;quot; and &amp;quot;Growable rows&amp;quot;. In these properties you may provide a list of columns / rows which should automatically resize by providing a list of numbers separated using comma (,). The numbers should start from 0, so if you would like the second and third column to resize, put &amp;quot;1,2&amp;quot; into &amp;quot;Growable cols&amp;quot;. This property is very useful to handle resizing of the window.&lt;br /&gt;
&lt;br /&gt;
Unfortunately you won't be able to set proportions other that 1:1 The &amp;quot;Proportion&amp;quot; property is also not used in this sizer.&lt;br /&gt;
&lt;br /&gt;
=== wxStdDialogButtonSizer ===&lt;br /&gt;
&lt;br /&gt;
This is a specialized sizer with one purpose - to provide a set of standard buttons with respect to the platform's look and feel. This sizer has a predefined list of components which it can handle - all are buttons and you can manage them using the sizer's properties. You cannot add your custom components into this sizer.&lt;br /&gt;
&lt;br /&gt;
Each button on this sizer has two properties in the sizer - whether the button should be enabled (for example wxID_OK for OK button) and its label. Note that labels for most buttons will be generated automatically and wxWidgets will skip them when it can read them from system settings. For example, on Linux only the Context Help button does not have a system-supplied label. It is also very probable that labels will be provided with language-specific strings (depending on the current system language). Not all configurations of buttons are valid - they won't break the application but buttons will overlap (for example Yes and OK).&lt;br /&gt;
&lt;br /&gt;
Here is an example of this sizer. My system is set up in Polish, so the labels are automatically in Polish.  They mean: Help, Cancel, Apply and OK.&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_007.png]]&lt;br /&gt;
&lt;br /&gt;
This screenshot was taken on a Linux box. You may see that the buttons have an extra image which is not available for standard buttons. With such a layout, users of the application will feel more comfortable, and such 'small' things make users say that the GUI was designed very well. On MS Windows, the sizer would have the same buttons but without images and they would be in a different order - the one that is used on windows by default.&lt;br /&gt;
&lt;br /&gt;
All of the above sizers can be found on the &amp;quot;Layout&amp;quot; tab. You can find two other components there which are not sizers but can be used for layout purposes. &lt;br /&gt;
&lt;br /&gt;
The first one is Spacer. It can be added to other sizers when you simply need some empty space instead of any particular component. Spacers have only width and height.&lt;br /&gt;
&lt;br /&gt;
The second one is wxSplitterWindow. When you use this component, you can add one or two child components into it and they will be separated with a dividing line (it's called a sash in wxWidgets). On the application you can drag it to dynamically adjust the size of managed components.&lt;br /&gt;
&lt;br /&gt;
Now that we know something about sizers let's turn to other components.&lt;br /&gt;
&lt;br /&gt;
== Especially Useful Standard Components ==&lt;br /&gt;
&lt;br /&gt;
wxWidgets provides all standard graphical components like static text, buttons, edit boxes, combo boxes, and so on. All are supported in wxSmith, so you can build a nice working environment. I'll briefly describe the components that are really useful in standard applications.&lt;br /&gt;
&lt;br /&gt;
=== wxButton ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_017.png]]&lt;br /&gt;
&lt;br /&gt;
This is standard button, a very common component. Its purpose is to run some piece of code when the user clicks on it. That's it.&lt;br /&gt;
&lt;br /&gt;
=== wxStaticText ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_018.png]]&lt;br /&gt;
&lt;br /&gt;
This component only shows user-defined text on the window. It doesn't generate any events.&lt;br /&gt;
&lt;br /&gt;
=== wxTextCtrl ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_019.png]]&lt;br /&gt;
&lt;br /&gt;
This component let's the user enter some text. It's basic functionality allows entering one-line text. After changing its properties, it may become a more advanced multiline editor with support for different fonts, colors and text styles.&lt;br /&gt;
&lt;br /&gt;
=== wxPanel ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_020.png]]&lt;br /&gt;
&lt;br /&gt;
Although this component may be a separate window, it is most commonly added as a comoponent in a parent window. It is particularly useful as a background for other components. It has a few functionalities - it can be used as background in notebooks and it may be a place where you put components without sizers. But it also has a few drawbacks - wxWidgets tends to do some tricks with wxPanel's size so it's not always possible to set the size we really want.&lt;br /&gt;
&lt;br /&gt;
=== wxChoice ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_021.png]]&lt;br /&gt;
&lt;br /&gt;
This component provides a drop-down list with available options. It works similarly to wxComboBox but the user cannot enter values. It can be used in situations when the user should use one of several available options. An event is generated when the user changes the selected component.&lt;br /&gt;
&lt;br /&gt;
=== wxComboBox ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_022.png]]&lt;br /&gt;
&lt;br /&gt;
This component provides a drop-down list similar to that of wxChoice. In the case of this component, the user can select one of the available values or enter his own if the component is not in a Read-Only state. A very good example of its usage is to provide some text entry with a stored list of previously entered values (like in search boxes). Like wxChoice, changing the selection generates an event. Additionally, changing the text and pressing enter also generates events. Tutorial 9 will illustrate its use. &lt;br /&gt;
&lt;br /&gt;
=== wxListBox ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_023.png]]&lt;br /&gt;
&lt;br /&gt;
This component provides a list where you can select one or more components. Changing the component or double-clicking on it generates an event.&lt;br /&gt;
&lt;br /&gt;
=== wxNotebook ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_024.png]]&lt;br /&gt;
&lt;br /&gt;
Notebook is very useful for complex resources since it groups content under tabs. Additionally, wxChoicebook and wxCombobook are also available but are not described here. Changing the selected notebook generates two events: one when the page starts to change (before change) and one when the page is finished changing (after change).&lt;br /&gt;
&lt;br /&gt;
=== wxCheckBox ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_025.png]]&lt;br /&gt;
&lt;br /&gt;
Check boxes may be used to map boolean values. Additionally, 2-state boxes can also be generated (with values: yes/no/unspecified). Changing the value emits an event.&lt;br /&gt;
&lt;br /&gt;
=== wxRadioBox ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_026.png]]&lt;br /&gt;
&lt;br /&gt;
Radio box works similarly to check boxes. The difference is that only one radiobox in a group can be selected. Groups may be defined by using wxRB_GROUP style. A radiobox which has this style set starts a new group. Changing the selected radiobox emits an event.&lt;br /&gt;
&lt;br /&gt;
=== wxGauge ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_027.png]]&lt;br /&gt;
&lt;br /&gt;
This component, also called a Progress Bar, can be used to show the progress of some operation. It's very useful when doing some calculation intensive operations. It can prevent users from getting frustrated when they do not see anything happening on the screen but only a window which seems hung.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt; * * * * &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
That's the end of this tutorial. We will get more experience with these subjects in the following tutorials. But you can also learn a lot by experimenting: add components, change properties, resize, move. You may try adding sizers into other sizers, a very useful technique absolutely required for more complex forms. Join me for the next tutorial!&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;'''[[WxSmith tutorial: Hello world|Previous]] | [[WxSmith tutorials|Index]] | [[WxSmith tutorial: Building more complex window|Next]]'''&amp;lt;/center&amp;gt;&lt;/div&gt;</summary>
		<author><name>Chatumao</name></author>
	</entry>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=Wxsmith_tutorial:_Working_with_items&amp;diff=7564</id>
		<title>Wxsmith tutorial: Working with items</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=Wxsmith_tutorial:_Working_with_items&amp;diff=7564"/>
		<updated>2013-04-29T10:16:51Z</updated>

		<summary type="html">&lt;p&gt;Chatumao: /* Excercise with Components */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:wxSmith Documentation]]&lt;br /&gt;
= Working with Menus and Components =&lt;br /&gt;
&lt;br /&gt;
In the [[wxSmith tutorial: Hello world|previous tutorial]] we learned how to create a small application using wxWidgets. We created a window with a few components inside. In this tutorial, we will first see how to use the menu bar at the top of the main window and then focus on sizers and wxWidgets components which can be put on a form or window. &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''A Note on Terminology'''&lt;br /&gt;
&lt;br /&gt;
BYO, the creator of wxSmith and original author of these tutorials, wrote &amp;quot;Each resource in wxSmith is made of items. All your buttons, text boxes, lists etc are items. Also some more abstract things like sizers, spacers (used to add empty space), menu entries or even timers are also called items in wxSmith. So basically anything that's inside the resource may be called an item. I'll also use the term component since it reflects the valid meaning too.&amp;quot; &lt;br /&gt;
&lt;br /&gt;
In fact, the word &amp;quot;item&amp;quot; is not found in the index of the Julian Smart and Kevin Hock book ''Cross-Platform GUI Programming with wxWidgets.'' The word is used in the book specifically for the elements of the drop-down lists of choice boxes, combo boxes, and other members of the class wxControlWithItems. In the revision of these tutorials, the word &amp;quot;item&amp;quot; is therefore generally being reserved for items in these lists and for items in a menu. Otherwise, the word &amp;quot;item&amp;quot; is generally being replaced by &amp;quot;component&amp;quot;, &amp;quot;widget&amp;quot;, or &amp;quot;control&amp;quot; as seems appropriate, though of course, it is also occasionally used with no special technical meaning. Also, BYO often uses the word &amp;quot;resource&amp;quot; to refer to a form or window. Smart and Hock use word the &amp;quot;resource&amp;quot; sparingly, mainly in the context of &amp;quot;resource files&amp;quot;.  The word seems overworked and needlessly abstract, so when what is intended is a form or window, the revisions will use one of those words, with no sharp distinction between them.   &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Note that all screenshots presented here were made on Linux but they should not be very different from the windows ones.&lt;br /&gt;
&lt;br /&gt;
== Working with Menus ==&lt;br /&gt;
&lt;br /&gt;
Following the directions given in Tutorial 1, start a new Code::Blocks project; call it Tutorial_2. Remember to add &amp;quot;event.Skip(TRUE);&amp;quot; at the appropriate place in the code, as explained in Tutorial 1. &lt;br /&gt;
&lt;br /&gt;
Build and run the program. You will see that it has two items on the main menu. We will add one more, Jump, at the top level and under it two more, Back and Out. Back will do nothing, but we will make Out close the program.&lt;br /&gt;
&lt;br /&gt;
Click on the “Tutorial_2frame.wxs” tab of the Editor window.  Just below the words “Tutorial_2framw.wxs” is a panel with two square icons.  Double left click on the leftmost one, which shows the word ''File'' suggestive of a menu.  Up comes the menu inspector window shown below.&lt;br /&gt;
&lt;br /&gt;
[[Image:1i.png]]  &lt;br /&gt;
   &lt;br /&gt;
Click on the various menu items shown and note how the content of the fields shown on the right side of the window are filled in.  Then click on the New button (in the lower right part of the window) to add the three additional menu items mentioned above, namely Jump at the top level and under it Back and Out. It does not matter where the items first appear; you use the arrow keys just above the “New” and “Delete” buttons to move around the item you have selected.  For the “Id” field of the “Out” item, put idMenuOut. You should make the menu inspector window look like this:&lt;br /&gt;
&lt;br /&gt;
[[Image:1j.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When you have the menu items properly arranged, click OK.   &lt;br /&gt;
&lt;br /&gt;
When you now build and run, you will see the new menu.  But clicking Jump | Out  does not close the program as desired because we have not programmed the response to that event.  To do so, we want to make wxSmith set up the frame for the routine which will be called when the menu item “Out” is clicked.  Go to the Management pane, Resources tab and persistently click on the little right-pointing triangles until the “Out” item can be seen, as in the screen shot below.&lt;br /&gt;
&lt;br /&gt;
[[Image:1k.png]]&lt;br /&gt;
&lt;br /&gt;
      &lt;br /&gt;
Click on the word “Out” and then on the {} icon in the panel below the Management pane. That will cause the pane below to show the words “EVT_MENU     --None--” . Click on the word “None” or the down arrow at the right end of the field; a menu drops down.  Pick the item  “-- Add New Handler --”, accept the suggested name (OnMenu3Selected), and over in the editor, the frame of our handler has been written, as shown below.  We have only to write the code, which will be simply “Close();”.&lt;br /&gt;
&lt;br /&gt;
[[Image:1l.png]]&lt;br /&gt;
&lt;br /&gt;
Now we can “Build and run”, drop down our menu, click on “Out”, and the program closes, as desired.&lt;br /&gt;
&lt;br /&gt;
== Windows and Components ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Each window in wxSmith is made of components. All your buttons, text boxes, lists, and so on are components. Also some more abstract things like sizers, spacers (used to add empty space), menu entries or even timers are also components.&lt;br /&gt;
&lt;br /&gt;
Every window has a root component. For a dialog window, it would be a wxDialog component; for a frame window, it would be wxFrame component; for a panel it would be a wxPanel component. In the [[wxSmith tutorial: Hello world|previous tutorial]] you probably noticed that some components may have &amp;quot;children&amp;quot;. For example, sizers had components inside their boxes. In this tutorial, you have seen sub-menu items inside main-menu items. The term &amp;quot;children&amp;quot; suggests the idea of a family tree, and indeed precisely such a tree structure is directly represented in the resource browser, as shown in the example below.&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_008.png]]&lt;br /&gt;
&lt;br /&gt;
In the picture above, you will see an example of such a tree. wxFontFaceEditorDlg is the currently opened form with a root component of type wxDialog. We can see that this resource consists of a few sizers and buttons, one text area and some spacers. It's definitely a fairly simple form. For more complicated forms, there could be more than 100 components. The tree (or Resource) browser can be very helpful for locating the code connected with a component; clicking on the component in the browser brings up its code in the editor.&lt;br /&gt;
&lt;br /&gt;
Each component has its properties - these are usually some values which describe the component. Some of them may affect the way component looks, some may change the component's behavior, and some may be dedicated to programming facilities. You will also find that there are some properties -- such as position and size -- common to many components.&lt;br /&gt;
&lt;br /&gt;
wxSmith allows you to edit components inside the properties browser (the window which is usually under the resource browser). If you select a component either by  clicking on it in the resource browser or by clicking on it inside the editor, the properties editor switches to edit its properties. Here's an example of the property browser:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_009.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can also use the Quick-Properties panel available after pressing the &amp;quot;Q&amp;quot; button on the right side of the editor:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_010.png]]&lt;br /&gt;
&lt;br /&gt;
The purpose of this panel is to provide most common properties in user-friendly way. It hasn't proven as useful as I had hoped, and you will probably find it helpful only while adjusting sizer-related settings.&lt;br /&gt;
&lt;br /&gt;
The last and the easiest way to work on a component is directly in the editor. You can grab drag boxes and change the component's size. You can also change its position by simply dragging it to another place.&lt;br /&gt;
&lt;br /&gt;
=== Excercise with Components ===&lt;br /&gt;
&lt;br /&gt;
Enough generalities; let's play with components. We can continue with the project started at the beginning of this tutorial. First let's add wxFlexGridSizer into our window. Like all sizers, it is located in Layout tab. (You'll remember how to add components from the [[wxSmith tutorial: Hello world|previous tutorial]]). Now let's add the following components into the sizer in the order given: wxButton, wxStaticText, wxTextCtrl, wxRadioButton and wxCheckBox. They can all be found on the Standard tab. The result should look like this:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_011.png]]&lt;br /&gt;
&lt;br /&gt;
In this picture, components I've selected have a light red border.&lt;br /&gt;
&lt;br /&gt;
Now that we have our playground, let's change some components. First, let's change the label and color of the button. To do so, click on the button and move to the properties browser. &amp;quot;Label&amp;quot; is the first property, and it's quite easy to change. Just click on the word &amp;quot;Label&amp;quot; on the right and type new text.&lt;br /&gt;
&lt;br /&gt;
Color is little bit harder to find. Usually components have two colors - Background and Foreground color. Background, as the name implies, is used to fill the component's background. Foreground, on the other hand, is used to paint some content onto the background. Note that there's no strict interpretation of these colors so you should experiment to find out their meaning. In wxButton, Background is what we want.&lt;br /&gt;
So let's find the Background property. It's value can be changed by using combobox:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_012.png]]&lt;br /&gt;
&lt;br /&gt;
On the list you may find a set of predefined system colors. When you choose one of them, they will be read from the current system settings making your application compatible with the system theme. There are also two special entries - Default (which means that we do not want to set our color) and Custom. When you select Custom, wxSmith will open a color dialog where you can choose any color you like. I have chosen light green, and here's the result:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_013.png]]&lt;br /&gt;
&lt;br /&gt;
There are also other properties we could talk about, but the best way to learn them is to play with them, so I leave those discoveries to you.&lt;br /&gt;
&lt;br /&gt;
Now let's use the mouse.&lt;br /&gt;
&lt;br /&gt;
The selected component will have eight black boxes -- drag handles -- around it. These boxes can be used to change the size of the component. You will easily notice when the mouse is over a handle because the cursor changes. Let's resize the wxTextCtrl (edit box):&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_014.png]]&lt;br /&gt;
&lt;br /&gt;
You may see that resizing the component will also change properties in the browser - '''Default Size''' is unchecked now and '''Width''' and '''Height''' are set to required values. There's another property which seems to be untouched - '''Size in Dialog Units''', which is also related to size. I'll explain it a bit.&lt;br /&gt;
&lt;br /&gt;
Usually when you must specify a size (or other size-related things) you provide a value in pixels. Alternatively you can specify values in a unit called a '''Dialog Unit'''. A '''Dialog Unit''' is usually a little bit bigger than one pixel and it's size depends of the size of the current font (actually it's the size of the font of some component's parent which has a font). This is useful when you want some values to be proportional to the size of text presented in the window. &lt;br /&gt;
&lt;br /&gt;
If you check '''Size in Dialog Units'', wxSmith will take care of it and sizes will be calculated in Dialog Units instead of pixels (although, naturally, you will still be able to resize components).&lt;br /&gt;
&lt;br /&gt;
Now let's change the position of the radio box. &amp;quot;But, wait,&amp;quot; you may say, &amp;quot;I thought you said that the sizer is responsible for the positioning.&amp;quot; That's right. We have limited possibilities to change position. Inside one sizer we can only reorder components; for more complex forms we can also move a component between two sizers or to areas where sizers do not apply. So, back to our example, let's move the radio box to position it right after the button. To do so, click on the radio button and drag it onto the button. When you start dragging, you will notice that the area of the sizer changes color to blue. This color change is a aid to show you what will be the new position of the dragged component. When you move the cursor onto the button, half of the button will become light-blue. When the left half is highlighted, the dragged component will be added before it. When the right half is highlighted, dragged component will be added after it. And when there's no highlighted component, the new component will be added as the last child of the parent:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_015.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When you drop the component, it will change it's position. Note that all the components after the new position also shift. That happens because the default setting of the wxFlexGridSizer allows only 3 components in one row (this can be changed in property browser) so the components just adapted to the new order.&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_016.png]]&lt;br /&gt;
&lt;br /&gt;
==Sizers== &lt;br /&gt;
&lt;br /&gt;
Now let's learn a little bit about components available in wxSmith. I'll describe all supported sizers and a few important components from the Standard palette. Let's start with sizers.&lt;br /&gt;
&lt;br /&gt;
We already know that sizers are responsible for automatically setting the position and size of some components. But how do they do that? Well, it depends on which sizer has been used. So what are the rules? The generic rule is that the sizer tries to use all its available space and place the components it manages in such way that they do not overlap. If the area available to the sizer is too small, it requests a bigger area, so you can be sure that no component will fall out of the window. (Unfortunately, you cannot be sure that after such adjustments the window will be small enough to fit on the screen, so be careful about that.) Another rule which should be mentioned here is that sizers automatically set-up the minimum size required by the window. Basically when you edit a window using sizers, you should be aware that you edit the smallest layout and without some tricks, you won't be able to resize the window to something smaller.&lt;br /&gt;
&lt;br /&gt;
Here are descriptions of all sizers available in wxSmith:&lt;br /&gt;
&lt;br /&gt;
=== wxBoxSizer ===&lt;br /&gt;
&lt;br /&gt;
wxBoxSizer is the most basic sizer available in wxWidgets. It's purpose is to align components in one line - one next to another - either horizontally or vertically. This sizer also tries to keep some proportions between components - for a horizontal sizer you can set factors which will keep proportionality of widths and the height of the sizer area will be equal to the height of the tallest component. Similarly, vertical sizers keep heights proportional and the width will be taken as the widest component. You specify whether the sizer is to be horizontal or vertical in the sizer's property browser.&lt;br /&gt;
&lt;br /&gt;
Here are examples of layout using box sizers (the first one is the horizontal one, the second is vertical one):&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_002.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In that example you may see that all components have the same width and height.&lt;br /&gt;
&lt;br /&gt;
But let's assume that we want Button2 to be two times wider that Button1 and Button3 to be three times wider than Button1. This can be easily done by using the Proportion property of managed components. By default, the value of all components is set to 1 so they have equal size. Changing the Proportion of second button to 2 would mean that it should be 2 times wider that the first or third one.&lt;br /&gt;
&lt;br /&gt;
Generally you can set any value you want here. One common technique is to set percentage values - for example setting proportions to values 20, 30 and 50 would mean that the first button should occupy 20% of the space, the second one 30% and the third one 50%. The special value 0 means that this component should be skipped in proportion calculations and it will won't automatically adjust it's size when the main window is resized.&lt;br /&gt;
&lt;br /&gt;
So if we want to get 1:2:3 proportions, we set 1 for Button1, 2 for Button2 and 3 for Button3. And here is the result:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_003.png]]&lt;br /&gt;
&lt;br /&gt;
Also note that if you create a resizable window and resize it, those 3 buttons will automatically grow and keep proportions. If you set the Proportion property for some component to 0, it won't change size as the user changes the size of the window. &lt;br /&gt;
&lt;br /&gt;
The other dimension which is not controlled by Proportion property may be controlled using the &amp;quot;Expand&amp;quot; and &amp;quot;Shaped&amp;quot; properties. They are simple checkboxes. If you check the first one, the component will expand it's width/height and will get the size of the biggest component managed by the same sizer. Selecting &amp;quot;Shaped&amp;quot; will also make the component resize but such components will try to keep the initial proportion between width and height so it doesn't have to use all available space. The effect of the &amp;quot;Expand&amp;quot; and &amp;quot;Shaped&amp;quot; properties can be seen when components differ in width or height; here's an example:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_004.png]]&lt;br /&gt;
&lt;br /&gt;
In this example, the first button is the biggest of the three. Its size will be used to adjust the sizes of the other buttons. The second one has its &amp;quot;Expand&amp;quot; property checked, and the third one does not. What can be seen here is that the third button expanded in only one dimension (the one managed by &amp;quot;Proportion&amp;quot; property), the second dimension was left untouched.&lt;br /&gt;
&lt;br /&gt;
You may also note that when a component does not fill its available area, it is centered. That's default behavior which can be changed. In the properties of components managed by sizer you will find properties called '''Horizontal align''' and '''Vertical align'''. Using these properties you can select where the component should be located when it's smaller that its available area.&lt;br /&gt;
&lt;br /&gt;
=== wxStaticBoxSizer ===&lt;br /&gt;
&lt;br /&gt;
This sizer is similar to wxBoxSizer with one exception: it adds an extra static box around managed components:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_005.png]]&lt;br /&gt;
&lt;br /&gt;
=== wxGridSizer ===&lt;br /&gt;
&lt;br /&gt;
This sizer is a little bit more advanced than wxBoxSizer because it aligns components on a grid, not on one line. You can specify the number of columns or number of rows in properties &amp;quot;Cols&amp;quot; and &amp;quot;Rows&amp;quot;. The default number of columns is set to 3 and number of rows is set to 0. When 0 is used, it means that sizer should automatically calculate this value to keep all managed components inside.&lt;br /&gt;
&lt;br /&gt;
This sizer makes an important assumption: all cells must have the same width and all must have the same height.  This means that the tallest managed component will set the height of all rows and the widest one will set the widths of all columns. If an component won't use the whole cell, it will be surrounded by empty space. (If you don't like this assumption, look at the wxFlexGridSizer.)&lt;br /&gt;
&lt;br /&gt;
Among the properties of a wxGridsizer you can also find horizontal and vertical spacings. These values set the spacing added between components. The result of using them is similar to using borders around managed components but with borders you would have to set borders for all components separately.&lt;br /&gt;
&lt;br /&gt;
In the case of wxGridSizer, the &amp;quot;Proportion&amp;quot; value is not used. But you may use &amp;quot;Expand&amp;quot;, &amp;quot;Shaped&amp;quot; or placement properties to adjust the result.&lt;br /&gt;
&lt;br /&gt;
Here's an example of a grid sizer:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_006.png]]&lt;br /&gt;
&lt;br /&gt;
=== wxFlexGridSizer ===&lt;br /&gt;
&lt;br /&gt;
This is a very useful one. It works similarly to wxGridSizer; but it does not force all columns to have the same width nor all rows to have the same height. Also not all columns resize when there's more space available for the sizer. Comparing to wxGridSizer you will find two extra properties here: &amp;quot;Growable cols&amp;quot; and &amp;quot;Growable rows&amp;quot;. In these properties you may provide a list of columns / rows which should automatically resize by providing a list of numbers separated using comma (,). The numbers should start from 0, so if you would like the second and third column to resize, put &amp;quot;1,2&amp;quot; into &amp;quot;Growable cols&amp;quot;. This property is very useful to handle resizing of the window.&lt;br /&gt;
&lt;br /&gt;
Unfortunately you won't be able to set proportions other that 1:1 The &amp;quot;Proportion&amp;quot; property is also not used in this sizer.&lt;br /&gt;
&lt;br /&gt;
=== wxStdDialogButtonSizer ===&lt;br /&gt;
&lt;br /&gt;
This is a specialized sizer with one purpose - to provide a set of standard buttons with respect to the platform's look and feel. This sizer has a predefined list of components which it can handle - all are buttons and you can manage them using the sizer's properties. You cannot add your custom components into this sizer.&lt;br /&gt;
&lt;br /&gt;
Each button on this sizer has two properties in the sizer - whether the button should be enabled (for example wxID_OK for OK button) and its label. Note that labels for most buttons will be generated automatically and wxWidgets will skip them when it can read them from system settings. For example, on Linux only the Context Help button does not have a system-supplied label. It is also very probable that labels will be provided with language-specific strings (depending on the current system language). Not all configurations of buttons are valid - they won't break the application but buttons will overlap (for example Yes and OK).&lt;br /&gt;
&lt;br /&gt;
Here is an example of this sizer. My system is set up in Polish, so the labels are automatically in Polish.  They mean: Help, Cancel, Apply and OK.&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_007.png]]&lt;br /&gt;
&lt;br /&gt;
This screenshot was taken on a Linux box. You may see that the buttons have an extra image which is not available for standard buttons. With such a layout, users of the application will feel more comfortable, and such 'small' things make users say that the GUI was designed very well. On MS Windows, the sizer would have the same buttons but without images and they would be in a different order - the one that is used on windows by default.&lt;br /&gt;
&lt;br /&gt;
All of the above sizers can be found on the &amp;quot;Layout&amp;quot; tab. You can find two other components there which are not sizers but can be used for layout purposes. &lt;br /&gt;
&lt;br /&gt;
The first one is Spacer. It can be added to other sizers when you simply need some empty space instead of any particular component. Spacers have only width and height.&lt;br /&gt;
&lt;br /&gt;
The second one is wxSplitterWindow. When you use this component, you can add one or two child components into it and they will be separated with a dividing line (it's called a sash in wxWidgets). On the application you can drag it to dynamically adjust the size of managed components.&lt;br /&gt;
&lt;br /&gt;
Now that we know something about sizers let's turn to other components.&lt;br /&gt;
&lt;br /&gt;
== Especially Useful Standard Components ==&lt;br /&gt;
&lt;br /&gt;
wxWidgets provides all standard graphical components like static text, buttons, edit boxes, combo boxes, and so on. All are supported in wxSmith, so you can build a nice working environment. I'll briefly describe the components that are really useful in standard applications.&lt;br /&gt;
&lt;br /&gt;
=== wxButton ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_017.png]]&lt;br /&gt;
&lt;br /&gt;
This is standard button, a very common component. Its purpose is to run some piece of code when the user clicks on it. That's it.&lt;br /&gt;
&lt;br /&gt;
=== wxStaticText ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_018.png]]&lt;br /&gt;
&lt;br /&gt;
This component only shows user-defined text on the window. It doesn't generate any events.&lt;br /&gt;
&lt;br /&gt;
=== wxTextCtrl ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_019.png]]&lt;br /&gt;
&lt;br /&gt;
This component let's the user enter some text. It's basic functionality allows entering one-line text. After changing its properties, it may become a more advanced multiline editor with support for different fonts, colors and text styles.&lt;br /&gt;
&lt;br /&gt;
=== wxPanel ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_020.png]]&lt;br /&gt;
&lt;br /&gt;
Although this component may be a separate window, it is most commonly added as a comoponent in a parent window. It is particularly useful as a background for other components. It has a few functionalities - it can be used as background in notebooks and it may be a place where you put components without sizers. But it also has a few drawbacks - wxWidgets tends to do some tricks with wxPanel's size so it's not always possible to set the size we really want.&lt;br /&gt;
&lt;br /&gt;
=== wxChoice ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_021.png]]&lt;br /&gt;
&lt;br /&gt;
This component provides a drop-down list with available options. It works similarly to wxComboBox but the user cannot enter values. It can be used in situations when the user should use one of several available options. An event is generated when the user changes the selected component.&lt;br /&gt;
&lt;br /&gt;
=== wxComboBox ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_022.png]]&lt;br /&gt;
&lt;br /&gt;
This component provides a drop-down list similar to that of wxChoice. In the case of this component, the user can select one of the available values or enter his own if the component is not in a Read-Only state. A very good example of its usage is to provide some text entry with a stored list of previously entered values (like in search boxes). Like wxChoice, changing the selection generates an event. Additionally, changing the text and pressing enter also generates events. Tutorial 9 will illustrate its use. &lt;br /&gt;
&lt;br /&gt;
=== wxListBox ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_023.png]]&lt;br /&gt;
&lt;br /&gt;
This component provides a list where you can select one or more components. Changing the component or double-clicking on it generates an event.&lt;br /&gt;
&lt;br /&gt;
=== wxNotebook ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_024.png]]&lt;br /&gt;
&lt;br /&gt;
Notebook is very useful for complex resources since it groups content under tabs. Additionally, wxChoicebook and wxCombobook are also available but are not described here. Changing the selected notebook generates two events: one when the page starts to change (before change) and one when the page is finished changing (after change).&lt;br /&gt;
&lt;br /&gt;
=== wxCheckBox ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_025.png]]&lt;br /&gt;
&lt;br /&gt;
Check boxes may be used to map boolean values. Additionally, 2-state boxes can also be generated (with values: yes/no/unspecified). Changing the value emits an event.&lt;br /&gt;
&lt;br /&gt;
=== wxRadioBox ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_026.png]]&lt;br /&gt;
&lt;br /&gt;
Radio box works similarly to check boxes. The difference is that only one radiobox in a group can be selected. Groups may be defined by using wxRB_GROUP style. A radiobox which has this style set starts a new group. Changing the selected radiobox emits an event.&lt;br /&gt;
&lt;br /&gt;
=== wxGauge ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_027.png]]&lt;br /&gt;
&lt;br /&gt;
This component, also called a Progress Bar, can be used to show the progress of some operation. It's very useful when doing some calculation intensive operations. It can prevent users from getting frustrated when they do not see anything happening on the screen but only a window which seems hung.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt; * * * * &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
That's the end of this tutorial. We will get more experience with these subjects in the following tutorials. But you can also learn a lot by experimenting: add components, change properties, resize, move. You may try adding sizers into other sizers, a very useful technique absolutely required for more complex forms. Join me for the next tutorial!&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;'''[[WxSmith tutorial: Hello world|Previous]] | [[WxSmith tutorials|Index]] | [[WxSmith tutorial: Building more complex window|Next]]'''&amp;lt;/center&amp;gt;&lt;/div&gt;</summary>
		<author><name>Chatumao</name></author>
	</entry>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=Wxsmith_tutorial:_Working_with_items&amp;diff=7563</id>
		<title>Wxsmith tutorial: Working with items</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=Wxsmith_tutorial:_Working_with_items&amp;diff=7563"/>
		<updated>2013-04-29T10:12:33Z</updated>

		<summary type="html">&lt;p&gt;Chatumao: /* Excercise with Components */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:wxSmith Documentation]]&lt;br /&gt;
= Working with Menus and Components =&lt;br /&gt;
&lt;br /&gt;
In the [[wxSmith tutorial: Hello world|previous tutorial]] we learned how to create a small application using wxWidgets. We created a window with a few components inside. In this tutorial, we will first see how to use the menu bar at the top of the main window and then focus on sizers and wxWidgets components which can be put on a form or window. &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''A Note on Terminology'''&lt;br /&gt;
&lt;br /&gt;
BYO, the creator of wxSmith and original author of these tutorials, wrote &amp;quot;Each resource in wxSmith is made of items. All your buttons, text boxes, lists etc are items. Also some more abstract things like sizers, spacers (used to add empty space), menu entries or even timers are also called items in wxSmith. So basically anything that's inside the resource may be called an item. I'll also use the term component since it reflects the valid meaning too.&amp;quot; &lt;br /&gt;
&lt;br /&gt;
In fact, the word &amp;quot;item&amp;quot; is not found in the index of the Julian Smart and Kevin Hock book ''Cross-Platform GUI Programming with wxWidgets.'' The word is used in the book specifically for the elements of the drop-down lists of choice boxes, combo boxes, and other members of the class wxControlWithItems. In the revision of these tutorials, the word &amp;quot;item&amp;quot; is therefore generally being reserved for items in these lists and for items in a menu. Otherwise, the word &amp;quot;item&amp;quot; is generally being replaced by &amp;quot;component&amp;quot;, &amp;quot;widget&amp;quot;, or &amp;quot;control&amp;quot; as seems appropriate, though of course, it is also occasionally used with no special technical meaning. Also, BYO often uses the word &amp;quot;resource&amp;quot; to refer to a form or window. Smart and Hock use word the &amp;quot;resource&amp;quot; sparingly, mainly in the context of &amp;quot;resource files&amp;quot;.  The word seems overworked and needlessly abstract, so when what is intended is a form or window, the revisions will use one of those words, with no sharp distinction between them.   &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Note that all screenshots presented here were made on Linux but they should not be very different from the windows ones.&lt;br /&gt;
&lt;br /&gt;
== Working with Menus ==&lt;br /&gt;
&lt;br /&gt;
Following the directions given in Tutorial 1, start a new Code::Blocks project; call it Tutorial_2. Remember to add &amp;quot;event.Skip(TRUE);&amp;quot; at the appropriate place in the code, as explained in Tutorial 1. &lt;br /&gt;
&lt;br /&gt;
Build and run the program. You will see that it has two items on the main menu. We will add one more, Jump, at the top level and under it two more, Back and Out. Back will do nothing, but we will make Out close the program.&lt;br /&gt;
&lt;br /&gt;
Click on the “Tutorial_2frame.wxs” tab of the Editor window.  Just below the words “Tutorial_2framw.wxs” is a panel with two square icons.  Double left click on the leftmost one, which shows the word ''File'' suggestive of a menu.  Up comes the menu inspector window shown below.&lt;br /&gt;
&lt;br /&gt;
[[Image:1i.png]]  &lt;br /&gt;
   &lt;br /&gt;
Click on the various menu items shown and note how the content of the fields shown on the right side of the window are filled in.  Then click on the New button (in the lower right part of the window) to add the three additional menu items mentioned above, namely Jump at the top level and under it Back and Out. It does not matter where the items first appear; you use the arrow keys just above the “New” and “Delete” buttons to move around the item you have selected.  For the “Id” field of the “Out” item, put idMenuOut. You should make the menu inspector window look like this:&lt;br /&gt;
&lt;br /&gt;
[[Image:1j.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When you have the menu items properly arranged, click OK.   &lt;br /&gt;
&lt;br /&gt;
When you now build and run, you will see the new menu.  But clicking Jump | Out  does not close the program as desired because we have not programmed the response to that event.  To do so, we want to make wxSmith set up the frame for the routine which will be called when the menu item “Out” is clicked.  Go to the Management pane, Resources tab and persistently click on the little right-pointing triangles until the “Out” item can be seen, as in the screen shot below.&lt;br /&gt;
&lt;br /&gt;
[[Image:1k.png]]&lt;br /&gt;
&lt;br /&gt;
      &lt;br /&gt;
Click on the word “Out” and then on the {} icon in the panel below the Management pane. That will cause the pane below to show the words “EVT_MENU     --None--” . Click on the word “None” or the down arrow at the right end of the field; a menu drops down.  Pick the item  “-- Add New Handler --”, accept the suggested name (OnMenu3Selected), and over in the editor, the frame of our handler has been written, as shown below.  We have only to write the code, which will be simply “Close();”.&lt;br /&gt;
&lt;br /&gt;
[[Image:1l.png]]&lt;br /&gt;
&lt;br /&gt;
Now we can “Build and run”, drop down our menu, click on “Out”, and the program closes, as desired.&lt;br /&gt;
&lt;br /&gt;
== Windows and Components ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Each window in wxSmith is made of components. All your buttons, text boxes, lists, and so on are components. Also some more abstract things like sizers, spacers (used to add empty space), menu entries or even timers are also components.&lt;br /&gt;
&lt;br /&gt;
Every window has a root component. For a dialog window, it would be a wxDialog component; for a frame window, it would be wxFrame component; for a panel it would be a wxPanel component. In the [[wxSmith tutorial: Hello world|previous tutorial]] you probably noticed that some components may have &amp;quot;children&amp;quot;. For example, sizers had components inside their boxes. In this tutorial, you have seen sub-menu items inside main-menu items. The term &amp;quot;children&amp;quot; suggests the idea of a family tree, and indeed precisely such a tree structure is directly represented in the resource browser, as shown in the example below.&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_008.png]]&lt;br /&gt;
&lt;br /&gt;
In the picture above, you will see an example of such a tree. wxFontFaceEditorDlg is the currently opened form with a root component of type wxDialog. We can see that this resource consists of a few sizers and buttons, one text area and some spacers. It's definitely a fairly simple form. For more complicated forms, there could be more than 100 components. The tree (or Resource) browser can be very helpful for locating the code connected with a component; clicking on the component in the browser brings up its code in the editor.&lt;br /&gt;
&lt;br /&gt;
Each component has its properties - these are usually some values which describe the component. Some of them may affect the way component looks, some may change the component's behavior, and some may be dedicated to programming facilities. You will also find that there are some properties -- such as position and size -- common to many components.&lt;br /&gt;
&lt;br /&gt;
wxSmith allows you to edit components inside the properties browser (the window which is usually under the resource browser). If you select a component either by  clicking on it in the resource browser or by clicking on it inside the editor, the properties editor switches to edit its properties. Here's an example of the property browser:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_009.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can also use the Quick-Properties panel available after pressing the &amp;quot;Q&amp;quot; button on the right side of the editor:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_010.png]]&lt;br /&gt;
&lt;br /&gt;
The purpose of this panel is to provide most common properties in user-friendly way. It hasn't proven as useful as I had hoped, and you will probably find it helpful only while adjusting sizer-related settings.&lt;br /&gt;
&lt;br /&gt;
The last and the easiest way to work on a component is directly in the editor. You can grab drag boxes and change the component's size. You can also change its position by simply dragging it to another place.&lt;br /&gt;
&lt;br /&gt;
=== Excercise with Components ===&lt;br /&gt;
&lt;br /&gt;
Enough generalities; let's play with components. We can continue with the project started at the beginning of this tutorial. First let's add wxFlexGridSizer into our window. Like all sizers, it is located in Layout tab. (You'll remember how to add components from the [[wxSmith tutorial: Hello world|previous tutorial]]). Now let's add the following components into the sizer in the order given: wxButton, wxStaticText, wxTextCtrl, wxRadioButton and wxCheckBox. They can all be found on the Standard tab. The result should look like this:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_011.png]]&lt;br /&gt;
&lt;br /&gt;
In this picture, components I've selected have a light red border.&lt;br /&gt;
&lt;br /&gt;
Now that we have our playground, let's change some components. First, let's change the label and color of the button. To do so, click on the button and move to the properties browser. &amp;quot;Label&amp;quot; is the first property, and it's quite easy to change. Just click on the word &amp;quot;Label&amp;quot; on the right and type new text.&lt;br /&gt;
&lt;br /&gt;
Color is little bit harder to find. Usually components have two colors - Background and Foreground color. Background, as the name implies, is used to fill the component's background. Foreground, on the other hand, is used to paint some content onto the background. Note that there's no strict interpretation of these colors so you should experiment to find out their meaning. In wxButton, Background is what we want.&lt;br /&gt;
So let's find the Background property. It's value can be changed by using combobox:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_012.png]]&lt;br /&gt;
&lt;br /&gt;
On the list you may find a set of predefined system colors. When you choose one of them, they will be read from the current system settings making your application compatible with the system theme. There are also two special entries - Default (which means that we do not want to set our color) and Custom. When you select Custom, wxSmith will open a color dialog where you can choose any color you like. I have chosen light green, and here's the result:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_013.png]]&lt;br /&gt;
&lt;br /&gt;
There are also other properties we could talk about, but the best way to learn them is to play with them, so I leave those discoveries to you.&lt;br /&gt;
&lt;br /&gt;
Now let's use the mouse.&lt;br /&gt;
&lt;br /&gt;
The selected component will have eight black boxes -- drag handles -- around it. These boxes can be used to change the size of the component. You will easily notice when the mouse is over a handle because the cursor changes. Let's resize the wxTextCtrl (edit box):&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_014.png]]&lt;br /&gt;
&lt;br /&gt;
You may see that resizing the component will also change properties in the browser - '''Default Size''' is unchecked now and '''Width''' and '''Height''' are set to required values. There's another property which seems to be untouched - '''Size in Dialog Units''', which is also related to size. I'll explain it a bit.&lt;br /&gt;
&lt;br /&gt;
Usually when you must specify size (or other size-related thing) you provide a value in pixels. Alternatively you can specify values in a unit called a '''Dialog Unit'''. A '''Dialog Unit'' is usually a little bit bigger than one pixel and it's size depends of the size of the current font (actually it's the size of the font of some component's parent which has a font). This is useful when you want some values to be proportional to the size of text presented in the window. &lt;br /&gt;
&lt;br /&gt;
If you check '''Size in Dialog Units'', wxSmith will take care of it and sizes will be calculated in Dialog Units instead of pixels (although, naturally, you will still be able to resize components).&lt;br /&gt;
&lt;br /&gt;
Now let's change the position of the radio box. &amp;quot;But, wait,&amp;quot; you may say, &amp;quot;I thought you said that the sizer is responsible for the positioning.&amp;quot; That's right. We have limited possibilities to change position. Inside one sizer we can only reorder components; for more complex forms we can also move a component between two sizers or to areas where sizers do not apply. So, back to our example, let's move the radio box to position it right after the button. To do so, click on the radio button and drag it onto the button. When you start dragging, you will notice that the area of the sizer changes color to blue. This color change is a aid to show you what will be the new position of the dragged component. When you move the cursor onto the button, half of the button will become light-blue. When the left half is highlighted, the dragged component will be added before it. When the right half is highlighted, dragged component will be added after it. And when there's no highlighted component, the new component will be added as the last child of the parent:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_015.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When you drop the component, it will change it's position. Note that all the components after the new position also shift. That happens because the default setting of the wxFlexGridSizer allows only 3 components in one row (this can be changed in property browser) so the components just adapted to the new order.&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_016.png]]&lt;br /&gt;
&lt;br /&gt;
==Sizers== &lt;br /&gt;
&lt;br /&gt;
Now let's learn a little bit about components available in wxSmith. I'll describe all supported sizers and a few important components from the Standard palette. Let's start with sizers.&lt;br /&gt;
&lt;br /&gt;
We already know that sizers are responsible for automatically setting the position and size of some components. But how do they do that? Well, it depends on which sizer has been used. So what are the rules? The generic rule is that the sizer tries to use all its available space and place the components it manages in such way that they do not overlap. If the area available to the sizer is too small, it requests a bigger area, so you can be sure that no component will fall out of the window. (Unfortunately, you cannot be sure that after such adjustments the window will be small enough to fit on the screen, so be careful about that.) Another rule which should be mentioned here is that sizers automatically set-up the minimum size required by the window. Basically when you edit a window using sizers, you should be aware that you edit the smallest layout and without some tricks, you won't be able to resize the window to something smaller.&lt;br /&gt;
&lt;br /&gt;
Here are descriptions of all sizers available in wxSmith:&lt;br /&gt;
&lt;br /&gt;
=== wxBoxSizer ===&lt;br /&gt;
&lt;br /&gt;
wxBoxSizer is the most basic sizer available in wxWidgets. It's purpose is to align components in one line - one next to another - either horizontally or vertically. This sizer also tries to keep some proportions between components - for a horizontal sizer you can set factors which will keep proportionality of widths and the height of the sizer area will be equal to the height of the tallest component. Similarly, vertical sizers keep heights proportional and the width will be taken as the widest component. You specify whether the sizer is to be horizontal or vertical in the sizer's property browser.&lt;br /&gt;
&lt;br /&gt;
Here are examples of layout using box sizers (the first one is the horizontal one, the second is vertical one):&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_002.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In that example you may see that all components have the same width and height.&lt;br /&gt;
&lt;br /&gt;
But let's assume that we want Button2 to be two times wider that Button1 and Button3 to be three times wider than Button1. This can be easily done by using the Proportion property of managed components. By default, the value of all components is set to 1 so they have equal size. Changing the Proportion of second button to 2 would mean that it should be 2 times wider that the first or third one.&lt;br /&gt;
&lt;br /&gt;
Generally you can set any value you want here. One common technique is to set percentage values - for example setting proportions to values 20, 30 and 50 would mean that the first button should occupy 20% of the space, the second one 30% and the third one 50%. The special value 0 means that this component should be skipped in proportion calculations and it will won't automatically adjust it's size when the main window is resized.&lt;br /&gt;
&lt;br /&gt;
So if we want to get 1:2:3 proportions, we set 1 for Button1, 2 for Button2 and 3 for Button3. And here is the result:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_003.png]]&lt;br /&gt;
&lt;br /&gt;
Also note that if you create a resizable window and resize it, those 3 buttons will automatically grow and keep proportions. If you set the Proportion property for some component to 0, it won't change size as the user changes the size of the window. &lt;br /&gt;
&lt;br /&gt;
The other dimension which is not controlled by Proportion property may be controlled using the &amp;quot;Expand&amp;quot; and &amp;quot;Shaped&amp;quot; properties. They are simple checkboxes. If you check the first one, the component will expand it's width/height and will get the size of the biggest component managed by the same sizer. Selecting &amp;quot;Shaped&amp;quot; will also make the component resize but such components will try to keep the initial proportion between width and height so it doesn't have to use all available space. The effect of the &amp;quot;Expand&amp;quot; and &amp;quot;Shaped&amp;quot; properties can be seen when components differ in width or height; here's an example:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_004.png]]&lt;br /&gt;
&lt;br /&gt;
In this example, the first button is the biggest of the three. Its size will be used to adjust the sizes of the other buttons. The second one has its &amp;quot;Expand&amp;quot; property checked, and the third one does not. What can be seen here is that the third button expanded in only one dimension (the one managed by &amp;quot;Proportion&amp;quot; property), the second dimension was left untouched.&lt;br /&gt;
&lt;br /&gt;
You may also note that when a component does not fill its available area, it is centered. That's default behavior which can be changed. In the properties of components managed by sizer you will find properties called '''Horizontal align''' and '''Vertical align'''. Using these properties you can select where the component should be located when it's smaller that its available area.&lt;br /&gt;
&lt;br /&gt;
=== wxStaticBoxSizer ===&lt;br /&gt;
&lt;br /&gt;
This sizer is similar to wxBoxSizer with one exception: it adds an extra static box around managed components:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_005.png]]&lt;br /&gt;
&lt;br /&gt;
=== wxGridSizer ===&lt;br /&gt;
&lt;br /&gt;
This sizer is a little bit more advanced than wxBoxSizer because it aligns components on a grid, not on one line. You can specify the number of columns or number of rows in properties &amp;quot;Cols&amp;quot; and &amp;quot;Rows&amp;quot;. The default number of columns is set to 3 and number of rows is set to 0. When 0 is used, it means that sizer should automatically calculate this value to keep all managed components inside.&lt;br /&gt;
&lt;br /&gt;
This sizer makes an important assumption: all cells must have the same width and all must have the same height.  This means that the tallest managed component will set the height of all rows and the widest one will set the widths of all columns. If an component won't use the whole cell, it will be surrounded by empty space. (If you don't like this assumption, look at the wxFlexGridSizer.)&lt;br /&gt;
&lt;br /&gt;
Among the properties of a wxGridsizer you can also find horizontal and vertical spacings. These values set the spacing added between components. The result of using them is similar to using borders around managed components but with borders you would have to set borders for all components separately.&lt;br /&gt;
&lt;br /&gt;
In the case of wxGridSizer, the &amp;quot;Proportion&amp;quot; value is not used. But you may use &amp;quot;Expand&amp;quot;, &amp;quot;Shaped&amp;quot; or placement properties to adjust the result.&lt;br /&gt;
&lt;br /&gt;
Here's an example of a grid sizer:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_006.png]]&lt;br /&gt;
&lt;br /&gt;
=== wxFlexGridSizer ===&lt;br /&gt;
&lt;br /&gt;
This is a very useful one. It works similarly to wxGridSizer; but it does not force all columns to have the same width nor all rows to have the same height. Also not all columns resize when there's more space available for the sizer. Comparing to wxGridSizer you will find two extra properties here: &amp;quot;Growable cols&amp;quot; and &amp;quot;Growable rows&amp;quot;. In these properties you may provide a list of columns / rows which should automatically resize by providing a list of numbers separated using comma (,). The numbers should start from 0, so if you would like the second and third column to resize, put &amp;quot;1,2&amp;quot; into &amp;quot;Growable cols&amp;quot;. This property is very useful to handle resizing of the window.&lt;br /&gt;
&lt;br /&gt;
Unfortunately you won't be able to set proportions other that 1:1 The &amp;quot;Proportion&amp;quot; property is also not used in this sizer.&lt;br /&gt;
&lt;br /&gt;
=== wxStdDialogButtonSizer ===&lt;br /&gt;
&lt;br /&gt;
This is a specialized sizer with one purpose - to provide a set of standard buttons with respect to the platform's look and feel. This sizer has a predefined list of components which it can handle - all are buttons and you can manage them using the sizer's properties. You cannot add your custom components into this sizer.&lt;br /&gt;
&lt;br /&gt;
Each button on this sizer has two properties in the sizer - whether the button should be enabled (for example wxID_OK for OK button) and its label. Note that labels for most buttons will be generated automatically and wxWidgets will skip them when it can read them from system settings. For example, on Linux only the Context Help button does not have a system-supplied label. It is also very probable that labels will be provided with language-specific strings (depending on the current system language). Not all configurations of buttons are valid - they won't break the application but buttons will overlap (for example Yes and OK).&lt;br /&gt;
&lt;br /&gt;
Here is an example of this sizer. My system is set up in Polish, so the labels are automatically in Polish.  They mean: Help, Cancel, Apply and OK.&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_007.png]]&lt;br /&gt;
&lt;br /&gt;
This screenshot was taken on a Linux box. You may see that the buttons have an extra image which is not available for standard buttons. With such a layout, users of the application will feel more comfortable, and such 'small' things make users say that the GUI was designed very well. On MS Windows, the sizer would have the same buttons but without images and they would be in a different order - the one that is used on windows by default.&lt;br /&gt;
&lt;br /&gt;
All of the above sizers can be found on the &amp;quot;Layout&amp;quot; tab. You can find two other components there which are not sizers but can be used for layout purposes. &lt;br /&gt;
&lt;br /&gt;
The first one is Spacer. It can be added to other sizers when you simply need some empty space instead of any particular component. Spacers have only width and height.&lt;br /&gt;
&lt;br /&gt;
The second one is wxSplitterWindow. When you use this component, you can add one or two child components into it and they will be separated with a dividing line (it's called a sash in wxWidgets). On the application you can drag it to dynamically adjust the size of managed components.&lt;br /&gt;
&lt;br /&gt;
Now that we know something about sizers let's turn to other components.&lt;br /&gt;
&lt;br /&gt;
== Especially Useful Standard Components ==&lt;br /&gt;
&lt;br /&gt;
wxWidgets provides all standard graphical components like static text, buttons, edit boxes, combo boxes, and so on. All are supported in wxSmith, so you can build a nice working environment. I'll briefly describe the components that are really useful in standard applications.&lt;br /&gt;
&lt;br /&gt;
=== wxButton ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_017.png]]&lt;br /&gt;
&lt;br /&gt;
This is standard button, a very common component. Its purpose is to run some piece of code when the user clicks on it. That's it.&lt;br /&gt;
&lt;br /&gt;
=== wxStaticText ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_018.png]]&lt;br /&gt;
&lt;br /&gt;
This component only shows user-defined text on the window. It doesn't generate any events.&lt;br /&gt;
&lt;br /&gt;
=== wxTextCtrl ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_019.png]]&lt;br /&gt;
&lt;br /&gt;
This component let's the user enter some text. It's basic functionality allows entering one-line text. After changing its properties, it may become a more advanced multiline editor with support for different fonts, colors and text styles.&lt;br /&gt;
&lt;br /&gt;
=== wxPanel ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_020.png]]&lt;br /&gt;
&lt;br /&gt;
Although this component may be a separate window, it is most commonly added as a comoponent in a parent window. It is particularly useful as a background for other components. It has a few functionalities - it can be used as background in notebooks and it may be a place where you put components without sizers. But it also has a few drawbacks - wxWidgets tends to do some tricks with wxPanel's size so it's not always possible to set the size we really want.&lt;br /&gt;
&lt;br /&gt;
=== wxChoice ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_021.png]]&lt;br /&gt;
&lt;br /&gt;
This component provides a drop-down list with available options. It works similarly to wxComboBox but the user cannot enter values. It can be used in situations when the user should use one of several available options. An event is generated when the user changes the selected component.&lt;br /&gt;
&lt;br /&gt;
=== wxComboBox ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_022.png]]&lt;br /&gt;
&lt;br /&gt;
This component provides a drop-down list similar to that of wxChoice. In the case of this component, the user can select one of the available values or enter his own if the component is not in a Read-Only state. A very good example of its usage is to provide some text entry with a stored list of previously entered values (like in search boxes). Like wxChoice, changing the selection generates an event. Additionally, changing the text and pressing enter also generates events. Tutorial 9 will illustrate its use. &lt;br /&gt;
&lt;br /&gt;
=== wxListBox ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_023.png]]&lt;br /&gt;
&lt;br /&gt;
This component provides a list where you can select one or more components. Changing the component or double-clicking on it generates an event.&lt;br /&gt;
&lt;br /&gt;
=== wxNotebook ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_024.png]]&lt;br /&gt;
&lt;br /&gt;
Notebook is very useful for complex resources since it groups content under tabs. Additionally, wxChoicebook and wxCombobook are also available but are not described here. Changing the selected notebook generates two events: one when the page starts to change (before change) and one when the page is finished changing (after change).&lt;br /&gt;
&lt;br /&gt;
=== wxCheckBox ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_025.png]]&lt;br /&gt;
&lt;br /&gt;
Check boxes may be used to map boolean values. Additionally, 2-state boxes can also be generated (with values: yes/no/unspecified). Changing the value emits an event.&lt;br /&gt;
&lt;br /&gt;
=== wxRadioBox ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_026.png]]&lt;br /&gt;
&lt;br /&gt;
Radio box works similarly to check boxes. The difference is that only one radiobox in a group can be selected. Groups may be defined by using wxRB_GROUP style. A radiobox which has this style set starts a new group. Changing the selected radiobox emits an event.&lt;br /&gt;
&lt;br /&gt;
=== wxGauge ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_027.png]]&lt;br /&gt;
&lt;br /&gt;
This component, also called a Progress Bar, can be used to show the progress of some operation. It's very useful when doing some calculation intensive operations. It can prevent users from getting frustrated when they do not see anything happening on the screen but only a window which seems hung.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt; * * * * &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
That's the end of this tutorial. We will get more experience with these subjects in the following tutorials. But you can also learn a lot by experimenting: add components, change properties, resize, move. You may try adding sizers into other sizers, a very useful technique absolutely required for more complex forms. Join me for the next tutorial!&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;'''[[WxSmith tutorial: Hello world|Previous]] | [[WxSmith tutorials|Index]] | [[WxSmith tutorial: Building more complex window|Next]]'''&amp;lt;/center&amp;gt;&lt;/div&gt;</summary>
		<author><name>Chatumao</name></author>
	</entry>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=Wxsmith_tutorial:_Working_with_items&amp;diff=7562</id>
		<title>Wxsmith tutorial: Working with items</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=Wxsmith_tutorial:_Working_with_items&amp;diff=7562"/>
		<updated>2013-04-29T10:01:25Z</updated>

		<summary type="html">&lt;p&gt;Chatumao: /* Windows and Components */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:wxSmith Documentation]]&lt;br /&gt;
= Working with Menus and Components =&lt;br /&gt;
&lt;br /&gt;
In the [[wxSmith tutorial: Hello world|previous tutorial]] we learned how to create a small application using wxWidgets. We created a window with a few components inside. In this tutorial, we will first see how to use the menu bar at the top of the main window and then focus on sizers and wxWidgets components which can be put on a form or window. &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''A Note on Terminology'''&lt;br /&gt;
&lt;br /&gt;
BYO, the creator of wxSmith and original author of these tutorials, wrote &amp;quot;Each resource in wxSmith is made of items. All your buttons, text boxes, lists etc are items. Also some more abstract things like sizers, spacers (used to add empty space), menu entries or even timers are also called items in wxSmith. So basically anything that's inside the resource may be called an item. I'll also use the term component since it reflects the valid meaning too.&amp;quot; &lt;br /&gt;
&lt;br /&gt;
In fact, the word &amp;quot;item&amp;quot; is not found in the index of the Julian Smart and Kevin Hock book ''Cross-Platform GUI Programming with wxWidgets.'' The word is used in the book specifically for the elements of the drop-down lists of choice boxes, combo boxes, and other members of the class wxControlWithItems. In the revision of these tutorials, the word &amp;quot;item&amp;quot; is therefore generally being reserved for items in these lists and for items in a menu. Otherwise, the word &amp;quot;item&amp;quot; is generally being replaced by &amp;quot;component&amp;quot;, &amp;quot;widget&amp;quot;, or &amp;quot;control&amp;quot; as seems appropriate, though of course, it is also occasionally used with no special technical meaning. Also, BYO often uses the word &amp;quot;resource&amp;quot; to refer to a form or window. Smart and Hock use word the &amp;quot;resource&amp;quot; sparingly, mainly in the context of &amp;quot;resource files&amp;quot;.  The word seems overworked and needlessly abstract, so when what is intended is a form or window, the revisions will use one of those words, with no sharp distinction between them.   &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Note that all screenshots presented here were made on Linux but they should not be very different from the windows ones.&lt;br /&gt;
&lt;br /&gt;
== Working with Menus ==&lt;br /&gt;
&lt;br /&gt;
Following the directions given in Tutorial 1, start a new Code::Blocks project; call it Tutorial_2. Remember to add &amp;quot;event.Skip(TRUE);&amp;quot; at the appropriate place in the code, as explained in Tutorial 1. &lt;br /&gt;
&lt;br /&gt;
Build and run the program. You will see that it has two items on the main menu. We will add one more, Jump, at the top level and under it two more, Back and Out. Back will do nothing, but we will make Out close the program.&lt;br /&gt;
&lt;br /&gt;
Click on the “Tutorial_2frame.wxs” tab of the Editor window.  Just below the words “Tutorial_2framw.wxs” is a panel with two square icons.  Double left click on the leftmost one, which shows the word ''File'' suggestive of a menu.  Up comes the menu inspector window shown below.&lt;br /&gt;
&lt;br /&gt;
[[Image:1i.png]]  &lt;br /&gt;
   &lt;br /&gt;
Click on the various menu items shown and note how the content of the fields shown on the right side of the window are filled in.  Then click on the New button (in the lower right part of the window) to add the three additional menu items mentioned above, namely Jump at the top level and under it Back and Out. It does not matter where the items first appear; you use the arrow keys just above the “New” and “Delete” buttons to move around the item you have selected.  For the “Id” field of the “Out” item, put idMenuOut. You should make the menu inspector window look like this:&lt;br /&gt;
&lt;br /&gt;
[[Image:1j.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When you have the menu items properly arranged, click OK.   &lt;br /&gt;
&lt;br /&gt;
When you now build and run, you will see the new menu.  But clicking Jump | Out  does not close the program as desired because we have not programmed the response to that event.  To do so, we want to make wxSmith set up the frame for the routine which will be called when the menu item “Out” is clicked.  Go to the Management pane, Resources tab and persistently click on the little right-pointing triangles until the “Out” item can be seen, as in the screen shot below.&lt;br /&gt;
&lt;br /&gt;
[[Image:1k.png]]&lt;br /&gt;
&lt;br /&gt;
      &lt;br /&gt;
Click on the word “Out” and then on the {} icon in the panel below the Management pane. That will cause the pane below to show the words “EVT_MENU     --None--” . Click on the word “None” or the down arrow at the right end of the field; a menu drops down.  Pick the item  “-- Add New Handler --”, accept the suggested name (OnMenu3Selected), and over in the editor, the frame of our handler has been written, as shown below.  We have only to write the code, which will be simply “Close();”.&lt;br /&gt;
&lt;br /&gt;
[[Image:1l.png]]&lt;br /&gt;
&lt;br /&gt;
Now we can “Build and run”, drop down our menu, click on “Out”, and the program closes, as desired.&lt;br /&gt;
&lt;br /&gt;
== Windows and Components ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Each window in wxSmith is made of components. All your buttons, text boxes, lists, and so on are components. Also some more abstract things like sizers, spacers (used to add empty space), menu entries or even timers are also components.&lt;br /&gt;
&lt;br /&gt;
Every window has a root component. For a dialog window, it would be a wxDialog component; for a frame window, it would be wxFrame component; for a panel it would be a wxPanel component. In the [[wxSmith tutorial: Hello world|previous tutorial]] you probably noticed that some components may have &amp;quot;children&amp;quot;. For example, sizers had components inside their boxes. In this tutorial, you have seen sub-menu items inside main-menu items. The term &amp;quot;children&amp;quot; suggests the idea of a family tree, and indeed precisely such a tree structure is directly represented in the resource browser, as shown in the example below.&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_008.png]]&lt;br /&gt;
&lt;br /&gt;
In the picture above, you will see an example of such a tree. wxFontFaceEditorDlg is the currently opened form with a root component of type wxDialog. We can see that this resource consists of a few sizers and buttons, one text area and some spacers. It's definitely a fairly simple form. For more complicated forms, there could be more than 100 components. The tree (or Resource) browser can be very helpful for locating the code connected with a component; clicking on the component in the browser brings up its code in the editor.&lt;br /&gt;
&lt;br /&gt;
Each component has its properties - these are usually some values which describe the component. Some of them may affect the way component looks, some may change the component's behavior, and some may be dedicated to programming facilities. You will also find that there are some properties -- such as position and size -- common to many components.&lt;br /&gt;
&lt;br /&gt;
wxSmith allows you to edit components inside the properties browser (the window which is usually under the resource browser). If you select a component either by  clicking on it in the resource browser or by clicking on it inside the editor, the properties editor switches to edit its properties. Here's an example of the property browser:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_009.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can also use the Quick-Properties panel available after pressing the &amp;quot;Q&amp;quot; button on the right side of the editor:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_010.png]]&lt;br /&gt;
&lt;br /&gt;
The purpose of this panel is to provide most common properties in user-friendly way. It hasn't proven as useful as I had hoped, and you will probably find it helpful only while adjusting sizer-related settings.&lt;br /&gt;
&lt;br /&gt;
The last and the easiest way to work on a component is directly in the editor. You can grab drag boxes and change the component's size. You can also change its position by simply dragging it to another place.&lt;br /&gt;
&lt;br /&gt;
=== Excercise with Components ===&lt;br /&gt;
&lt;br /&gt;
Enough generalities; let's play with components. We can continue with the project started at the beginning of this tutorial. First let's add wxFlexGridSizer into our window. Like all sizers, it is located in Layout tab. (You'll remember how to add components from the [[wxSmith tutorial: Hello world|previous tutorial]]). Now let's add the following components into the sizer in the order given: wxButton, wxStaticText, wxTextCtrl, wxRadioButton and wxCheckBox. They can all be found on the Standard tab. The result should look like this:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_011.png]]&lt;br /&gt;
&lt;br /&gt;
In this picture, components I've selected have a light red border.&lt;br /&gt;
&lt;br /&gt;
Now that we have our playground, let's change some components. First, let's change the label and color of the button. To do so, click on the button and move to the properties browser. &amp;quot;Label&amp;quot; is the first property, and it's quite easy to change. Just click on the word &amp;quot;Label&amp;quot; on the right and type new text.&lt;br /&gt;
&lt;br /&gt;
Color is little bit harder to find. Usually components have two colors - Background and Foreground color. Background, as the name implies, is used to fill the component's background. Foreground, on the other hand, is used to paint some content onto the background. Note that there's no strict interpretation of these colors so you should experiment to find out their meaning. In wxButton, Background is what we want.&lt;br /&gt;
So let's find the Background property. It's value can be changed by using combobox:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_012.png]]&lt;br /&gt;
&lt;br /&gt;
On the list you may find set of predefined system colors. When you choose one of them, they will be read from current system settings making you application compatible with system theme. There are also two special entries - Default (which means that we do not want to set our color) and Custom. When you select Custom, wxSmith will open a color dialog where you can choose any color you like. I have chosen light green, and here's the result:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_013.png]]&lt;br /&gt;
&lt;br /&gt;
There are also other properties we could talk about, but the best way to learn them is to play with them, so I leave those discoveries to you.&lt;br /&gt;
&lt;br /&gt;
Now let's use the mouse.&lt;br /&gt;
&lt;br /&gt;
The selected component will have eight black boxes -- drag handles -- around it. These boxes can be used to change the size of the component. You will easily notice when the mouse is over a handle because the cursor changes. Let's resize the wxTextCtrl (edit box):&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_014.png]]&lt;br /&gt;
&lt;br /&gt;
You may see that resizing the component will also change properties in the browser - '''Default Size''' is unchecked now and '''Width''' and '''Height''' are set to required values. There's another property which seems to be untouched - '''Size in Dialog Units''', which is also related to size. I'll explain it a bit.&lt;br /&gt;
&lt;br /&gt;
Usually when you must specify size (or other size-related thing) you provide a value in pixels. Alternatively you can specify values in a unit called a '''Dialog Unit'''. A '''Dialog Unit'' is usually a little bit bigger than one pixel and it's size depends of the size of the current font (actually it's the size of the font of some component's parent which has a font). This is useful when you want some values to be proportional to the size of text presented in the window. &lt;br /&gt;
&lt;br /&gt;
If you check '''Size in Dialog Units'', wxSmith will take care of it and sizes will be calculated in Dialog Units instead of pixels (although, naturally, you will still be able to resize components).&lt;br /&gt;
&lt;br /&gt;
Now let's change the position of the radio box. &amp;quot;But, wait,&amp;quot; you may say, &amp;quot;I thought you said that the sizer is responsible for the positioning.&amp;quot; That's right. We have limited possibilities to change position. Inside one sizer we can only reorder components; for more complex forms we can also move a component between two sizers or to areas where sizers do not apply. So, back to our example, let's move the radio box to position it right after the button. To do so, click on the radio button and drag it onto the button. When you start dragging, you will notice that the area of the sizer changes color to blue. This color change is a aid to show you what will be the new position of the dragged component. When you move the cursor onto the button, half of the button will become light-blue. When the left half is highlighted, the dragged component will be added before it. When the right half is highlighted, dragged component will be added after it. And when there's no highlighted component, the new component will be added as the last child of the parent:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_015.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When you drop the component, it will change it's position. Note that all the components after the new position also shift. That happens because the default setting of the wxFlexGridSizer allows only 3 components in one row (this can be changed in property browser) so the components just adapted to the new order.&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_016.png]]&lt;br /&gt;
&lt;br /&gt;
==Sizers== &lt;br /&gt;
&lt;br /&gt;
Now let's learn a little bit about components available in wxSmith. I'll describe all supported sizers and a few important components from the Standard palette. Let's start with sizers.&lt;br /&gt;
&lt;br /&gt;
We already know that sizers are responsible for automatically setting the position and size of some components. But how do they do that? Well, it depends on which sizer has been used. So what are the rules? The generic rule is that the sizer tries to use all its available space and place the components it manages in such way that they do not overlap. If the area available to the sizer is too small, it requests a bigger area, so you can be sure that no component will fall out of the window. (Unfortunately, you cannot be sure that after such adjustments the window will be small enough to fit on the screen, so be careful about that.) Another rule which should be mentioned here is that sizers automatically set-up the minimum size required by the window. Basically when you edit a window using sizers, you should be aware that you edit the smallest layout and without some tricks, you won't be able to resize the window to something smaller.&lt;br /&gt;
&lt;br /&gt;
Here are descriptions of all sizers available in wxSmith:&lt;br /&gt;
&lt;br /&gt;
=== wxBoxSizer ===&lt;br /&gt;
&lt;br /&gt;
wxBoxSizer is the most basic sizer available in wxWidgets. It's purpose is to align components in one line - one next to another - either horizontally or vertically. This sizer also tries to keep some proportions between components - for a horizontal sizer you can set factors which will keep proportionality of widths and the height of the sizer area will be equal to the height of the tallest component. Similarly, vertical sizers keep heights proportional and the width will be taken as the widest component. You specify whether the sizer is to be horizontal or vertical in the sizer's property browser.&lt;br /&gt;
&lt;br /&gt;
Here are examples of layout using box sizers (the first one is the horizontal one, the second is vertical one):&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_002.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In that example you may see that all components have the same width and height.&lt;br /&gt;
&lt;br /&gt;
But let's assume that we want Button2 to be two times wider that Button1 and Button3 to be three times wider than Button1. This can be easily done by using the Proportion property of managed components. By default, the value of all components is set to 1 so they have equal size. Changing the Proportion of second button to 2 would mean that it should be 2 times wider that the first or third one.&lt;br /&gt;
&lt;br /&gt;
Generally you can set any value you want here. One common technique is to set percentage values - for example setting proportions to values 20, 30 and 50 would mean that the first button should occupy 20% of the space, the second one 30% and the third one 50%. The special value 0 means that this component should be skipped in proportion calculations and it will won't automatically adjust it's size when the main window is resized.&lt;br /&gt;
&lt;br /&gt;
So if we want to get 1:2:3 proportions, we set 1 for Button1, 2 for Button2 and 3 for Button3. And here is the result:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_003.png]]&lt;br /&gt;
&lt;br /&gt;
Also note that if you create a resizable window and resize it, those 3 buttons will automatically grow and keep proportions. If you set the Proportion property for some component to 0, it won't change size as the user changes the size of the window. &lt;br /&gt;
&lt;br /&gt;
The other dimension which is not controlled by Proportion property may be controlled using the &amp;quot;Expand&amp;quot; and &amp;quot;Shaped&amp;quot; properties. They are simple checkboxes. If you check the first one, the component will expand it's width/height and will get the size of the biggest component managed by the same sizer. Selecting &amp;quot;Shaped&amp;quot; will also make the component resize but such components will try to keep the initial proportion between width and height so it doesn't have to use all available space. The effect of the &amp;quot;Expand&amp;quot; and &amp;quot;Shaped&amp;quot; properties can be seen when components differ in width or height; here's an example:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_004.png]]&lt;br /&gt;
&lt;br /&gt;
In this example, the first button is the biggest of the three. Its size will be used to adjust the sizes of the other buttons. The second one has its &amp;quot;Expand&amp;quot; property checked, and the third one does not. What can be seen here is that the third button expanded in only one dimension (the one managed by &amp;quot;Proportion&amp;quot; property), the second dimension was left untouched.&lt;br /&gt;
&lt;br /&gt;
You may also note that when a component does not fill its available area, it is centered. That's default behavior which can be changed. In the properties of components managed by sizer you will find properties called '''Horizontal align''' and '''Vertical align'''. Using these properties you can select where the component should be located when it's smaller that its available area.&lt;br /&gt;
&lt;br /&gt;
=== wxStaticBoxSizer ===&lt;br /&gt;
&lt;br /&gt;
This sizer is similar to wxBoxSizer with one exception: it adds an extra static box around managed components:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_005.png]]&lt;br /&gt;
&lt;br /&gt;
=== wxGridSizer ===&lt;br /&gt;
&lt;br /&gt;
This sizer is a little bit more advanced than wxBoxSizer because it aligns components on a grid, not on one line. You can specify the number of columns or number of rows in properties &amp;quot;Cols&amp;quot; and &amp;quot;Rows&amp;quot;. The default number of columns is set to 3 and number of rows is set to 0. When 0 is used, it means that sizer should automatically calculate this value to keep all managed components inside.&lt;br /&gt;
&lt;br /&gt;
This sizer makes an important assumption: all cells must have the same width and all must have the same height.  This means that the tallest managed component will set the height of all rows and the widest one will set the widths of all columns. If an component won't use the whole cell, it will be surrounded by empty space. (If you don't like this assumption, look at the wxFlexGridSizer.)&lt;br /&gt;
&lt;br /&gt;
Among the properties of a wxGridsizer you can also find horizontal and vertical spacings. These values set the spacing added between components. The result of using them is similar to using borders around managed components but with borders you would have to set borders for all components separately.&lt;br /&gt;
&lt;br /&gt;
In the case of wxGridSizer, the &amp;quot;Proportion&amp;quot; value is not used. But you may use &amp;quot;Expand&amp;quot;, &amp;quot;Shaped&amp;quot; or placement properties to adjust the result.&lt;br /&gt;
&lt;br /&gt;
Here's an example of a grid sizer:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_006.png]]&lt;br /&gt;
&lt;br /&gt;
=== wxFlexGridSizer ===&lt;br /&gt;
&lt;br /&gt;
This is a very useful one. It works similarly to wxGridSizer; but it does not force all columns to have the same width nor all rows to have the same height. Also not all columns resize when there's more space available for the sizer. Comparing to wxGridSizer you will find two extra properties here: &amp;quot;Growable cols&amp;quot; and &amp;quot;Growable rows&amp;quot;. In these properties you may provide a list of columns / rows which should automatically resize by providing a list of numbers separated using comma (,). The numbers should start from 0, so if you would like the second and third column to resize, put &amp;quot;1,2&amp;quot; into &amp;quot;Growable cols&amp;quot;. This property is very useful to handle resizing of the window.&lt;br /&gt;
&lt;br /&gt;
Unfortunately you won't be able to set proportions other that 1:1 The &amp;quot;Proportion&amp;quot; property is also not used in this sizer.&lt;br /&gt;
&lt;br /&gt;
=== wxStdDialogButtonSizer ===&lt;br /&gt;
&lt;br /&gt;
This is a specialized sizer with one purpose - to provide a set of standard buttons with respect to the platform's look and feel. This sizer has a predefined list of components which it can handle - all are buttons and you can manage them using the sizer's properties. You cannot add your custom components into this sizer.&lt;br /&gt;
&lt;br /&gt;
Each button on this sizer has two properties in the sizer - whether the button should be enabled (for example wxID_OK for OK button) and its label. Note that labels for most buttons will be generated automatically and wxWidgets will skip them when it can read them from system settings. For example, on Linux only the Context Help button does not have a system-supplied label. It is also very probable that labels will be provided with language-specific strings (depending on the current system language). Not all configurations of buttons are valid - they won't break the application but buttons will overlap (for example Yes and OK).&lt;br /&gt;
&lt;br /&gt;
Here is an example of this sizer. My system is set up in Polish, so the labels are automatically in Polish.  They mean: Help, Cancel, Apply and OK.&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_007.png]]&lt;br /&gt;
&lt;br /&gt;
This screenshot was taken on a Linux box. You may see that the buttons have an extra image which is not available for standard buttons. With such a layout, users of the application will feel more comfortable, and such 'small' things make users say that the GUI was designed very well. On MS Windows, the sizer would have the same buttons but without images and they would be in a different order - the one that is used on windows by default.&lt;br /&gt;
&lt;br /&gt;
All of the above sizers can be found on the &amp;quot;Layout&amp;quot; tab. You can find two other components there which are not sizers but can be used for layout purposes. &lt;br /&gt;
&lt;br /&gt;
The first one is Spacer. It can be added to other sizers when you simply need some empty space instead of any particular component. Spacers have only width and height.&lt;br /&gt;
&lt;br /&gt;
The second one is wxSplitterWindow. When you use this component, you can add one or two child components into it and they will be separated with a dividing line (it's called a sash in wxWidgets). On the application you can drag it to dynamically adjust the size of managed components.&lt;br /&gt;
&lt;br /&gt;
Now that we know something about sizers let's turn to other components.&lt;br /&gt;
&lt;br /&gt;
== Especially Useful Standard Components ==&lt;br /&gt;
&lt;br /&gt;
wxWidgets provides all standard graphical components like static text, buttons, edit boxes, combo boxes, and so on. All are supported in wxSmith, so you can build a nice working environment. I'll briefly describe the components that are really useful in standard applications.&lt;br /&gt;
&lt;br /&gt;
=== wxButton ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_017.png]]&lt;br /&gt;
&lt;br /&gt;
This is standard button, a very common component. Its purpose is to run some piece of code when the user clicks on it. That's it.&lt;br /&gt;
&lt;br /&gt;
=== wxStaticText ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_018.png]]&lt;br /&gt;
&lt;br /&gt;
This component only shows user-defined text on the window. It doesn't generate any events.&lt;br /&gt;
&lt;br /&gt;
=== wxTextCtrl ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_019.png]]&lt;br /&gt;
&lt;br /&gt;
This component let's the user enter some text. It's basic functionality allows entering one-line text. After changing its properties, it may become a more advanced multiline editor with support for different fonts, colors and text styles.&lt;br /&gt;
&lt;br /&gt;
=== wxPanel ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_020.png]]&lt;br /&gt;
&lt;br /&gt;
Although this component may be a separate window, it is most commonly added as a comoponent in a parent window. It is particularly useful as a background for other components. It has a few functionalities - it can be used as background in notebooks and it may be a place where you put components without sizers. But it also has a few drawbacks - wxWidgets tends to do some tricks with wxPanel's size so it's not always possible to set the size we really want.&lt;br /&gt;
&lt;br /&gt;
=== wxChoice ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_021.png]]&lt;br /&gt;
&lt;br /&gt;
This component provides a drop-down list with available options. It works similarly to wxComboBox but the user cannot enter values. It can be used in situations when the user should use one of several available options. An event is generated when the user changes the selected component.&lt;br /&gt;
&lt;br /&gt;
=== wxComboBox ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_022.png]]&lt;br /&gt;
&lt;br /&gt;
This component provides a drop-down list similar to that of wxChoice. In the case of this component, the user can select one of the available values or enter his own if the component is not in a Read-Only state. A very good example of its usage is to provide some text entry with a stored list of previously entered values (like in search boxes). Like wxChoice, changing the selection generates an event. Additionally, changing the text and pressing enter also generates events. Tutorial 9 will illustrate its use. &lt;br /&gt;
&lt;br /&gt;
=== wxListBox ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_023.png]]&lt;br /&gt;
&lt;br /&gt;
This component provides a list where you can select one or more components. Changing the component or double-clicking on it generates an event.&lt;br /&gt;
&lt;br /&gt;
=== wxNotebook ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_024.png]]&lt;br /&gt;
&lt;br /&gt;
Notebook is very useful for complex resources since it groups content under tabs. Additionally, wxChoicebook and wxCombobook are also available but are not described here. Changing the selected notebook generates two events: one when the page starts to change (before change) and one when the page is finished changing (after change).&lt;br /&gt;
&lt;br /&gt;
=== wxCheckBox ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_025.png]]&lt;br /&gt;
&lt;br /&gt;
Check boxes may be used to map boolean values. Additionally, 2-state boxes can also be generated (with values: yes/no/unspecified). Changing the value emits an event.&lt;br /&gt;
&lt;br /&gt;
=== wxRadioBox ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_026.png]]&lt;br /&gt;
&lt;br /&gt;
Radio box works similarly to check boxes. The difference is that only one radiobox in a group can be selected. Groups may be defined by using wxRB_GROUP style. A radiobox which has this style set starts a new group. Changing the selected radiobox emits an event.&lt;br /&gt;
&lt;br /&gt;
=== wxGauge ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_027.png]]&lt;br /&gt;
&lt;br /&gt;
This component, also called a Progress Bar, can be used to show the progress of some operation. It's very useful when doing some calculation intensive operations. It can prevent users from getting frustrated when they do not see anything happening on the screen but only a window which seems hung.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt; * * * * &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
That's the end of this tutorial. We will get more experience with these subjects in the following tutorials. But you can also learn a lot by experimenting: add components, change properties, resize, move. You may try adding sizers into other sizers, a very useful technique absolutely required for more complex forms. Join me for the next tutorial!&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;'''[[WxSmith tutorial: Hello world|Previous]] | [[WxSmith tutorials|Index]] | [[WxSmith tutorial: Building more complex window|Next]]'''&amp;lt;/center&amp;gt;&lt;/div&gt;</summary>
		<author><name>Chatumao</name></author>
	</entry>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=Wxsmith_tutorial:_Working_with_items&amp;diff=7561</id>
		<title>Wxsmith tutorial: Working with items</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=Wxsmith_tutorial:_Working_with_items&amp;diff=7561"/>
		<updated>2013-04-29T09:58:58Z</updated>

		<summary type="html">&lt;p&gt;Chatumao: /* Windows and Components */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:wxSmith Documentation]]&lt;br /&gt;
= Working with Menus and Components =&lt;br /&gt;
&lt;br /&gt;
In the [[wxSmith tutorial: Hello world|previous tutorial]] we learned how to create a small application using wxWidgets. We created a window with a few components inside. In this tutorial, we will first see how to use the menu bar at the top of the main window and then focus on sizers and wxWidgets components which can be put on a form or window. &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''A Note on Terminology'''&lt;br /&gt;
&lt;br /&gt;
BYO, the creator of wxSmith and original author of these tutorials, wrote &amp;quot;Each resource in wxSmith is made of items. All your buttons, text boxes, lists etc are items. Also some more abstract things like sizers, spacers (used to add empty space), menu entries or even timers are also called items in wxSmith. So basically anything that's inside the resource may be called an item. I'll also use the term component since it reflects the valid meaning too.&amp;quot; &lt;br /&gt;
&lt;br /&gt;
In fact, the word &amp;quot;item&amp;quot; is not found in the index of the Julian Smart and Kevin Hock book ''Cross-Platform GUI Programming with wxWidgets.'' The word is used in the book specifically for the elements of the drop-down lists of choice boxes, combo boxes, and other members of the class wxControlWithItems. In the revision of these tutorials, the word &amp;quot;item&amp;quot; is therefore generally being reserved for items in these lists and for items in a menu. Otherwise, the word &amp;quot;item&amp;quot; is generally being replaced by &amp;quot;component&amp;quot;, &amp;quot;widget&amp;quot;, or &amp;quot;control&amp;quot; as seems appropriate, though of course, it is also occasionally used with no special technical meaning. Also, BYO often uses the word &amp;quot;resource&amp;quot; to refer to a form or window. Smart and Hock use word the &amp;quot;resource&amp;quot; sparingly, mainly in the context of &amp;quot;resource files&amp;quot;.  The word seems overworked and needlessly abstract, so when what is intended is a form or window, the revisions will use one of those words, with no sharp distinction between them.   &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Note that all screenshots presented here were made on Linux but they should not be very different from the windows ones.&lt;br /&gt;
&lt;br /&gt;
== Working with Menus ==&lt;br /&gt;
&lt;br /&gt;
Following the directions given in Tutorial 1, start a new Code::Blocks project; call it Tutorial_2. Remember to add &amp;quot;event.Skip(TRUE);&amp;quot; at the appropriate place in the code, as explained in Tutorial 1. &lt;br /&gt;
&lt;br /&gt;
Build and run the program. You will see that it has two items on the main menu. We will add one more, Jump, at the top level and under it two more, Back and Out. Back will do nothing, but we will make Out close the program.&lt;br /&gt;
&lt;br /&gt;
Click on the “Tutorial_2frame.wxs” tab of the Editor window.  Just below the words “Tutorial_2framw.wxs” is a panel with two square icons.  Double left click on the leftmost one, which shows the word ''File'' suggestive of a menu.  Up comes the menu inspector window shown below.&lt;br /&gt;
&lt;br /&gt;
[[Image:1i.png]]  &lt;br /&gt;
   &lt;br /&gt;
Click on the various menu items shown and note how the content of the fields shown on the right side of the window are filled in.  Then click on the New button (in the lower right part of the window) to add the three additional menu items mentioned above, namely Jump at the top level and under it Back and Out. It does not matter where the items first appear; you use the arrow keys just above the “New” and “Delete” buttons to move around the item you have selected.  For the “Id” field of the “Out” item, put idMenuOut. You should make the menu inspector window look like this:&lt;br /&gt;
&lt;br /&gt;
[[Image:1j.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When you have the menu items properly arranged, click OK.   &lt;br /&gt;
&lt;br /&gt;
When you now build and run, you will see the new menu.  But clicking Jump | Out  does not close the program as desired because we have not programmed the response to that event.  To do so, we want to make wxSmith set up the frame for the routine which will be called when the menu item “Out” is clicked.  Go to the Management pane, Resources tab and persistently click on the little right-pointing triangles until the “Out” item can be seen, as in the screen shot below.&lt;br /&gt;
&lt;br /&gt;
[[Image:1k.png]]&lt;br /&gt;
&lt;br /&gt;
      &lt;br /&gt;
Click on the word “Out” and then on the {} icon in the panel below the Management pane. That will cause the pane below to show the words “EVT_MENU     --None--” . Click on the word “None” or the down arrow at the right end of the field; a menu drops down.  Pick the item  “-- Add New Handler --”, accept the suggested name (OnMenu3Selected), and over in the editor, the frame of our handler has been written, as shown below.  We have only to write the code, which will be simply “Close();”.&lt;br /&gt;
&lt;br /&gt;
[[Image:1l.png]]&lt;br /&gt;
&lt;br /&gt;
Now we can “Build and run”, drop down our menu, click on “Out”, and the program closes, as desired.&lt;br /&gt;
&lt;br /&gt;
== Windows and Components ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Each window in wxSmith is made of components. All your buttons, text boxes, lists, and so on are components. Also some more abstract things like sizers, spacers (used to add empty space), menu entries or even timers are also components.&lt;br /&gt;
&lt;br /&gt;
Every window has a root component. For a dialog window, it would be a wxDialog component; for a frame window, it would be wxFrame component; for a panel it would be a wxPanel component. In the [[wxSmith tutorial: Hello world|previous tutorial]] you probably noticed that some components may have &amp;quot;children&amp;quot;. For example, sizers had components inside their boxes. In this tutorial, you have seen sub-menu items inside main-menu items. The term &amp;quot;children&amp;quot; suggests the idea of a family tree, and indeed precisely such a tree structure is directly represented in the resource browser, as shown in the example below.&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_008.png]]&lt;br /&gt;
&lt;br /&gt;
In the picture above, you will see an example of such a tree. wxFontFaceEditorDlg is the currently opened form with a root component of type wxDialog. We can see that this resource consists of a few sizers and buttons, one text area and some spacers. It's definitely a fairly simple form. For more complicated forms, there could be more than 100 components. The tree (or Resource) browser can be very helpful for locating the code connected with a component; clicking on the component in the browser brings up its code in the editor.&lt;br /&gt;
&lt;br /&gt;
Each component has its properties - these are usually some values which describe the component. Some of them may affect the way component looks, some may change the component's behavior, and some may be dedicated to programming facilities. You will also find that there are some properties -- such as position and size -- common to many components.&lt;br /&gt;
&lt;br /&gt;
wxSmith allows you to edit components inside the properties browser (the window which is usually under the resource browser). If you select a component either by  clicking on it in the resource browser or by clicking on it inside editor, the properties editor switches to edit its properties. Here's an example of the property browser:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_009.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can also use the Quick-Properties panel available after pressing the &amp;quot;Q&amp;quot; button on the right side of the editor:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_010.png]]&lt;br /&gt;
&lt;br /&gt;
The purpose of this panel is to provide most common properties in user-friendly way. It hasn't proven as useful as I had hoped, and you will probably find it helpful only while adjusting sizer-related settings.&lt;br /&gt;
&lt;br /&gt;
The last and the easiest way to work on a component is directly in the editor. You can grab drag boxes and change the component's size. You can also change its position by simply dragging it to another place.&lt;br /&gt;
&lt;br /&gt;
=== Excercise with Components ===&lt;br /&gt;
&lt;br /&gt;
Enough generalities; let's play with components. We can continue with the project started at the beginning of this tutorial. First let's add wxFlexGridSizer into our window. Like all sizers, it is located in Layout tab. (You'll remember how to add components from the [[wxSmith tutorial: Hello world|previous tutorial]]). Now let's add the following components into the sizer in the order given: wxButton, wxStaticText, wxTextCtrl, wxRadioButton and wxCheckBox. They can all be found on the Standard tab. The result should look like this:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_011.png]]&lt;br /&gt;
&lt;br /&gt;
In this picture, components I've selected have a light red border.&lt;br /&gt;
&lt;br /&gt;
Now that we have our playground, let's change some components. First, let's change the label and color of the button. To do so, click on the button and move to the properties browser. &amp;quot;Label&amp;quot; is the first property, and it's quite easy to change. Just click on the word &amp;quot;Label&amp;quot; on the right and type new text.&lt;br /&gt;
&lt;br /&gt;
Color is little bit harder to find. Usually components have two colors - Background and Foreground color. Background, as the name implies, is used to fill the component's background. Foreground, on the other hand, is used to paint some content onto the background. Note that there's no strict interpretation of these colors so you should experiment to find out their meaning. In wxButton, Background is what we want.&lt;br /&gt;
So let's find the Background property. It's value can be changed by using combobox:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_012.png]]&lt;br /&gt;
&lt;br /&gt;
On the list you may find set of predefined system colors. When you choose one of them, they will be read from current system settings making you application compatible with system theme. There are also two special entries - Default (which means that we do not want to set our color) and Custom. When you select Custom, wxSmith will open a color dialog where you can choose any color you like. I have chosen light green, and here's the result:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_013.png]]&lt;br /&gt;
&lt;br /&gt;
There are also other properties we could talk about, but the best way to learn them is to play with them, so I leave those discoveries to you.&lt;br /&gt;
&lt;br /&gt;
Now let's use the mouse.&lt;br /&gt;
&lt;br /&gt;
The selected component will have eight black boxes -- drag handles -- around it. These boxes can be used to change the size of the component. You will easily notice when the mouse is over a handle because the cursor changes. Let's resize the wxTextCtrl (edit box):&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_014.png]]&lt;br /&gt;
&lt;br /&gt;
You may see that resizing the component will also change properties in the browser - '''Default Size''' is unchecked now and '''Width''' and '''Height''' are set to required values. There's another property which seems to be untouched - '''Size in Dialog Units''', which is also related to size. I'll explain it a bit.&lt;br /&gt;
&lt;br /&gt;
Usually when you must specify size (or other size-related thing) you provide a value in pixels. Alternatively you can specify values in a unit called a '''Dialog Unit'''. A '''Dialog Unit'' is usually a little bit bigger than one pixel and it's size depends of the size of the current font (actually it's the size of the font of some component's parent which has a font). This is useful when you want some values to be proportional to the size of text presented in the window. &lt;br /&gt;
&lt;br /&gt;
If you check '''Size in Dialog Units'', wxSmith will take care of it and sizes will be calculated in Dialog Units instead of pixels (although, naturally, you will still be able to resize components).&lt;br /&gt;
&lt;br /&gt;
Now let's change the position of the radio box. &amp;quot;But, wait,&amp;quot; you may say, &amp;quot;I thought you said that the sizer is responsible for the positioning.&amp;quot; That's right. We have limited possibilities to change position. Inside one sizer we can only reorder components; for more complex forms we can also move a component between two sizers or to areas where sizers do not apply. So, back to our example, let's move the radio box to position it right after the button. To do so, click on the radio button and drag it onto the button. When you start dragging, you will notice that the area of the sizer changes color to blue. This color change is a aid to show you what will be the new position of the dragged component. When you move the cursor onto the button, half of the button will become light-blue. When the left half is highlighted, the dragged component will be added before it. When the right half is highlighted, dragged component will be added after it. And when there's no highlighted component, the new component will be added as the last child of the parent:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_015.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When you drop the component, it will change it's position. Note that all the components after the new position also shift. That happens because the default setting of the wxFlexGridSizer allows only 3 components in one row (this can be changed in property browser) so the components just adapted to the new order.&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_016.png]]&lt;br /&gt;
&lt;br /&gt;
==Sizers== &lt;br /&gt;
&lt;br /&gt;
Now let's learn a little bit about components available in wxSmith. I'll describe all supported sizers and a few important components from the Standard palette. Let's start with sizers.&lt;br /&gt;
&lt;br /&gt;
We already know that sizers are responsible for automatically setting the position and size of some components. But how do they do that? Well, it depends on which sizer has been used. So what are the rules? The generic rule is that the sizer tries to use all its available space and place the components it manages in such way that they do not overlap. If the area available to the sizer is too small, it requests a bigger area, so you can be sure that no component will fall out of the window. (Unfortunately, you cannot be sure that after such adjustments the window will be small enough to fit on the screen, so be careful about that.) Another rule which should be mentioned here is that sizers automatically set-up the minimum size required by the window. Basically when you edit a window using sizers, you should be aware that you edit the smallest layout and without some tricks, you won't be able to resize the window to something smaller.&lt;br /&gt;
&lt;br /&gt;
Here are descriptions of all sizers available in wxSmith:&lt;br /&gt;
&lt;br /&gt;
=== wxBoxSizer ===&lt;br /&gt;
&lt;br /&gt;
wxBoxSizer is the most basic sizer available in wxWidgets. It's purpose is to align components in one line - one next to another - either horizontally or vertically. This sizer also tries to keep some proportions between components - for a horizontal sizer you can set factors which will keep proportionality of widths and the height of the sizer area will be equal to the height of the tallest component. Similarly, vertical sizers keep heights proportional and the width will be taken as the widest component. You specify whether the sizer is to be horizontal or vertical in the sizer's property browser.&lt;br /&gt;
&lt;br /&gt;
Here are examples of layout using box sizers (the first one is the horizontal one, the second is vertical one):&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_002.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In that example you may see that all components have the same width and height.&lt;br /&gt;
&lt;br /&gt;
But let's assume that we want Button2 to be two times wider that Button1 and Button3 to be three times wider than Button1. This can be easily done by using the Proportion property of managed components. By default, the value of all components is set to 1 so they have equal size. Changing the Proportion of second button to 2 would mean that it should be 2 times wider that the first or third one.&lt;br /&gt;
&lt;br /&gt;
Generally you can set any value you want here. One common technique is to set percentage values - for example setting proportions to values 20, 30 and 50 would mean that the first button should occupy 20% of the space, the second one 30% and the third one 50%. The special value 0 means that this component should be skipped in proportion calculations and it will won't automatically adjust it's size when the main window is resized.&lt;br /&gt;
&lt;br /&gt;
So if we want to get 1:2:3 proportions, we set 1 for Button1, 2 for Button2 and 3 for Button3. And here is the result:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_003.png]]&lt;br /&gt;
&lt;br /&gt;
Also note that if you create a resizable window and resize it, those 3 buttons will automatically grow and keep proportions. If you set the Proportion property for some component to 0, it won't change size as the user changes the size of the window. &lt;br /&gt;
&lt;br /&gt;
The other dimension which is not controlled by Proportion property may be controlled using the &amp;quot;Expand&amp;quot; and &amp;quot;Shaped&amp;quot; properties. They are simple checkboxes. If you check the first one, the component will expand it's width/height and will get the size of the biggest component managed by the same sizer. Selecting &amp;quot;Shaped&amp;quot; will also make the component resize but such components will try to keep the initial proportion between width and height so it doesn't have to use all available space. The effect of the &amp;quot;Expand&amp;quot; and &amp;quot;Shaped&amp;quot; properties can be seen when components differ in width or height; here's an example:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_004.png]]&lt;br /&gt;
&lt;br /&gt;
In this example, the first button is the biggest of the three. Its size will be used to adjust the sizes of the other buttons. The second one has its &amp;quot;Expand&amp;quot; property checked, and the third one does not. What can be seen here is that the third button expanded in only one dimension (the one managed by &amp;quot;Proportion&amp;quot; property), the second dimension was left untouched.&lt;br /&gt;
&lt;br /&gt;
You may also note that when a component does not fill its available area, it is centered. That's default behavior which can be changed. In the properties of components managed by sizer you will find properties called '''Horizontal align''' and '''Vertical align'''. Using these properties you can select where the component should be located when it's smaller that its available area.&lt;br /&gt;
&lt;br /&gt;
=== wxStaticBoxSizer ===&lt;br /&gt;
&lt;br /&gt;
This sizer is similar to wxBoxSizer with one exception: it adds an extra static box around managed components:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_005.png]]&lt;br /&gt;
&lt;br /&gt;
=== wxGridSizer ===&lt;br /&gt;
&lt;br /&gt;
This sizer is a little bit more advanced than wxBoxSizer because it aligns components on a grid, not on one line. You can specify the number of columns or number of rows in properties &amp;quot;Cols&amp;quot; and &amp;quot;Rows&amp;quot;. The default number of columns is set to 3 and number of rows is set to 0. When 0 is used, it means that sizer should automatically calculate this value to keep all managed components inside.&lt;br /&gt;
&lt;br /&gt;
This sizer makes an important assumption: all cells must have the same width and all must have the same height.  This means that the tallest managed component will set the height of all rows and the widest one will set the widths of all columns. If an component won't use the whole cell, it will be surrounded by empty space. (If you don't like this assumption, look at the wxFlexGridSizer.)&lt;br /&gt;
&lt;br /&gt;
Among the properties of a wxGridsizer you can also find horizontal and vertical spacings. These values set the spacing added between components. The result of using them is similar to using borders around managed components but with borders you would have to set borders for all components separately.&lt;br /&gt;
&lt;br /&gt;
In the case of wxGridSizer, the &amp;quot;Proportion&amp;quot; value is not used. But you may use &amp;quot;Expand&amp;quot;, &amp;quot;Shaped&amp;quot; or placement properties to adjust the result.&lt;br /&gt;
&lt;br /&gt;
Here's an example of a grid sizer:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_006.png]]&lt;br /&gt;
&lt;br /&gt;
=== wxFlexGridSizer ===&lt;br /&gt;
&lt;br /&gt;
This is a very useful one. It works similarly to wxGridSizer; but it does not force all columns to have the same width nor all rows to have the same height. Also not all columns resize when there's more space available for the sizer. Comparing to wxGridSizer you will find two extra properties here: &amp;quot;Growable cols&amp;quot; and &amp;quot;Growable rows&amp;quot;. In these properties you may provide a list of columns / rows which should automatically resize by providing a list of numbers separated using comma (,). The numbers should start from 0, so if you would like the second and third column to resize, put &amp;quot;1,2&amp;quot; into &amp;quot;Growable cols&amp;quot;. This property is very useful to handle resizing of the window.&lt;br /&gt;
&lt;br /&gt;
Unfortunately you won't be able to set proportions other that 1:1 The &amp;quot;Proportion&amp;quot; property is also not used in this sizer.&lt;br /&gt;
&lt;br /&gt;
=== wxStdDialogButtonSizer ===&lt;br /&gt;
&lt;br /&gt;
This is a specialized sizer with one purpose - to provide a set of standard buttons with respect to the platform's look and feel. This sizer has a predefined list of components which it can handle - all are buttons and you can manage them using the sizer's properties. You cannot add your custom components into this sizer.&lt;br /&gt;
&lt;br /&gt;
Each button on this sizer has two properties in the sizer - whether the button should be enabled (for example wxID_OK for OK button) and its label. Note that labels for most buttons will be generated automatically and wxWidgets will skip them when it can read them from system settings. For example, on Linux only the Context Help button does not have a system-supplied label. It is also very probable that labels will be provided with language-specific strings (depending on the current system language). Not all configurations of buttons are valid - they won't break the application but buttons will overlap (for example Yes and OK).&lt;br /&gt;
&lt;br /&gt;
Here is an example of this sizer. My system is set up in Polish, so the labels are automatically in Polish.  They mean: Help, Cancel, Apply and OK.&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_007.png]]&lt;br /&gt;
&lt;br /&gt;
This screenshot was taken on a Linux box. You may see that the buttons have an extra image which is not available for standard buttons. With such a layout, users of the application will feel more comfortable, and such 'small' things make users say that the GUI was designed very well. On MS Windows, the sizer would have the same buttons but without images and they would be in a different order - the one that is used on windows by default.&lt;br /&gt;
&lt;br /&gt;
All of the above sizers can be found on the &amp;quot;Layout&amp;quot; tab. You can find two other components there which are not sizers but can be used for layout purposes. &lt;br /&gt;
&lt;br /&gt;
The first one is Spacer. It can be added to other sizers when you simply need some empty space instead of any particular component. Spacers have only width and height.&lt;br /&gt;
&lt;br /&gt;
The second one is wxSplitterWindow. When you use this component, you can add one or two child components into it and they will be separated with a dividing line (it's called a sash in wxWidgets). On the application you can drag it to dynamically adjust the size of managed components.&lt;br /&gt;
&lt;br /&gt;
Now that we know something about sizers let's turn to other components.&lt;br /&gt;
&lt;br /&gt;
== Especially Useful Standard Components ==&lt;br /&gt;
&lt;br /&gt;
wxWidgets provides all standard graphical components like static text, buttons, edit boxes, combo boxes, and so on. All are supported in wxSmith, so you can build a nice working environment. I'll briefly describe the components that are really useful in standard applications.&lt;br /&gt;
&lt;br /&gt;
=== wxButton ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_017.png]]&lt;br /&gt;
&lt;br /&gt;
This is standard button, a very common component. Its purpose is to run some piece of code when the user clicks on it. That's it.&lt;br /&gt;
&lt;br /&gt;
=== wxStaticText ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_018.png]]&lt;br /&gt;
&lt;br /&gt;
This component only shows user-defined text on the window. It doesn't generate any events.&lt;br /&gt;
&lt;br /&gt;
=== wxTextCtrl ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_019.png]]&lt;br /&gt;
&lt;br /&gt;
This component let's the user enter some text. It's basic functionality allows entering one-line text. After changing its properties, it may become a more advanced multiline editor with support for different fonts, colors and text styles.&lt;br /&gt;
&lt;br /&gt;
=== wxPanel ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_020.png]]&lt;br /&gt;
&lt;br /&gt;
Although this component may be a separate window, it is most commonly added as a comoponent in a parent window. It is particularly useful as a background for other components. It has a few functionalities - it can be used as background in notebooks and it may be a place where you put components without sizers. But it also has a few drawbacks - wxWidgets tends to do some tricks with wxPanel's size so it's not always possible to set the size we really want.&lt;br /&gt;
&lt;br /&gt;
=== wxChoice ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_021.png]]&lt;br /&gt;
&lt;br /&gt;
This component provides a drop-down list with available options. It works similarly to wxComboBox but the user cannot enter values. It can be used in situations when the user should use one of several available options. An event is generated when the user changes the selected component.&lt;br /&gt;
&lt;br /&gt;
=== wxComboBox ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_022.png]]&lt;br /&gt;
&lt;br /&gt;
This component provides a drop-down list similar to that of wxChoice. In the case of this component, the user can select one of the available values or enter his own if the component is not in a Read-Only state. A very good example of its usage is to provide some text entry with a stored list of previously entered values (like in search boxes). Like wxChoice, changing the selection generates an event. Additionally, changing the text and pressing enter also generates events. Tutorial 9 will illustrate its use. &lt;br /&gt;
&lt;br /&gt;
=== wxListBox ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_023.png]]&lt;br /&gt;
&lt;br /&gt;
This component provides a list where you can select one or more components. Changing the component or double-clicking on it generates an event.&lt;br /&gt;
&lt;br /&gt;
=== wxNotebook ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_024.png]]&lt;br /&gt;
&lt;br /&gt;
Notebook is very useful for complex resources since it groups content under tabs. Additionally, wxChoicebook and wxCombobook are also available but are not described here. Changing the selected notebook generates two events: one when the page starts to change (before change) and one when the page is finished changing (after change).&lt;br /&gt;
&lt;br /&gt;
=== wxCheckBox ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_025.png]]&lt;br /&gt;
&lt;br /&gt;
Check boxes may be used to map boolean values. Additionally, 2-state boxes can also be generated (with values: yes/no/unspecified). Changing the value emits an event.&lt;br /&gt;
&lt;br /&gt;
=== wxRadioBox ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_026.png]]&lt;br /&gt;
&lt;br /&gt;
Radio box works similarly to check boxes. The difference is that only one radiobox in a group can be selected. Groups may be defined by using wxRB_GROUP style. A radiobox which has this style set starts a new group. Changing the selected radiobox emits an event.&lt;br /&gt;
&lt;br /&gt;
=== wxGauge ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_027.png]]&lt;br /&gt;
&lt;br /&gt;
This component, also called a Progress Bar, can be used to show the progress of some operation. It's very useful when doing some calculation intensive operations. It can prevent users from getting frustrated when they do not see anything happening on the screen but only a window which seems hung.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt; * * * * &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
That's the end of this tutorial. We will get more experience with these subjects in the following tutorials. But you can also learn a lot by experimenting: add components, change properties, resize, move. You may try adding sizers into other sizers, a very useful technique absolutely required for more complex forms. Join me for the next tutorial!&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;'''[[WxSmith tutorial: Hello world|Previous]] | [[WxSmith tutorials|Index]] | [[WxSmith tutorial: Building more complex window|Next]]'''&amp;lt;/center&amp;gt;&lt;/div&gt;</summary>
		<author><name>Chatumao</name></author>
	</entry>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=Wxsmith_tutorial:_Working_with_items&amp;diff=7560</id>
		<title>Wxsmith tutorial: Working with items</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=Wxsmith_tutorial:_Working_with_items&amp;diff=7560"/>
		<updated>2013-04-29T09:51:59Z</updated>

		<summary type="html">&lt;p&gt;Chatumao: /* Windows and Components */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:wxSmith Documentation]]&lt;br /&gt;
= Working with Menus and Components =&lt;br /&gt;
&lt;br /&gt;
In the [[wxSmith tutorial: Hello world|previous tutorial]] we learned how to create a small application using wxWidgets. We created a window with a few components inside. In this tutorial, we will first see how to use the menu bar at the top of the main window and then focus on sizers and wxWidgets components which can be put on a form or window. &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''A Note on Terminology'''&lt;br /&gt;
&lt;br /&gt;
BYO, the creator of wxSmith and original author of these tutorials, wrote &amp;quot;Each resource in wxSmith is made of items. All your buttons, text boxes, lists etc are items. Also some more abstract things like sizers, spacers (used to add empty space), menu entries or even timers are also called items in wxSmith. So basically anything that's inside the resource may be called an item. I'll also use the term component since it reflects the valid meaning too.&amp;quot; &lt;br /&gt;
&lt;br /&gt;
In fact, the word &amp;quot;item&amp;quot; is not found in the index of the Julian Smart and Kevin Hock book ''Cross-Platform GUI Programming with wxWidgets.'' The word is used in the book specifically for the elements of the drop-down lists of choice boxes, combo boxes, and other members of the class wxControlWithItems. In the revision of these tutorials, the word &amp;quot;item&amp;quot; is therefore generally being reserved for items in these lists and for items in a menu. Otherwise, the word &amp;quot;item&amp;quot; is generally being replaced by &amp;quot;component&amp;quot;, &amp;quot;widget&amp;quot;, or &amp;quot;control&amp;quot; as seems appropriate, though of course, it is also occasionally used with no special technical meaning. Also, BYO often uses the word &amp;quot;resource&amp;quot; to refer to a form or window. Smart and Hock use word the &amp;quot;resource&amp;quot; sparingly, mainly in the context of &amp;quot;resource files&amp;quot;.  The word seems overworked and needlessly abstract, so when what is intended is a form or window, the revisions will use one of those words, with no sharp distinction between them.   &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Note that all screenshots presented here were made on Linux but they should not be very different from the windows ones.&lt;br /&gt;
&lt;br /&gt;
== Working with Menus ==&lt;br /&gt;
&lt;br /&gt;
Following the directions given in Tutorial 1, start a new Code::Blocks project; call it Tutorial_2. Remember to add &amp;quot;event.Skip(TRUE);&amp;quot; at the appropriate place in the code, as explained in Tutorial 1. &lt;br /&gt;
&lt;br /&gt;
Build and run the program. You will see that it has two items on the main menu. We will add one more, Jump, at the top level and under it two more, Back and Out. Back will do nothing, but we will make Out close the program.&lt;br /&gt;
&lt;br /&gt;
Click on the “Tutorial_2frame.wxs” tab of the Editor window.  Just below the words “Tutorial_2framw.wxs” is a panel with two square icons.  Double left click on the leftmost one, which shows the word ''File'' suggestive of a menu.  Up comes the menu inspector window shown below.&lt;br /&gt;
&lt;br /&gt;
[[Image:1i.png]]  &lt;br /&gt;
   &lt;br /&gt;
Click on the various menu items shown and note how the content of the fields shown on the right side of the window are filled in.  Then click on the New button (in the lower right part of the window) to add the three additional menu items mentioned above, namely Jump at the top level and under it Back and Out. It does not matter where the items first appear; you use the arrow keys just above the “New” and “Delete” buttons to move around the item you have selected.  For the “Id” field of the “Out” item, put idMenuOut. You should make the menu inspector window look like this:&lt;br /&gt;
&lt;br /&gt;
[[Image:1j.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When you have the menu items properly arranged, click OK.   &lt;br /&gt;
&lt;br /&gt;
When you now build and run, you will see the new menu.  But clicking Jump | Out  does not close the program as desired because we have not programmed the response to that event.  To do so, we want to make wxSmith set up the frame for the routine which will be called when the menu item “Out” is clicked.  Go to the Management pane, Resources tab and persistently click on the little right-pointing triangles until the “Out” item can be seen, as in the screen shot below.&lt;br /&gt;
&lt;br /&gt;
[[Image:1k.png]]&lt;br /&gt;
&lt;br /&gt;
      &lt;br /&gt;
Click on the word “Out” and then on the {} icon in the panel below the Management pane. That will cause the pane below to show the words “EVT_MENU     --None--” . Click on the word “None” or the down arrow at the right end of the field; a menu drops down.  Pick the item  “-- Add New Handler --”, accept the suggested name (OnMenu3Selected), and over in the editor, the frame of our handler has been written, as shown below.  We have only to write the code, which will be simply “Close();”.&lt;br /&gt;
&lt;br /&gt;
[[Image:1l.png]]&lt;br /&gt;
&lt;br /&gt;
Now we can “Build and run”, drop down our menu, click on “Out”, and the program closes, as desired.&lt;br /&gt;
&lt;br /&gt;
== Windows and Components ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Each window in wxSmith is made of components. All your buttons, text boxes, lists, and so on are components. Also some more abstract things like sizers, spacers (used to add empty space), menu entries or even timers are also components.&lt;br /&gt;
&lt;br /&gt;
Every window has a root component. For a dialog window, it would be a wxDialog component; for a frame window, it would be wxFrame component; for a panel it would be a wxPanel component. In the [[wxSmith tutorial: Hello world|previous tutorial]] you probably noticed that some components may have &amp;quot;children&amp;quot;. For example, sizers had components inside their boxes. In this tutorial, you have seen sub-menu items inside main-menu items. The term &amp;quot;children&amp;quot; suggests the idea of a family tree, and indeed precisely such a tree structure is directly represented in the resource browser, as shown in the example below.&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_008.png]]&lt;br /&gt;
&lt;br /&gt;
In the picture above, you will see an example of such a tree. wxFontFaceEditorDlg is the currently opened form with a root component of type wxDialog. We can see that this resource consists of a few sizers and buttons, one text area and some spacers. It's definitely a fairly simple form. For more complicated forms, there could be more than 100 components. The tree (or Resource) browser can be very helpful for locating the code connected with a component; clicking on the component in the browser brings up its code in the editor.&lt;br /&gt;
&lt;br /&gt;
Each component has its properties - these are usually some values which describe the component. Some of them may affect the way component looks, some may change the component's behavior, and some may be dedicated to programming facilities. You will also find that there are some properties -- such as position and size -- common to many components.&lt;br /&gt;
&lt;br /&gt;
wxSmith allows you to edit components inside the properties browser (the window which is usually under the resource browser). If you select an component either by  clicking on it in the resource browser or by clicking on it inside editor, the properties editor switches to edit its properties. Here's an example of the property browser:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_009.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can also use the Quick-Properties panel available after pressing the &amp;quot;Q&amp;quot; button on the right side of the editor:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_010.png]]&lt;br /&gt;
&lt;br /&gt;
The purpose of this panel is to provide most common properties in user-friendly way. It hasn't proven as useful as I had hoped, and you will probably find it helpful only while adjusting sizer-related settings.&lt;br /&gt;
&lt;br /&gt;
The last and the easiest way to work on a component is directly in the editor. You can grab drag boxes and change the component's size. You can also change its position by simply dragging it to another place.&lt;br /&gt;
&lt;br /&gt;
=== Excercise with Components ===&lt;br /&gt;
&lt;br /&gt;
Enough generalities; let's play with components. We can continue with the project started at the beginning of this tutorial. First let's add wxFlexGridSizer into our window. Like all sizers, it is located in Layout tab. (You'll remember how to add components from the [[wxSmith tutorial: Hello world|previous tutorial]]). Now let's add the following components into the sizer in the order given: wxButton, wxStaticText, wxTextCtrl, wxRadioButton and wxCheckBox. They can all be found on the Standard tab. The result should look like this:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_011.png]]&lt;br /&gt;
&lt;br /&gt;
In this picture, components I've selected have a light red border.&lt;br /&gt;
&lt;br /&gt;
Now that we have our playground, let's change some components. First, let's change the label and color of the button. To do so, click on the button and move to the properties browser. &amp;quot;Label&amp;quot; is the first property, and it's quite easy to change. Just click on the word &amp;quot;Label&amp;quot; on the right and type new text.&lt;br /&gt;
&lt;br /&gt;
Color is little bit harder to find. Usually components have two colors - Background and Foreground color. Background, as the name implies, is used to fill the component's background. Foreground, on the other hand, is used to paint some content onto the background. Note that there's no strict interpretation of these colors so you should experiment to find out their meaning. In wxButton, Background is what we want.&lt;br /&gt;
So let's find the Background property. It's value can be changed by using combobox:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_012.png]]&lt;br /&gt;
&lt;br /&gt;
On the list you may find set of predefined system colors. When you choose one of them, they will be read from current system settings making you application compatible with system theme. There are also two special entries - Default (which means that we do not want to set our color) and Custom. When you select Custom, wxSmith will open a color dialog where you can choose any color you like. I have chosen light green, and here's the result:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_013.png]]&lt;br /&gt;
&lt;br /&gt;
There are also other properties we could talk about, but the best way to learn them is to play with them, so I leave those discoveries to you.&lt;br /&gt;
&lt;br /&gt;
Now let's use the mouse.&lt;br /&gt;
&lt;br /&gt;
The selected component will have eight black boxes -- drag handles -- around it. These boxes can be used to change the size of the component. You will easily notice when the mouse is over a handle because the cursor changes. Let's resize the wxTextCtrl (edit box):&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_014.png]]&lt;br /&gt;
&lt;br /&gt;
You may see that resizing the component will also change properties in the browser - '''Default Size''' is unchecked now and '''Width''' and '''Height''' are set to required values. There's another property which seems to be untouched - '''Size in Dialog Units''', which is also related to size. I'll explain it a bit.&lt;br /&gt;
&lt;br /&gt;
Usually when you must specify size (or other size-related thing) you provide a value in pixels. Alternatively you can specify values in a unit called a '''Dialog Unit'''. A '''Dialog Unit'' is usually a little bit bigger than one pixel and it's size depends of the size of the current font (actually it's the size of the font of some component's parent which has a font). This is useful when you want some values to be proportional to the size of text presented in the window. &lt;br /&gt;
&lt;br /&gt;
If you check '''Size in Dialog Units'', wxSmith will take care of it and sizes will be calculated in Dialog Units instead of pixels (although, naturally, you will still be able to resize components).&lt;br /&gt;
&lt;br /&gt;
Now let's change the position of the radio box. &amp;quot;But, wait,&amp;quot; you may say, &amp;quot;I thought you said that the sizer is responsible for the positioning.&amp;quot; That's right. We have limited possibilities to change position. Inside one sizer we can only reorder components; for more complex forms we can also move a component between two sizers or to areas where sizers do not apply. So, back to our example, let's move the radio box to position it right after the button. To do so, click on the radio button and drag it onto the button. When you start dragging, you will notice that the area of the sizer changes color to blue. This color change is a aid to show you what will be the new position of the dragged component. When you move the cursor onto the button, half of the button will become light-blue. When the left half is highlighted, the dragged component will be added before it. When the right half is highlighted, dragged component will be added after it. And when there's no highlighted component, the new component will be added as the last child of the parent:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_015.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When you drop the component, it will change it's position. Note that all the components after the new position also shift. That happens because the default setting of the wxFlexGridSizer allows only 3 components in one row (this can be changed in property browser) so the components just adapted to the new order.&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_016.png]]&lt;br /&gt;
&lt;br /&gt;
==Sizers== &lt;br /&gt;
&lt;br /&gt;
Now let's learn a little bit about components available in wxSmith. I'll describe all supported sizers and a few important components from the Standard palette. Let's start with sizers.&lt;br /&gt;
&lt;br /&gt;
We already know that sizers are responsible for automatically setting the position and size of some components. But how do they do that? Well, it depends on which sizer has been used. So what are the rules? The generic rule is that the sizer tries to use all its available space and place the components it manages in such way that they do not overlap. If the area available to the sizer is too small, it requests a bigger area, so you can be sure that no component will fall out of the window. (Unfortunately, you cannot be sure that after such adjustments the window will be small enough to fit on the screen, so be careful about that.) Another rule which should be mentioned here is that sizers automatically set-up the minimum size required by the window. Basically when you edit a window using sizers, you should be aware that you edit the smallest layout and without some tricks, you won't be able to resize the window to something smaller.&lt;br /&gt;
&lt;br /&gt;
Here are descriptions of all sizers available in wxSmith:&lt;br /&gt;
&lt;br /&gt;
=== wxBoxSizer ===&lt;br /&gt;
&lt;br /&gt;
wxBoxSizer is the most basic sizer available in wxWidgets. It's purpose is to align components in one line - one next to another - either horizontally or vertically. This sizer also tries to keep some proportions between components - for a horizontal sizer you can set factors which will keep proportionality of widths and the height of the sizer area will be equal to the height of the tallest component. Similarly, vertical sizers keep heights proportional and the width will be taken as the widest component. You specify whether the sizer is to be horizontal or vertical in the sizer's property browser.&lt;br /&gt;
&lt;br /&gt;
Here are examples of layout using box sizers (the first one is the horizontal one, the second is vertical one):&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_002.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In that example you may see that all components have the same width and height.&lt;br /&gt;
&lt;br /&gt;
But let's assume that we want Button2 to be two times wider that Button1 and Button3 to be three times wider than Button1. This can be easily done by using the Proportion property of managed components. By default, the value of all components is set to 1 so they have equal size. Changing the Proportion of second button to 2 would mean that it should be 2 times wider that the first or third one.&lt;br /&gt;
&lt;br /&gt;
Generally you can set any value you want here. One common technique is to set percentage values - for example setting proportions to values 20, 30 and 50 would mean that the first button should occupy 20% of the space, the second one 30% and the third one 50%. The special value 0 means that this component should be skipped in proportion calculations and it will won't automatically adjust it's size when the main window is resized.&lt;br /&gt;
&lt;br /&gt;
So if we want to get 1:2:3 proportions, we set 1 for Button1, 2 for Button2 and 3 for Button3. And here is the result:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_003.png]]&lt;br /&gt;
&lt;br /&gt;
Also note that if you create a resizable window and resize it, those 3 buttons will automatically grow and keep proportions. If you set the Proportion property for some component to 0, it won't change size as the user changes the size of the window. &lt;br /&gt;
&lt;br /&gt;
The other dimension which is not controlled by Proportion property may be controlled using the &amp;quot;Expand&amp;quot; and &amp;quot;Shaped&amp;quot; properties. They are simple checkboxes. If you check the first one, the component will expand it's width/height and will get the size of the biggest component managed by the same sizer. Selecting &amp;quot;Shaped&amp;quot; will also make the component resize but such components will try to keep the initial proportion between width and height so it doesn't have to use all available space. The effect of the &amp;quot;Expand&amp;quot; and &amp;quot;Shaped&amp;quot; properties can be seen when components differ in width or height; here's an example:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_004.png]]&lt;br /&gt;
&lt;br /&gt;
In this example, the first button is the biggest of the three. Its size will be used to adjust the sizes of the other buttons. The second one has its &amp;quot;Expand&amp;quot; property checked, and the third one does not. What can be seen here is that the third button expanded in only one dimension (the one managed by &amp;quot;Proportion&amp;quot; property), the second dimension was left untouched.&lt;br /&gt;
&lt;br /&gt;
You may also note that when a component does not fill its available area, it is centered. That's default behavior which can be changed. In the properties of components managed by sizer you will find properties called '''Horizontal align''' and '''Vertical align'''. Using these properties you can select where the component should be located when it's smaller that its available area.&lt;br /&gt;
&lt;br /&gt;
=== wxStaticBoxSizer ===&lt;br /&gt;
&lt;br /&gt;
This sizer is similar to wxBoxSizer with one exception: it adds an extra static box around managed components:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_005.png]]&lt;br /&gt;
&lt;br /&gt;
=== wxGridSizer ===&lt;br /&gt;
&lt;br /&gt;
This sizer is a little bit more advanced than wxBoxSizer because it aligns components on a grid, not on one line. You can specify the number of columns or number of rows in properties &amp;quot;Cols&amp;quot; and &amp;quot;Rows&amp;quot;. The default number of columns is set to 3 and number of rows is set to 0. When 0 is used, it means that sizer should automatically calculate this value to keep all managed components inside.&lt;br /&gt;
&lt;br /&gt;
This sizer makes an important assumption: all cells must have the same width and all must have the same height.  This means that the tallest managed component will set the height of all rows and the widest one will set the widths of all columns. If an component won't use the whole cell, it will be surrounded by empty space. (If you don't like this assumption, look at the wxFlexGridSizer.)&lt;br /&gt;
&lt;br /&gt;
Among the properties of a wxGridsizer you can also find horizontal and vertical spacings. These values set the spacing added between components. The result of using them is similar to using borders around managed components but with borders you would have to set borders for all components separately.&lt;br /&gt;
&lt;br /&gt;
In the case of wxGridSizer, the &amp;quot;Proportion&amp;quot; value is not used. But you may use &amp;quot;Expand&amp;quot;, &amp;quot;Shaped&amp;quot; or placement properties to adjust the result.&lt;br /&gt;
&lt;br /&gt;
Here's an example of a grid sizer:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_006.png]]&lt;br /&gt;
&lt;br /&gt;
=== wxFlexGridSizer ===&lt;br /&gt;
&lt;br /&gt;
This is a very useful one. It works similarly to wxGridSizer; but it does not force all columns to have the same width nor all rows to have the same height. Also not all columns resize when there's more space available for the sizer. Comparing to wxGridSizer you will find two extra properties here: &amp;quot;Growable cols&amp;quot; and &amp;quot;Growable rows&amp;quot;. In these properties you may provide a list of columns / rows which should automatically resize by providing a list of numbers separated using comma (,). The numbers should start from 0, so if you would like the second and third column to resize, put &amp;quot;1,2&amp;quot; into &amp;quot;Growable cols&amp;quot;. This property is very useful to handle resizing of the window.&lt;br /&gt;
&lt;br /&gt;
Unfortunately you won't be able to set proportions other that 1:1 The &amp;quot;Proportion&amp;quot; property is also not used in this sizer.&lt;br /&gt;
&lt;br /&gt;
=== wxStdDialogButtonSizer ===&lt;br /&gt;
&lt;br /&gt;
This is a specialized sizer with one purpose - to provide a set of standard buttons with respect to the platform's look and feel. This sizer has a predefined list of components which it can handle - all are buttons and you can manage them using the sizer's properties. You cannot add your custom components into this sizer.&lt;br /&gt;
&lt;br /&gt;
Each button on this sizer has two properties in the sizer - whether the button should be enabled (for example wxID_OK for OK button) and its label. Note that labels for most buttons will be generated automatically and wxWidgets will skip them when it can read them from system settings. For example, on Linux only the Context Help button does not have a system-supplied label. It is also very probable that labels will be provided with language-specific strings (depending on the current system language). Not all configurations of buttons are valid - they won't break the application but buttons will overlap (for example Yes and OK).&lt;br /&gt;
&lt;br /&gt;
Here is an example of this sizer. My system is set up in Polish, so the labels are automatically in Polish.  They mean: Help, Cancel, Apply and OK.&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_007.png]]&lt;br /&gt;
&lt;br /&gt;
This screenshot was taken on a Linux box. You may see that the buttons have an extra image which is not available for standard buttons. With such a layout, users of the application will feel more comfortable, and such 'small' things make users say that the GUI was designed very well. On MS Windows, the sizer would have the same buttons but without images and they would be in a different order - the one that is used on windows by default.&lt;br /&gt;
&lt;br /&gt;
All of the above sizers can be found on the &amp;quot;Layout&amp;quot; tab. You can find two other components there which are not sizers but can be used for layout purposes. &lt;br /&gt;
&lt;br /&gt;
The first one is Spacer. It can be added to other sizers when you simply need some empty space instead of any particular component. Spacers have only width and height.&lt;br /&gt;
&lt;br /&gt;
The second one is wxSplitterWindow. When you use this component, you can add one or two child components into it and they will be separated with a dividing line (it's called a sash in wxWidgets). On the application you can drag it to dynamically adjust the size of managed components.&lt;br /&gt;
&lt;br /&gt;
Now that we know something about sizers let's turn to other components.&lt;br /&gt;
&lt;br /&gt;
== Especially Useful Standard Components ==&lt;br /&gt;
&lt;br /&gt;
wxWidgets provides all standard graphical components like static text, buttons, edit boxes, combo boxes, and so on. All are supported in wxSmith, so you can build a nice working environment. I'll briefly describe the components that are really useful in standard applications.&lt;br /&gt;
&lt;br /&gt;
=== wxButton ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_017.png]]&lt;br /&gt;
&lt;br /&gt;
This is standard button, a very common component. Its purpose is to run some piece of code when the user clicks on it. That's it.&lt;br /&gt;
&lt;br /&gt;
=== wxStaticText ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_018.png]]&lt;br /&gt;
&lt;br /&gt;
This component only shows user-defined text on the window. It doesn't generate any events.&lt;br /&gt;
&lt;br /&gt;
=== wxTextCtrl ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_019.png]]&lt;br /&gt;
&lt;br /&gt;
This component let's the user enter some text. It's basic functionality allows entering one-line text. After changing its properties, it may become a more advanced multiline editor with support for different fonts, colors and text styles.&lt;br /&gt;
&lt;br /&gt;
=== wxPanel ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_020.png]]&lt;br /&gt;
&lt;br /&gt;
Although this component may be a separate window, it is most commonly added as a comoponent in a parent window. It is particularly useful as a background for other components. It has a few functionalities - it can be used as background in notebooks and it may be a place where you put components without sizers. But it also has a few drawbacks - wxWidgets tends to do some tricks with wxPanel's size so it's not always possible to set the size we really want.&lt;br /&gt;
&lt;br /&gt;
=== wxChoice ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_021.png]]&lt;br /&gt;
&lt;br /&gt;
This component provides a drop-down list with available options. It works similarly to wxComboBox but the user cannot enter values. It can be used in situations when the user should use one of several available options. An event is generated when the user changes the selected component.&lt;br /&gt;
&lt;br /&gt;
=== wxComboBox ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_022.png]]&lt;br /&gt;
&lt;br /&gt;
This component provides a drop-down list similar to that of wxChoice. In the case of this component, the user can select one of the available values or enter his own if the component is not in a Read-Only state. A very good example of its usage is to provide some text entry with a stored list of previously entered values (like in search boxes). Like wxChoice, changing the selection generates an event. Additionally, changing the text and pressing enter also generates events. Tutorial 9 will illustrate its use. &lt;br /&gt;
&lt;br /&gt;
=== wxListBox ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_023.png]]&lt;br /&gt;
&lt;br /&gt;
This component provides a list where you can select one or more components. Changing the component or double-clicking on it generates an event.&lt;br /&gt;
&lt;br /&gt;
=== wxNotebook ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_024.png]]&lt;br /&gt;
&lt;br /&gt;
Notebook is very useful for complex resources since it groups content under tabs. Additionally, wxChoicebook and wxCombobook are also available but are not described here. Changing the selected notebook generates two events: one when the page starts to change (before change) and one when the page is finished changing (after change).&lt;br /&gt;
&lt;br /&gt;
=== wxCheckBox ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_025.png]]&lt;br /&gt;
&lt;br /&gt;
Check boxes may be used to map boolean values. Additionally, 2-state boxes can also be generated (with values: yes/no/unspecified). Changing the value emits an event.&lt;br /&gt;
&lt;br /&gt;
=== wxRadioBox ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_026.png]]&lt;br /&gt;
&lt;br /&gt;
Radio box works similarly to check boxes. The difference is that only one radiobox in a group can be selected. Groups may be defined by using wxRB_GROUP style. A radiobox which has this style set starts a new group. Changing the selected radiobox emits an event.&lt;br /&gt;
&lt;br /&gt;
=== wxGauge ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_027.png]]&lt;br /&gt;
&lt;br /&gt;
This component, also called a Progress Bar, can be used to show the progress of some operation. It's very useful when doing some calculation intensive operations. It can prevent users from getting frustrated when they do not see anything happening on the screen but only a window which seems hung.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt; * * * * &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
That's the end of this tutorial. We will get more experience with these subjects in the following tutorials. But you can also learn a lot by experimenting: add components, change properties, resize, move. You may try adding sizers into other sizers, a very useful technique absolutely required for more complex forms. Join me for the next tutorial!&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;'''[[WxSmith tutorial: Hello world|Previous]] | [[WxSmith tutorials|Index]] | [[WxSmith tutorial: Building more complex window|Next]]'''&amp;lt;/center&amp;gt;&lt;/div&gt;</summary>
		<author><name>Chatumao</name></author>
	</entry>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=Talk:WxSmith_tutorial:_Hello_world&amp;diff=7559</id>
		<title>Talk:WxSmith tutorial: Hello world</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=Talk:WxSmith_tutorial:_Hello_world&amp;diff=7559"/>
		<updated>2013-04-29T09:31:41Z</updated>

		<summary type="html">&lt;p&gt;Chatumao: /* Using Close() in an OnClose() handler */ new section&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a wonderful tutorial which bring me to the world of wxWidget step by step, Thanks! As a beginner myself, I really learned a lot from this page.&lt;br /&gt;
I think I can create some video tutorials ( use Wink or other screen cast tools) to support these topics.&lt;br /&gt;
&lt;br /&gt;
== Using Close() in an OnClose() handler ==&lt;br /&gt;
&lt;br /&gt;
Doing this makes the program crash when closing via close symbol.&lt;br /&gt;
http://forums.wxwidgets.org/viewtopic.php?t=34967&amp;amp;p=143167&lt;br /&gt;
Somebody forgot to change the tutorial or is this intentional?&lt;/div&gt;</summary>
		<author><name>Chatumao</name></author>
	</entry>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=Wxsmith_tutorial:_Working_with_items&amp;diff=7558</id>
		<title>Wxsmith tutorial: Working with items</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=Wxsmith_tutorial:_Working_with_items&amp;diff=7558"/>
		<updated>2013-04-29T09:15:39Z</updated>

		<summary type="html">&lt;p&gt;Chatumao: /* Working with Menus and Components */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:wxSmith Documentation]]&lt;br /&gt;
= Working with Menus and Components =&lt;br /&gt;
&lt;br /&gt;
In the [[wxSmith tutorial: Hello world|previous tutorial]] we learned how to create a small application using wxWidgets. We created a window with a few components inside. In this tutorial, we will first see how to use the menu bar at the top of the main window and then focus on sizers and wxWidgets components which can be put on a form or window. &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''A Note on Terminology'''&lt;br /&gt;
&lt;br /&gt;
BYO, the creator of wxSmith and original author of these tutorials, wrote &amp;quot;Each resource in wxSmith is made of items. All your buttons, text boxes, lists etc are items. Also some more abstract things like sizers, spacers (used to add empty space), menu entries or even timers are also called items in wxSmith. So basically anything that's inside the resource may be called an item. I'll also use the term component since it reflects the valid meaning too.&amp;quot; &lt;br /&gt;
&lt;br /&gt;
In fact, the word &amp;quot;item&amp;quot; is not found in the index of the Julian Smart and Kevin Hock book ''Cross-Platform GUI Programming with wxWidgets.'' The word is used in the book specifically for the elements of the drop-down lists of choice boxes, combo boxes, and other members of the class wxControlWithItems. In the revision of these tutorials, the word &amp;quot;item&amp;quot; is therefore generally being reserved for items in these lists and for items in a menu. Otherwise, the word &amp;quot;item&amp;quot; is generally being replaced by &amp;quot;component&amp;quot;, &amp;quot;widget&amp;quot;, or &amp;quot;control&amp;quot; as seems appropriate, though of course, it is also occasionally used with no special technical meaning. Also, BYO often uses the word &amp;quot;resource&amp;quot; to refer to a form or window. Smart and Hock use word the &amp;quot;resource&amp;quot; sparingly, mainly in the context of &amp;quot;resource files&amp;quot;.  The word seems overworked and needlessly abstract, so when what is intended is a form or window, the revisions will use one of those words, with no sharp distinction between them.   &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Note that all screenshots presented here were made on Linux but they should not be very different from the windows ones.&lt;br /&gt;
&lt;br /&gt;
== Working with Menus ==&lt;br /&gt;
&lt;br /&gt;
Following the directions given in Tutorial 1, start a new Code::Blocks project; call it Tutorial_2. Remember to add &amp;quot;event.Skip(TRUE);&amp;quot; at the appropriate place in the code, as explained in Tutorial 1. &lt;br /&gt;
&lt;br /&gt;
Build and run the program. You will see that it has two items on the main menu. We will add one more, Jump, at the top level and under it two more, Back and Out. Back will do nothing, but we will make Out close the program.&lt;br /&gt;
&lt;br /&gt;
Click on the “Tutorial_2frame.wxs” tab of the Editor window.  Just below the words “Tutorial_2framw.wxs” is a panel with two square icons.  Double left click on the leftmost one, which shows the word ''File'' suggestive of a menu.  Up comes the menu inspector window shown below.&lt;br /&gt;
&lt;br /&gt;
[[Image:1i.png]]  &lt;br /&gt;
   &lt;br /&gt;
Click on the various menu items shown and note how the content of the fields shown on the right side of the window are filled in.  Then click on the New button (in the lower right part of the window) to add the three additional menu items mentioned above, namely Jump at the top level and under it Back and Out. It does not matter where the items first appear; you use the arrow keys just above the “New” and “Delete” buttons to move around the item you have selected.  For the “Id” field of the “Out” item, put idMenuOut. You should make the menu inspector window look like this:&lt;br /&gt;
&lt;br /&gt;
[[Image:1j.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When you have the menu items properly arranged, click OK.   &lt;br /&gt;
&lt;br /&gt;
When you now build and run, you will see the new menu.  But clicking Jump | Out  does not close the program as desired because we have not programmed the response to that event.  To do so, we want to make wxSmith set up the frame for the routine which will be called when the menu item “Out” is clicked.  Go to the Management pane, Resources tab and persistently click on the little right-pointing triangles until the “Out” item can be seen, as in the screen shot below.&lt;br /&gt;
&lt;br /&gt;
[[Image:1k.png]]&lt;br /&gt;
&lt;br /&gt;
      &lt;br /&gt;
Click on the word “Out” and then on the {} icon in the panel below the Management pane. That will cause the pane below to show the words “EVT_MENU     --None--” . Click on the word “None” or the down arrow at the right end of the field; a menu drops down.  Pick the item  “-- Add New Handler --”, accept the suggested name (OnMenu3Selected), and over in the editor, the frame of our handler has been written, as shown below.  We have only to write the code, which will be simply “Close();”.&lt;br /&gt;
&lt;br /&gt;
[[Image:1l.png]]&lt;br /&gt;
&lt;br /&gt;
Now we can “Build and run”, drop down our menu, click on “Out”, and the program closes, as desired.&lt;br /&gt;
&lt;br /&gt;
== Windows and Components ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Each window in wxSmith is made of components. All your buttons, text boxes, lists, and so on are components. Also some more abstract things like sizers, spacers (used to add empty space), menu entries or even timers are also components.&lt;br /&gt;
&lt;br /&gt;
Every window has a root component. For a dialog window, it would be a wxDialog component; for a frame window, it would be wxFrame component; for a panel it would be a wxPanel component. In the [[wxSmith tutorial: Hello world|previous tutorial]] you probably noticed that some components may have &amp;quot;children&amp;quot;. For example, sizers had components inside their boxes. In this tutorial, you you have seen sub-menu items inside main-menu items. The term &amp;quot;children&amp;quot; suggests the idea of a family tree, and indeed precisely such a tree structure is directly represented in the resource browser, as shown in the example below.&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_008.png]]&lt;br /&gt;
&lt;br /&gt;
In the picture above, you will see an example of such a tree. wxFontFaceEditorDlg is the currently opened form with a root component of type wxDialog. We can see that this resource consists of a few sizers and buttons, one text area and some spacers. It's definitely a fairly simple form. For more complicated forms, there could be more than 100 components. The tree (or Resource) browser can be very helpful for locating the code connected with a component; clicking on the component in the browser brings up its code in the editor.&lt;br /&gt;
&lt;br /&gt;
Each component has its properties - these are usually some values which describe the component. Some of them may affect the way component looks, some may change the component's behavior, and some may be dedicated to programming facilities. You will also find that there are some properties -- such as position and size -- common to many components.&lt;br /&gt;
&lt;br /&gt;
wxSmith allows you to edit components inside the properties browser (the window which is usually under the resource browser). If you select an component either by  clicking on it in the resource browser or by clicking on it inside editor, the properties editor switches to edit its properties. Here's an example of the property browser:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_009.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can also use the Quick-Properties panel available after pressing the &amp;quot;Q&amp;quot; button on the right side of the editor:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_010.png]]&lt;br /&gt;
&lt;br /&gt;
The purpose of this panel is to provide most common properties in user-friendly way. It hasn't proven as useful as I had hoped, and you will probably find it helpful only while adjusting sizer-related settings.&lt;br /&gt;
&lt;br /&gt;
The last and the easiest way to work on a component is directly in the editor. You can grab drag boxes and change the component's size. You can also change its position by simply dragging it to another place.&lt;br /&gt;
&lt;br /&gt;
=== Excercise with Components ===&lt;br /&gt;
&lt;br /&gt;
Enough generalities; let's play with components. We can continue with the project started at the beginning of this tutorial. First let's add wxFlexGridSizer into our window. Like all sizers, it is located in Layout tab. (You'll remember how to add components from the [[wxSmith tutorial: Hello world|previous tutorial]]). Now let's add the following components into the sizer in the order given: wxButton, wxStaticText, wxTextCtrl, wxRadioButton and wxCheckBox. They can all be found on the Standard tab. The result should look like this:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_011.png]]&lt;br /&gt;
&lt;br /&gt;
In this picture, components I've selected have a light red border.&lt;br /&gt;
&lt;br /&gt;
Now that we have our playground, let's change some components. First, let's change the label and color of the button. To do so, click on the button and move to the properties browser. &amp;quot;Label&amp;quot; is the first property, and it's quite easy to change. Just click on the word &amp;quot;Label&amp;quot; on the right and type new text.&lt;br /&gt;
&lt;br /&gt;
Color is little bit harder to find. Usually components have two colors - Background and Foreground color. Background, as the name implies, is used to fill the component's background. Foreground, on the other hand, is used to paint some content onto the background. Note that there's no strict interpretation of these colors so you should experiment to find out their meaning. In wxButton, Background is what we want.&lt;br /&gt;
So let's find the Background property. It's value can be changed by using combobox:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_012.png]]&lt;br /&gt;
&lt;br /&gt;
On the list you may find set of predefined system colors. When you choose one of them, they will be read from current system settings making you application compatible with system theme. There are also two special entries - Default (which means that we do not want to set our color) and Custom. When you select Custom, wxSmith will open a color dialog where you can choose any color you like. I have chosen light green, and here's the result:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_013.png]]&lt;br /&gt;
&lt;br /&gt;
There are also other properties we could talk about, but the best way to learn them is to play with them, so I leave those discoveries to you.&lt;br /&gt;
&lt;br /&gt;
Now let's use the mouse.&lt;br /&gt;
&lt;br /&gt;
The selected component will have eight black boxes -- drag handles -- around it. These boxes can be used to change the size of the component. You will easily notice when the mouse is over a handle because the cursor changes. Let's resize the wxTextCtrl (edit box):&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_014.png]]&lt;br /&gt;
&lt;br /&gt;
You may see that resizing the component will also change properties in the browser - '''Default Size''' is unchecked now and '''Width''' and '''Height''' are set to required values. There's another property which seems to be untouched - '''Size in Dialog Units''', which is also related to size. I'll explain it a bit.&lt;br /&gt;
&lt;br /&gt;
Usually when you must specify size (or other size-related thing) you provide a value in pixels. Alternatively you can specify values in a unit called a '''Dialog Unit'''. A '''Dialog Unit'' is usually a little bit bigger than one pixel and it's size depends of the size of the current font (actually it's the size of the font of some component's parent which has a font). This is useful when you want some values to be proportional to the size of text presented in the window. &lt;br /&gt;
&lt;br /&gt;
If you check '''Size in Dialog Units'', wxSmith will take care of it and sizes will be calculated in Dialog Units instead of pixels (although, naturally, you will still be able to resize components).&lt;br /&gt;
&lt;br /&gt;
Now let's change the position of the radio box. &amp;quot;But, wait,&amp;quot; you may say, &amp;quot;I thought you said that the sizer is responsible for the positioning.&amp;quot; That's right. We have limited possibilities to change position. Inside one sizer we can only reorder components; for more complex forms we can also move a component between two sizers or to areas where sizers do not apply. So, back to our example, let's move the radio box to position it right after the button. To do so, click on the radio button and drag it onto the button. When you start dragging, you will notice that the area of the sizer changes color to blue. This color change is a aid to show you what will be the new position of the dragged component. When you move the cursor onto the button, half of the button will become light-blue. When the left half is highlighted, the dragged component will be added before it. When the right half is highlighted, dragged component will be added after it. And when there's no highlighted component, the new component will be added as the last child of the parent:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_015.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When you drop the component, it will change it's position. Note that all the components after the new position also shift. That happens because the default setting of the wxFlexGridSizer allows only 3 components in one row (this can be changed in property browser) so the components just adapted to the new order.&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_016.png]]&lt;br /&gt;
&lt;br /&gt;
==Sizers== &lt;br /&gt;
&lt;br /&gt;
Now let's learn a little bit about components available in wxSmith. I'll describe all supported sizers and a few important components from the Standard palette. Let's start with sizers.&lt;br /&gt;
&lt;br /&gt;
We already know that sizers are responsible for automatically setting the position and size of some components. But how do they do that? Well, it depends on which sizer has been used. So what are the rules? The generic rule is that the sizer tries to use all its available space and place the components it manages in such way that they do not overlap. If the area available to the sizer is too small, it requests a bigger area, so you can be sure that no component will fall out of the window. (Unfortunately, you cannot be sure that after such adjustments the window will be small enough to fit on the screen, so be careful about that.) Another rule which should be mentioned here is that sizers automatically set-up the minimum size required by the window. Basically when you edit a window using sizers, you should be aware that you edit the smallest layout and without some tricks, you won't be able to resize the window to something smaller.&lt;br /&gt;
&lt;br /&gt;
Here are descriptions of all sizers available in wxSmith:&lt;br /&gt;
&lt;br /&gt;
=== wxBoxSizer ===&lt;br /&gt;
&lt;br /&gt;
wxBoxSizer is the most basic sizer available in wxWidgets. It's purpose is to align components in one line - one next to another - either horizontally or vertically. This sizer also tries to keep some proportions between components - for a horizontal sizer you can set factors which will keep proportionality of widths and the height of the sizer area will be equal to the height of the tallest component. Similarly, vertical sizers keep heights proportional and the width will be taken as the widest component. You specify whether the sizer is to be horizontal or vertical in the sizer's property browser.&lt;br /&gt;
&lt;br /&gt;
Here are examples of layout using box sizers (the first one is the horizontal one, the second is vertical one):&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_002.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In that example you may see that all components have the same width and height.&lt;br /&gt;
&lt;br /&gt;
But let's assume that we want Button2 to be two times wider that Button1 and Button3 to be three times wider than Button1. This can be easily done by using the Proportion property of managed components. By default, the value of all components is set to 1 so they have equal size. Changing the Proportion of second button to 2 would mean that it should be 2 times wider that the first or third one.&lt;br /&gt;
&lt;br /&gt;
Generally you can set any value you want here. One common technique is to set percentage values - for example setting proportions to values 20, 30 and 50 would mean that the first button should occupy 20% of the space, the second one 30% and the third one 50%. The special value 0 means that this component should be skipped in proportion calculations and it will won't automatically adjust it's size when the main window is resized.&lt;br /&gt;
&lt;br /&gt;
So if we want to get 1:2:3 proportions, we set 1 for Button1, 2 for Button2 and 3 for Button3. And here is the result:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_003.png]]&lt;br /&gt;
&lt;br /&gt;
Also note that if you create a resizable window and resize it, those 3 buttons will automatically grow and keep proportions. If you set the Proportion property for some component to 0, it won't change size as the user changes the size of the window. &lt;br /&gt;
&lt;br /&gt;
The other dimension which is not controlled by Proportion property may be controlled using the &amp;quot;Expand&amp;quot; and &amp;quot;Shaped&amp;quot; properties. They are simple checkboxes. If you check the first one, the component will expand it's width/height and will get the size of the biggest component managed by the same sizer. Selecting &amp;quot;Shaped&amp;quot; will also make the component resize but such components will try to keep the initial proportion between width and height so it doesn't have to use all available space. The effect of the &amp;quot;Expand&amp;quot; and &amp;quot;Shaped&amp;quot; properties can be seen when components differ in width or height; here's an example:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_004.png]]&lt;br /&gt;
&lt;br /&gt;
In this example, the first button is the biggest of the three. Its size will be used to adjust the sizes of the other buttons. The second one has its &amp;quot;Expand&amp;quot; property checked, and the third one does not. What can be seen here is that the third button expanded in only one dimension (the one managed by &amp;quot;Proportion&amp;quot; property), the second dimension was left untouched.&lt;br /&gt;
&lt;br /&gt;
You may also note that when a component does not fill its available area, it is centered. That's default behavior which can be changed. In the properties of components managed by sizer you will find properties called '''Horizontal align''' and '''Vertical align'''. Using these properties you can select where the component should be located when it's smaller that its available area.&lt;br /&gt;
&lt;br /&gt;
=== wxStaticBoxSizer ===&lt;br /&gt;
&lt;br /&gt;
This sizer is similar to wxBoxSizer with one exception: it adds an extra static box around managed components:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_005.png]]&lt;br /&gt;
&lt;br /&gt;
=== wxGridSizer ===&lt;br /&gt;
&lt;br /&gt;
This sizer is a little bit more advanced than wxBoxSizer because it aligns components on a grid, not on one line. You can specify the number of columns or number of rows in properties &amp;quot;Cols&amp;quot; and &amp;quot;Rows&amp;quot;. The default number of columns is set to 3 and number of rows is set to 0. When 0 is used, it means that sizer should automatically calculate this value to keep all managed components inside.&lt;br /&gt;
&lt;br /&gt;
This sizer makes an important assumption: all cells must have the same width and all must have the same height.  This means that the tallest managed component will set the height of all rows and the widest one will set the widths of all columns. If an component won't use the whole cell, it will be surrounded by empty space. (If you don't like this assumption, look at the wxFlexGridSizer.)&lt;br /&gt;
&lt;br /&gt;
Among the properties of a wxGridsizer you can also find horizontal and vertical spacings. These values set the spacing added between components. The result of using them is similar to using borders around managed components but with borders you would have to set borders for all components separately.&lt;br /&gt;
&lt;br /&gt;
In the case of wxGridSizer, the &amp;quot;Proportion&amp;quot; value is not used. But you may use &amp;quot;Expand&amp;quot;, &amp;quot;Shaped&amp;quot; or placement properties to adjust the result.&lt;br /&gt;
&lt;br /&gt;
Here's an example of a grid sizer:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_006.png]]&lt;br /&gt;
&lt;br /&gt;
=== wxFlexGridSizer ===&lt;br /&gt;
&lt;br /&gt;
This is a very useful one. It works similarly to wxGridSizer; but it does not force all columns to have the same width nor all rows to have the same height. Also not all columns resize when there's more space available for the sizer. Comparing to wxGridSizer you will find two extra properties here: &amp;quot;Growable cols&amp;quot; and &amp;quot;Growable rows&amp;quot;. In these properties you may provide a list of columns / rows which should automatically resize by providing a list of numbers separated using comma (,). The numbers should start from 0, so if you would like the second and third column to resize, put &amp;quot;1,2&amp;quot; into &amp;quot;Growable cols&amp;quot;. This property is very useful to handle resizing of the window.&lt;br /&gt;
&lt;br /&gt;
Unfortunately you won't be able to set proportions other that 1:1 The &amp;quot;Proportion&amp;quot; property is also not used in this sizer.&lt;br /&gt;
&lt;br /&gt;
=== wxStdDialogButtonSizer ===&lt;br /&gt;
&lt;br /&gt;
This is a specialized sizer with one purpose - to provide a set of standard buttons with respect to the platform's look and feel. This sizer has a predefined list of components which it can handle - all are buttons and you can manage them using the sizer's properties. You cannot add your custom components into this sizer.&lt;br /&gt;
&lt;br /&gt;
Each button on this sizer has two properties in the sizer - whether the button should be enabled (for example wxID_OK for OK button) and its label. Note that labels for most buttons will be generated automatically and wxWidgets will skip them when it can read them from system settings. For example, on Linux only the Context Help button does not have a system-supplied label. It is also very probable that labels will be provided with language-specific strings (depending on the current system language). Not all configurations of buttons are valid - they won't break the application but buttons will overlap (for example Yes and OK).&lt;br /&gt;
&lt;br /&gt;
Here is an example of this sizer. My system is set up in Polish, so the labels are automatically in Polish.  They mean: Help, Cancel, Apply and OK.&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_007.png]]&lt;br /&gt;
&lt;br /&gt;
This screenshot was taken on a Linux box. You may see that the buttons have an extra image which is not available for standard buttons. With such a layout, users of the application will feel more comfortable, and such 'small' things make users say that the GUI was designed very well. On MS Windows, the sizer would have the same buttons but without images and they would be in a different order - the one that is used on windows by default.&lt;br /&gt;
&lt;br /&gt;
All of the above sizers can be found on the &amp;quot;Layout&amp;quot; tab. You can find two other components there which are not sizers but can be used for layout purposes. &lt;br /&gt;
&lt;br /&gt;
The first one is Spacer. It can be added to other sizers when you simply need some empty space instead of any particular component. Spacers have only width and height.&lt;br /&gt;
&lt;br /&gt;
The second one is wxSplitterWindow. When you use this component, you can add one or two child components into it and they will be separated with a dividing line (it's called a sash in wxWidgets). On the application you can drag it to dynamically adjust the size of managed components.&lt;br /&gt;
&lt;br /&gt;
Now that we know something about sizers let's turn to other components.&lt;br /&gt;
&lt;br /&gt;
== Especially Useful Standard Components ==&lt;br /&gt;
&lt;br /&gt;
wxWidgets provides all standard graphical components like static text, buttons, edit boxes, combo boxes, and so on. All are supported in wxSmith, so you can build a nice working environment. I'll briefly describe the components that are really useful in standard applications.&lt;br /&gt;
&lt;br /&gt;
=== wxButton ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_017.png]]&lt;br /&gt;
&lt;br /&gt;
This is standard button, a very common component. Its purpose is to run some piece of code when the user clicks on it. That's it.&lt;br /&gt;
&lt;br /&gt;
=== wxStaticText ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_018.png]]&lt;br /&gt;
&lt;br /&gt;
This component only shows user-defined text on the window. It doesn't generate any events.&lt;br /&gt;
&lt;br /&gt;
=== wxTextCtrl ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_019.png]]&lt;br /&gt;
&lt;br /&gt;
This component let's the user enter some text. It's basic functionality allows entering one-line text. After changing its properties, it may become a more advanced multiline editor with support for different fonts, colors and text styles.&lt;br /&gt;
&lt;br /&gt;
=== wxPanel ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_020.png]]&lt;br /&gt;
&lt;br /&gt;
Although this component may be a separate window, it is most commonly added as a comoponent in a parent window. It is particularly useful as a background for other components. It has a few functionalities - it can be used as background in notebooks and it may be a place where you put components without sizers. But it also has a few drawbacks - wxWidgets tends to do some tricks with wxPanel's size so it's not always possible to set the size we really want.&lt;br /&gt;
&lt;br /&gt;
=== wxChoice ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_021.png]]&lt;br /&gt;
&lt;br /&gt;
This component provides a drop-down list with available options. It works similarly to wxComboBox but the user cannot enter values. It can be used in situations when the user should use one of several available options. An event is generated when the user changes the selected component.&lt;br /&gt;
&lt;br /&gt;
=== wxComboBox ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_022.png]]&lt;br /&gt;
&lt;br /&gt;
This component provides a drop-down list similar to that of wxChoice. In the case of this component, the user can select one of the available values or enter his own if the component is not in a Read-Only state. A very good example of its usage is to provide some text entry with a stored list of previously entered values (like in search boxes). Like wxChoice, changing the selection generates an event. Additionally, changing the text and pressing enter also generates events. Tutorial 9 will illustrate its use. &lt;br /&gt;
&lt;br /&gt;
=== wxListBox ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_023.png]]&lt;br /&gt;
&lt;br /&gt;
This component provides a list where you can select one or more components. Changing the component or double-clicking on it generates an event.&lt;br /&gt;
&lt;br /&gt;
=== wxNotebook ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_024.png]]&lt;br /&gt;
&lt;br /&gt;
Notebook is very useful for complex resources since it groups content under tabs. Additionally, wxChoicebook and wxCombobook are also available but are not described here. Changing the selected notebook generates two events: one when the page starts to change (before change) and one when the page is finished changing (after change).&lt;br /&gt;
&lt;br /&gt;
=== wxCheckBox ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_025.png]]&lt;br /&gt;
&lt;br /&gt;
Check boxes may be used to map boolean values. Additionally, 2-state boxes can also be generated (with values: yes/no/unspecified). Changing the value emits an event.&lt;br /&gt;
&lt;br /&gt;
=== wxRadioBox ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_026.png]]&lt;br /&gt;
&lt;br /&gt;
Radio box works similarly to check boxes. The difference is that only one radiobox in a group can be selected. Groups may be defined by using wxRB_GROUP style. A radiobox which has this style set starts a new group. Changing the selected radiobox emits an event.&lt;br /&gt;
&lt;br /&gt;
=== wxGauge ===&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut02_027.png]]&lt;br /&gt;
&lt;br /&gt;
This component, also called a Progress Bar, can be used to show the progress of some operation. It's very useful when doing some calculation intensive operations. It can prevent users from getting frustrated when they do not see anything happening on the screen but only a window which seems hung.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt; * * * * &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
That's the end of this tutorial. We will get more experience with these subjects in the following tutorials. But you can also learn a lot by experimenting: add components, change properties, resize, move. You may try adding sizers into other sizers, a very useful technique absolutely required for more complex forms. Join me for the next tutorial!&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;'''[[WxSmith tutorial: Hello world|Previous]] | [[WxSmith tutorials|Index]] | [[WxSmith tutorial: Building more complex window|Next]]'''&amp;lt;/center&amp;gt;&lt;/div&gt;</summary>
		<author><name>Chatumao</name></author>
	</entry>
</feed>