All Manuals > LispWorks IDE User Guide > 19 The Interface Builder

19.3 Creating an interface layout

The default view in the Interface Builder is the layouts view, as shown in Displaying the layouts in the Interface Builder. You use this view to specify the entire GUI, with the exception of the menus. Click the Layouts tab to swap to this view from any other in the Interface Builder.

Displaying the layouts in the Interface Builder

The Interface Builder has three sections in the layouts view.

19.3.1 Interface box

The interface text box displays the name of the current interface; the interface that you are currently working on. Note that there may be several other interfaces loaded into the Interface Builder, but only one can be current.

To switch to another loaded interface, or to create a new interface, type the name of the interface into this area and press Return. You might find it useful to type just a few characters and then press Up or Down to invoke in-place completion. The interface you specify appears and its layouts are shown in the Interface Builder.

19.3.2 Graph area

This area displays, in graph form, the CAPI elements of the current interface.

The context menu allows you to insert CAPI elements and also gives you access to the standard graph commands described in 6 Manipulating Graphs.

By default, the graph is laid out from left to right. The main interface name is shown at the extreme left, and the layouts and elements defined for that interface are shown to the right. The hierarchy of the layouts (that is, which elements are contained in which layouts, and so on) is immediately apparent in the graph.

An item selected in the graph can be operated on by commands in the Object menu in the Interface Builder's menu bar. This menu contains the standard action commands described in 3.8 Performing operations on selected objects, as well as a number of other commands described throughout this chapter.

To remove a layout or pane from your interface definition, select it in the graph area and choose Edit > Cut or press the toolbar button.

19.3.3 Button panels

At the bottom of the Interface Builder is a tab layouts, each tab of which contains a number of buttons. These tabs list the classes of CAPI elements that can be used in the design of your interface.

The precise list of items available depends on the package of the current interface. To change this package, choose Interface > Package... and specify a package name in the dialog that appears. You must specify a package which already exists in the Lisp image.

Note: The package of the current interface is not necessarily the same as the current package of the Interface Builder. Like all other tools, the Interface Builder has its own current package, which affects the display of symbol names throughout the tool; see 3.7.1 Specifying a package for details. By contrast, the package of the current interface is the package in which the interface is actually defined. The window elements which are available for the current interface depend on the visibility of symbols in that package. By default, both the package of the current interface and the current package of the Interface Builder are set to CL-USER by default.

An element chosen from any of these areas can be operated on by commands in the Object menu. This menu contains the standard action commands described in 3.8 Performing operations on selected objects.

19.3.4 Adding new elements to the layout

To add a new element to the layout, click the relevant button in any of the tabs in the button panel. The element is added as the child of the currently selected graph node. If nothing is currently selected, the element is added as the child of the last selected node.

Because construction of the interface layout is performed by selecting CAPI elements directly, you must be familiar with the way that these elements are used in the construction of an interface.

For instance, the first element to add to an interface is likely to be a CAPI layout element, such as an instance of the row-layout class or column-layout class. Not surprisingly, these types of element can be found in the Layouts tab of the button panel. Elements such as buttons or panes (or other layouts) are then added to this layout. In order to generate CAPI interfaces, it is important to understand that all window elements must be arranged inside a layout element in this way.

When you add an element to the design, two windows are updated:

When you add an item, an instance of that class is created. By default, the values of certain attributes are set so that the element can be displayed and the hierarchy layout updated in a sensible way. This typically means that name and title attributes are initialized with the name of the element that has been added, together with a numeric suffix. For instance, the first output pane that is added to an interface is called Output-Pane-1. You should normally change these attribute values to something more sensible, as well as set the values of other attributes. See 19.6 Performing operations on objects for details about this.

For a practical introduction to the process of creating an interface using the Interface Builder, see 19.9 Example: Using The Interface Builder.

19.3.5 Removing elements from a layout

To remove an element from a layout, select it in the graph area of the Layouts view and choose Edit > Cut or press the toolbar button.

19.3.6 Creating different views

If you are familiar with other tools in the LispWorks IDE, you know the importance of different views for an individual tool. The Interface Builder itself provides separate views for looking at the layouts, the menu system, and the code produced for each interface. You can achieve this in your own applications by adding a tab layouts to your interface.

By default, the first layout created is the default view for the interface. By specifying, elsewhere in the interface, callbacks which display the other layouts, you can design a mechanism which allows you to switch between views, within the same interface. This is how all the tools in the LispWorks IDE have been designed; the callbacks specified for menu items in the View menu allow different layouts to be displayed within the same interface.

19.3.7 Inheriting parts of the layout

If you are designing an interface which uses different layouts to produce a number of views, you may want different views to share some elements; for instance, the same list panel, or even a whole layout, can appear in several different views. This is done by creating separate objects of the same type, and then altering the attributes of one so that they match the attributes of the one which you want to inherit.

For instance, to inherit a display pane called DISPLAY-PANE-1:

  1. Ensure that DISPLAY-PANE-1 has already been created in the interface.
  2. Select the layout that you want the inherited display pane to appear in.
  3. Create a new display pane by selecting the correct item in the Panes area and pressing Return.
  4. Change the attributes of the new display pane so that they match the attributes of DISPLAY-PANE-1.

The fact that two layouts now contain the same display pane is reflected in the graph. For details on how to change the attributes of an object, see 19.6.4 Setting the attributes for the selected object.


LispWorks IDE User Guide (Windows version) - 01 Dec 2021 19:38:04