-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmenuselectframe1.pas
119 lines (99 loc) · 4.19 KB
/
menuselectframe1.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
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
{==============================================================================}
{ Copyright (c) 2010, 2011, 2012 by Donald R. Ziesig. All Rights Reserved. }
{==============================================================================}
{ This file is part of MagicWebsiteBuilder. }
{ }
{ MagicWebsiteBuilder is free software: you can redistribute it and/or modify }
{ it under the terms of the GNU General Public License as published by }
{ the Free Software Foundation, either version 3 of the License, or }
{ (at your option) any later version. }
{ }
{ MagicWebsiteBuilder is distributed in the hope that it will be useful, }
{ but WITHOUT ANY WARRANTY; without even the implied warranty of }
{ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the }
{ GNU General Public License for more details. }
{ }
{ You should have received a copy of the GNU General Public License }
{ along with MagicWebsiteBuilder in file COPYING. If not, see }
{ <http://www.gnu.org/licenses/>. }
{==============================================================================}
unit MenuSelectFrame1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, ComCtrls, ExtCtrls,
Dialogs,
WebsiteMenusUnit1, MenusFrame1;
type
{ TMenuSelectFrame }
TMenuSelectFrame = class(TFrame)
MenusFrame1: TMenusFrame;
MenusFrame2: TMenusFrame;
PageControl1: TPageControl;
Panel1: TPanel;
Panel2: TPanel;
PrimaryMenuPositionRG: TRadioGroup;
SecondaryMenuPositionRG: TRadioGroup;
TabSheet1: TTabSheet;
TabSheet2: TTabSheet;
procedure PrimaryMenuPositionRGClick(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
constructor Create( AOwner : TComponent ); override;
procedure Save( Data : TWebsiteMenusData );
procedure Load( Data : TWebsiteMenusData );
end;
implementation
uses
Common1;
{$R *.lfm}
{ TMenuSelectFrame }
procedure TMenuSelectFrame.PrimaryMenuPositionRGClick(Sender: TObject);
var
I : Integer;
begin
SecondaryMenuPositionRG.Items.Clear;
SecondaryMenuPositionRG.Items.Add('None');
for I := 0 to PrimaryMenuPositionRG.Items.Count - 1 do
if I <> PrimaryMenuPositionRG.ItemIndex then
SecondaryMenuPositionRG.Items.Add(PrimaryMenuPositionRG.Items[I]);
SecondaryMenuPositionRG.ItemIndex := 0;
end;
constructor TMenuSelectFrame.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
PageControl1.TabIndex := 0;
PrimaryMenuPositionRG.ItemIndex := 0;
end;
procedure TMenuSelectFrame.Save(Data: TWebsiteMenusData);
var
I : Integer;
begin
I := PageControl1.TabIndex; // Hack to work around inability to set
if I < 0 then // PageControl's TabIndex in constructor.
PageControl1.TabIndex := 0;
Data.PrimaryMenu.MenuPosition := PrimaryMenuPositionRG.Items[PrimaryMenuPositionRG.ItemIndex];
Data.SecondaryMenu.MenuPosition := SecondaryMenuPositionRG.Items[SecondaryMenuPositionRG.ItemIndex];
MenusFrame1.SetData( Data.PrimaryMenu );
MenusFrame2.SetData( Data.SecondaryMenu );
MenusFrame1.Save( Data.PrimaryMenu ); // LOOK HERE need to separate Primary from Secondary
MenusFrame2.Save( Data.SecondaryMenu ); // LOOK HERE need to separate Primary from Secondary
end;
procedure TMenuSelectFrame.Load(Data: TWebsiteMenusData);
var
I : Integer;
begin
I := PageControl1.TabIndex; // Hack to work around inability to set
if I < 0 then // PageControl's TabIndex in constructor.
PageControl1.TabIndex := 0;
SetPositionRG( PrimaryMenuPositionRG, Data.PrimaryMenu.MenuPosition );
PrimaryMenuPositionRGClick( nil );
SetPositionRG( SecondaryMenuPositionRG, Data.SecondaryMenu.MenuPosition );
MenusFrame1.SetData( Data.PrimaryMenu );
MenusFrame2.SetData( Data.SecondaryMenu );
MenusFrame1.Load( Data.PrimaryMenu ); // LOOK HERE need to separate Primary from Secondary
MenusFrame2.Load( Data.SecondaryMenu ); // LOOK HERE need to separate Primary from Secondary
end;
end.