Using 'Window' and 'Application'

There are two add-ons included with the application which can help you to design the user interface of your program and create C++ classes, thus saving lots of time. You can modify the window/view resources in the resource file even after compilation; you do not have to recompile your code, your application will still work after adding or removing any menu items or views. Whats more the classes that you have to include when compiling are only some kilobytes, so there will be very small impact on the code size. How this all works and what is generated is explained here.


Classes used by an application

IEResourceHandler

As its name suggests this class is the interface between your application and the resource file, its task is e.g. loading the necessary GUI add-ons and creating window instances. The GUI element add-ons are loaded from /add-ons/InterfaceElements from the boot volume.

IEResourceHandler is created and initialized when the application starts in the constructor of IEApplication, so you have to do nothing special about it. This class is used by IEWindow and IEApplication classes, you do not have to override it.

By default it assumes that the window/menu and other resource are attached to the application image, but if there are other resource files as well, you can add it to IEResourceHandler by calling its AddResourceFile(record_ref rsrcfile) method. After the call you are ready to instantiate windows from the resource file specified by the argument. It's so simple.

One thing you should know about IEResourceHandler: there is a global IEResourceHandler *resourcehandler variable which all the windows and application uses. But again, you have to access it very rarely if at all.

IEApplication

IEApplication is a generic simple application class. Currently it's only task is to create and initialize the resource handler. In the near future several new features will be added.

When you create an application called e.g. 'test app' the following classes are derived from IEApplication:

IEApplication -> IETestApp (generated, don't modify) -> TestApp (skeleton generated, modify)

IETestApp is the class what Interface Elements maintains, it will be recreated at the next 'Generate Source' so you should not modify it. However you can (and have to) modify the class that inherits from it, called TestApp. The skeleton of TestApp is created for your convenience with the possible methods you should implement. TestApp will never be overwritten by subsequent regenerations.

IEWindow

IEWindow is a generic window class. It can instantiate itself and its views from the window data in the resource file. It knows how to set and read the view variables or update the views. It provides you an ExitHook, and dependant window handling. In the following release this will be better documented.

When you create a window called e.g. 'my window' the following classes are derived from IEWindow:

IEWindow -> IEMyWindow (generated, don't modify) -> MyWindow (skeleton generated, modify)

IEMyWindow is the class what Interface Elements maintains, it will be recreated at the next 'Generate Source' so you should not modify it. However you can (and have to) modify the class that inherits from it, called MyWindow. The skeleton of MyWindow is created for your convenience with the possible methods you should implement. MyWindow will never be overwritten by subsequent regenerations.


The 'Application' Add-on

You can specify the name of your application, the main menu (by dropping a previously created main menu), an about box (by dropping a previously created window), and some windows to open when the application starts up. The resource created is a flattened BMessage of type 'IApp'.


The 'Window' Add-on

You can design the layout of your window and its views interactively here. You have to specify

You can make a snapshot of the window coordinates by pressing the little camera icons.
The resource created is a flattened BMessage of type 'IWin'.

Editing your window

You can drag the GUI elements (which should be in /boot/add-ons/InterfaceElements) to your window, and edit, move, center, stretch, duplicate or delete them.

There are keyboard shortcuts you can use:

Mouse control: When you drag a view to another parent, you will be asked if the view shall belong to the new parent. It is always the left top coordinate of the view frame rectangle that decides the parent. Note that if you drag a view outside of its parent, the view will not be seen during dragging. Don't worry, this is not a bug of the editor, but a feature of the BeOS(tm) Interface Kit (views cannot draw outside of their parent).

By selecting 'Center Horizontally', 'Center Vertically' or 'Center All (H+V)' from the popup, the view will be centered in its parent.

By selecting 'Stretch Horizontally', 'Stretch Vertically' or 'Stretch All (H+V)' from the popup, the view will be stretched to fit its parent.