TBar
Fuente: source/classes/bar.prg
Inherits from: TControl
TBar is a button bar container that displays a horizontal or vertical strip of bitmap buttons with optional group separators. It supports multiple visual styles including flat 3D, Office 2007/2010/2013/2015 themes, GDI+ rendering, dark theme, and floating/dockable toolbars.
Key DATA Members
| DATA | Type | Description |
|---|---|---|
nGroups | Numeric | Number of button groups in the bar |
nMode | Numeric | Docking position: BAR_TOP(1), BAR_LEFT(2), BAR_RIGHT(3), BAR_DOWN(4), BAR_FLOAT(5) |
nBtnWidth | Numeric | Button width (default 28 pixels) |
nBtnHeight | Numeric | Button height (default 28 pixels) |
l3D | Logical | Enable 3D button borders |
l2007 | Logical | Office 2007 theme look |
l2010 | Logical | Office 2010 theme look |
l2013 | Logical | Office 2013 flat theme look |
l2015 | Logical | Office 2015 theme look |
lGDIP | Logical | Enable GDI+ rendering (read-only) |
lBorder | Logical | Show bar border |
bClrGrad | Codeblock | Gradient color codeblock |
Methods
| Method | Description |
|---|---|
New( oWnd, nBtnW, nBtnH, l3D, cMode, oCursor, l2007, l2010, l2013, lBorder, oBrush, aGrad, nColor, lHScroll, l2015, nAlto, lGDIP, lDesign, cVarName ) | Create a new TBar attached to oWnd |
NewAt( nRow, nCol, nWidth, nHeight, nBtnW, nBtnH, oWnd, l3D, cMode ) | Create a TBar at a specific position and size |
Add( oBtnBmp, nPos ) | Add a TButtonBmp to the bar |
AddGroup( nPos ) | Insert a visual group separator |
Del( nPos, lRefresh ) | Remove a button from the bar |
Adjust() | Recalculate button positions and bar size |
Float() | Undock the bar into a floating window |
GoDown() / GoLeft() / GoRight() / GoTop() | Dock the bar to the specified edge |
SetDarkTheme() | Apply dark theme colors to the bar |
SetGradients( aGrad, oBrush, nColor ) | Apply gradient background |
Redefine( nId, oWnd, nWidth, nHeight, l2007, l2010, l2013, lBorder, l2015 ) | Redefine from dialog resource |
Example: Top Bar with 3 Buttons
#include "FiveWin.ch"
function Main()
local oWnd, oBar
DEFINE WINDOW oWnd TITLE "Button Bar Demo" SIZE 600, 400
oBar := TBar():New( oWnd, 32, 32,, "TOP" )
oBar:Add( TButtonBmp():New(,, "New", oWnd,, 32, 32,,, .F., .F.,,,,, "new.bmp" ) )
oBar:Add( TButtonBmp():New(,, "Open", oWnd,, 32, 32,,, .F., .F.,,,,, "open.bmp" ) )
oBar:Add( TButtonBmp():New(,, "Save", oWnd,, 32, 32,,, .F., .F.,,,,, "save.bmp" ) )
ACTIVATE WINDOW oWnd CENTERED
return nil
Notes
- TBar auto-sizes to fit its parent window width (top/down) or height (left/right).
- Use the
cModeparameter to set initial docking:"TOP","LEFT","RIGHT","BOTTOM", or"FLOAT". - The
l97Lookdata member controls backward-compatible flat button appearance. Keep it as NIL for modern button rendering. - Office themes (l2007, l2010, l2013, l2015) are mutually exclusive; enable only one.
- TBar supports right-button context menus for runtime customization.