Chapter Contents

Previous

Next
SAS/AF Software: Class Dictionary

Using the Tab Layout Class

A tab layout consists of a set of partitions and tabs. A single tab is "attached" to each partition, much like a tab divider can be attached to a page in a notebook. The tabs are arranged in a row or rows, typically along the top or left side of the collection of partitions. A client area exists within each partition, and a client object can occupy this client area. By default, this client object is a container box which can contain other widgets.

You can think of the rows of tabs like folders arranged in a stack or dividers in a notebook. Only one tab (or "folder") is active at a time, and this active tab appears as a raised tab in the top-most folder. The tab layout manages the display of the client areas, so when a user selects a tab, the client objects assigned to that tab's client area display while the client objects associated with all other tabs remain hidden.


Creating a Tab Layout

To create a tab layout object:

  1. Decide how you want to organize the objects in your application's interface. Define divisions or subject areas for your tabs and the objects that are associated with those divisions or subject areas.

  2. Open (or build) a frame and add a tab layout object. For example, select Make from the Actions menu, then select Tab Layout Object to add a lab layout.

  3. Define attributes for the tab layout object.

  4. Add widgets to the client area of each tab:

  5. Select the action from the Actions pop-up menu. For example, you could set region attributes through this pop-up menu selection.

At run time, users of your application select a tab to access the control and/or data entry widgets in that tab's client area.


Using Tab Groups

A single group of tabs covers the needs of most applications. However, some situations may require keeping sets of tabs separate from other tabs. For example, imagine that you have a stack of folders of information for a company and its subsidiaries. If you only needed to look at information in the folders for one subsidiary, you would place all of its folders in a group on top of the stack and work with them, leaving the other folders stacked below them on your desktop.

The Tab Layout class handles these association requirements through groups of tabs. A group is a set of logically-related tabs. Tabs in a group appear together and never occupy the same row as tabs in other groups. You can maintain visual differences between tab groups by specifying group color, group spacing, or group indention. (See _setTabs, _setGroupIndention, and _setGroupSpacing for more information.)


Advanced Uses of the Tab Layout Class

There are two ways of implementing a tab layout:

Tab Layout as an Organizational Device
Create a tab layout object with each tab associated with its own client object. Write code to handle user interactions with the client objects. The SCL code does not have to recognize or address the tab layout; a client object is only accessible to users if the object is displayed in the client area of the active tab. Processing only occurs on visible objects. The tab layout object, then, serves to organize the widgets and unclutter the frame.

Tab Layout as a Control
Create a tab layout object with fewer client objects (one per group, one for the entire tabber, or even no client objects at all), and register for the events generated when the user changes tabs and groups. Write code to send methods to the widgets in the client area when tabber events are received, to add and remove widgets from the client area, or to send methods to objects that are not visually associated with the tab layout at all.

There are three primary ways of creating a tab layout:


Communicating with the Tab Layout Object

Suppose that you want to use a tab layout object to allow the user to view any one of three text files (a task list, a work schedule, and a project plan), depending on which tab is selected. To implement this file viewer, you create a tab layout object with three tabs, labeled "Tasks," "Schedule," and "Plan," and a single client object containing an external file viewer object. When a user changes tabs, you change the file with which the viewer is associated.

There are two ways to handle the detection of user tab selection: querying the tab layout under its object label, or trapping events.

Querying the Tab Layout

Interactive selection of a tab runs the object label section of your SCL, where you can notify the external file viewer to display the correct file.

Your SCL should look like this:

init:
   /* define the array of filenames to */
   /* correspond to tab ids */
   array tabfiles[3] $8 ("tasklist","workschd",
                         "cafemenu");
return;

tabber:
   /* processing a user's single-click */
   /* selection */
   if _status = " " then do;
      /* determine which tab is selected */
      call notify ('tabber', 
                   '_getActiveTab', id);
      call notify ('viewer', '_setFile',
                   tabfiles[id], 'n');
   end;
return;

Trapping Events

Interactive selection of a tab generates a sequence of events to keep your application apprised of the current tab and group. If your tab layout object has tabs arranged in groups, it will generate group events when a tab is selected in a group other than the currently- active group. If there are no groups, or the new tab is in the same group as the previously-active tab, the tab layout will not generate group events.

The events occur in the following order:
TAB DESELECTED
GROUP DESELECTED (if appropriate)
GROUP SELECTED (if appropriate)
TAB SELECTED

Your frame SCL should look like this:

init:
   call notify ('viewer',
                '_setInstanceMethod',
                '_newFile',
                'lib.cat.viewer.scl',
                'newfile');

   call notify ('viewer',
                '_setEventHandler',
                'tabber',
                'TAB SELECTED','_newFile',
                'viewer');
return;

and lib.cat.viewer.scl should look like this:

array tabfiles[3] $8 ("tasklist", "workschd",
                      "cafemenu");

newfile: method tabid 8;
   call send (_self_, '_setFile',
              tabfiles[tabid], 'n');
endmethod;


Additional Information

Units of Measure

Several of the methods accept a unit of measure parameter. The following table lists the valid units and provides a definition:

Name    Description
in      inches
cm      centimeters
mm      millimeters
pt      points
pc      picas
el      l-space (one-third the width of an em)
em      the width of a piece of type about as
        wide as it is tall; usually 1 ln in
        the x-direction
en      n-space (half the width of an em)
ex      x-space (height of the x-character)
fg      figure width (width of the zero-
        character)
sp      space (width of the space-character)
cc      width of the widest character in the 
        font
ht      height of the tallest character in
        the font
dp      depth of the deepest character in the
        font
ln      line space (1ht + 1dp)
px      x-pixels
py      y-pixels

Font dependent units (el, em, en, ex, fg, sp, cc, ht, dp, ln) are calculated using the label font. Whenever the label font changes (see _setLabelFont), the font dependent units are recalculated.

Tab Layout Events

The Tab Layout class generates four events to keep your application apprised of the current active tab and group. To receive these events, use the Object class method _setEventHandler. Refer to the _setEventHandler method for details.

GROUP DESELECTED
This event is broadcast whenever a group is deselected.

Your method should accept a single numeric parameter for the identifier of the group that was deselected.

GROUP SELECTED
This event is broadcast whenever a group is selected.

Your method should accept a single numeric parameter for the identifier of the group that was selected.

TAB DESELECTED
This event is broadcast whenever a tab is deselected.

Your method should accept a single numeric parameter for the identifier of the tab that was deselected.

TAB SELECTED
This event is broadcast whenever a tab is selected.

Your method should accept a single numeric parameter for the identifier of the tab that was selected.

See Trapping Events for an example of tab layout event handling.


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.