• NAB/MWT Properties: Displays and edits the properties of an instance selected in the Editor, Tree, or List.
• NAB/MWT Attributes: Displays and edits the attributes of a selected instance. The only attribute for a variable is Global. A window instance has a Type that identifies it as a Normal window, a Class definition, or an object store that isolates window configuration information in a file.
• NAB/MWT Procedures: Associates event procedures written in a procedural language with instances. A procedure has an arbitrary Procedure name, a Function name by which it is called, and a Trigger that specifies the conditions for calling it.
• NAB/MWT Object Box: Displays icons for all object types and classes implemented by WideStudio/MWT. These are added to an application window by simply dragging them into the Editor.
So let’s create our first NAB project. Select File→New→Project and you’ll find a new wizard category called NAB. Expand that and select NAB/MWT Project (Figure 6.14). Next, you’re asked to select between C++ and Java as the Programming language. Leave it as C++. Then you give the project a name. Call it “HelloNAB” and click Finish.
Figure 6.14: Select NAB project wizard.
The new project shows up in the C/C++ Projects view, and already has a number of files including a template .ccp file. In fact, Eclipse went ahead and built the project, although there isn’t anything useful in it yet. Have a look at HelloNAB.cpp
just to get a feel for what’s there. Remember that the objective of NAB is to generate programs that make use of the WideStudio/MWT libraries.
Select File→New→Other…. The wizard dialog now has another entry under NAB called NAB/MWT Window. Select that and click Next. The new window gets a name, a class, and a type. For now, leave the defaults and click Finish. The new window shows up in the NAB/MWT Editor and the Properties view shows that it is 400×400 pixels. Add a Title string property. Call it “NAB Application.”
Now we’ll add a button to the window. Find the Commands section in the Object Box view and select the first entry, WSCvbn (Button class)
. Select that and click somewhere near the upper left corner of the newwin001
tab of the Editor. A new button instance is created. Grab a corner of the button and expand it. Note that the Properties view reflects the current location and size of the button, among other things.
Edit the properties (in the Properties view) as follows:
X: 10
Y: 10
Width: 200
Height: 30
Label string: Hello
The result should look like Figure 6.15.
Figure 6.15: Application window in NAB/MWT perspective.
In order for our new button to actually do something, we have to attach it to an event procedure. With the Hello button selected in the Editor, click the Add procedure icon in the Procedures view to bring up the dialog in Figure 6.16. Name the function “hello_button” and select ACTIVATE as the trigger.
Figure 6.16: NAB Create Procedure dialog.
Clicking OK creates a new .cpp file with a template for the hello_button()
function. In the source code Editor, enter the following line in the hello_button()
function:
object->setProperty(WSNlabelString, "Hello from NAB");
When you save the revised hello_button.cpp
file, the project is rebuilt. Now we have a program that does something.
As we have with previous projects, open the Debug Configurations dialog and create a new configuration for this project. The default values should be fine. Click Apply if it’s active and click Debug. The Debug perspective displays an error in an Editor tab saying that no source is available for “main()”. That’s because main()
is supplied by the WideStudio/MWT library. That’s OK, because we’re not interested in debugging main()
.
Click the Resume icon. The application window with the Hello button shows up (Figure 6.17). When you click the button, the label changes to the string you set in the hello_button()
function.
Figure 6.17: The running application window.
Granted this is not a very exciting application, but it does serve to illustrate the fundamental capabilities of NAB. You can easily build and test the GUI elements of an embedded application on your host and then move it over to the target. In a sense, this is a more elaborate version of the simple simulation we did in the previous chapter.
While building a native application is an instructive exercise, the real power of WideStudio/MWT and the NAB plug-in is the ability to rebuild the project for an embedded target environment. The target environment is configured and described in the project Properties dialog.
When you select Properties for an NAB project, you’ll find three additional entries in the navigation paneclass="underline"
• NAB/MWT Platform SDK Environment
• NAB/MWT Project Class Library Settings
• NAB/MWT Project Settings
For now, we’ll take a look at the Project Settings dialog shown in Figure 6.18. There are three tabs. Target Settings has three items. Encoding lets you specify a character encoding if one is not explicitly specified in the program. Application type is one of Normal Application, Class Library, Netscape Plugin, or Console Application.
Figure 6.18: NAB/MWT Project Settings dialog.
The Target drop-down brings up a very extensive list of all the platforms supported by WideStudio/MWT (Figure 6.19). Of course, selecting anything other than Native assumes you have the appropriate cross-development tool chain, and have built the corresponding MWT runtime libraries.
Figure 6.19: NAB/MWT targets.
The Compiler Settings (Figure 6.20) and Linker Settings tabs take the place of the C/C++ Build→Settings dialog for ordinary C/C++ projects. This is because NAB creates its own makefiles. Here is where you would specify a cross compiler for your embedded target. Note also that this is where Debug mode is enabled.
Figure 6.20: NAB project Compiler Settings.
The NAB/MWT Platform SDK Environment settings are an artifact of the original WideStudio IDE and are likely to be deleted in the next major update, according to the NAB project lead. Its functionality has effectively been supplanted by the Project Settings. Incidentally, T-Engine is a popular embedded platform in Japan that grew out of the TRON project.
6.4 Other DSDP Subprojects
Although they’re still in the incubation stage, it’s worth at least describing the remaining subprojects under the Device Software Development Platform. If you’re developing mobile devices, you might want to look into them.
6.4.1 Mobile Tools for Java (MTJ)