TabCards  -  Tabbed Card Editor

by Graham Crow


This application must be unarchived to another disc or your hard drive before it will work correctly.


Some programs for Macs and PCs use the metaphor of a stack of tabbed index cards as a convenient way of displaying many data items without taking up too much desktop space. Clicking on a tab causes the relevant card to pop up to the top of the stack. This month's Wimp Topics article describes a technique for achieving the same effect on an Acorn RISC OS machine.

The method depends on producing:
(a) a template file containing the necessary windows and icons;
(b) some Basic code to make it all work.

A tabbed card comprises a parent window and a number of panes, one for each tab. The parent window contains the buttons, the tabs, a large 'plinth' icon (on which the panes fit) and two mask icons for each tab. Each pane contains the icons required for that particular card.

TabCardEd is a special Tab Card Editor to automate the creation of the template file, which is otherwise very fiddly indeed. The application outputs both a template file and a list of variables for importing into your program. Template files may subsequently be dragged onto the application for further amendment.

In addition, there is an Examples directory containing TabCard, a fully working application containing all the code you need to implement your own Tab Cards, and a sample template file which contains a possible alternative look for TabCardEd itself.

You will need access to a template editor such as Acorn's FormEd to add your own icons to the 'cards'.

Starting TabCardEd
Launch the application in the usual way by double-clicking on its icon. This results in the icon appearing on the icon bar and the main window opening. Click on the Test button to open the default Tab Card window, which has three tabs and two buttons.

Before you start to create your own card, you should have a rough idea of the design: the number and size of the panes and how best to group the items on each card.

The main window
The main window is in two sections, Features and Dimensions, which are described shortly. At first, the default settings apply, and these may be reinstated at any time by clicking on the Set defaults button. Clicking on Test opens a Tab Card which conforms to the current settings. This test window is updated immediately whenever you change any of the settings.

Under Features you can change the title, the tabs and the buttons. You may also specify whether or not blank panes should be supplied with frames and labels. The title may be up to 255 characters long, and is terminated by pressing Return. If the length of the title is greater than the width of the test window, then only the right-most part will be displayed.

The number of tabs (between 2 and 9) is set by clicking on the bump icons or entering the required value and pressing Return. The pop-up menu opens a window in which you can enter the tab text (up to 12 characters per tab). Press Return or click on Test to implement. The setting of the radio buttons determine whether the tabs are placed at the top or to the right of the panes. The number of buttons (between 0 and 4) is set in the same way as tabs (note that button 1 is always the default button on the right). The option button allows you to decide whether or not to add a frame and label to each blank pane. Note that these option are only available when working on a fresh card.

Under Dimensions you can alter the settings for pane width and height, top and right margins, tab height and gap between tabs, all within pre-set limits. A single click on the bump icons alters the value by 2 OS units, a Shift-click by 8 OS units, and a Ctrl-click sets the maximum or minimum value. Note that the parent's size is automatically adjusted to take account of the combination of panes, buttons and tabs. The purpose of adjusting the margin is to allow space to add your own icons to the parent window, using a template editor.

Saving the data
When satisfied, click Menu over either window and drag the TCdata directory icon to a filer window. The saved directory contains the template file (TCtemps) and the text file (TCvars). TCtemps is used directly by your program, while TCvars gives a list of variable assignments for importing into the initialisation routine within your program.

Adding your own icons
To add your own icons to the panes, drag the TCtemps file to a template editor. Since all the panes are the same size, it looks best if a similar density of icons is achieved on each. If you decide to add extra icons to the parent, they must be higher-numbered icons than those that are already there.

Editing the template file
If you want to change any aspects of the template file after adding
icons to the panes, for example to fine-tune the size, you can drop
the 'TCtemps' file onto the application. A warning is given if
there is currently unsaved data. Make the amendments and save them.

The TabCard example application
The Examples directory contains TabCard, a fully-working example application including all the code you need to implement your own tabbed cards. It also contains a TCdata directory in which TabCardEd has been used to improve its own design! Try dragging the TCtemps file on to TabCardEd to see the effect.

Running TabCard opens the Preferences example which is based on the scrolling equivalent in Impression Style. Have a look at the Basic program; the sections you need are surrounded by asterisks. Taking them in logical order:

DEF PROCinit sets aside space for pq% (the pane block) and Pane%() (to hold the pane window handles). The first pane is set as the initial pane, and the flag modechanged% is set to FALSE. Next come the variables imported from TCvars. The values for panetop% and paneleft% determine the pane offset from the top and left of the parent respectively, and toptabs% is a flag to say whether the tabs are to be placed at the top or to the right.

DEF PROCtemplates contains code to load our template and set up window handles for the parent and each of its panes. The mask is set for the first tab, and the current pane window handle is held in panew%.

DEF PROCpane is the code which ensures that the pane is opened in the correct position. Note that it is called from the three subsequent window procedures, which are concerned with opening and closing windows.

DEF PROCmouse contains code to identify mouse clicks on the parent window and respond appropriately. If a button is clicked, you must initiate some action. If a tab is clicked, a call is made to PROCchangemask.

DEF PROCchangemask takes as its parameters the old and new tab numbers and sets the mask icons accordingly.

DEF PROCmask fills the mask with the appropriate background colour, whereas DEF PROCunmask() makes the mask transparent.

Finally, we need to deal with the special situation where the user changes to a differently sized screen mode when our window is at the top of the screen, and our pane becomes displaced in its parent. The fix is to set the flag modechanged% (see DEF PROCmessage) and respond to this by reopening our window when the task receives a null reason code (see DEF PROCpoll).

Possible extensions
You may wish to have a go at developing the tabbed card system yourself. Possible extensions that have occurred to me are:
(a) the ability to handle multiple tabbed windows;
(b) provision for the addition of sprites on tabs;
(c) foreground and background colour options.

You may have other ideas. Good luck with your tabbed windows!

 Copyright RISC User Magazine 1996
