Introduction
In this training, you will construct a BoxSizer class to position child widgets with a horizontal orientation on the window of the WVGA Display.
Steps:
- Create a New Source File
- Construct a BoxSizer
Prerequisites
You have prepared the Host PC with all the development software tools and Ensemble Graphics Toolkit source code as explained in:
You have installed and prepared theEclipse IDE for C/C++ Developers as explained in:
Create a New Source File
In this section you will be creating a newsizer.cpp source file that you will build in later sections demonstrating the BoxSizer class.
You will use EgtProject and its settings you entered in the training:Ensemble Graphics Toolkit -- First Application using Eclipse IDE
2
You will be adding a new source file with the name:sizer.cpp. If you have a*.cpp source file from a previous Ensemble Graphics Toolkit training, perform the following steps:
b
SelectDebug andRelease and click on theOK button.
The selected*.cpp will be excluded from the build.
3
Right click onEgtProject and selectClean Project.
5
Entersizer.cpp into theSource file: text box. Click on theFinish button.
A new source file tabsizer.cpp is created within theEgtProject.
6
Enter the following source code to thesizer.cpp window pane:
7
Save your program by selectingFile > Save. You may also save by pressingCTRL+S.
You have completed adding a new source file to EgtProject.
Construct a BoxSizer
1
To build the project, hover overEgtProject, right-click and selectBuild Project from the menu. Or you can click on theBuild icon.
The Console window (bottom pane) will display the build progress.
2
To set run properties, hover overEgtProject, right-click and selectRun As > Run Configurations… from the menu.
4
In theRun Configurations window, enter the following in theRemote Absolute File Path for C/C++ Application: text box:
/root/sizer
You may see the previous program/root/???? here. Replace with/root/sizer.
This is the location thesizer.cpp executable will be loaded and run on the target.
5
Click on theApply button.
6
Click on theRun button.
7
Observe the WVGA Display on the target:
Thesizer.cpp executable is running remotely on the target.
Observe the child widgets with a horizontal orientation.
BoxSizer class
From~/egt/docs/html/annotated.html, click on theBoxSizer class. All the functions, attributes, and the constructor associated with the class are documented here.
HorizontalBoxSizer and VerticalBoxSizer class
TheHorizontalBoxSizer andVerticalBoxSizer classes are helper variations for the BoxSizer class.
From~/egt/docs/html/annotated.html, click on theHorizontalBoxSizer andVerticalBoxSizer class. All the functions, attributes, and the constructor associated with these classes are documented here.
Icons
The EGT library comes with a set of icons and images installed by default. Their location is/usr/share/libegt/icons.
To access these icons and images, the scheme uses icon like so:
auto play_button = egt::Image(“icon:play.png”);
These icons are available in different size; 16px, 32px, 64px and 128px. Unless specified, the default icon size is 32px.
8
To stop the program, press theStop button (upper left hand, just below the menu bar).
Before you start another session, be sure toStop the current session.
Summary
In this training, you explored the construction of the BoxSizer class to position child widgets with a horizontal orientation on the window of the WVGA Display.
What’s Next?
There’s plenty more to learn. Here are some additional Ensemble Graphics Toolkit training resources to help you gain more knowledge and skills:







