![]() |
![]() |
![]() |
![]() |
This chapter describes working with an application as a whole in PhAB.
It includes:For information on running an application, see the Generating, Compiling, and Running Code chapter.
To create a new application, choose New from the File menu, or press Ctrl -N . If you're already working on an application, PhAB asks if you want to save any changes to that application before closing it.
PhAB creates a new unnamed application that consists of a single main window, named base. PhAB displays a dialog from which you must choose the style of the base window:
Choosing the style of the base window.
After creating an application, you should:
![]() |
You should develop a naming convention for all the widgets, modules, functions, and so on. This will make managing your application easier. |
To open an existing application, choose Open from the File menu, press Ctrl -O , or choose Open from PhAB's toolbar:
The Open button on PhAB's toolbar.
You'll see the application selector:
Application Selector dialog.
If the application you want is in another directory, type the directory name in the Application Directory field, then press Enter.
To choose the application, do one of the following:
Or:
Or:
![]() |
If someone already has the application open,
PhAB won't open it unless you started PhAB with the -n option.
If you're using NFS or SMB, you should start PhAB with the -n option because you can't lock files with either. For more information, see appbuilder in the QNX 6 Utilities Reference. |
You can save your application in several ways, as described in the sections below.
![]() |
To ensure the latest changes to your application are in effect, PhAB automatically saves your application whenever you regenerate or make your application code. |
For information on using version-control software with PhAB applications, see "Version control" in the Generating, Compiling, and Running Code chapter.
To save a new unnamed application or to save an application under another name or in a different directory:
![]() |
If you type a new directory name, it's saved. The next time you want to look in that directory, click on the button to the right of the directory field and select the directory from the list. |
![]() |
If you rename an application, you'll find that the name of the
executable isn't changed. This is because PhAB doesn't change the
Makefile. To change the name of the executable:
|
To save an existing application, choose Save from the File menu, press Ctrl -S , or select the Save button on PhAB's toolbar:
The Save button on PhAB's toolbar.
To overwrite an existing application:
Or:
To close an application, choose Close from the File menu. If you've made any changes but haven't saved your application, PhAB asks you whether or not you want to save it.
The Application Startup Information dialog lets you set up the typical operations that are performed when an application starts. You can:
To open this dialog:
Or
Here's the dialog, with some sample information filled in:
Application Startup Information dialog.
Once you've made your changes, click on Done.
Most applications have a global header that's included in all source code files. If you plan to use a global header in your application, you should set up the header before PhAB generates any code. This lets PhAB automatically include the header in each file it generates.
To set up a global header:
For example, to set up a globals.h header file, you can simply enter: globals
![]() |
If you specify the header after some code has been generated, you'll have to go back and manually add the header to the stub files that were previously generated. |
Your application can include an initialization function that's called before any modules or widgets are created. In it you could initialize data, open widget databases, set up signal handlers, and so on. To set up an initialization function:
When you specify a setup function, PhAB generates a stub function; for information on specifying the language (C or C++) and the filename, see "Function names and filenames" in the Working with Code chapter.
By default, all PhAB-generated applications have the following command-line options:
If server_name is: | This server is used: |
---|---|
node_path | node_path/dev/photon |
fullpath | fullpath |
relative_path | /dev/relative_path |
By default, all these options are enabled so that users can dynamically move or resize the application, or specify its initial state. For example, to start an application in console 4 (the center of the workspace), specify the command-line options:
-x100% -y100%
The PhAB API processes these options before it calls the initialization function; if you plan to add your own command-line options to an application, make sure you pick options that don't conflict with these. You should also code your option processing to handle and ignore these options. If you don't, you'll see errors on the console when you run the application. See the discussion on the initialization function in the Working with Code chapter.
If you don't want users to move or resize the application:
PhAB converts your widgets' instance names into ABN_... manifests that you can use in your code to refer to your widgets by name. You can optionally include the instance-name text string in the widgets' memory. To do this:
![]() |
Including instance names increases the amount of memory required to run your application. |
Use ApInstanceName() to find this string for a widget -- see the Photon Library Reference for more information.
When you first create an application, the mandatory base window is preset as the initial and only startup window. Using the Application Startup Information dialog, you can tell your application to:
The window that appears first in the Windows Opened/Startup list is the initial startup window:
Typically, the application's main window is the first created.
For each window in the startup list, you can specify information that's identical to the information used to create a module-type link callback, as described in the Editing Resources and Callbacks in PhAB chapter.
The information for each window includes:
The buttons below the function name determine whether the setup function is called before the window is realized, after the window is realized, or both.
To add a new window to the startup window list, click on <NEW>, fill in the window information, and Click on Apply.
To modify an existing startup window, select the window from the "Windows Opened/Startup" list, enter whatever changes are needed in the window information fields, and then click on Apply.
To delete an existing startup window, select the window from the "Windows Opened/Startup" list and click on Remove.
PhAB lets you import several types of files, by using the Import Files item in the file menu:
The steps are the same for all types:
When importing a PhAB module from another application, the file selector may display several modules. Each type of module has a different file extension; see "Module types" in the Working with Modules chapter.
![]() |
Callbacks aren't imported, only the module and the widgets themselves.
After importing the module, you can attach new application-specific
callbacks.
Normally, PhAB retains the instance name of each imported widget. However, if it detects a duplicate name, it changes that name to the widget-class name to avoid code-generation errors. |
When importing graphics images, the file selector displays all files with the following extensions:
PhAB imports the graphic as a PtLabel into the currently selected module, and sets the widget's Pt_ARG_LABEL_TYPE resource to Pt_IMAGE. If you wish to edit the imported image, use the pixmap editor, as described in the Editing Resources and Callbacks in PhAB chapter.
![]() |
![]() |
![]() |
![]() |