forked from oulan/Asuite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PropertyItem.pas
164 lines (146 loc) · 5.29 KB
/
PropertyItem.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
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
158
159
160
161
162
163
164
unit PropertyItem;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, VirtualTrees, Vcl.ExtCtrls, Vcl.StdCtrls, BaseEntityPage,
ulNodeDataTypes, DKLang;
type
TfrmPropertyItem = class(TForm)
btnOk: TButton;
btnCancel: TButton;
pnlPropertyPage: TPanel;
vstCategory: TVirtualStringTree;
DKLanguageController1: TDKLanguageController;
procedure vstCategoryFreeNode(Sender: TBaseVirtualTree; Node: PVirtualNode);
procedure vstCategoryGetText(Sender: TBaseVirtualTree; Node: PVirtualNode;
Column: TColumnIndex; TextType: TVSTTextType; var CellText: string);
procedure vstCategoryGetImageIndex(Sender: TBaseVirtualTree;
Node: PVirtualNode; Kind: TVTImageKind; Column: TColumnIndex;
var Ghosted: Boolean; var ImageIndex: Integer);
procedure vstCategoryAddToSelection(Sender: TBaseVirtualTree;
Node: PVirtualNode);
procedure vstCategoryInitNode(Sender: TBaseVirtualTree; ParentNode,
Node: PVirtualNode; var InitialStates: TVirtualNodeInitStates);
procedure FormCreate(Sender: TObject);
procedure btnCancelClick(Sender: TObject);
procedure btnOkClick(Sender: TObject);
private
{ Private declarations }
procedure SaveNodeData(Sender: TBaseVirtualTree; Node: PVirtualNode;
Data: Pointer; var Abort: Boolean);
strict private
FCurrentPage: TfrmBaseEntityPage;
FFrameGeneral, FFrameAdvanced: PVirtualNode;
FListNodeData: TvCustomRealNodeData;
public
{ Public declarations }
function Execute(ANodeData:TvCustomRealNodeData):Integer;
end;
var
frmPropertyItem: TfrmPropertyItem;
implementation
uses
ulFrameUtils, BaseGeneralPropertyPage, AdvancedPropertyPage, ulEnumerations,
BehaviorPropertyPage, AppConfig, CatGeneralPropertyPage, SWGeneralPropertyPage,
Main, udImages;
{$R *.dfm}
procedure TfrmPropertyItem.btnCancelClick(Sender: TObject);
begin
ModalResult := mrCancel;
end;
procedure TfrmPropertyItem.btnOkClick(Sender: TObject);
var
ResultNode: PVirtualNode;
begin
//If IterateSubtree returns a value, something is wrong
ResultNode := vstCategory.IterateSubtree(nil, SaveNodeData, nil);
if Not Assigned(ResultNode) then
begin
FListNodeData.Changed := True;
//If changed, refresh cache icon
FListNodeData.ResetIcon;
FListNodeData.ImageIndex := ImagesDM.GetIconIndex(FListNodeData);
if frmMain.Visible then
frmMain.FocusControl(frmMain.vstList);
ModalResult := mrOk;
end;
end;
function TfrmPropertyItem.Execute(ANodeData: TvCustomRealNodeData): Integer;
begin
FListNodeData := ANodeData;
//General
if (ANodeData.DataType = vtdtFile) or (ANodeData.DataType = vtdtFolder) then
FFrameGeneral := AddFrameNode(vstCategory, nil, TPageFrameClass(TfrmSWGeneralPropertyPage.Create(Self, ANodeData)))
else
if ANodeData.DataType = vtdtCategory then
FFrameGeneral := AddFrameNode(vstCategory, nil, TPageFrameClass(TfrmCatGeneralPropertyPage.Create(Self, ANodeData)));
FFrameAdvanced := AddFrameNode(vstCategory, nil, TPageFrameClass(TfrmAdvancedPropertyPage.Create(Self, ANodeData)));
AddFrameNode(vstCategory, nil, TPageFrameClass(TfrmBehaviorPropertyPage.Create(Self, ANodeData)));
//Select node (automatically open frame using vst's AddToSelection event)
vstCategory.Selected[FFrameGeneral] := True;
vstCategory.FullExpand;
Result := ShowModal;
end;
procedure TfrmPropertyItem.FormCreate(Sender: TObject);
begin
vstCategory.NodeDataSize := SizeOf(rFramesNodeData);
vstCategory.Clear;
end;
procedure TfrmPropertyItem.SaveNodeData(Sender: TBaseVirtualTree;
Node: PVirtualNode; Data: Pointer; var Abort: Boolean);
var
NodeData : PFramesNodeData;
begin
//Call Frame's function SaveData
NodeData := vstCategory.GetNodeData(Node);
Abort := Not(TfrmBaseEntityPage(NodeData.Frame).SaveData);
end;
procedure TfrmPropertyItem.vstCategoryAddToSelection(Sender: TBaseVirtualTree;
Node: PVirtualNode);
var
NodeData : PFramesNodeData;
begin
NodeData := Sender.GetNodeData(Node);
if Assigned(NodeData) then
LoadPage(FCurrentPage, NodeData.Frame, pnlPropertyPage);
end;
procedure TfrmPropertyItem.vstCategoryFreeNode(Sender: TBaseVirtualTree;
Node: PVirtualNode);
var
NodeData : PFramesNodeData;
begin
NodeData := Sender.GetNodeData(Node);
if Assigned(NodeData) then
begin
TfrmBaseEntityPage(NodeData.Frame).Free;
NodeData.Title := '';
end;
end;
procedure TfrmPropertyItem.vstCategoryGetImageIndex(Sender: TBaseVirtualTree;
Node: PVirtualNode; Kind: TVTImageKind; Column: TColumnIndex;
var Ghosted: Boolean; var ImageIndex: Integer);
var
NodeData : PFramesNodeData;
begin
NodeData := Sender.GetNodeData(Node);
if Assigned(NodeData) then
ImageIndex := NodeData.ImageIndex;
end;
procedure TfrmPropertyItem.vstCategoryGetText(Sender: TBaseVirtualTree;
Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType;
var CellText: string);
var
NodeData : PFramesNodeData;
begin
NodeData := Sender.GetNodeData(Node);
CellText := 'Options Page';
if Assigned(NodeData) then
if NodeData.Title <> '' then
CellText := NodeData.Title;
end;
procedure TfrmPropertyItem.vstCategoryInitNode(Sender: TBaseVirtualTree;
ParentNode, Node: PVirtualNode; var InitialStates: TVirtualNodeInitStates);
begin
Node.NodeHeight := 36;
end;
end.