class tabBook

superclass(es) customControl
subclass(es) -
description This class is a control window by which multiple panel windows with controls on it can be combined into a single control. For each panel inside the tabbook control a tab is visible that displays the associated panel if it is selected.

pl_img26.gif (2450 bytes)
see also panel - calc example program

tasks

A tabbook consists of a collection of panel windows and a set of tabs to select a single panel window. A page of a tabbook is a tab and a panel window. Each page inside a tabbook is identified by it's name. After a page has been created the panel window of the page can be retrieved by the method findPage/2. The class of the panel window can be used for placing controls on.

Default is that the tabs of the tabbook are drawn at the top of the control, however it is possible to have the tabs drawn at the bottom of the control, the method putTabPos/1 can be used for determining where the tabs are drawn. The width of each tab is adjusted to the size of the text identifying the page, this default behavior can be overridden by the method putFixedTabWidth/3. If each tab has the same width it is possible to turn the option on that the tabbook draws the text of the current tab with a bold font instead of a normal font, the method putCurrentBoldFont/1 can be used for setting this option.

The tabbook class has two specific callbacks, they are called onBeforeSwitch/4 and onAfterSwitch/1. As the names imply the first callback is executed if the user wants to switch to a new current page and the other callback is executed after the switch to the new current page was done. It is possible by responding to the onBeforeSwitch/4 callback to prevent a switch to a specific page, the event structure contains the name of the old current page, the new current page and a variable which can be assigned a value, if the variable is assigned false then the switch is not performed (it is never possible to switch to a disabled page).

pl_img25.gif (2209 bytes)
The control also supports a keyboard interface with shortcuts, switching to a tab can be done by pressing a single letter. Which letter to associate with a tab is determined by the text of the tab, the character following the & character inside the text becomes the shortcut letter. For instance: the text of the first tab is '&House' and the text of the second tab is '&Personal'. if the tabs of the tabbook control have the keyboard focus then by pressing the letter 'P' the 'Personal' page becomes the new current, if the letter 'H' is pressed the 'House' page is shown.

methods

createPage(Name, Output)

func Create a new panel window for controls inside the tabbook. Each panel inside a tabbook has an unique name.
pre The variable Name must contain a valid string.
post If a new page was created then was true assigned to the variable Output, else was false assigned.
arrow.gif (1632 bytes) A new panel window is created, it is assigned to the variable Output.

createPage(Name, Panel, Output)

func Create a new page for controls inside the tabbook. The second parameter must refer to an instance of the class panel. The panel instance becomes a child window of the tabbook control and it is deleted by the tabbook if the tabbook control is deleted.
pre The variable Panel must refer to an instance of the class panel window.
post If a new page was created then was true assigned to the variable Output, else was false assigned.
arrow.gif (1632 bytes) The second parameter must refer to an instance of the class panel.

removePage(Name, Output)

func Remove a panel window from the collection of panel windows of the tabbook.
pre The variable Name must contain a valid string.
post If the page was removed then was true assigned to the variable Output, else was false assigned.

renamePage(OldName, NewName, Output)

func Rename a page of a tabbook instance, the page to rename must have the name "OldName" and the new name assigned will be "NewName".
pre The variables OldName and NewName must contain a valid string.
post If the page was renamed then was true assigned to the variable Output, else was false assigned.

findPage(Name, OutputPanel)

func Search for the panel window of the page that has the same name as the value of the variable Name.
pre The variable Name must contain a valid string.
post If there was a page with the same name then the panel window instance was assigned to the variable OutputPanel, else no value was assigned to the variable.

findPagePoint(point(X, Y), OutputPanel)

func Search for the panel window of the page that has a tab in which the point(X, Y) lies. The point must be inside the tab of the panel window.
pre The variables X and Y must contain integer values.
post If there was a page of which the point was inside it's tab then the panel window of the page was assigned to the variable OutputPanel, else no value was assigned to the variable.

findPageIndex(I, OutputPanel)

func Search for the panel window which occupies position "I" inside the list of tabs. The index of the first tab is 0, the order of tabs changes each time the user chooses another current page.
pre The variable I must contain integer value.
post If there was a page with the specified index value then the panel window of the page was assigned to the variable OutputPanel, else no value was assigned to the variable.

giveName(I, OutputName)

func Return the name of the tabbook page with index position "I".The index of the first tab is 0, the order of tabs changes each time the user chooses another current page.
pre The variable I must contain integer value.
post If there was a page with the specified index value then the name of the page was assigned to the variable OutputPanel, else no value was assigned to the variable.

giveIndex(Name, OutputIndex)

func Return the index number of the page with the same name as the value of the variable Name. The index of the first tab is 0.
pre The variable Name must contain a string value.
post If there was a page with the specified name then the index of the page was assigned to the variable OutputPanel, else the value -1 was assigned to the variable.

enablePage(Name, YesNo, Output)

func Enable or disable the page, and all the controls on the same page. The page to enable or disable is identified by the value of the variable Name, to disable a page the parameter YesNo must contain the value false, to enable a page this variable must contain true.
pre The variable Name must contain a string value, variable YesNo must contain a boolean value (true or false).
post If there was a page with the specified name and YesNo was false then the page was disabled, if YesNo was true the page was enabled, and true was assigned to the variable Output. If there was no page with the specified name then was false assigned to Output.

isPageEnabled(Name, Output)

func Determine if a page is enabled or disabled.
pre The variable Name must contain a string value.
post If there was a page with the specified name and the page was enabled then was true assigned to the variable Output, if the page was disabled or if there was no page with the specified name then was false assigned.

