Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit View.Components.Accordion001;
- interface
- uses
- Winapi.Windows,
- Winapi.Messages,
- System.SysUtils,
- System.Variants,
- System.Classes,
- Vcl.Graphics,
- Vcl.Controls,
- Vcl.Forms,
- Vcl.Dialogs,
- Vcl.ExtCtrls,
- Vcl.StdCtrls,
- View.Components.Interfaces,
- View.Components.Attributes.Interfaces,
- View.Components.Attributes,
- View.Styles.States,
- View.Services.Utils,
- UButtonColor;
- type
- TComponentAccordion001 = class(TForm, iComponents<TComponentAccordion001>)
- Panel1: TPanel;
- Panel2: TPanel;
- Label1: TLabel;
- Image1: TImage;
- Panel3: TPanel;
- Panel4: TPanel;
- ColorButton1: TColorButton;
- procedure FormCreate(Sender: TObject);
- procedure ColorButton1MouseEnter(Sender: TObject);
- procedure ColorButton1MouseLeave(Sender: TObject);
- procedure ColorButton1Click(Sender: TObject);
- private
- { Private declarations }
- FAttributes : iComponentAttributes<TComponentAccordion001>;
- FAlign : TAlign;
- FBackGround : TColor;
- FButtonHeight : Integer;
- FContainer : TWinControl;
- FCountSubMenu : Integer;
- FDestBackGround : TColor;
- FFontSize : Integer;
- FFontColor : TColor;
- FImage : String;
- FOnClick : TProc<TObject>;
- FTitle : String;
- public
- { Public declarations }
- function Component : TWinControl;
- function Attributes : iComponentAttributes<TComponentAccordion001>;
- function LoadAttributes (aValue : String) : TComponentAccordion001;
- function Container (aValue : TWinControl) : iComponents<TComponentAccordion001>;
- function AddSubMenu(aValue : TWinControl) : TComponentAccordion001;
- function This : TComponentAccordion001;
- end;
- var
- ComponentAccordion001: TComponentAccordion001;
- implementation
- {$R *.dfm}
- { TComponentAccordion001 }
- function TComponentAccordion001.AddSubMenu(
- aValue: TWinControl): TComponentAccordion001;
- begin
- Result := Self;
- aValue.Parent:=Panel3;
- Inc(FCountSubMenu);
- TServiceUtils.ResourceImage('ico_keydown', Image1);
- end;
- function TComponentAccordion001.Attributes: iComponentAttributes<TComponentAccordion001>;
- begin
- Result := FAttributes;
- end;
- procedure TComponentAccordion001.ColorButton1Click(Sender: TObject);
- begin
- if Assigned(FOnclick) then
- FOnClick(Sender);
- Panel1.Height:=FButtonHeight;
- if FCountSubMenu > 0 then
- begin
- if not Panel3.Visible then
- Panel1.Height := FButtonHeight + (FCountSubMenu * FButtonHeight);
- Panel3.Visible := not Panel3.Visible;
- TServiceUtils.ResourceImage('ico_keydown', Image1);
- if Panel3.Visible then
- TServiceUtils.ResourceImage('ico_keyup', Image1);
- end;
- end;
- procedure TComponentAccordion001.ColorButton1MouseEnter(Sender: TObject);
- begin
- Panel1.Color := FAttributes.DestBackGround;
- Image1.Visible:=True;
- end;
- procedure TComponentAccordion001.ColorButton1MouseLeave(Sender: TObject);
- begin
- Panel1.Color := FAttributes.BackGround;
- if FCountSubMenu <=0 then
- Image1.Visible:=False;
- end;
- function TComponentAccordion001.Component: TWinControl;
- begin
- Result := Panel1;
- if Assigned(FContainer) then Panel1.Parent:=FContainer;
- Panel3.Visible:=False;
- Panel1.Height := FButtonHeight;
- Panel1.Align := FAttributes.Align;
- Panel1.Color := FAttributes.BackGround;
- Label1.Font.Color:=FAttributes.FontColor;
- Label1.Caption:=FAttributes.Title;
- Image1.Visible:=False;
- Image1.Visible:=not (FCountSubMenu = 0);
- TServiceUtils.ResourceImage(FAttributes.Image, Image1);
- end;
- function TComponentAccordion001.Container(
- aValue: TWinControl): iComponents<TComponentAccordion001>;
- begin
- Result := Self;
- FContainer := aValue;
- end;
- procedure TComponentAccordion001.FormCreate(Sender: TObject);
- begin
- FAttributes := TComponentAttributes<TComponentAccordion001>.New(Self);
- FButtonHeight := 60;
- FCountSubMenu := 0;
- end;
- function TComponentAccordion001.LoadAttributes(
- aValue: String): TComponentAccordion001;
- var
- FLoadAttributes : iComponentAttributes<TComponentAccordion001>;
- begin
- Result := Self;
- FLoadAttributes := (StylesStates.GetStyle(aValue) as iComponentAttributes<TComponentAccordion001>);
- FAttributes := FLoadAttributes.Clone;
- FAttributes.Parent(Self);
- end;
- function TComponentAccordion001.This: TComponentAccordion001;
- begin
- Result := Self;
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement