source: cprs/trunk/CPRS-Chart/fReminderTree.pas@ 840

Last change on this file since 840 was 830, checked in by Kevin Toppenberg, 14 years ago

Upgrading to version 27

File size: 21.4 KB
RevLine 
[456]1unit fReminderTree;
2
3interface
4
5uses
6 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
[830]7 StdCtrls, ORCtrls, ExtCtrls, ComCtrls, ImgList, ORFn, Menus, fBase508Form,
8 VA508AccessibilityManager, VA508ImageListLabeler;
[456]9
10type
[830]11 TtvRem508Manager = class(TVA508ComponentManager)
12 private
13 function getDueDate(sData : String): String;
14 function getLastOcc(sData : String): String;
15 function getPriority(sData : String): String;
16 function getName(sData : String): String;
17 function getImgText(Node : TORTreeNode): String;
18 public
19 constructor Create; override;
20 function GetValue(Component: TWinControl): string; override;
21 function GetItem(Component: TWinControl): TObject; override;
22 end;
23
24 TfrmReminderTree = class(TfrmBase508Form)
[456]25 pnlTop: TPanel;
26 tvRem: TORTreeView;
27 hcRem: THeaderControl;
28 pnlTopRight: TPanel;
29 bvlGap: TBevel;
30 lbRem: TORListBox;
31 mmMain: TMainMenu;
32 memAction: TMenuItem;
33 memEvalAll: TMenuItem;
34 memEval: TMenuItem;
35 N2: TMenuItem;
36 memRefresh: TMenuItem;
37 memEvalCat: TMenuItem;
38 mnuCoverSheet: TMenuItem;
39 mnuExit: TMenuItem;
[830]40 imgLblReminders: TVA508ImageListLabeler;
[456]41 procedure FormClose(Sender: TObject; var Action: TCloseAction);
42 procedure FormCreate(Sender: TObject);
43 procedure tvRemExpanded(Sender: TObject; Node: TTreeNode);
44 procedure tvRemCollapsed(Sender: TObject; Node: TTreeNode);
45 procedure pnlTopResize(Sender: TObject);
46 procedure lbRemDrawItem(Control: TWinControl; Index: Integer;
47 Rect: TRect; State: TOwnerDrawState);
48 procedure lbRemChange(Sender: TObject);
49 procedure lbRemClick(Sender: TObject);
50 procedure tvRemEnter(Sender: TObject);
51 procedure tvRemExit(Sender: TObject);
52 procedure hcRemSectionClick(HeaderControl: THeaderControl;
53 Section: THeaderSection);
54 procedure tvRemClick(Sender: TObject);
55 procedure tvRemChange(Sender: TObject; Node: TTreeNode);
56 procedure tvRemMouseDown(Sender: TObject; Button: TMouseButton;
57 Shift: TShiftState; X, Y: Integer);
58 procedure memEvalClick(Sender: TObject);
59 procedure memEvalAllClick(Sender: TObject);
60 procedure FormDestroy(Sender: TObject);
61 procedure memRefreshClick(Sender: TObject);
62 procedure memActionClick(Sender: TObject);
63 procedure memEvalCatClick(Sender: TObject);
64 procedure mnuCoverSheetClick(Sender: TObject);
65 procedure tvRemNodeCaptioning(Sender: TObject; var Caption: String);
66 procedure mnuExitClick(Sender: TObject);
67 private
[830]68 tvRem508Manager : TtvRem508Manager;
[456]69 FLinking: boolean;
70 FSortOrder: integer;
71 FSortAssending: boolean;
72 FSorting: boolean;
73 FUpdating: boolean;
74 memView: TORMenuItem;
75 DateColWidth: integer;
76 LastDateColWidth: integer;
77 PriorityColWidth: integer;
78 procedure SetRemHeaderSectionWidth( SectionIndex: integer; NewWidth: integer);
79 protected
80 procedure Resync(FromTree: boolean);
81 procedure RemindersChanged(Sender: TObject);
82 procedure ResetlbItems(RootNode: TTreeNode);
83 procedure LinkTopControls(FromTree: boolean);
84 procedure SyncTopControls(FromTree: boolean);
85 procedure SortNode(const Node: TTreeNode);
86 function SortData(Node: TORTreeNode): string;
87// procedure PositionToReminder(Sender: TObject);
88 procedure ProcessedRemindersChanged(Sender: TObject);
89 public
90 procedure EnableActions;
91 procedure SetFontSize( NewFontSize: integer);
92 end;
93
94procedure ViewReminderTree;
95
96var
97 frmReminderTree: TfrmReminderTree = nil;
98 RemTreeDlgLeft: integer = 0;
99 RemTreeDlgTop: integer = 0;
100 RemTreeDlgWidth: integer = 0;
101 RemTreeDlgHeight: integer = 0;
102
103const
104 ReminderTreeName = 'frmReminderTree';
105
106implementation
107
108uses uReminders, dShared, uConst, fReminderDialog, fNotes, rMisc,
[830]109 rReminders, fRemCoverSheet, VA2006Utils;
[456]110
111{$R *.DFM}
112
113const
114 UnscaledDateColWidth = 70;
115 UnscaledLastDateColWidth = 89;
116 UnscaledPriorityColWidth = 43;
117
118procedure ViewReminderTree;
119
120begin
121 if(not InitialRemindersLoaded) then
122 StartupReminders;
123 if(not assigned(frmReminderTree)) then
124 frmReminderTree := TfrmReminderTree.Create(Application);
125 frmReminderTree.Show;
126end;
127
128procedure TfrmReminderTree.FormClose(Sender: TObject;
129 var Action: TCloseAction);
130begin
131 Action := caFree;
132end;
133
134procedure TfrmReminderTree.FormCreate(Sender: TObject);
135begin
[830]136 FixHeaderControlDelphi2006Bug(hcRem);
[456]137 memView := TORMenuItem.Create(mmMain);
138 memView.Caption := '&View';
139 memView.Add(TORMenuItem.Create(memView));
140 mmMain.Items.Insert(0, memView);
141
142 bvlGap.Height := GetSystemMetrics(SM_CYHSCROLL);
143 FSortOrder := -1;
144 FSortAssending := TRUE;
145 SetReminderMenuSelectRoutine(memView);
146 NotifyWhenRemindersChange(RemindersChanged);
147// NotifyWhenProcessingReminderChanges(PositionToReminder);
148 ProcessedReminders.Notifier.NotifyWhenChanged(ProcessedRemindersChanged);
149 SetFontSize(MainFontSize);
150 SetReminderFormBounds(Self, 0, 0, Self.Width, Self.Height,
151 RemTreeDlgLeft, RemTreeDlgTop, RemTreeDlgWidth, RemTreeDlgHeight);
[830]152 tvRem508Manager := TtvRem508Manager.Create;
153 amgrMain.ComponentManager[tvRem] := tvRem508Manager;
[456]154end;
155
156procedure TfrmReminderTree.LinkTopControls(FromTree: boolean);
157var
158 idx: integer;
159
160begin
161 if(not FLinking) then
162 begin
163 FLinking := TRUE;
164 try
165 if(FromTree) then
166 begin
167 if(assigned(tvRem.Selected)) then
168 begin
169 idx := lbRem.Items.IndexOfObject(tvRem.Selected);
170 lbRem.ItemIndex := idx;
171 end
172 else
173 lbRem.ItemIndex := -1;
174 end
175 else
176 begin
177 if(lbRem.ItemIndex < 0) then
178 tvRem.Selected := nil
179 else
180 tvRem.Selected := TTreeNode(lbRem.Items.Objects[lbRem.ItemIndex]);
181 end;
182 finally
183 FLinking := FALSE;
184 end;
185 end;
186end;
187
188procedure TfrmReminderTree.RemindersChanged(Sender: TObject);
189const
190 ARTxt = 'Available Reminders';
191
192var
193 OldUpdating: boolean;
194
195begin
196 EnableActions;
197 if(GetReminderStatus = rsNone) then
198 begin
199 tvRem.Selected := nil;
200 Close;
201 exit;
202 end;
203 OldUpdating := FUpdating;
204 try
205 FUpdating := TRUE;
206 lbRem.Items.BeginUpdate;
207 try
208 try
209 BuildReminderTree(tvRem);
210 lbRem.Clear;
211 ResetlbItems(nil);
212 LinkTopControls(TRUE);
213 SyncTopControls(TRUE);
214 pnlTopResize(Self);
215 finally
216 FUpdating := FALSE;
217 tvRem.Invalidate;
218 lbRem.Invalidate;
219 end;
220 if(RemindersEvaluatingInBackground) then
221 hcRem.Sections[0].Text := ARTxt + ' (Evaluating Reminders...)'
222 else
223 hcRem.Sections[0].Text := ARTxt;
224 finally
225 lbRem.Items.EndUpdate;
226 end;
227 finally
228 FUpdating := OldUpdating;
229 end;
230end;
231
232procedure TfrmReminderTree.ResetlbItems(RootNode: TTreeNode);
233var
234 Firsti, i: integer;
235 First, Node: TTreeNode;
236 sl: TStringList;
237 lvl: integer;
238 Add2LB: boolean;
239 Tmp, Data: string;
240
241 function IsVis(Node: TTreeNode): boolean; // IsVisible doesn't work when updating
242 begin
243 Result := TRUE;
244 Node := Node.Parent;
245 while(Result and (assigned(Node))) do
246 begin
247 Result := Node.Expanded;
248 Node := Node.Parent;
249 end;
250 end;
251
252begin
253 if(not FSorting) then
254 begin
255 if(assigned(RootNode)) then
256 begin
257 Node := RootNode.GetFirstChild;
258 lvl := RootNode.Level;
259 Add2LB := RootNode.Expanded;
260 Firsti := lbRem.Items.IndexOfObject(RootNode)+1;
261 end
262 else
263 begin
264 Node := tvRem.Items.GetFirstNode;
265 lvl := -1;
266 Add2LB := TRUE;
267 Firsti := 0;
268 end;
269 First := Node;
270 if(assigned(Node)) then
271 begin
272 sl := TStringList.Create;
273 try
[830]274 sl.Assign(lbRem.Items); // Must use regualr assign, FastAssign doesn't copy objects.
[456]275 while(assigned(Node) and (Node.Level > lvl)) do
276 begin
277 i := sl.IndexOfObject(Node);
278 if(i >= 0) then
279 sl.Delete(i);
280 Node := Node.GetNext;
281 end;
282 if(Add2LB) then
283 begin
284 i := Firsti;
285 Node := First;
286 while(assigned(Node) and (Node.Level > lvl)) do
287 begin
288 if(IsVis(Node)) then
289 begin
290 Tmp := TORTreeNode(Node).StringData;
291 Data := Piece(Tmp,U,RemTreeDateIdx) + U + Piece(Tmp,U,RemTreeDateIdx+1) + U +
292 RemPriorityText[StrToIntDef(Piece(Tmp, U, 5), 2)];
293 sl.InsertObject(i, Data, Node);
294 inc(i);
295 end;
296 Node := Node.GetNext;
297 end;
298 end;
299 lbRem.Items.Assign(sl);
300 finally
301 sl.Free;
302 end;
303 end;
304 end;
305end;
306
307procedure TfrmReminderTree.SyncTopControls(FromTree: boolean);
308begin
309 if(lbRem.Items.Count > 0) and (tvRem.TopItem <> lbRem.Items.Objects[lbRem.TopIndex]) then
310 begin
311 if(FromTree) then
312 lbRem.TopIndex := lbRem.Items.IndexOfObject(tvRem.TopItem)
313 else
314 tvRem.TopItem := TTreeNode(lbRem.Items.Objects[lbRem.TopIndex]);
315 end;
316end;
317
318procedure TfrmReminderTree.tvRemExpanded(Sender: TObject; Node: TTreeNode);
319begin
320 if(FUpdating) then exit;
321 FUpdating := TRUE;
322 try
323 ResetlbItems(Node);
324 pnlTopResize(Self);
325 finally
326 FUpdating := FALSE;
327 end;
328end;
329
330procedure TfrmReminderTree.tvRemCollapsed(Sender: TObject;
331 Node: TTreeNode);
332begin
333 if(FUpdating) then exit;
334 FUpdating := TRUE;
335 try
336 ResetlbItems(Node);
337 pnlTopResize(Self);
338 finally
339 FUpdating := FALSE;
340 end;
341end;
342
343procedure TfrmReminderTree.pnlTopResize(Sender: TObject);
344var
345 Tmp,Adj: integer;
346
347begin
348 Tmp := DateColWidth + LastDateColWidth + PriorityColWidth + 4;
349 if(lbRem.Width <> (lbRem.ClientWidth + 4)) then
350 Adj := ScrollBarWidth
351 else
352 Adj := 0;
353 pnlTopRight.Width := Tmp + Adj;
354 Tmp := pnlTop.Width - DateColWidth - LastDateColWidth - PriorityColWidth - 2 - Adj;
355 SetRemHeaderSectionWidth( 0, Tmp);
356 tvRem.Items.BeginUpdate;
357 try
358 tvRem.Height := pnlTop.Height - hcRem.Height;
359 if(tvRem.Width <> (tvRem.ClientWidth+4)) then
360 inc(Tmp, ScrollBarWidth);
361 tvRem.Width := Tmp;
362 finally
363 tvRem.Items.EndUpdate;
364 end;
365 bvlGap.Visible := (tvRem.Height <> (tvRem.ClientHeight+4));
366end;
367
368procedure TfrmReminderTree.lbRemDrawItem(Control: TWinControl;
369 Index: Integer; Rect: TRect; State: TOwnerDrawState);
370var
371 Tmp: string;
372 Flags: Longint;
373
374begin
375 SyncTopControls(FALSE);
376 if (odSelected in State) then
377 begin
378 if((ActiveControl = lbRem) or (ActiveControl = tvRem)) then
379 begin
380 lbRem.Canvas.Brush.Color := clHighlight;
381 lbRem.Canvas.Font.Color := clHighlightText
382 end
383 else
384 begin
385 lbRem.Canvas.Brush.Color := clInactiveBorder;
386 lbRem.Canvas.Font.Color := clWindowText;
387 end;
388 end;
389 Flags := lbRem.DrawTextBiDiModeFlags(DT_SINGLELINE or DT_VCENTER);
390 Tmp := piece(lbRem.Items[Index],U,1);
391 lbRem.Canvas.FillRect(Rect);
392 Inc(Rect.Left, 6);
393 DrawText(lbRem.Canvas.Handle, PChar(Tmp), Length(Tmp), Rect, Flags);
394 inc(Rect.Left, DateColWidth);
395 Tmp := piece(lbRem.Items[Index],U,2);
396 DrawText(lbRem.Canvas.Handle, PChar(Tmp), Length(Tmp), Rect, Flags);
397 inc(Rect.Left, LastDateColWidth);
398 Tmp := piece(lbRem.Items[Index],U,3);
399 DrawText(lbRem.Canvas.Handle, PChar(Tmp), Length(Tmp), Rect, Flags);
400end;
401
402procedure TfrmReminderTree.lbRemChange(Sender: TObject);
403begin
404 Resync(FALSE);
405 tvRem.SetFocus;
406end;
407
408procedure TfrmReminderTree.lbRemClick(Sender: TObject);
409begin
410 tvRem.SetFocus;
411end;
412
413procedure TfrmReminderTree.tvRemEnter(Sender: TObject);
414begin
415 if(FUpdating) then exit;
416 if(ActiveControl = lbRem) or (ActiveControl = tvRem) then
417 lbRem.Invalidate;
418end;
419
420procedure TfrmReminderTree.tvRemExit(Sender: TObject);
421begin
422 if(FUpdating) then exit;
423 if(ActiveControl <> lbRem) and (ActiveControl <> tvRem) then
424 lbRem.Invalidate;
425end;
426
427procedure TfrmReminderTree.hcRemSectionClick(HeaderControl: THeaderControl;
428 Section: THeaderSection);
429var
430 i, SortIdx: integer;
431 exp: boolean;
432 Sel, Node: TTreeNode;
433
434begin
435 SortIdx := -1;
436 for i := 0 to 3 do
437 begin
438 if(Section = hcRem.Sections[i]) then
439 begin
440 SortIdx := i;
441 break;
442 end;
443 end;
444 if(SortIdx >= 0) then
445 begin
446 Sel := tvRem.Selected;
447 if(FSortOrder = SortIdx) then
448 FSortAssending := not FSortAssending
449 else
450 FSortOrder := SortIdx;
451
452 FSorting := TRUE;
453 tvRem.Items.BeginUpdate;
454 try
455 Node := tvRem.Items.GetFirstNode;
456 while(assigned(Node)) do
457 begin
458 exp := Node.Expanded;
459 SortNode(Node);
460 if(Node.Expanded <> exp) then
461 Node.Expanded := exp;
462 Node := Node.GetNextSibling;
463 end;
464 finally
465 tvRem.Items.EndUpdate;
466 FSorting := FALSE;
467 end;
468 ResetlbItems(nil);
469 tvRem.Selected := Sel;
470 end;
471end;
472
473procedure TfrmReminderTree.SortNode(const Node: TTreeNode);
474var
475 i: integer;
476 sl: TStringList;
477 Tmp, TmpLast: TTreeNode;
478 exp: boolean;
479
480begin
481 if(Node.HasChildren) then
482 begin
483 sl := TStringList.Create;
484 try
485 Tmp := Node.GetFirstChild;
486 while assigned(Tmp) do
487 begin
488 sl.AddObject(SortData(TORTreeNode(Tmp)), Tmp);
489 Tmp := Tmp.GetNextSibling;
490 end;
491 sl.sort;
492 TmpLast := Node;
493 for i := 0 to sl.Count-1 do
494 begin
495 if(FSortAssending) then
496 Tmp := TTreeNode(sl.Objects[i])
497 else
498 Tmp := TTreeNode(sl.Objects[sl.Count-1-i]);
499 exp := Tmp.Expanded;
500 if(i = 0) then
501 Tmp.MoveTo(TmpLast, naAddChildFirst)
502 else
503 Tmp.MoveTo(TmpLast, naInsert);
504 TmpLast := Tmp;
505 SortNode(Tmp);
506 Tmp.Expanded := exp;
507 end;
508 finally
509 sl.Free;
510 end;
511 end;
512end;
513
514function TfrmReminderTree.SortData(Node: TORTreeNode): string;
515
516 function ZForm(str: string; Num: integer): string;
517 begin
518 Result := copy(StringOfChar('0', Num)+str,1+length(str),Num);
519 end;
520
521begin
522 Result := ZForm(piece(Node.StringData, U, RemTreeDateIdx+2),5);
523 case FSortOrder of
524 1: Result := ZForm(Piece(Node.StringData, U, 3), 15)+'.'+Result;
525 2: Result := ZForm(Piece(Node.StringData, U, 4), 15)+'.'+Result;
526 3: Result := Piece(Node.StringData, U, 5)+'.'+Result;
527 end;
528end;
529
530procedure TfrmReminderTree.tvRemClick(Sender: TObject);
531begin
532 Resync(TRUE);
533end;
534
535procedure TfrmReminderTree.tvRemChange(Sender: TObject; Node: TTreeNode);
536var
537 p1: string;
538
539begin
540 memView.Data := '';
541 if(assigned(Node)) then
542 begin
543 p1 := Piece((Node as TORTreeNode).StringData, U, 1);
544 if(Copy(p1,1,1) = RemCode) then
545 begin
546 memView.Data := (Node as TORTreeNode).StringData;
547 end;
548 end;
549 EnableActions;
550
551 Resync(TRUE);
552end;
553
554procedure TfrmReminderTree.tvRemMouseDown(Sender: TObject;
555 Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
556begin
557 Resync(TRUE);
558end;
559
560procedure TfrmReminderTree.Resync(FromTree: boolean);
561begin
562 if(FUpdating) then exit;
563 FUpdating := TRUE;
564 try
565 LinkTopControls(FromTree);
566 SyncTopControls(FromTree);
567 finally
568 FUpdating := FALSE;
569 end;
570end;
571
572{procedure TfrmReminderTree.PositionToReminder(Sender: TObject);
573begin
574 if(assigned(Sender)) then
575 begin
576 if(Sender is TReminder) then
577 begin
578 tvRem.Selected := tvRem.FindPieceNode(RemCode + (Sender as TReminder).IEN, 1);
579 if(assigned(tvRem.Selected)) then
580 TORTreeNode(tvRem.Selected).EnsureVisible;
581 end;
582 end
583 else
584 tvRem.Selected := nil;
585end;}
586
587procedure TfrmReminderTree.memEvalClick(Sender: TObject);
588var
589 Node: TORTreeNode;
590 p1: string;
591
592begin
593 Node := TORTreeNode(tvRem.Selected);
594 if(assigned(Node)) then
595 begin
596 p1 := Piece(Node.StringData, U, 1);
597 if(Copy(p1,1,1) = RemCode) then
598 EvalReminder(StrToIntDef(Copy(p1,2,MaxInt),0));
599 end;
600end;
601
602procedure TfrmReminderTree.EnableActions;
603var
604 OK: boolean;
605 Node: TORTreeNode;
606 p1: string;
607
608begin
609 Node := TORTreeNode(tvRem.Selected);
610 if(assigned(Node)) then
611 p1 := Piece(Node.StringData, U, 1)
612 else
613 p1 := '';
614 if(assigned(Node)) then
615 OK := (Copy(p1,1,1) = RemCode)
616 else
617 OK := FALSE;
618 memEval.Enabled := OK;
619 memEvalAll.Enabled := (ProcessedReminders.Count > 0);
620 memRefresh.Enabled := (not ReminderDialogActive);
621 mnuCoverSheet.Enabled := (NewRemCoverSheetListActive or CanEditAllRemCoverSheetLists);
622 memAction.Enabled := (OK or memEvalAll.Enabled or memRefresh.Enabled or mnuCoverSheet.Enabled);
623 if(assigned(Node)) then
624 OK := ((Copy(p1,1,1) = CatCode) and (p1 <> OtherCatID) and (Node.HasChildren))
625 else
626 OK := FALSE;
627 memEvalCat.Enabled := OK;
628 memEvalCat.Tag := integer(Node);
629end;
630
631procedure TfrmReminderTree.ProcessedRemindersChanged(Sender: TObject);
632begin
633 EnableActions;
634end;
635
636procedure TfrmReminderTree.memEvalAllClick(Sender: TObject);
637begin
638 EvalProcessed;
639end;
640
641procedure TfrmReminderTree.FormDestroy(Sender: TObject);
642begin
643 frmReminderTree := nil;
644 ProcessedReminders.Notifier.RemoveNotify(ProcessedRemindersChanged);
645// RemoveNotifyWhenProcessingReminderChanges(PositionToReminder);
646 RemoveNotifyRemindersChange(RemindersChanged);
647 RemTreeDlgLeft := Self.Left;
648 RemTreeDlgTop := Self.Top;
649 RemTreeDlgWidth := Self.Width;
650 RemTreeDlgHeight := Self.Height;
651end;
652
653procedure TfrmReminderTree.memRefreshClick(Sender: TObject);
654begin
655 KillObj(@ReminderDialogInfo, TRUE);
656 UpdateReminderDialogStatus;
657 EnableActions;
658end;
659
660procedure TfrmReminderTree.memActionClick(Sender: TObject);
661begin
662 EnableActions;
663end;
664
665procedure TfrmReminderTree.memEvalCatClick(Sender: TObject);
666begin
667 EvaluateCategoryClicked(nil, Sender);
668end;
669
670procedure TfrmReminderTree.mnuCoverSheetClick(Sender: TObject);
671begin
672 EditCoverSheetReminderList(not CanEditAllRemCoverSheetLists);
673end;
674
675procedure TfrmReminderTree.SetFontSize(NewFontSize: integer);
676var
677 TotalWidth: integer;
678begin
679 DateColWidth := ResizeWidth(Font, MainFont, UnscaledDateColWidth);
680 LastDateColWidth := ResizeWidth(Font, MainFont, UnscaledLastDateColWidth);
681 PriorityColWidth := ResizeWidth(Font, MainFont, UnscaledPriorityColWidth);
682 ResizeAnchoredFormToFont(self);
683 TotalWidth := hcRem.Width;
684 SetRemHeaderSectionWidth( 0, TotalWidth - DateColWidth - LastDateColWidth - PriorityColWidth);
685 SetRemHeaderSectionWidth( 1, DateColWidth);
686 SetRemHeaderSectionWidth( 2, LastDateColWidth);
687 SetRemHeaderSectionWidth( 3, PriorityColWidth);
688
689 lbRem.ItemHeight := ((Abs(Font.Height)+ 6) div 2)*2; //tvRem.ItemHeight;
690 //This is called "best guess calibration"
691 if Font.Size > 12 then lbRem.ItemHeight := lbRem.ItemHeight + 2;
692 //I am reluctant to use an alignment on the tvRem as there si lots of resizing
693 //tricks going on with the scroll bar at the bottom.
694 tvRem.Top := hcRem.Top+hcRem.Height;
695 pnlTopResize(self);
696end;
697
698procedure TfrmReminderTree.SetRemHeaderSectionWidth( SectionIndex: integer; NewWidth: integer);
699begin
700 hcRem.Sections[SectionIndex].MinWidth := 0;
701 hcRem.Sections[SectionIndex].MaxWidth := NewWidth;
702 hcRem.Sections[SectionIndex].MinWidth := NewWidth;
703 hcRem.Sections[SectionIndex].Width := NewWidth;
704end;
705
706procedure TfrmReminderTree.tvRemNodeCaptioning(Sender: TObject;
707 var Caption: String);
708var
709 StringData: string;
710begin
711 StringData := (Sender as TORTreeNode).StringData;
712 if (Length(StringData) > 0) and (StringData[1] = 'R') then //Only tag reminder statuses
713 case StrToIntDef(Piece(StringData,'^',6 {Due}),-1) of
714 0: Caption := Caption + ' -- Applicable';
715 1: Caption := Caption + ' -- DUE';
716 2: Caption := Caption + ' -- Not Applicable';
717 else Caption := Caption + ' -- Not Evaluated';
718 end;
719end;
720
[830]721procedure TfrmReminderTree.mnuExitClick(Sender: TObject);
[456]722begin
[830]723 Close;
[456]724end;
725
[830]726{ TGrdLab508Manager }
727
728constructor TtvRem508Manager.Create;
[456]729begin
[830]730 inherited Create([mtValue, mtItemChange]);
[456]731end;
732
[830]733function TtvRem508Manager.getDueDate(sData: String): String;
[456]734begin
[830]735 Result := Piece(sData,U,3);
736 if Result <> '' then
737 Result := ' Due Date: ' + FormatFMDateTimeStr('mm/dd/yyyy',Result);
[456]738end;
739
[830]740function TtvRem508Manager.getImgText(Node: TORTreeNode): String;
741begin
742 Result := '';
743 if Node.ImageIndex > -1 then
744 Result := frmReminderTree.imgLblReminders.RemoteLabeler.Labels.Items[Node.ImageIndex].Caption + ' ';
745end;
746
747function TtvRem508Manager.GetItem(Component: TWinControl): TObject;
748var
749 tv : TORTreeView;
750begin
751 tv := TORTreeView(Component);
752 Result := tv.Selected;
753end;
754
755function TtvRem508Manager.getLastOcc(sData: String): String;
756begin
757 Result := Piece(sData,U,4);
758 if Result <> '' then
759 Result := ' Last Occurrence: ' + FormatFMDateTimeStr('mm/dd/yyyy',Result);
760end;
761
762function TtvRem508Manager.getName(sData: String): String;
763begin
764 Result := Piece(sData,U,2);
765end;
766
767function TtvRem508Manager.getPriority(sData: String): String;
768begin
769 Result := Piece(sData,U,5);
770 if Result = '2' then
771 Result := '';
772 if Result <> '' then
773 Result := ' Priority: ' + Result;
774end;
775
776function TtvRem508Manager.GetValue(Component: TWinControl): string;
777var
778 Node: TORTreeNode;
779begin
780 Node := TORTreeNode(TORTreeView(Component).Selected);
781 Result := getImgText(Node) + getName(Node.StringData) + getDueDate(Node.StringData) +
782 getLastOcc(Node.StringData) + getPriority(Node.StringData);
783end;
784
785
[456]786end.
Note: See TracBrowser for help on using the repository browser.