contains(Output)

func Determine the number of pages a tabbook has.
pre TRUE
post The number of pages of the tabbook was assigned to the variable Output.

switchToPage(Name, Output)

func Make another page of the tabbook the new current page. The new current page will be displayed.
pre The variable Name must contain a string value.
post If there was a page with the specified name then that page has become the current page and is shown, true was assigned to the variable Output. If there was no page with the same name then false was assigned to the variable Output.

switchToPanel(Panel, Output)

func Make another page of the tabbook the new current page. The panel window of the new current page is equal to the value of the variable Panel.
pre The variable Panel must refer to an instance of the class panel.
post If there was a page with the specified panel then that page has become the current page and is shown, true was assigned to the variable Output. If there was no page with the same panel then false was assigned to the variable Output.

currentPage(Output)

func Return the name of the current page.
pre TRUE
post If there was a current page then the name identifying that current page was assigned to Output.

tabPos(Output)

func Return a constant that describes where the tabs of the tabbook control are drawn.
pre TRUE
post If the tabs are drawn at the top then the value 'top' was assigned, if the tabs are drawn at the bottom then the value 'bottom' was assigned.

putTabPos(Pos)

func Determine where the tabs of the tabbook control are drawn, at the top or at the bottom of the control.
pre The variable Output must either contain the value 'top' or 'bottom'.
post The position of where the tabs are drawn was changed if the input variable contained a correct value.

tabHeight(Output)

func Return the height of all the tabs in pixels.
pre TRUE
post The Output variable was assigned the height of all tabs.

putTabHeight(Height, Redraw)

func Set the height of all tabs, the specified value will be the new height in pixels. The parameter Redraw controls whether the tabbook control is redrawn.
pre The variable Height must contain an integer value. The variable Redraw must contain true or false
post The height of all tabs was changed to the value of the variable Height. If Redraw contained the value true the tabbook was redrawn.

tabWidth(Output)

func Return the width of all tabs if the option to draw each tab with the same width is on.
pre TRUE
post The Output variable was assigned the standard width of all tabs if all the tabs must be drawn with the same width.
arrow.gif (1632 bytes) See the method putFixedTabWidth/3.

fixedTabWidth(Output)

func Return the width of each tab if all the tabs have the same fixed width.
pre TRUE
post The width of all tabs was assigned to Output if the width of each tab is fixed.

putFixedTabWidth(YesNo, Width, Redraw)

func Set the same width for all the tabs or switch this option off. If YesNo contains the value true then each tab will have the same width that is equal to the value of the parameter Width. If YesNo contains false then the width of each tab is adapted to the text of the page. The parameter Redraw controls whether the tabbook control is redrawn.
pre The variables YesNo and Redraw must contain true or false, the variable Width must contain an integer value.
post If YesNo was true each tab will have the same width and that width is equal to the value of the parameter Width, if YesNo was false the width of each tab is adapted to the text of the page. If Redraw contained the value true then the control was immediately redrawn.

showFocusRect(Output)

func Determine if the focus rectangle is drawn on a tab if the tab has the keyboard focus.
pre TRUE
post If the focus rectangle is drawn then true was assigned to Output else false was assigned.

putShowFocusRect(YesNo)

func Disable or enable the drawing of the focus rectangle on a tab of a page if the tab has the keyboard focus.
pre The variable YesNo must contain the value true or false.
post If YesNo contained true the focus rectangle is drawn else not.

currentBoldFont(Output)

func Check if the text of the current tab is drawn with a bold text font or not, this is only possible if each tab has the same width.
pre TRUE
post If the text of the current tab is drawn with a bold font then true was assigned to the variable Output, else was false assigned.
arrow.gif (1632 bytes) See the method putFixedTabWidth/3.

putCurrentBoldFont(YesNo)

func Determine if the text of the current tab is drawn with a bold text font or not, this is only possible if each tab has the same width.
pre The variable YesNo must contain the value true or false.
post If YesNo contains the value true then the text of the current tab is drawn with a bold font, else it is drawn with a normal font.
arrow.gif (1632 bytes) See the method putFixedTabWidth/3.

putBackgroundColor(clr(R, G, B), Redraw)

func Set the background color of the tabbook control.
pre The variables R, G, and B must contain integer values in the range [0, 255]. The parameter Redraw must contain either the value true or false.
post The background color was changed to the color specified by the variables R, G and B.

backgroundColor(R, G, B)

func Get the background color of the tabbook control.
pre TRUE.
post The Red, Green and Blue values of the background color were unified with the values of the variables R, G and B.

callbacks

onBeforeSwitch(Sender, OldPage, NewPage, Allowed)

func This callback event is executed just before a switch to a new current page, the names of the old current and the new current page are in the variables OldPage and NewPage, by assigning a value to the variable Allowed it is possible to allow the switch to the new page or to prevent it.
pre The variable Sender refers to the tabbook window which contains the pages. The variable OldPage contains the page that will no longer be the current page if the switch to a new current page is done. The variable NewPage contains the name of the new current page. The variable Allowed is empty.
post If true was assigned to the variable Allowed then the switch to the new current page was executed, else if false was assigned the switch was not done.

onAfterSwitch(Sender, NewPage)

func This callback event is executed after a successful switch to a new current page.
pre The variable Sender refers to the tabbook window which contains the pages. The variable NewPage contains the name of the new current page.
post TRUE