2 TfmActionListEditor = class(TForm)
\r
10 chkStayOnTop: TCheckBox;
\r
11 lvActions: TListView;
\r
12 procedure FormResize(Sender: TObject);
\r
13 procedure FormShow(Sender: TObject);
\r
14 procedure chkStayOnTopClick(Sender: TObject);
\r
15 procedure btAddClick(Sender: TObject);
\r
16 procedure btDelClick(Sender: TObject);
\r
17 procedure btUpClick(Sender: TObject);
\r
18 procedure btDownClick(Sender: TObject);
\r
19 procedure FormKeyDown(Sender: TObject; var Key: Word;
\r
20 Shift: TShiftState);
\r
21 procedure lvActionsSelectItem(Sender: TObject; Item: TListItem;
\r
23 {$IFDEF VER90} {$DEFINE OLDDELPHI} {$ENDIF}
\r
24 {$IFDEF VER100} {$DEFINE OLDDELPHI} {$ENDIF}
\r
26 procedure lvActionsChange(Sender: TObject; Item: TListItem; Change: TItemChange);
\r
28 procedure lvActionsEdited(Sender: TObject; Item: TListItem;
\r
30 procedure FormDestroy(Sender: TObject);
\r
31 procedure FormClose(Sender: TObject; var Action: TCloseAction);
\r
33 { Private declarations }
\r
34 FActionList: TComponent;
\r
35 procedure SetActionList(const Value: TComponent);
\r
36 procedure AdjustButtons;
\r
39 { Public declarations }
\r
40 property ActionList: TComponent read FActionList write SetActionList;
\r
41 procedure MakeActive( SelectAny: Boolean );
\r
42 constructor Create( AOwner: TComponent ); override;
\r
43 procedure NameChanged(Sender: TComponent);
\r
47 fmlvActionsEditor: TfmActionListEditor;
\r
51 uses mirror, mckCtrls, mckObjs;
\r
55 procedure TfmActionListEditor.AdjustButtons;
\r
58 LI := lvActions.Selected;
\r
61 btAdd.Enabled := lvActions.Items.Count = 0;
\r
62 btDel.Enabled := FALSE;
\r
63 btUp.Enabled := FALSE;
\r
64 btDown.Enabled := FALSE;
\r
68 btAdd.Enabled := TRUE;
\r
69 btDel.Enabled := TRUE;
\r
70 btUp.Enabled := LI.Index > 0;
\r
71 btDown.Enabled := LI.Index < lvActions.Items.Count - 1;
\r
75 procedure TfmActionListEditor.FormResize(Sender: TObject);
\r
77 lvActions.Columns[ 0 ].Width := lvActions.ClientWidth;
\r
80 procedure TfmActionListEditor.MakeActive(SelectAny: Boolean);
\r
86 if lvActions.Items.Count > 0 then
\r
87 if lvActions.Selected = nil then
\r
89 lvActions.Selected := lvActions.Items[ 0 ];
\r
90 if lvActions.Selected <> nil then
\r
92 Act := lvActions.Selected.Data;
\r
93 F := (FActionList as TKOLActionList).Owner as TForm;
\r
96 {$IFDEF _D6orHigher}
\r
97 F.Designer.QueryInterface(IFormDesigner,D);
\r
102 if QueryFormDesigner( D, FD ) then
\r
104 RemoveSelection( FD );
\r
105 FD.SelectComponent( Act );
\r
112 procedure TfmActionListEditor.SetActionList(const Value: TComponent);
\r
113 var LV: TKOLActionList;
\r
115 FActionList := Value;
\r
116 LV := FActionList as TKOLActionList;
\r
117 Caption := LV.Name + ' actions';
\r
120 procedure TfmActionListEditor.FormShow(Sender: TObject);
\r
124 AL: TKOLActionList;
\r
126 lvActions.Items.BeginUpdate;
\r
129 lvActions.Items.Clear;
\r
130 if FActionList <> nil then
\r
131 if FActionList is TKOLActionList then
\r
133 AL := FActionList as TKOLActionList;
\r
134 for I := 0 to AL.Count-1 do
\r
136 LI := lvActions.Items.Add;
\r
139 LI.Caption := Act.Name;
\r
144 lvActions.Items.EndUpdate;
\r
148 procedure TfmActionListEditor.chkStayOnTopClick(Sender: TObject);
\r
150 if chkStayOnTop.Checked then
\r
151 FormStyle := fsStayOnTop
\r
153 FormStyle := fsNormal;
\r
156 procedure TfmActionListEditor.btAddClick(Sender: TObject);
\r
159 AL: TKOLActionList;
\r
163 if FActionList = nil then Exit;
\r
164 if not( FActionList is TKOLActionList ) then Exit;
\r
165 AL := FActionList as TKOLActionList;
\r
166 LI := lvActions.Selected;
\r
169 Act := TKOLAction.Create( AL.Owner );
\r
170 LI := lvActions.Items.Add;
\r
175 if LI.Index >= lvActions.Items.Count then
\r
176 Act := TKOLAction.Create( AL.Owner )
\r
179 Act := TKOLAction.Create( AL.Owner );
\r
180 Act.ActionList:=AL;
\r
181 AL.List.Move( lvActions.Items.Count, LI.Index + 1 );
\r
183 LI := lvActions.Items.Insert( LI.Index + 1 );
\r
186 if AL <> nil then begin
\r
187 Act.ActionList:=AL;
\r
188 if AL.Owner is TForm then
\r
189 for I := 1 to MaxInt do
\r
191 S := 'Action' + IntToStr( I );
\r
192 if (AL.Owner as TForm).FindComponent( S ) = nil then
\r
193 if AL.FindComponent( S ) = nil then
\r
200 lvActions.Selected := nil;
\r
201 lvActions.Selected := LI;
\r
202 lvActions.ItemFocused := LI;
\r
203 LI.MakeVisible( FALSE );
\r
206 procedure TfmActionListEditor.btDelClick(Sender: TObject);
\r
211 LI := lvActions.Selected;
\r
218 if J >= lvActions.Items.Count then
\r
222 lvActions.Selected := lvActions.Items[ J ];
\r
223 lvActions.ItemFocused := lvActions.Selected;
\r
227 if lvActions.Items.Count = 0 then
\r
231 procedure TfmActionListEditor.btUpClick(Sender: TObject);
\r
232 var LI, LI1: TListItem;
\r
234 AL: TKOLActionList;
\r
236 if FActionList = nil then Exit;
\r
237 if not(FActionList is TKOLActionList) then Exit;
\r
238 AL := FActionList as TKOLActionList;
\r
239 LI := lvActions.Selected;
\r
240 if LI = nil then Exit;
\r
242 LI1 := lvActions.Items.Insert( I );
\r
243 LI1.Caption := LI.Caption;
\r
244 LI1.Data := LI.Data;
\r
245 AL.List.Move( I + 1, I );
\r
247 lvActions.Selected := LI1;
\r
248 lvActions.ItemFocused := LI1;
\r
252 procedure TfmActionListEditor.btDownClick(Sender: TObject);
\r
253 var LI, LI1: TListItem;
\r
254 AL: TKOLActionList;
\r
256 if FActionList = nil then Exit;
\r
257 if not(FActionList is TKOLActionList) then Exit;
\r
258 AL := FActionList as TKOLActionList;
\r
259 LI := lvActions.Selected;
\r
260 if LI = nil then Exit;
\r
261 AL.List.Move( LI.Index, LI.Index + 1 );
\r
262 LI1 := lvActions.Items.Insert( LI.Index + 2 );
\r
263 LI1.Caption := LI.Caption;
\r
264 LI1.Data := LI.Data;
\r
266 lvActions.Selected := LI1;
\r
267 lvActions.ItemFocused := LI1;
\r
271 procedure TfmActionListEditor.FormKeyDown(Sender: TObject; var Key: Word;
\r
272 Shift: TShiftState);
\r
275 VK_F2: if (lvActions.Selected <> nil) then
\r
276 lvActions.Selected.EditCaption
\r
278 VK_INSERT: btAdd.Click;
\r
279 VK_DELETE: if not lvActions.IsEditing then btDel.Click else exit;
\r
280 VK_RETURN: if (ActiveControl = lvActions) and not lvActions.IsEditing and
\r
281 (lvActions.Selected <> nil) then
\r
282 lvActions.Selected.EditCaption
\r
284 VK_UP: if (GetKeyState( VK_CONTROL ) < 0) then
\r
287 VK_DOWN: if (GetKeyState( VK_CONTROL ) < 0) then
\r
295 procedure TfmActionListEditor.lvActionsSelectItem(Sender: TObject;
\r
296 Item: TListItem; Selected: Boolean);
\r
299 MakeActive( FALSE );
\r
303 procedure TfmActionListEditor.lvActionsChange(Sender: TObject; Item: TListItem; Change: TItemChange);
\r
305 if lvActions.Selected <> nil then
\r
306 MakeActive( FALSE );
\r
310 procedure TfmActionListEditor.lvActionsEdited(Sender: TObject;
\r
311 Item: TListItem; var S: String);
\r
312 var Act: TKOLAction;
\r
314 if Item = nil then Exit;
\r
315 if S = '' then begin
\r
321 MakeActive( FALSE );
\r
324 procedure TfmActionListEditor.FormDestroy(Sender: TObject);
\r
325 var LV: TKOLActionList;
\r
327 Rpt( 'Destroying ActionList columns editor' );
\r
328 if FActionList = nil then Exit;
\r
329 LV := FActionList as TKOLActionList;
\r
330 LV.ActiveDesign := nil;
\r
333 procedure TfmActionListEditor.FormClose(Sender: TObject;
\r
334 var Action: TCloseAction);
\r
336 Rpt( 'Closing ActionList columns editor' );
\r
338 modalResult := mrOK;
\r
341 procedure TfmActionListEditor.NameChanged(Sender: TComponent);
\r
345 for i:=0 to lvActions.Items.Count - 1 do
\r
346 if lvActions.Items[i].Data = Sender then begin
\r
347 lvActions.Items[i].Caption:=Sender.Name;
\r
351 procedure TfmActionListEditor.SelectLV;
\r
356 if FActionList <> nil then
\r
358 F := (FActionList as TKOLActionList).Owner as TForm;
\r
361 Rpt( 'Form found: ' + F.Name );
\r
363 {$IFDEF _D6orHigher} //
\r
364 F.Designer.QueryInterface(IFormDesigner,D); //
\r
371 Rpt( 'IDesigner interface returned' );
\r
372 if QueryFormDesigner( D, FD ) then
\r
374 Rpt( 'IFormDesigner interface quered' );
\r
376 RemoveSelection( FD );
\r
377 FD.SelectComponent( FActionList );
\r
379 Rpt( 'EXCEPTION *** Could not clear selection!' )
\r
388 constructor TfmActionListEditor.Create(AOwner: TComponent);
\r
396 HorzScrollBar.Visible := False;
\r
397 VertScrollBar.Visible := False;
\r
398 BorderIcons := [biSystemMenu];
\r
399 Caption := 'Actions';
\r
400 //Color := clBtnFace;
\r
401 //Font.Charset := DEFAULT_CHARSET;
\r
402 //Font.Color := clWindowText;
\r
403 //Font.Height := -11;
\r
404 Font.Name := 'MS Sans Serif';
\r
405 //Font.Style := [];
\r
406 KeyPreview := True;
\r
407 //OldCreateOrder := False;
\r
409 OnClose := FormClose;
\r
410 OnDestroy := FormDestroy;
\r
411 OnKeyDown := FormKeyDown;
\r
412 OnResize := FormResize;
\r
413 OnShow := FormShow;
\r
414 PixelsPerInch := 96;
\r
415 //TextHeight := 13;
\r
416 pnButtons := TPanel.Create( Self );
\r
425 BevelOuter := bvNone;
\r
427 btAdd := TButton.Create( pnButtons );
\r
430 Parent := pnButtons;
\r
437 OnClick := btAddClick;
\r
439 btDel := TButton.Create( pnButtons );
\r
442 Parent := pnButtons;
\r
447 Caption := '&Delete';
\r
449 OnClick := btDelClick;
\r
451 btUp := TButton.Create( pnButtons );
\r
454 Parent := pnButtons;
\r
461 OnClick := btUpClick;
\r
463 btDown := TButton.Create( pnButtons );
\r
466 Parent := pnButtons;
\r
471 Caption := '&Down';
\r
473 OnClick := btDownClick;
\r
475 chkStayOnTop := TCheckBox.Create( pnButtons );
\r
476 with chkStayOnTop do
\r
478 Parent := pnButtons;
\r
483 Caption := 'Stay On &Top';
\r
485 OnClick := chkStayOnTopClick;
\r
488 pnView := TPanel.Create( Self );
\r
497 BevelOuter := bvNone;
\r
500 lvActions := TListView.Create( pnView );
\r
510 HideSelection := False;
\r
514 ShowColumnHeaders := False;
\r
516 ViewStyle := vsReport;
\r
517 OnEdited := lvActionsEdited;
\r
519 OnChange := lvActionsChange;
\r
521 OnSelectItem := lvActionsSelectItem;
\r