-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathSearch.pas
170 lines (146 loc) · 4.64 KB
/
Search.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
165
166
167
168
169
170
unit Search;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls;
type
TFSearch = class(TForm)
ESearchText: TEdit;
LText: TLabel;
BOk: TButton;
BCancel: TButton;
CBOHPSearch: TCheckBox;
LKey: TLabel;
CKey: TComboBox;
CMM: TComboBox;
CCapo: TComboBox;
LCapo: TLabel;
LTempo: TLabel;
CTempo: TComboBox;
Panel1: TPanel;
BOptions: TButton;
procedure BCancelClick(Sender: TObject);
procedure BOkClick(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure ESearchTextKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormShow(Sender: TObject);
procedure BOptionsClick(Sender: TObject);
procedure ESearchTextEnter(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
// Used to keep this window off the projection screen
procedure WMWindowPosChanging(var hMsg: TWMWindowPosChanging); message WM_WINDOWPOSCHANGING;
public
bShowOptions : boolean;
SearchText : string;
CRec,posX,posY : integer;
Entered : boolean;
SAdvanced, SSimple : string;
{ Public declarations }
end;
var
FSearch: TFSearch;
implementation
uses SearchResults, SBMain, EditProj;
{$R *.DFM}
procedure TFSearch.BCancelClick(Sender: TObject);
begin
SearchTexT:='';
Entered:=false;
close;
end;
procedure TFSearch.BOkClick(Sender: TObject);
begin
SearchText:=ESearchText.Text;
Entered:=true;
CRec:=0;
close;
end;
procedure TFSearch.FormActivate(Sender: TObject);
begin
ESearchText.SelectAll;
end;
procedure TFSearch.ESearchTextKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key=VK_ESCAPE then BCancelClick(Sender);
if Key=VK_RETURN then BOkClick(Sender);
end;
procedure TFSearch.FormClose(Sender: TObject; var Action: TCloseAction);
begin
posX:=left;
posY:=top;
end;
procedure TFSearch.FormShow(Sender: TObject);
begin
top:=posY;
left:=posX;
Height := BOptions.Top + BOptions.Height + (Height - ClientRect.Bottom);
if FSearchResults.Visible then
FSearchResults.Hide;
// If the options are not being shown then reset the hidden ones to 'don't care'
bShowOptions := not bShowOptions;
BOptionsClick(Sender);
ESearchText.SetFocus;
end;
procedure TFSearch.BOptionsClick(Sender: TObject);
begin
bShowOptions := not bShowOptions;
if bShowOptions then begin
Height := Panel1.Top + Panel1.Height + (Height - ClientRect.Bottom);
BOptions.Caption := SSimple;
end else begin
CCapo.ItemIndex := 0;
CKey.ItemIndex := 0;
CMM.ItemIndex := 0;
CTempo.ItemIndex := 0;
Height := BOptions.Top + BOptions.Height + (Height - ClientRect.Bottom);
BOptions.Caption := SAdvanced;
end;
ESearchText.SetFocus;
end;
procedure TFSearch.ESearchTextEnter(Sender: TObject);
begin
ESearchText.SelectAll;
end;
procedure TFSearch.FormCreate(Sender: TObject);
begin
bShowOptions := false;
SAdvanced := 'Advanced >>';
SSimple := '<< Simple';
end;
procedure TFSearch.WMWindowPosChanging(var hMsg: TWMWindowPosChanging);
var rBadRect, rCurRect : TRect;
var ptBadCentre : TPoint;
begin
// Only restrict access once projection form is visible
if FSongbase.BProjectReady and FProjWin.Visible then begin
// Get the desktop rectangle that we don't want to let this screen have
// any intersections with.
rBadRect := Rect( FSongBase.ptDisplayOrigin.X,
FSongBase.ptDisplayOrigin.Y,
FSongBase.ptDisplayOrigin.X + FSongBase.szDisplaySize.cx,
FSongBase.ptDisplayOrigin.Y + FSongBase.szDisplaySize.cy );
rCurRect := Rect( hMsg.WindowPos.x, hMsg.WindowPos.y,
hMsg.WindowPos.x + Width, hMsg.WindowPos.y + Height );
// Work out centre of 'illegal' area so we can work out which side to push off
ptBadCentre.X := FSongBase.ptDisplayOrigin.X + (FSongBase.szDisplaySize.cx div 2);
ptBadCentre.Y := FSongBase.ptDisplayOrigin.Y + (FSongBase.szDisplaySize.cy div 2);
// And do the logic to prevent overlap in X
if (rCurRect.Right < ptBadCentre.X) and (rCurRect.Right > rBadRect.Left) then begin
rCurRect.Left := rBadRect.Left - (rCurRect.Right - rCurRect.Left);
rCurRect.Right := rBadRect.Left;
end;
if (rCurRect.Left > ptBadCentre.X) and (rCurRect.Left < rBadRect.Right) then begin
rCurRect.Right := rBadRect.Right + (rCurRect.Right - rCurRect.Left);
rCurRect.Left := rBadRect.Right;
end;
hMsg.WindowPos.x := rCurRect.Left;
hMsg.WindowPos.y := rCurRect.Top;
end;
inherited;
end;
end.