unit dToolPanel;
interface
uses
SysUtils, Classes, Forms, Controls, ExtCtrls, Graphics,
Generics.Collections,
AdvPanel, AdvGlowButton;
type
TdToolPanelTab =
class;
TOpenDirection = (odLeft, odRight);
TOnClosePanel =
procedure(Sender: TObject; Panel: TdToolPanelTab)
of object;
TOnOpenPanel =
procedure(Sender: TObject; Panel: TdToolPanelTab)
of object;
TdToolPanelTab =
class(TCollectionItem)
// der eigentliche Tab
strict private
FOpenWith: Integer;
FPanelForm: TForm;
FPanelButton: TAdvGlowButton;
FPanelButtonImageIndex: Integer;
public
constructor Create(Collection: TCollection; Parent: TWinControl);
reintroduce;
destructor Destroy;
override;
property PanelForm: TForm
read FPanelForm
write FPanelForm;
// die Form für den Content
property PanelButton: TAdvGlowButton
read FPanelButton
write FPanelButton;
// der Button für den Tab
published
property PanelButtonImageIndex: Integer
read FPanelButtonImageIndex
write FPanelButtonImageIndex;
property OpenWith: Integer
read FOpenWith
write FOpenWith;
// legt die Breite des PanelForms fest
end;
TPanelList =
class(TCollection)
// die Collection der Tabs
private
function GetItem(
Index: Integer): TdToolPanelTab;
procedure SetItem(
Index: Integer; Value: TdToolPanelTab);
protected
FOwner: TAdvPanel;
public
constructor Create(Owner: TAdvPanel; Parent: TWinControl);
function Add: TdToolPanelTab;
function Owner: TAdvPanel;
property Items[
Index: Integer]: TdToolPanelTab
read GetItem
write SetItem;
default;
end;
TdToolPanel =
class(TAdvPanel)
// die Basis
strict private
FOpenDirection: TOpenDirection;
FPanels: TPanelList;
FActivePanel: TdToolPanelTab;
FButtonImages: TImageList;
FButtonHeight: Integer;
procedure SetActivePanel(
const Value: TdToolPanelTab);
private
protected
public
procedure Loaded;
override;
published
constructor Create(Owner: TComponent);
override;
destructor Destroy;
override;
property ActivePanel: TdToolPanelTab
read FActivePanel
write SetActivePanel;
property Panels: TPanelList
read FPanels
write FPanels;
property ButtonImages: TImageList
read FButtonImages
write FButtonImages;
property ButtonHeight: Integer
read FButtonHeight
write FButtonHeight
default 100;
property OpenDirection: TOpenDirection
read FOpenDirection
write FOpenDirection;
end;
procedure Register;
implementation
{ TdToolPanel }
// Initialisierung
constructor TdToolPanel.Create;
begin
inherited;
FPanels := TPanelList.Create(
nil, Self);
FOpenDirection := odLeft;
FButtonHeight := 100;
end;
destructor TdToolPanel.Destroy;
begin
FPanels.Free;
inherited;
end;
procedure TdToolPanel.Loaded;
begin
inherited;
//
end;
procedure TdToolPanel.SetActivePanel(
const Value: TdToolPanelTab);
begin
FActivePanel := Value;
//
end;
{ TdToolPanelTab }
constructor TdToolPanelTab.Create(Collection: TCollection; Parent: TWinControl);
begin
inherited Create(Collection);
FPanelButton := TAdvGlowButton.Create(
nil);
// FPanelButton.Parent := Parent;
FPanelButton.Align := alTop;
FPanelButton.AlignWithMargins := True;
FPanelButton.Caption := '
';
FPanelButton.Margins.Bottom := 0;
FPanelButton.Margins.Left := 2;
FPanelButton.Margins.Right := 2;
FPanelButton.Margins.Top := 2;
FPanelForm := TForm.Create(
nil);
end;
destructor TdToolPanelTab.Destroy;
begin
FPanelForm.Free;
FPanelButton.Free;
inherited;
end;
{ TPanelList }
// Initialisation
constructor TPanelList.Create(Owner: TAdvPanel; Parent: TWinControl);
begin
inherited Create(TdToolPanelTab);
FOwner := Owner;
end;
// Getter // Setter
function TPanelList.GetItem(
Index: Integer): TdToolPanelTab;
begin
Result := TdToolPanelTab(
inherited GetItem(
Index));
end;
procedure TPanelList.SetItem(
Index: Integer; Value: TdToolPanelTab);
begin
inherited SetItem(
Index, Value);
end;
// Work
function TPanelList.Add: TdToolPanelTab;
begin
Result := TdToolPanelTab(
inherited Add);
end;
function TPanelList.Owner: TAdvPanel;
begin
Result := FOwner;
end;
procedure Register;
begin
RegisterComponents('
DIMOWA', [TdToolPanel]);
end;
end.