source: cprs/branches/foia-cprs/CPRS-Chart/Templates/fTemplateObjects.pas@ 1482

Last change on this file since 1482 was 459, checked in by Kevin Toppenberg, 16 years ago

Adding foia-cprs branch

File size: 2.6 KB
Line 
1unit fTemplateObjects;
2
3interface
4
5uses
6 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
7 ORCtrls, StdCtrls, ExtCtrls, ComCtrls, ORFn, dShared;
8
9type
10 TfrmTemplateObjects = class(TForm)
11 cboObjects: TORComboBox;
12 pnlBottom: TPanel;
13 btnCancel: TButton;
14 btnInsert: TButton;
15 btnRefresh: TButton;
16 procedure FormShow(Sender: TObject);
17 procedure btnInsertClick(Sender: TObject);
18 procedure cboObjectsDblClick(Sender: TObject);
19 procedure btnCancelClick(Sender: TObject);
20 procedure btnRefreshClick(Sender: TObject);
21 procedure FormClose(Sender: TObject; var Action: TCloseAction);
22 private
23 Fre: TRichEdit;
24 FAutoLongLines: TNotifyEvent;
25 procedure InsertObject;
26 procedure Setre(const Value: TRichEdit);
27 public
28 procedure UpdateStatus;
29 property re: TRichEdit read Fre write Setre;
30 property AutoLongLines: TNotifyEvent read FAutoLongLines write FAutoLongLines;
31 end;
32
33implementation
34
35{$R *.DFM}
36
37procedure TfrmTemplateObjects.FormShow(Sender: TObject);
38begin
39 ResizeAnchoredFormToFont(self);
40 //ResizeAnchoredFormToFont doesn't work right on the button positions for some reason.
41 btnCancel.Left := pnlBottom.ClientWidth - btnCancel.Width;
42 btnInsert.Left := btnCancel.Left - btnInsert.Width - 5;
43 btnRefresh.Left := btnInsert.Left - btnRefresh.Width - 5;
44 cboObjects.SelectAll;
45 cboObjects.SetFocus;
46end;
47
48procedure TfrmTemplateObjects.btnInsertClick(Sender: TObject);
49begin
50 InsertObject;
51end;
52
53procedure TfrmTemplateObjects.InsertObject;
54var
55 cnt: integer;
56
57begin
58 if(not Fre.ReadOnly) and (cboObjects.ItemIndex >= 0) then
59 begin
60 cnt := Fre.Lines.Count;
61 Fre.SelText := '|'+Piece(cboObjects.Items[cboObjects.ItemIndex],U,3)+'|';
62 if(assigned(FAutoLongLines) and (cnt <> FRe.Lines.Count)) then
63 FAutoLongLines(Self);
64 end;
65end;
66
67procedure TfrmTemplateObjects.cboObjectsDblClick(Sender: TObject);
68begin
69 InsertObject;
70end;
71
72procedure TfrmTemplateObjects.btnCancelClick(Sender: TObject);
73begin
74 Close;
75end;
76
77procedure TfrmTemplateObjects.FormClose(Sender: TObject;
78 var Action: TCloseAction);
79begin
80 Action := caHide;
81end;
82
83procedure TfrmTemplateObjects.Setre(const Value: TRichEdit);
84begin
85 Fre := Value;
86 UpdateStatus;
87end;
88
89procedure TfrmTemplateObjects.UpdateStatus;
90begin
91 btnInsert.Enabled := (not re.ReadOnly);
92end;
93
94procedure TfrmTemplateObjects.btnRefreshClick(Sender: TObject);
95begin
96cboObjects.SelectAll;
97cboObjects.Clear;
98dmodShared.RefreshObject := true;
99dmodShared.LoadTIUObjects;
100CboOBJECTS.Items.AddStrings(dmodShared.TIUObjects);
101end;
102
103end.
Note: See TracBrowser for help on using the repository browser.