source: cprs/branches/foia-cprs/CPRS-Chart/Orders/fODValidateAction.pas@ 1083

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

Adding foia-cprs branch

File size: 8.1 KB
Line 
1unit fODValidateAction;
2
3interface
4
5uses
6 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
7 ORFn, uCore, StdCtrls, CheckLst, ComCtrls,ExtCtrls,uConst, ORCtrls;
8
9type
10 TfrmInvalidActionList = class(TForm)
11 pnlTop: TPanel;
12 lstActDeniedOrders: TCaptionListBox;
13 Label1: TLabel;
14 hdrAction: THeaderControl;
15 pnlBottom: TPanel;
16 Label2: TLabel;
17 lstValidOrders: TCaptionListBox;
18 Panel1: TPanel;
19 btnOK: TButton;
20 procedure lstActDeniedOrdersDrawItem(Control: TWinControl;
21 Index: Integer; TheRect: TRect; State: TOwnerDrawState);
22 procedure lstActDeniedOrdersMeasureItem(Control: TWinControl;
23 Index: Integer; var AHeight: Integer);
24 procedure btnOKClick(Sender: TObject);
25 procedure FormCreate(Sender: TObject);
26 procedure hdrActionSectionResize(HeaderControl: THeaderControl;
27 Section: THeaderSection);
28 procedure lstValidOrdersMeasureItem(Control: TWinControl;
29 Index: Integer; var AHeight: Integer);
30 procedure lstValidOrdersDrawItem(Control: TWinControl; Index: Integer;
31 TheRect: TRect; State: TOwnerDrawState);
32 procedure FormResize(Sender: TObject);
33 private
34 { Private declarations }
35 TheInvaList: TStringList;
36 procedure RedrawActiveList;
37 public
38 { Public declarations }
39 end;
40
41 procedure DisplayOrdersForAction(TheInvalidList: TStringList; TheValidList: TStringList; TheAction: String);
42
43implementation
44
45{$R *.DFM}
46
47procedure DisplayOrdersForAction(TheInvalidList: TStringList; TheValidList: TStringList; TheAction: String);
48var
49 frmInvalidActionList: TfrmInvalidActionList;
50 i: integer;
51begin
52 frmInvalidActionList := TfrmInvalidActionList.Create(Application);
53 frmInvalidActionList.TheInvaList :=TheInvalidList;
54 if TheAction = OA_CHGEVT then
55 begin
56 frmInvalidActionList.Caption := 'Change Release Event';
57 frmInvalidActionList.Label1.Caption := 'You can not change the release event for the following orders.';
58 frmInvalidActionList.Label2.Caption := 'You can change the release event for the following orders.';
59 end;
60 if TheAction = OA_EDREL then
61 begin
62 frmInvalidActionList.Caption := 'Release Order(s) To Service';
63 frmInvalidActionList.Label1.Caption := 'You can not release the following orders to service.';
64 frmInvalidActionList.Label2.Caption := 'You can release the following orders to service.';
65 end;
66 for i := 0 to TheInvalidList.Count - 1 do
67 begin
68 frmInvalidActionList.lstActDeniedOrders.Items.Add(Piece(TheInvalidList[i], U, 1) + ' ' + Piece(TheInvalidList[i], U, 2));
69 end;
70 for i := 0 to TheValidList.Count - 1 do
71 begin
72 frmInvalidActionList.lstValidOrders.Items.Add(TheValidList[i]);
73 end;
74 if TheValidList.Count = 0 then
75 begin
76 frmInvalidActionList.lstValidOrders.Visible := False;
77 frmInvalidActionList.pnlBottom.Visible := False;
78 frmInvalidActionList.Height := frmInvalidActionList.Height - frmInvalidActionList.pnlBottom.Height;
79 end;
80 Beep;
81 frmInvalidActionList.ShowModal;
82 frmInvalidActionList.TheInvaList.Free;
83end;
84
85procedure TfrmInvalidActionList.lstActDeniedOrdersDrawItem(
86 Control: TWinControl; Index: Integer; TheRect: TRect;
87 State: TOwnerDrawState);
88var
89 x,x1,x2: string;
90 ARect: TRect;
91 i,RightSide: integer;
92 SaveColor: TColor;
93begin
94 inherited;
95 with lstActDeniedOrders do
96 begin
97 ARect := TheRect;
98 Canvas.FillRect(ARect);
99 Canvas.Pen.Color := clSilver;
100 Canvas.MoveTo(ARect.Left, ARect.Bottom - 1);
101 Canvas.LineTo(ARect.Right, ARect.Bottom - 1);
102 RightSide := -2;
103 for i := 0 to 1 do
104 begin
105 RightSide := RightSide + hdrAction.Sections[i].Width;
106 Canvas.MoveTo(RightSide, ARect.Bottom - 1);
107 Canvas.LineTo(RightSide, ARect.Top);
108 end;
109 if Index < Items.Count then
110 begin
111 x1 := FilteredString(Piece(TheInvaList[index],'^',1));
112 x2 := Piece(TheInvaList[index],'^',2);
113 for i := 0 to 1 do
114 begin
115 if i > 0 then ARect.Left := ARect.Right + 2 else ARect.Left := 2;
116 ARect.Right := ARect.Left + hdrAction.Sections[i].Width - 6;
117 SaveColor := Canvas.Brush.Color;
118 if i = 0 then
119 x := x1;
120 if i = 1 then
121 x := x2;
122 DrawText(Canvas.Handle, PChar(x), Length(x), ARect, DT_LEFT or DT_NOPREFIX or DT_WORDBREAK);
123 Canvas.Brush.Color := SaveColor;
124 ARect.Right := ARect.Right + 4;
125 end;
126 end;
127 end;
128end;
129
130procedure TfrmInvalidActionList.lstActDeniedOrdersMeasureItem(
131 Control: TWinControl; Index: Integer; var AHeight: Integer);
132var
133 x1,x2: string;
134 ARect: TRect;
135 TextHeight, ReasonHeight, NewHeight: Integer;
136begin
137 inherited;
138 AHeight := MainFontHeight + 2;
139 NewHeight := AHeight;
140 with lstActDeniedOrders do if Index < Items.Count then
141 begin
142 x1 := FilteredString(Piece(TheInvaList[index],'^',1));
143 x2 := Piece(TheInvaList[index],'^',2);
144
145 ARect := ItemRect(Index);
146 ARect.Right := hdrAction.Sections[0].Width - 6;
147 ARect.Left := 0; ARect.Top := 0; ARect.Bottom := 0;
148 TextHeight := DrawText(Canvas.Handle, PChar(x1), Length(x1), ARect,
149 DT_CALCRECT or DT_LEFT or DT_NOPREFIX or DT_WORDBREAK) + 2;
150
151 ARect := ItemRect(Index);
152 ARect.Right := hdrAction.Sections[1].Width - 6;
153 ARect.Left := 0; ARect.Top := 0; ARect.Bottom := 0;
154 ReasonHeight := DrawText(Canvas.Handle, PChar(x2), Length(x2), ARect,
155 DT_CALCRECT or DT_LEFT or DT_NOPREFIX or DT_WORDBREAK) + 2;
156 NewHeight := HigherOf(TextHeight, ReasonHeight);
157 if NewHeight > 255 then NewHeight := 255;
158 if NewHeight < 13 then NewHeight := 13;
159 end;
160 AHeight := NewHeight;
161end;
162
163procedure TfrmInvalidActionList.btnOKClick(Sender: TObject);
164begin
165 Close;
166end;
167
168procedure TfrmInvalidActionList.FormCreate(Sender: TObject);
169begin
170 TheInvaList := TStringList.Create;
171end;
172
173procedure TfrmInvalidActionList.hdrActionSectionResize(
174 HeaderControl: THeaderControl; Section: THeaderSection);
175begin
176 inherited;
177 RedrawSuspend(Self.Handle);
178 RedrawActiveList;
179 RedrawActivate(Self.Handle);
180 lstActDeniedOrders.Invalidate;
181end;
182
183procedure TfrmInvalidActionList.RedrawActiveList;
184var
185 i, SaveTop: Integer;
186begin
187 with lstActDeniedOrders do
188 begin
189 RedrawSuspend(Handle);
190 SaveTop := TopIndex;
191 Clear;
192 for i := 0 to TheInvaList.Count - 1 do
193 Items.Add(Piece(TheInvaList[i], U, 1) + ' ' + Piece(TheInvaList[i], U, 2));
194 TopIndex := SaveTop;
195 RedrawActivate(Handle);
196 end;
197end;
198
199procedure TfrmInvalidActionList.lstValidOrdersMeasureItem(
200 Control: TWinControl; Index: Integer; var AHeight: Integer);
201var
202 x: string;
203 ARect: TRect;
204 NewHeight: Integer;
205begin
206 inherited;
207 AHeight := MainFontHeight + 2;
208 NewHeight := AHeight;
209 with lstValidOrders do if Index < Items.Count then
210 begin
211 x := FilteredString(lstValidOrders.Items[index]);
212 ARect := ItemRect(Index);
213 ARect.Right := hdrAction.Sections[0].Width - 6;
214 ARect.Left := 0; ARect.Top := 0; ARect.Bottom := 0;
215 NewHeight := DrawText(Canvas.Handle, PChar(x), Length(x), ARect,
216 DT_CALCRECT or DT_LEFT or DT_NOPREFIX or DT_WORDBREAK) + 2;
217 if NewHeight > 255 then NewHeight := 255;
218 if NewHeight < 13 then NewHeight := 13;
219 end;
220 AHeight := NewHeight;
221end;
222
223procedure TfrmInvalidActionList.lstValidOrdersDrawItem(
224 Control: TWinControl; Index: Integer; TheRect: TRect;
225 State: TOwnerDrawState);
226var
227 x: string;
228 ARect: TRect;
229 SaveColor: TColor;
230begin
231 inherited;
232 with lstValidOrders do
233 begin
234 ARect := TheRect;
235 Canvas.FillRect(ARect);
236 Canvas.Pen.Color := clSilver;
237 SaveColor := Canvas.Brush.Color;
238 Canvas.MoveTo(ARect.Left, ARect.Bottom - 1);
239 Canvas.LineTo(ARect.Right, ARect.Bottom - 1);
240 if Index < Items.Count then
241 begin
242 x := FilteredString(lstValidOrders.Items[index]);
243 DrawText(Canvas.Handle, PChar(x), Length(x), ARect, DT_LEFT or DT_NOPREFIX or DT_WORDBREAK);
244 Canvas.Brush.Color := SaveColor;
245 ARect.Right := ARect.Right + 4;
246 end;
247 end;
248end;
249
250procedure TfrmInvalidActionList.FormResize(Sender: TObject);
251begin
252 if pnlBottom.Visible then
253 pnlTop.Height := (Height div 5 ) * 2
254end;
255
256end.
Note: See TracBrowser for help on using the repository browser.