BS PanelTrans is a helper unit designed to overcome the styling limitations of standard VCL/LCL controls in Lazarus and Delphi applications. The core idea remains the same: transforming a simple TPanel into a functional UI element that behaves like a Button, Speed Button, BitBtn, Group Box, Check Box, or Radio Button.
The main intention is to allow complete customization of color and font for implementing custom color themes in your applications!
Note: The TBSPanelTransManager and the TBSPanelTransToolbar greatly simplify the management and destruction of custom controls.
This is the base class for all transformations and provides the core functionality. It utilizes a TPanel and a TLabel (which can be created internally if needed). You should not use this class directly in your application.
Initial property values are derived from the panel being transformed.
Property Description
Caption The text displayed on the control.
Enabled, Visible The control's operational and visibility state.
Font, ParentFont Font property and the state to use the parent's font.
ParentColor State to use the parent's color.
Hint, ShowHint The control's hint text and whether to display it.
Transparent The control's opacity. Default is true except for button and bitbtn.
Cursor Mouse cursor when it hovers.
These classes transform the panel into a regular button, speed button, or bitbtn. They fully support TAction and advanced color styling.
Styling & Action Properties: Includes Color, HoverColor, ClickColor, DownColor, BorderColor, RoundCorners, Action, ModalResult, and TPopupMenu support.
Methods & Events: Invalidate, PrcSetupColors, Click, and OnClick.
Group Box: TBSPanelAsGroupBox
Draws a distinctive border around the panel area.
Property: BorderColor.
Check Box: TBSPanelAsCheckBox
Produces a check box control by internally creating a TCheckBox.
Property: Checked.
Radio Button: TBSPanelAsRadioButton
Produces a radio button control by internally creating a TRadioButton.
Properties: Checked, GroupId (to link radio buttons).
This class is designed to handle all created controls, greatly simplifying theme management and memory cleanup.
Purpose: Registers all created TBSPanelTrans objects (buttons, group boxes, etc.) for centralized control.
Cleanup: When the manager instance is destroyed, it automatically destroys all registered control objects, eliminating the need for manual individual destruction calls (e.g., in OnDestroy).
Centralized Control: Allows you to change properties (e.g., Font or ParentColor) across all managed controls. Note that this method can only set properties that are available for all registered controls of the same specific class.
This class transforms a TPanel to act like a TToolbar for hosting custom buttons. It is not a descendant of TBSPanelTrans.
Functionality: Manages a collection of TBSPanelAsButton items created within the host panel.
Internal Management: It employs an internal TBSPanelTransManager to automatically handle the creation, destruction, and potentially the collective property changes of all its button items.
Usage: You simply instantiate the toolbar class, associate it with a target TPanel, and use its methods to add your custom buttons.
The demo written in Lazarus contains the full helper unit, uBSPanelTrans. Please run the demo to see BS PanelTrans in action and learn more about its implementation.Â
The pictures below are screenshots of the demo showing how BS PanelTrans transforms panels, compared side-by-side with the standard controls.