-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPanelSplitView.pas
More file actions
157 lines (134 loc) · 4.18 KB
/
PanelSplitView.pas
File metadata and controls
157 lines (134 loc) · 4.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
unit PanelSplitView;
interface
uses
System.SysUtils, System.Classes, Vcl.Controls, Vcl.ExtCtrls, Vcl.Forms,
Vcl.Graphics;
type
TSVCloseStyle = (svColapse, svCompact);
TSVPlacement = (svLeft, svRight);
TSVViewState = (Colapsado, Expandido);
type
TPanelSplitView = class(TPanel)
private
procedure setWidthCompact(const Value: Integer);
Protected
fSplitViewState : TSVViewState; // Estado do SplitView
fSaveWidthSplitView : Integer; // Tamanho do painel antes de estar colapsado
fImageVisibleWidth : Integer; // Tamanho das impagens visiveis quando o closeStyle = Compact
fUseAnimation : Boolean; // Anima o recolhimento/Expansão ou não
fPlacement : TSVPlacement; // Local do Split View
fCloseStyle : TSVCloseStyle; // Modo de Fechamento (Compact ou Colapse)
fWidthCompact : Integer;
procedure SetCloseStyle (CloseStyle : TSVCloseStyle);
procedure SetPlacement (aPlacement : TSVPlacement);
procedure SetAnimation (Animation : Boolean);
procedure SetViewState (aViewState : TSVViewState);
procedure Colapse;
procedure Expand;
Published
property SplitViewState : TSVViewState read fSplitViewState write SetViewState;
property SaveWidthSplitView : Integer read fSaveWidthSplitView write fSaveWidthSplitView;
property ImageVisibleWidth : Integer read fImageVisibleWidth write fImageVisibleWidth;
property UseAnimation : Boolean read fUseAnimation write SetAnimation;
property Placement : TSVPlacement read fPlacement write SetPlacement;
property CloseStyle : TSVCloseStyle read fCloseStyle write SetCloseStyle;
property WidthCompact : Integer read fWidthCompact write setWidthCompact;
// constructor Create (aPanel : TPanel); overload;
// destructor Destroy; override;
Public
procedure MoveSplitView;
constructor Create(AOwner: TComponent); override;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Standard', [TPanelSplitView]);
end;
procedure TPanelSplitView.SetCloseStyle (CloseStyle : TSVCloseStyle);
begin
if CloseStyle = svCompact Then
ImageVisibleWidth := fWidthCompact
else
ImageVisibleWidth := 0;
End;
procedure TPanelSplitView.SetPlacement (aPlacement : TSVPlacement);
begin
fPlacement := aPlacement;
if aPlacement = svLeft then
Align := alLeft
else
Align := alRight;
end;
procedure TPanelSplitView.SetAnimation (Animation : Boolean);
begin
fUseAnimation := Animation;
end;
procedure TPanelSplitView.SetViewState (aViewState : TSVViewState);
begin
fSplitViewState := aViewState;
end;
procedure TPanelSplitView.setWidthCompact(const Value: Integer);
var ValueLimit : integer;
begin
ValueLimit := Trunc(Width);
if Value > ValueLimit then
fWidthCompact := ValueLimit
else
fWidthCompact := Value;
end;
procedure TPanelSplitView.Colapse;
Var
Cont : Integer;
Begin
SaveWidthSplitView := Width;
if UseAnimation then
begin
for Cont := 1 to Width - ImageVisibleWidth do
begin
Width := Width - 1;
Application.ProcessMessages;
end;
end
else
begin
Width := ImageVisibleWidth;
end;
SplitViewState := Colapsado;
End;
constructor TPanelSplitView.Create(AOwner: TComponent);
begin
inherited;
Align := alLeft;
Color := cl3DDkShadow;
fWidthCompact := 50;
SetViewState (Expandido);
SetAnimation(True);
SetCloseStyle(svColapse);
end;
procedure TPanelSplitView.Expand;
Var
Cont : Integer;
Begin
if UseAnimation then
begin
for Cont := 1 to SaveWidthSplitView - ImageVisibleWidth do begin
Width := Width + 1;
Application.ProcessMessages;
end;
end
eLse
begin
SetPlacement(fPlacement);
Width := SaveWidthSplitView;
End;
SplitViewState := Expandido;
End;
procedure TPanelSplitView.MoveSplitView;
begin
if SplitViewState = Expandido then
Colapse
else
Expand;
end;
end.