[Previous] [Contents] [Index] [Next]

Working with Applications

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.

Creating an application

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


Choosing the style of the base window.


After creating an application, you should:


Note: You should develop a naming convention for all the widgets, modules, functions, and so on. This will make managing your application easier.

Opening an application

To open an existing application, choose Open from the File menu, press Ctrl -O , or choose Open from PhAB's toolbar:


Open button


The Open button on PhAB's toolbar.


You'll see the application selector:


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:


Note: 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.


Saving an application

You can save your application in several ways, as described in the sections below.


Note: 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.

Naming or renaming an application

To save a new unnamed application or to save an application under another name or in a different directory:

  1. Choose Save As from the File menu. You'll see the application selector dialog.

    Application selector

  2. The dialog lists the contents of a directory. If you want to save your application in another directory, type the directory name in the Application Directory field, then press Enter.
    Note: 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.

  3. Type the name of the application in the Application Name field.
  4. Press Enter or click on Save Application.

Note: 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:
  • Edit the Makefile manually and change every occurrence of the executable's name.

    Or:

  • If you haven't changed the Makefile since it was first generated, delete it and regenerate the application. See the Generating, Compiling, and Running Code chapter.

Saving an existing application

To save an existing application, choose Save from the File menu, press Ctrl -S , or select the Save button on PhAB's toolbar:


Save button


The Save button on PhAB's toolbar.


Overwriting an existing application

To overwrite an existing application:

  1. Choose Save As from the File menu.
  2. Do one of the following:

Closing an application

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.

Specifying application startup information

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:

Here's the dialog, with some sample information filled in:


Application Startup Information dialog


Application Startup Information dialog.


Once you've made your changes, click on Done.

Specifying a global header file

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:

  1. Press F2 or choose Startup Info/Modules from the Application menu. You'll see the Application Startup Information dialog.
  2. In the Global Header field, type the name of the header file you plan to use. You don't have to include the .h extension.

    For example, to set up a globals.h header file, you can simply enter: globals

  3. To edit the header immediately, click on the icon next to the Global Header field. You can edit the header only if you've named the application by saving it. The format of the header file is discussed in the Working with Code chapter.

Note: 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.

Initialization function

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:

  1. Press F2 or choose StartUp Info/Modules from the Application menu. You'll see the Application Startup Information dialog.
  2. In the Initialization Function field, type the name of the 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.

  3. To edit the function immediately, click on the icon next to the Initialization Function field. You can edit the function only if you've named the application by saving it. The prototype of this function is discussed in the Working with Code chapter.

Command-line options

By default, all PhAB-generated applications have the following command-line options:

-h height[%]
The height of the window, in pixels, or as a percentage of the screen height if % is specified.
-s server_name
The name of the Photon server:
If server_name is: This server is used:
node_path node_path/dev/photon
fullpath fullpath
relative_path /dev/relative_path
-w width[%]
The width of the window, in pixels, or as a percentage of the screen width if % is specified.
-x position[%][r]
The x coordinate of the upper-left corner of the window, in pixels, or as a percentage of screen width if % is specified. If r is specified, the coordinate is relative to the current console.
-y position[%][r]
The y coordinate of the upper-left corner of the window, in pixels, or as a percentage of screen height if % is specified. If r is specified, the coordinate is relative to the current console.
-Si|m|n
The initial state of the main window (iconified, maximized, or normal).

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:

  1. Press F2 or from the Application menu, choose Startup Info/Modules to open the Application Startup Information dialog.
  2. Set the toggle buttons for the options as required.

Including instance names

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:

  1. Press F2 or from the Application menu, choose Startup Info/Modules to open the Application Startup Information dialog.
  2. Click on the Store Names for ApInstanceName() toggle button.

Note: 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.

Startup windows

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:

Window Name
The name of the window module. To select from a list of existing windows, click on the icon next to this field. If you specify the name of a module that doesn't exist, PhAB asks whether it should create that module.
Window Location
Where the window will appear; see "Positioning a module" in the Working with Modules chapter.
Setup Function
The function that's called when the window is realized (optional). To edit the function, click on the icon next to this field.

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.

Apply
Applies any changes.
Revert
Restores the window information to its original state.
Remove
Deletes the selected window from the startup list.

Adding a startup window

To add a new window to the startup window list, click on <NEW>, fill in the window information, and Click on Apply.

Modifying a startup window

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.

Deleting a startup window

To delete an existing startup window, select the window from the "Windows Opened/Startup" list and click on Remove.

Importing files

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:

  1. Choose Import Files from the File menu, then choose the appropriate type from the Import Files submenu. You'll see a file selector.
  2. The file selector displays the available files of the specified type in the current directory.
  3. To select a file, do one of the following:

Importing PhAB modules from other applications

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.


Note: 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.


Importing graphics images

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.


[Previous] [Contents] [Index] [Next]