TYCTogglePanel = class(TCustomPanel)
private
FOnAfterClose,
FOnAfterOpen,
FOnBeforeClose,
FOnBeforeOpen: TNotifyEvent;
FStatus: TYCTogglePanelStatus;
FLocked: Boolean;
FIsOpen: Boolean;
FHeightOpen: Integer;
FHeightClosed: Integer;
FResizeParent: Boolean;
procedure SetHeightOpen(const AValue: Integer);
procedure SetHeightClosed(const AValue: Integer);
procedure SetIsOpen(const AValue: Boolean);
function GetStatus: TYCTogglePanelStatus;
procedure SetStatus(const AValue: TYCTogglePanelStatus);
protected
procedure DblClickPanel(Sender: TObject);
procedure ParentResize;
public
constructor Create(AOwner: TComponent); override;
procedure Toggle;
procedure Open;
procedure Close;
property ResizeParent: Boolean read FResizeParent write FResizeParent default True;
property Locked: Boolean read FLocked write FLocked default False;
property HeightOpen: Integer read FHeightOpen write SetHeightOpen;
property HeightClosed: Integer read FHeightClosed write SetHeightClosed;
property IsOpen: Boolean read FIsOpen write SetIsOpen default True;
published
property Align;
property BevelOuter;
property Color;
property TabOrder;
property Status: TYCTogglePanelStatus read GetStatus write SetStatus;
property OnAfterClose: TNotifyEvent read FOnAfterClose write FOnAfterClose;
property OnAfterOpen: TNotifyEvent read FOnAfterOpen write FOnAfterOpen;
property OnBeforeClose: TNotifyEvent read FOnBeforeClose write FOnBeforeClose;
property OnBeforeOpen: TNotifyEvent read FOnBeforeOpen write FOnBeforeOpen;
end; {TYCTogglePanel}
procedure Register;
implementation
uses
Controls,
YCStyling, YCFonts, YCResource;
constructor TYCTogglePanel.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FIsOpen := True;
FLocked := False;
FResizeParent := True;
FHeightOpen := 12;
FHeightClosed := 6;
HeightOpen := 28;
HeightClosed := 6;
Color := cDfltFuncPnlCol;
Font.Name := DefaultFontName;
Anchors := [akLeft, akRight, akBottom];
BevelOuter := bvLowered;
Align := alBottom;
FStatus := tpsOpenNotLocked;
OnDblClick := DblClickPanel;
/// Height := 28; This doesn't work either.
Parent := AOwner as TWinControl;
end;
.
.
.
procedure TYCTogglePanel.SetHeightOpen(const AValue: Integer);
begin
if (AValue = FHeightOpen) or (AValue <= FHeightClosed) then
Exit;
FHeightOpen := AValue;
if IsOpen then
Height := FHeightOpen;
end;
procedure TYCTogglePanel.SetHeightClosed(const AValue: Integer);
begin
if (AValue <> FHeightClosed) or (not (AValue in [0..Pred(HeightOpen)])) then
Exit;
FHeightClosed := AValue;
if not IsOpen then
Height := FHeightClosed;
end;