-
Notifications
You must be signed in to change notification settings - Fork 10
/
DW.VCL.NavBar.pas
91 lines (71 loc) · 2.11 KB
/
DW.VCL.NavBar.pas
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
unit DW.VCL.NavBar;
interface
uses
SysUtils, Classes, StrUtils, DW.VCL.CustomRegion, DWElementTag;
type
TDWNavBarFixed = (bsnvfxNone, bsnvfxTop, bsnvfxBottom);
TDWNavBarBase = class(TDWCustomRegion);
TDWNavBar = class(TDWNavBarBase)
private
FFluid: boolean;
FFixed: TDWNavBarFixed;
FInverse: boolean;
protected
procedure InternalRenderCss(var ACss: string); override;
public
constructor Create(AOwner: TComponent); override;
function RenderHTML: TDWElementTag; override;
published
property BSFluid: boolean read FFluid write FFluid default False;
property BSInverse: boolean read FInverse write FInverse default False;
property BSFixed: TDWNavBarFixed read FFixed write FFixed default bsnvfxNone;
end;
TDWNavBarHeader = class(TDWNavBarBase)
protected
procedure InternalRenderCss(var ACss: string); override;
end;
TDWNavBarCollapse = class(TDWNavBarBase)
protected
procedure InternalRenderCss(var ACss: string); override;
end;
implementation
uses
DW.VCL.Common, DWUtils;
{ TDWNavBar }
constructor TDWNavBar.Create(AOwner: TComponent);
begin
inherited;
FFluid := False;
FFixed := bsnvfxNone;
FInverse := False;
FTagName := 'nav';
end;
procedure TDWNavBar.InternalRenderCss(var ACss: string);
begin
TDWBSCommon.AddCssClass(ACss, 'navbar navbar-' + iif(FInverse, 'inverse', 'default'));
if FFixed = bsnvfxTop then
TDWBSCommon.AddCssClass(ACss, 'navbar-fixed-top')
else if FFixed = bsnvfxBottom then
TDWBSCommon.AddCssClass(ACss, ' navbar-fixed-bottom');
inherited;
end;
function TDWNavBar.RenderHTML: TDWElementTag;
begin
Result := Inherited;
FRegionDiv := Result.Contents.AddElement('div');
FRegionDiv.AddClassParam('container' + iif(FFluid, '-fluid', ''));
end;
{ TDWNavBarHeader }
procedure TDWNavBarHeader.InternalRenderCss(var ACss: string);
begin
TDWBSCommon.AddCssClass(ACss, 'navbar-header');
inherited;
end;
{ TDWNavBarCollapse }
procedure TDWNavBarCollapse.InternalRenderCss(var ACss: string);
begin
TDWBSCommon.AddCssClass(ACss, 'navbar-collapse');
TDWBSCommon.AddCssClass(ACss, 'collapse');
inherited;
end;
end.