TBarTabs
Source: source/classes/bartabs.prg
Standalone class (not descendant of TControl)
TBarTabs combines TTabs with TBar to create a ribbon-like tabbed toolbar interface. Each tab is associated with a separate toolbar that becomes visible when the tab is selected. This provides a compact way to organize toolbar buttons into functional groups, similar to the ribbon pattern found in modern desktop applications.
Key DATA Members
| DATA | Type | Description |
|---|---|---|
aBars | Array | Array of TBar objects, one per tab |
oTabs | Object | TTabs control for switching between toolbars |
oPanel | Object | TPanel container holding the tabs and buttons |
oWnd | Object | Parent window |
nBar | Numeric | Index of the currently active toolbar tab |
Methods
| Method | Description |
|---|---|
New( oWnd, nBtnWidth, nBtnHeight, aPrompts, acBitmaps, nOption, l3D, l2007 ) | Create a new TBarTabs control with initial tabs |
AddBar( cPrompt, cBitmap ) | Add a new tab with its associated toolbar. Returns the TBar object. |
Example: Three-Tab Toolbar
#include "FiveWin.ch"
function Main()
local oWnd, oBarTabs, oBar
local aPrompts := { "Home", "Insert", "View" }
local acBitmaps := {}
DEFINE WINDOW oWnd TITLE "BarTabs Demo" SIZE 600, 200
oBarTabs := TBarTabs():New( oWnd, 64, 32, aPrompts, acBitmaps, 1, .F., .T. )
// Home tab buttons
oBar := oBarTabs:aBars[ 1 ]
DEFINE BUTTON OF oBar PROMPT "Cut"
DEFINE BUTTON OF oBar PROMPT "Copy"
DEFINE BUTTON OF oBar PROMPT "Paste"
// Insert tab buttons
oBar := oBarTabs:aBars[ 2 ]
DEFINE BUTTON OF oBar PROMPT "Table"
DEFINE BUTTON OF oBar PROMPT "Image"
// View tab buttons
oBar := oBarTabs:aBars[ 3 ]
DEFINE BUTTON OF oBar PROMPT "Zoom In"
DEFINE BUTTON OF oBar PROMPT "Zoom Out"
oBarTabs:oPanel:ReSize()
ACTIVATE WINDOW oWnd CENTERED
return nil
Notes
- TBarTabs is a standalone class that does not inherit from TControl. It manages a TPanel container that holds a TTabs control and multiple TBar toolbars.
- The constructor creates one toolbar per prompt. Use
AddBar()to add toolbars dynamically after construction. - Set
l3D := .T.for a classic 3D button look, orl2007 := .T.(default) for the Office 2007-style gradient appearance. - The panel is positioned as
oWnd:oTop, meaning it attaches to the top of the parent window. CalloBarTabs:oPanel:ReSize()after adding buttons to ensure correct layout. - Only the toolbar corresponding to the selected tab is visible; switching tabs automatically hides the previous toolbar and shows the new one.
- Bitmaps for tab headers can be provided via the
acBitmapsarray parameter, which is passed directly to the TTabs control.