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