[453] | 1 | //kt -- Modified with SourceScanner on 9/5/2007
|
---|
| 2 | unit fHFSearch;
|
---|
| 3 |
|
---|
| 4 | interface
|
---|
| 5 |
|
---|
| 6 | uses
|
---|
| 7 | Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
|
---|
| 8 | fAutoSz, ORFn, StdCtrls, ComCtrls, ORCtrls, ExtCtrls, DKLang;
|
---|
| 9 |
|
---|
| 10 | type
|
---|
| 11 | TfrmHFSearch = class(TfrmAutoSz)
|
---|
| 12 | cbxSearch: TORComboBox;
|
---|
| 13 | tvSearch: TORTreeView;
|
---|
| 14 | pnlBottom: TPanel;
|
---|
| 15 | btnOK: TButton;
|
---|
| 16 | btnCancel: TButton;
|
---|
| 17 | splMain: TSplitter;
|
---|
| 18 | lblCat: TLabel;
|
---|
| 19 | DKLanguageController2: TDKLanguageController;
|
---|
| 20 | procedure FormCreate(Sender: TObject);
|
---|
| 21 | procedure btnOKClick(Sender: TObject);
|
---|
| 22 | procedure tvSearchDblClick(Sender: TObject);
|
---|
| 23 | procedure tvSearchGetImageIndex(Sender: TObject; Node: TTreeNode);
|
---|
| 24 | procedure tvSearchChange(Sender: TObject; Node: TTreeNode);
|
---|
| 25 | procedure cbxSearchChange(Sender: TObject);
|
---|
| 26 | private
|
---|
| 27 | FCode: string;
|
---|
| 28 | FChanging: boolean;
|
---|
| 29 | procedure UpdateCat;
|
---|
| 30 | public
|
---|
| 31 | end;
|
---|
| 32 |
|
---|
| 33 | procedure HFLookup(var Code: string);
|
---|
| 34 |
|
---|
| 35 | implementation
|
---|
| 36 |
|
---|
| 37 | uses rPCE, dShared, fEncounterFrame;
|
---|
| 38 |
|
---|
| 39 | {$R *.DFM}
|
---|
| 40 |
|
---|
| 41 | //const
|
---|
| 42 | //CatTxt = 'Category: '; <-- original line. //kt 9/5/2007
|
---|
| 43 | var
|
---|
| 44 | CatTxt : string; //kt
|
---|
| 45 |
|
---|
| 46 | procedure SetupVars;
|
---|
| 47 | //kt Added entire function to replace constant declarations 9/5/2007
|
---|
| 48 | begin
|
---|
| 49 | CatTxt := DKLangConstW('fHFSearch_Categoryx');
|
---|
| 50 | end;
|
---|
| 51 |
|
---|
| 52 | procedure HFLookup(var Code: string);
|
---|
| 53 | var
|
---|
| 54 | frmHFSearch: TfrmHFSearch;
|
---|
| 55 |
|
---|
| 56 | begin
|
---|
| 57 | frmHFSearch := TfrmHFSearch.Create(Application);
|
---|
| 58 | try
|
---|
| 59 | ResizeFormToFont(TForm(frmHFSearch));
|
---|
| 60 | frmHFSearch.ShowModal;
|
---|
| 61 | Code := frmHFSearch.FCode;
|
---|
| 62 | finally
|
---|
| 63 | frmHFSearch.Free;
|
---|
| 64 | end;
|
---|
| 65 | end;
|
---|
| 66 |
|
---|
| 67 | procedure TfrmHFSearch.cbxSearchChange(Sender: TObject);
|
---|
| 68 | var
|
---|
| 69 | Node: TORTreeNode;
|
---|
| 70 | CurCat, NodeCat: TTreeNode;
|
---|
| 71 | ID: string;
|
---|
| 72 |
|
---|
| 73 | begin
|
---|
| 74 | inherited;
|
---|
| 75 | if(not FChanging) then
|
---|
| 76 | begin
|
---|
| 77 | FChanging := TRUE;
|
---|
| 78 | try
|
---|
| 79 | btnOK.Enabled := (cbxSearch.ItemIndex >= 0);
|
---|
| 80 | if(cbxSearch.ItemIndex < 0) then
|
---|
| 81 | tvSearch.Selected := nil
|
---|
| 82 | else
|
---|
| 83 | begin
|
---|
| 84 | ID := cbxSearch.ItemID;
|
---|
| 85 | if(assigned(tvSearch.Selected)) then
|
---|
| 86 | begin
|
---|
| 87 | CurCat := tvSearch.Selected;
|
---|
| 88 | while (assigned(CurCat.Parent)) do
|
---|
| 89 | CurCat := CurCat.Parent;
|
---|
| 90 | end
|
---|
| 91 | else
|
---|
| 92 | CurCat := nil;
|
---|
| 93 | Node := TORTreeNode(tvSearch.Items.GetFirstNode);
|
---|
| 94 | while assigned(Node) do
|
---|
| 95 | begin
|
---|
| 96 | if(piece(Node.StringData,U,1)= ID) then
|
---|
| 97 | begin
|
---|
| 98 | NodeCat := Node;
|
---|
| 99 | while (assigned(NodeCat.Parent)) do
|
---|
| 100 | NodeCat := NodeCat.Parent;
|
---|
| 101 | RedrawSuspend(tvSearch.Handle);
|
---|
| 102 | try
|
---|
| 103 | if(CurCat <> NodeCat) then
|
---|
| 104 | tvSearch.FullCollapse;
|
---|
| 105 | tvSearch.Selected := Node;
|
---|
| 106 | Node.EnsureVisible;
|
---|
| 107 | finally
|
---|
| 108 | RedrawActivate(tvSearch.Handle);
|
---|
| 109 | end;
|
---|
| 110 | break;
|
---|
| 111 | end;
|
---|
| 112 | Node := TORTreeNode(Node.GetNext);
|
---|
| 113 | end;
|
---|
| 114 | end;
|
---|
| 115 | UpdateCat;
|
---|
| 116 | finally
|
---|
| 117 | FChanging := FALSE;
|
---|
| 118 | end;
|
---|
| 119 | end;
|
---|
| 120 | end;
|
---|
| 121 |
|
---|
| 122 |
|
---|
| 123 | procedure TfrmHFSearch.FormCreate(Sender: TObject);
|
---|
| 124 | var
|
---|
| 125 | HFList: TStringList;
|
---|
| 126 | i: integer;
|
---|
| 127 | Node :TORTreeNode;
|
---|
| 128 | CAT: string;
|
---|
| 129 |
|
---|
| 130 | begin
|
---|
| 131 | inherited;
|
---|
| 132 | HFList := TStringList.Create;
|
---|
| 133 | try
|
---|
| 134 | LoadcboOther(HFList, uEncPCEData.Location, PCE_HF);
|
---|
| 135 | for i := 0 to HFList.Count-1 do
|
---|
| 136 | begin
|
---|
| 137 | if(Piece(HFList[i],U,3)='F') then
|
---|
| 138 | cbxSearch.Items.Add(pieces(HFList[i],U,1,2));
|
---|
| 139 | end;
|
---|
| 140 | for i := 0 to HFList.Count-1 do
|
---|
| 141 | begin
|
---|
| 142 | if(Piece(HFList[i],U,3)='C') then
|
---|
| 143 | begin
|
---|
| 144 | with TORTreeNode(tvSearch.Items.Add(nil, '')) do
|
---|
| 145 | begin
|
---|
| 146 | StringData := HFList[i];
|
---|
| 147 | StateIndex := 2;
|
---|
| 148 | end;
|
---|
| 149 | end;
|
---|
| 150 | end;
|
---|
| 151 | for i := 0 to HFList.Count-1 do
|
---|
| 152 | begin
|
---|
| 153 | if(Piece(HFList[i],U,3)='F') then
|
---|
| 154 | begin
|
---|
| 155 | CAT := piece(HFList[i],U,4);
|
---|
| 156 | Node := TORTreeNode(tvSearch.Items.GetFirstNode);
|
---|
| 157 | while(assigned(Node)) do
|
---|
| 158 | begin
|
---|
| 159 | if(Piece(Node.StringData, U, 1) = CAT) then
|
---|
| 160 | break;
|
---|
| 161 | Node := TORTreeNode(Node.GetNextSibling);
|
---|
| 162 | end;
|
---|
| 163 | TORTreeNode(tvSearch.Items.AddChild(Node, '')).StringData := Pieces(HFList[i],U,1,2);
|
---|
| 164 | end;
|
---|
| 165 | end;
|
---|
| 166 | // tvSearch.Invalidate;
|
---|
| 167 | finally
|
---|
| 168 | HFList.Free;
|
---|
| 169 | end;
|
---|
| 170 | end;
|
---|
| 171 |
|
---|
| 172 | procedure TfrmHFSearch.btnOKClick(Sender: TObject);
|
---|
| 173 | begin
|
---|
| 174 | inherited;
|
---|
| 175 | if cbxSearch.ItemIndex = -1 then Exit;
|
---|
| 176 | FCode := cbxSearch.Items[cbxSearch.ItemIndex];
|
---|
| 177 | ModalResult := mrOK;
|
---|
| 178 | end;
|
---|
| 179 |
|
---|
| 180 | procedure TfrmHFSearch.tvSearchDblClick(Sender: TObject);
|
---|
| 181 | begin
|
---|
| 182 | inherited;
|
---|
| 183 | btnOKClick(Sender);
|
---|
| 184 | end;
|
---|
| 185 |
|
---|
| 186 | procedure TfrmHFSearch.tvSearchGetImageIndex(Sender: TObject;
|
---|
| 187 | Node: TTreeNode);
|
---|
| 188 | begin
|
---|
| 189 | inherited;
|
---|
| 190 | if(piece(TORTreeNode(Node).StringData,U,3)= 'C') then
|
---|
| 191 | begin
|
---|
| 192 | if(Node.Expanded) then
|
---|
| 193 | Node.StateIndex := 3
|
---|
| 194 | else
|
---|
| 195 | Node.StateIndex := 2;
|
---|
| 196 | end;
|
---|
| 197 | // tvSearch.Invalidate;
|
---|
| 198 | end;
|
---|
| 199 |
|
---|
| 200 | procedure TfrmHFSearch.tvSearchChange(Sender: TObject; Node: TTreeNode);
|
---|
| 201 | begin
|
---|
| 202 | inherited;
|
---|
| 203 | if(not FChanging) then
|
---|
| 204 | begin
|
---|
| 205 | FChanging := TRUE;
|
---|
| 206 | try
|
---|
| 207 | if(assigned(Node)) then
|
---|
| 208 | cbxSearch.SelectByID(Piece(TORTreeNode(Node).StringData,U,1))
|
---|
| 209 | else
|
---|
| 210 | cbxSearch.ItemIndex := -1;
|
---|
| 211 | btnOK.Enabled := (cbxSearch.ItemIndex >= 0);
|
---|
| 212 | UpdateCat;
|
---|
| 213 | finally
|
---|
| 214 | FChanging := FALSE;
|
---|
| 215 | end;
|
---|
| 216 | end;
|
---|
| 217 | end;
|
---|
| 218 |
|
---|
| 219 | procedure TfrmHFSearch.UpdateCat;
|
---|
| 220 | var
|
---|
| 221 | NodeCat: TTreeNode;
|
---|
| 222 |
|
---|
| 223 | begin
|
---|
| 224 | NodeCat := tvSearch.Selected;
|
---|
| 225 | if(assigned(NodeCat)) then
|
---|
| 226 | begin
|
---|
| 227 | while (assigned(NodeCat.Parent)) do
|
---|
| 228 | NodeCat := NodeCat.Parent;
|
---|
| 229 | lblCat.Caption := CatTxt + NodeCat.Text;
|
---|
| 230 | end
|
---|
| 231 | else
|
---|
| 232 | lblCat.Caption := CatTxt;
|
---|
| 233 | cbxSearch.Caption := lblCat.Caption;
|
---|
| 234 | end;
|
---|
| 235 |
|
---|
| 236 | end.
|
---|