source: cprs/branches/tmg-cprs/CPRS-Chart/fDrawers.pas@ 466

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

Initial upload of TMG-CPRS 1.0.26.69

File size: 46.6 KB
Line 
1//kt -- Modified with SourceScanner on 7/15/2007
2unit fDrawers;
3{
4bugs noticed:
5 if delete only note (currently editing) then drawers and encounter button still enabled
6}
7//vw mod for template callup. Checks in test 4/15/07
8interface
9
10uses
11 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
12 ExtCtrls, StdCtrls, Buttons, ORCtrls, ComCtrls, ImgList, uTemplates,
13 Menus, ORClasses, ORFn, DKLang;
14
15type
16 TDrawer = (odNone, odTemplates, odEncounter, odReminders, odOrders);
17 TDrawers = set of TDrawer;
18
19 TfrmDrawers = class(TForm)
20 lbOrders: TORListBox;
21 sbOrders: TORAlignSpeedButton;
22 sbReminders: TORAlignSpeedButton;
23 sbEncounter: TORAlignSpeedButton;
24 sbTemplates: TORAlignSpeedButton;
25 pnlOrdersButton: TKeyClickPanel;
26 pnlRemindersButton: TKeyClickPanel;
27 pnlEncounterButton: TKeyClickPanel;
28 pnlTemplatesButton: TKeyClickPanel;
29 lbEncounter: TORListBox;
30 popTemplates: TPopupMenu;
31 mnuPreviewTemplate: TMenuItem;
32 pnlTemplates: TPanel;
33 tvTemplates: TORTreeView;
34 N1: TMenuItem;
35 mnuCollapseTree: TMenuItem;
36 N2: TMenuItem;
37 mnuEditTemplates: TMenuItem;
38 pnlTemplateSearch: TPanel;
39 btnFind: TORAlignButton;
40 edtSearch: TCaptionEdit;
41 mnuFindTemplates: TMenuItem;
42 mnuNewTemplate: TMenuItem;
43 cbMatchCase: TCheckBox;
44 cbWholeWords: TCheckBox;
45 mnuInsertTemplate: TMenuItem;
46 tvReminders: TORTreeView;
47 mnuDefault: TMenuItem;
48 N3: TMenuItem;
49 mnuGotoDefault: TMenuItem;
50 N4: TMenuItem;
51 mnuViewNotes: TMenuItem;
52 mnuCopyTemplate: TMenuItem;
53 N5: TMenuItem;
54 mnuViewTemplateIconLegend: TMenuItem;
55 DKLanguageController1: TDKLanguageController;
56 procedure FormCanResize(Sender: TObject; var NewWidth,
57 NewHeight: Integer; var Resize: Boolean);
58 procedure FormResize(Sender: TObject);
59 procedure sbTemplatesClick(Sender: TObject);
60 procedure sbEncounterClick(Sender: TObject);
61 procedure sbRemindersClick(Sender: TObject);
62 procedure sbOrdersClick(Sender: TObject);
63 procedure sbResize(Sender: TObject);
64 procedure tvTemplatesGetImageIndex(Sender: TObject; Node: TTreeNode);
65 procedure tvTemplatesGetSelectedIndex(Sender: TObject;
66 Node: TTreeNode);
67 procedure tvTemplatesExpanding(Sender: TObject; Node: TTreeNode;
68 var AllowExpansion: Boolean);
69 procedure tvTemplatesClick(Sender: TObject);
70 procedure tvTemplatesDblClick(Sender: TObject);
71 procedure tvTemplatesCollapsing(Sender: TObject; Node: TTreeNode;
72 var AllowCollapse: Boolean);
73 procedure tvTemplatesKeyDown(Sender: TObject; var Key: Word;
74 Shift: TShiftState);
75 procedure tvTemplatesKeyUp(Sender: TObject; var Key: Word;
76 Shift: TShiftState);
77 procedure popTemplatesPopup(Sender: TObject);
78 procedure mnuPreviewTemplateClick(Sender: TObject);
79 procedure FormDestroy(Sender: TObject);
80 procedure mnuCollapseTreeClick(Sender: TObject);
81 procedure btnFindClick(Sender: TObject);
82 procedure edtSearchChange(Sender: TObject);
83 procedure ToggleMenuItem(Sender: TObject);
84 procedure edtSearchEnter(Sender: TObject);
85 procedure edtSearchExit(Sender: TObject);
86 procedure mnuFindTemplatesClick(Sender: TObject);
87 procedure tvTemplatesDragging(Sender: TObject; Node: TTreeNode;
88 var CanDrag: Boolean);
89 procedure mnuEditTemplatesClick(Sender: TObject);
90 procedure mnuNewTemplateClick(Sender: TObject);
91 procedure FormCreate(Sender: TObject);
92 procedure pnlTemplateSearchResize(Sender: TObject);
93 procedure cbFindOptionClick(Sender: TObject);
94 procedure mnuInsertTemplateClick(Sender: TObject);
95 procedure tvRemindersMouseUp(Sender: TObject; Button: TMouseButton;
96 Shift: TShiftState; X, Y: Integer);
97 procedure tvRemindersCurListChanged(Sender: TObject; Node: TTreeNode);
98 procedure mnuDefaultClick(Sender: TObject);
99 procedure mnuGotoDefaultClick(Sender: TObject);
100 procedure mnuViewNotesClick(Sender: TObject);
101 procedure mnuCopyTemplateClick(Sender: TObject);
102 procedure mnuViewTemplateIconLegendClick(Sender: TObject);
103 procedure pnlTemplatesButtonEnter(Sender: TObject);
104 procedure pnlTemplatesButtonExit(Sender: TObject);
105 procedure tvRemindersKeyDown(Sender: TObject; var Key: Word;
106 Shift: TShiftState);
107 procedure tvRemindersNodeCaptioning(Sender: TObject;
108 var Caption: String);
109 procedure tvRemindersAddition(Sender: TObject; Node: TTreeNode);
110 procedure tvRemindersDeletion(Sender: TObject; Node: TTreeNode);
111 private
112 //kt Begin Mod (change Consts to Vars) 7/15/2007
113 DrawerSplitters : string; //kt
114 FindNextText : string; //kt
115 //kt End Mod -------------------
116 FOpenToNode: string;
117 FOldMouseUp: TMouseEvent;
118 FEmptyNodeCount: integer;
119 FOldDragDrop: TDragDropEvent;
120 FOldDragOver: TDragOverEvent;
121 FOldFontChanged: TNotifyEvent;
122 FTextIconWidth: integer;
123 FInternalResize: integer;
124 FHoldResize: integer;
125 FOpenDrawer: TDrawer;
126 FLastOpenSize: integer;
127 FButtonHeights: integer;
128 FInternalExpand :boolean;
129 FInternalHiddenExpand :boolean;
130 FAsk :boolean;
131 FAskExp :boolean;
132 FAskNode :TTreeNode;
133 FDragNode :TTreeNode;
134 FClickOccurred: boolean;
135 FRichEditControl: TRichEdit;
136 FFindNext: boolean;
137 FLastFoundNode: TTreeNode;
138 FSplitter: TSplitter;
139 FOldCanResize: TCanResizeEvent;
140 FSplitterActive: boolean;
141 FHasPersonalTemplates: boolean;
142 FRemNotifyList: TORNotifyList;
143 FDefTempPiece: integer;
144 FNewNoteButton: TButton;
145 FCurrentVisibleDrawers: TDrawers;
146 FCurrentEnabledDrawers: TDrawers;
147 function GetAlign: TAlign;
148 procedure SetAlign(const Value: TAlign);
149 function MinDrawerControlHeight: integer;
150 procedure DisableArrowKeyMove(Sender: TObject);
151 protected
152 procedure PositionToReminder(Sender: TObject);
153 procedure RemindersChanged(Sender: TObject);
154 procedure SetFindNext(const Value: boolean);
155 procedure ReloadTemplates;
156 procedure SetRichEditControl(const Value: TRichEdit);
157 procedure CheckAsk;
158 procedure FontChanged(Sender: TObject);
159 procedure InitButtons;
160 procedure StartInternalResize;
161 procedure EndInternalResize;
162 procedure ResizeToVisible;
163 function ButtonHeights: integer;
164 procedure GetDrawerControls(Drawer: TDrawer;
165 var Btn: TORAlignSpeedButton;
166 var Ctrl: TWinControl);
167 procedure AddTemplateNode(const tmpl: TTemplate; const Owner: TTreeNode = nil);
168 procedure MoveCaret(X, Y: integer);
169 procedure NewRECDragDrop(Sender, Source: TObject; X, Y: Integer);
170 procedure NewRECDragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState;
171 var Accept: Boolean);
172 procedure InsertText;
173 procedure SetSplitter(const Value: TSplitter);
174 procedure SplitterCanResize(Sender: TObject; var NewSize: Integer; var Accept: Boolean);
175 procedure SetSplitterActive(Active: boolean);
176 function EnableDrawer(Drawer: TDrawer; EnableIt: boolean): boolean;
177 function InsertOK(Ask: boolean): boolean;
178 procedure OpenToNode(Path: string = '');
179 property FindNext: boolean read FFindNext write SetFindNext;
180 procedure SetupVars;
181 public
182 constructor CreateDrawers(AOwner: TComponent; AParent: TWinControl;
183 VisibleDrawers, EnabledDrawers: TDrawers);
184 procedure ExternalReloadTemplates;
185 procedure OpenDrawer(Drawer: TDrawer);
186 procedure ToggleDrawer(Drawer: TDrawer);
187 procedure ShowDrawers(Drawers: TDrawers);
188 procedure EnableDrawers(Drawers: TDrawers);
189 procedure DisplayDrawers(Show: Boolean); overload;
190 procedure DisplayDrawers(Show: Boolean; AEnable, ADisplay: TDrawers); overload;
191 function CanEditTemplates: boolean;
192 function CanEditShared: boolean;
193 procedure UpdatePersonalTemplates;
194 procedure NotifyWhenRemTreeChanges(Proc: TNotifyEvent);
195 procedure RemoveNotifyWhenRemTreeChanges(Proc: TNotifyEvent);
196 procedure ResetTemplates;
197 property RichEditControl: TRichEdit read FRichEditControl write SetRichEditControl;
198 property NewNoteButton: TButton read FNewNoteButton write FNewNoteButton;
199 property Splitter: TSplitter read FSplitter write SetSplitter;
200 property HasPersonalTemplates: boolean read FHasPersonalTemplates;
201 property LastOpenSize: integer read FLastOpenSize write FLastOpenSize;
202 property DefTempPiece: integer read FDefTempPiece write FDefTempPiece;
203 property TheOpenDrawer: TDrawer read FOpenDrawer;
204 published
205 property Align: TAlign read GetAlign write SetAlign;
206 end;
207
208{ There is a different instance of frmDrawers on each tab, so make the
209 frmDrawers variable local to each tab, do not use this global var! }
210//var
211 //frmDrawers: TfrmDrawers;
212
213const
214 DrawerSplitters = 'frmDrawersSplitters';
215
216implementation
217
218uses fTemplateView, uCore, rTemplates, fTemplateEditor, dShared, uReminders,
219 fReminderDialog, RichEdit, fRptBox, Clipbrd, fTemplateDialog, fIconLegend,
220 uAccessibleTreeView, uAccessibleTreeNode;
221
222{$R *.DFM}
223
224const
225 BaseMinDrawerControlHeight = 24;
226//FindNextText = 'Find Next'; <-- original line. //kt 7/15/2007
227
228procedure TfrmDrawers.SetupVars;
229//kt Added entire function to replace constant declarations 7/15/2007
230begin
231 FindNextText := DKLangConstW('fDrawers_Find_Next');
232end;
233
234function TfrmDrawers.MinDrawerControlHeight: integer;
235begin
236 result := ResizeHeight( BaseFont, MainFont, BaseMinDrawerControlHeight);
237end;
238
239procedure TfrmDrawers.ResizeToVisible;
240var
241 NewHeight: integer;
242 od: TDrawer;
243 Button: TORAlignSpeedButton;
244 WinCtrl: TWinControl;
245
246 procedure AllCtrls(AAlign: TAlign);
247 var
248 od: TDrawer;
249
250 begin
251 Parent.DisableAlign;
252 try
253 for od := succ(low(TDrawer)) to high(TDrawer) do
254 begin
255 GetDrawerControls(od, Button, WinCtrl);
256 Button.Parent.Align := AAlign;
257 WinCtrl.Align := AAlign;
258 end;
259 finally
260 Parent.EnableAlign;
261 end;
262 end;
263
264begin
265 if((FHoldResize = 0) and Visible) then
266 begin
267 FButtonHeights := -1; //Force re-calculate
268 NewHeight := 0;
269 AllCtrls(alNone);
270 for od := succ(low(TDrawer)) to high(TDrawer) do
271 begin
272 GetDrawerControls(od, Button, WinCtrl);
273 if(Button.Parent.Visible) then
274 begin
275 Button.Parent.Top := NewHeight;
276 inc(NewHeight, Button.Parent.Height);
277 WinCtrl.Top := NewHeight;
278 if(WinCtrl.Visible) then
279 begin
280 if(FLastOpenSize < 10) or (FLastOpenSize > (Parent.Height - 20)) then
281 begin
282 FLastOpenSize := (Parent.Height div 4) * 3;
283 dec(FLastOpenSize, ButtonHeights);
284 if(FLastOpenSize < MinDrawerControlHeight) then
285 FLastOpenSize := MinDrawerControlHeight;
286 end;
287 inc(NewHeight, FLastOpenSize);
288 WinCtrl.Height := FLastOpenSize;
289 end
290 else
291 WinCtrl.Height := 0;
292 end;
293 end;
294 AllCtrls(alTop);
295 StartInternalResize;
296 try
297 ClientHeight := NewHeight
298 finally
299 EndInternalResize;
300 end;
301 end;
302end;
303
304procedure TfrmDrawers.FormCanResize(Sender: TObject; var NewWidth,
305 NewHeight: Integer; var Resize: Boolean);
306var
307 od: TDrawer;
308 Btn: TORAlignSpeedButton;
309 Ctrl: TWinControl;
310 IsVisible: boolean;
311
312begin
313 if(FInternalResize = 0) then
314 begin
315 IsVisible := FALSE;
316 for od := succ(low(TDrawer)) to high(TDrawer) do
317 begin
318 GetDrawerControls(od, Btn, Ctrl);
319 if(Ctrl.Visible) then
320 begin
321 IsVisible := TRUE;
322 break;
323 end;
324 end;
325 if(not IsVisible) then
326 NewHeight := ButtonHeights;
327 end;
328end;
329
330function TfrmDrawers.ButtonHeights: integer;
331begin
332 if(FButtonHeights < 0) then
333 begin
334 FButtonHeights := 0;
335 if(pnlOrdersButton.Visible) then
336 inc(FButtonHeights, sbOrders.Height);
337 if(pnlRemindersButton.Visible) then
338 inc(FButtonHeights, sbReminders.Height);
339 if(pnlEncounterButton.Visible) then
340 inc(FButtonHeights, sbEncounter.Height);
341 if(pnlTemplatesButton.Visible) then
342 inc(FButtonHeights, sbTemplates.Height);
343 end;
344 Result := FButtonHeights;
345end;
346
347procedure TfrmDrawers.ShowDrawers(Drawers: TDrawers);
348var
349 od: TDrawer;
350 Btn: TORAlignSpeedButton;
351 Ctrl: TWinControl;
352 SaveLOS: integer;
353
354begin
355 if(FCurrentVisibleDrawers = []) or (Drawers <> FCurrentVisibleDrawers) then
356 begin
357 FCurrentVisibleDrawers := Drawers;
358 SaveLOS := FLastOpenSize;
359 OpenDrawer(odNone);
360 for od := succ(low(TDrawer)) to high(TDrawer) do
361 begin
362 GetDrawerControls(od, Btn, Ctrl);
363 Btn.Parent.Visible := (od in Drawers);
364 Ctrl.Visible := FALSE;
365 Ctrl.Height := 0;
366 end;
367 FButtonHeights := -1;
368 FLastOpenSize := SaveLOS;
369 ResizeToVisible;
370 if(odReminders in Drawers) then
371 begin
372 NotifyWhenRemindersChange(RemindersChanged);
373 NotifyWhenProcessingReminderChanges(PositionToReminder);
374 end
375 else
376 begin
377 RemoveNotifyRemindersChange(RemindersChanged);
378 RemoveNotifyWhenProcessingReminderChanges(PositionToReminder);
379 end;
380 end;
381end;
382
383procedure TfrmDrawers.OpenDrawer(Drawer: TDrawer);
384var
385 Btn: TORAlignSpeedButton;
386 Ctrl: TWinControl;
387
388begin
389 if(FOpenDrawer <> Drawer) then
390 begin
391 StartInternalResize;
392 try
393 if(FOpenDrawer <> odNone) then
394 begin
395 GetDrawerControls(FOpenDrawer, Btn, Ctrl);
396 Btn.Down := FALSE;
397 with Btn.Parent as TPanel do
398 if BevelOuter = bvLowered then
399 BevelOuter := bvRaised;
400 Ctrl.Visible := FALSE;
401 Ctrl.Height := 0;
402 end;
403 if(Drawer = odNone) then
404 begin
405 FOpenDrawer := Drawer;
406 SetSplitterActive(FALSE);
407 end
408 else
409 begin
410 GetDrawerControls(Drawer, Btn, Ctrl);
411 if(Btn.Parent.Visible) and (Btn.Enabled) then
412 begin
413 SetSplitterActive(TRUE);
414 Btn.Down := TRUE;
415 with Btn.Parent as TPanel do
416 if BevelOuter = bvRaised then
417 BevelOuter := bvLowered;
418 Ctrl.Visible := TRUE;
419 FOpenDrawer := Drawer;
420 end
421 else
422 SetSplitterActive(FALSE);
423 end;
424 finally
425 EndInternalResize;
426 end;
427 ResizeToVisible;
428 end;
429end;
430
431procedure TfrmDrawers.GetDrawerControls(Drawer: TDrawer;
432 var Btn: TORAlignSpeedButton; var Ctrl: TWinControl);
433begin
434 case Drawer of
435 odTemplates:
436 begin
437 Btn := sbTemplates;
438 Ctrl := pnlTemplates;
439 end;
440
441 odEncounter:
442 begin
443 Btn := sbEncounter;
444 Ctrl := lbEncounter;
445 end;
446
447 odReminders:
448 begin
449 Btn := sbReminders;
450 Ctrl := tvReminders;
451 end;
452
453 odOrders:
454 begin
455 Btn := sbOrders;
456 Ctrl := lbOrders;
457 end;
458
459 else
460 begin
461 Btn := nil;
462 Ctrl := nil;
463 end;
464 end;
465end;
466
467constructor TfrmDrawers.CreateDrawers(AOwner: TComponent; AParent: TWinControl;
468 VisibleDrawers, EnabledDrawers: TDrawers);
469begin
470 FInternalResize := 0;
471 StartInternalResize;
472 try
473 Create(AOwner);
474 FButtonHeights := -1;
475 FLastOpenSize := 0;
476 FOpenDrawer := odNone;
477 Parent := AParent;
478 Align := alBottom;
479 FOldFontChanged := Font.OnChange;
480 Font.OnChange := FontChanged;
481 InitButtons;
482 ShowDrawers(VisibleDrawers);
483 EnableDrawers(EnabledDrawers);
484 Show;
485 finally
486 EndInternalResize;
487 end;
488end;
489
490function TfrmDrawers.EnableDrawer(Drawer: TDrawer; EnableIt: boolean): boolean;
491var
492 Btn: TORAlignSpeedButton;
493 Ctrl: TWinControl;
494
495begin
496 inc(FHoldResize);
497 try
498 GetDrawerControls(Drawer, Btn, Ctrl);
499 Btn.Parent.Enabled := EnableIt;
500 if(Drawer = FOpenDrawer) and (not Btn.Parent.Enabled) then
501 OpenDrawer(odNone);
502 finally
503 dec(FHoldResize);
504 end;
505 ResizeToVisible;
506 Result := EnableIt;
507end;
508
509procedure TfrmDrawers.EnableDrawers(Drawers: TDrawers);
510var
511 od: TDrawer;
512
513begin
514 if(FCurrentEnabledDrawers = []) or (Drawers <> FCurrentEnabledDrawers) then
515 begin
516 FCurrentEnabledDrawers := Drawers;
517 inc(FHoldResize);
518 try
519 for od := succ(low(TDrawer)) to high(TDrawer) do
520 EnableDrawer(od, (od in Drawers));
521 finally
522 dec(FHoldResize);
523 end;
524 ResizeToVisible;
525 end;
526end;
527
528procedure TfrmDrawers.FormResize(Sender: TObject);
529begin
530 if(FInternalResize = 0) and (FOpenDrawer <> odNone) then
531 begin
532 FLastOpenSize := Height;
533 dec(FLastOpenSize, ButtonHeights);
534 if(FLastOpenSize < MinDrawerControlHeight) then
535 FLastOpenSize := MinDrawerControlHeight;
536 ResizeToVisible;
537 end;
538end;
539
540procedure TfrmDrawers.sbTemplatesClick(Sender: TObject);
541begin
542 if(FOpenDrawer <> odTemplates) then
543 begin
544 ReloadTemplates;
545 btnFind.Enabled := (edtSearch.Text <> '');
546 pnlTemplateSearch.Visible := mnuFindTemplates.Checked;
547 end;
548 ToggleDrawer(odTemplates);
549end;
550
551procedure TfrmDrawers.sbEncounterClick(Sender: TObject);
552begin
553 ToggleDrawer(odEncounter);
554end;
555
556procedure TfrmDrawers.sbRemindersClick(Sender: TObject);
557begin
558 if(InitialRemindersLoaded) then
559 ToggleDrawer(odReminders)
560 else
561 begin
562 StartupReminders;
563 if(GetReminderStatus = rsNone) then
564 begin
565 EnableDrawer(odReminders, FALSE);
566 sbReminders.Down := FALSE;
567 with sbReminders.Parent as TPanel do
568 if BevelOuter = bvLowered then
569 BevelOuter := bvRaised;
570 end
571 else
572 ToggleDrawer(odReminders)
573 end;
574end;
575
576procedure TfrmDrawers.sbOrdersClick(Sender: TObject);
577begin
578 ToggleDrawer(odOrders);
579end;
580
581procedure TfrmDrawers.ToggleDrawer(Drawer: TDrawer);
582begin
583 if(Drawer = FOpenDrawer) then
584 OpenDrawer(odNone)
585 else
586 OpenDrawer(Drawer);
587end;
588
589procedure TfrmDrawers.EndInternalResize;
590begin
591 if(FInternalResize > 0) then dec(FInternalResize);
592end;
593
594procedure TfrmDrawers.StartInternalResize;
595begin
596 inc(FInternalResize);
597end;
598
599procedure TfrmDrawers.sbResize(Sender: TObject);
600var
601 Button: TORAlignSpeedButton;
602 Mar: integer; // Mar Needed because you can't assign Margin a negative value
603
604begin
605 Button := (Sender as TORAlignSpeedButton);
606 Mar := (Button.Width - FTextIconWidth) div 2;
607 if(Mar < 0) then
608 Mar := 0;
609 Button.Margin := Mar;
610end;
611
612procedure TfrmDrawers.InitButtons;
613var
614 od: TDrawer;
615 Btn: TORAlignSpeedButton;
616 Ctrl: TWinControl;
617 TmpWidth: integer;
618 TmpHeight: integer;
619 MaxHeight: integer;
620
621begin
622 StartInternalResize;
623 try
624 FTextIconWidth := 0;
625 MaxHeight := 0;
626 for od := succ(low(TDrawer)) to high(TDrawer) do
627 begin
628 GetDrawerControls(od, Btn, Ctrl);
629 TmpWidth := Canvas.TextWidth(Btn.Caption) + Btn.Spacing +
630 (Btn.Glyph.Width div Btn.NumGlyphs) + 4;
631 if(TmpWidth > FTextIconWidth) then
632 FTextIconWidth := TmpWidth;
633 TmpHeight := Canvas.TextHeight(Btn.Caption) + 9;
634 if(TmpHeight > MaxHeight) then
635 MaxHeight := TmpHeight;
636 end;
637 if(MaxHeight > 0) then
638 begin
639 for od := succ(low(TDrawer)) to high(TDrawer) do
640 begin
641 GetDrawerControls(od, Btn, Ctrl);
642 Btn.Parent.Height := MaxHeight;
643 end;
644 end;
645 Constraints.MinWidth := FTextIconWidth;
646 finally
647 EndInternalResize;
648 end;
649 ResizeToVisible;
650end;
651
652procedure TfrmDrawers.FontChanged(Sender: TObject);
653var
654 Ht: integer;
655
656begin
657 if(assigned(FOldFontChanged)) then
658 FOldFontChanged(Sender);
659 if(FInternalResize = 0) then
660 begin
661 InitButtons;
662 ResizeToVisible;
663 btnFind.Width := Canvas.TextWidth(FindNextText) + 10;
664 btnFind.Height := edtSearch.Height;
665 btnFind.Left := pnlTemplateSearch.Width - btnFind.Width;
666 edtSearch.Width := pnlTemplateSearch.Width - btnFind.Width;
667 cbMatchCase.Width := Canvas.TextWidth(cbMatchCase.Caption)+23;
668 cbWholeWords.Width := Canvas.TextWidth(cbWholeWords.Caption)+23;
669 Ht := Canvas.TextHeight(cbMatchCase.Caption);
670 if(Ht < 17) then Ht := 17;
671 pnlTemplateSearch.Height := edtSearch.Height + Ht;
672 cbMatchCase.Height := Ht;
673 cbWholeWords.Height := Ht;
674 cbMatchCase.Top := edtSearch.Height;
675 cbWholeWords.Top := edtSearch.Height;
676 pnlTemplateSearchResize(Sender);
677 end;
678end;
679
680procedure TfrmDrawers.AddTemplateNode(const tmpl: TTemplate; const Owner: TTreeNode = nil);
681begin
682 dmodShared.AddTemplateNode(tvTemplates, FEmptyNodeCount, tmpl, FALSE, Owner);
683end;
684
685procedure TfrmDrawers.tvTemplatesGetImageIndex(Sender: TObject;
686 Node: TTreeNode);
687
688begin
689 Node.ImageIndex := dmodShared.ImgIdx(Node);
690end;
691
692procedure TfrmDrawers.tvTemplatesGetSelectedIndex(Sender: TObject;
693 Node: TTreeNode);
694begin
695//vw mod for template callup. Checks in test
696
697 //Application.MessageBox(PChar('Node='+IntToStr(Node.Index)+' tvtemplates.VertScrollPos='+IntToStr(tvTemplates.VertScrollPos)),PChar(Application.Title),MB_ICONINFORMATION);
698// sbTemplates.Caption := 'Templates '+ 'Node='+IntToStr(Node.Index)+' VertScrollPos='+IntToStr(tvTemplates.VertScrollPos) ; <-- original line. //kt 7/15/2007
699 sbTemplates.Caption := DKLangConstW('fDrawers_Templates')+ DKLangConstW('fDrawers_Nodex')+IntToStr(Node.Index)+DKLangConstW('fDrawers_VertScrollPosx')+IntToStr(tvTemplates.VertScrollPos) ; //kt added 7/15/2007
700//end vw mod
701 Node.SelectedIndex := dmodShared.ImgIdx(Node);
702end;
703
704procedure TfrmDrawers.tvTemplatesExpanding(Sender: TObject;
705 Node: TTreeNode; var AllowExpansion: Boolean);
706begin
707 if(assigned(Node)) then
708 begin
709 if(Dragging) then EndDrag(FALSE);
710 if(not FInternalExpand) then
711 begin
712 if(TTemplate(Node.Data).RealType = ttGroup) then
713 begin
714 FAsk := TRUE;
715 FAskExp := TRUE;
716 AllowExpansion := FALSE;
717 FAskNode := Node;
718 end;
719 end;
720 if(AllowExpansion) then
721 begin
722 FClickOccurred := FALSE;
723 AllowExpansion := dmodShared.ExpandNode(tvTemplates, Node, FEmptyNodeCount);
724 if(FInternalHiddenExpand) then AllowExpansion := FALSE;
725 end;
726 end;
727 //vw mod for template callup. Checks in test
728
729 //Application.MessageBox(PChar('Node='+IntToStr(Node.Index)+' tvtemplates.VertScrollPos='+IntToStr(tvTemplates.VertScrollPos)),PChar(Application.Title),MB_ICONINFORMATION);
730// sbTemplates.Caption := 'Templates '+ 'Node='+IntToStr(Node.Index)+' VertScrollPos='+IntToStr(tvTemplates.VertScrollPos) ; <-- original line. //kt 7/15/2007
731 sbTemplates.Caption := DKLangConstW('fDrawers_Templates')+ DKLangConstW('fDrawers_Nodex')+IntToStr(Node.Index)+DKLangConstW('fDrawers_VertScrollPosx')+IntToStr(tvTemplates.VertScrollPos) ; //kt added 7/15/2007
732 //end vw mod
733end;
734
735procedure TfrmDrawers.CheckAsk;
736begin
737 if(FAsk) then
738 begin
739 FAsk := FALSE;
740 FInternalExpand := TRUE;
741 try
742 if(FAskExp) then
743 FAskNode.Expand(FALSE)
744 else
745 FAskNode.Collapse(FALSE);
746 finally
747 FInternalExpand := FALSE;
748 end;
749 end;
750end;
751
752procedure TfrmDrawers.tvTemplatesClick(Sender: TObject);
753begin
754 FClickOccurred := TRUE;
755 CheckAsk;
756end;
757
758procedure TfrmDrawers.tvTemplatesDblClick(Sender: TObject);
759begin
760 if(not FClickOccurred) then CheckAsk
761 else
762 begin
763 FAsk := FALSE;
764 if((assigned(tvTemplates.Selected)) and
765 (TTemplate(tvTemplates.Selected.Data).RealType in [ttDoc, ttGroup])) then
766 InsertText;
767 end;
768end;
769
770procedure TfrmDrawers.tvTemplatesCollapsing(Sender: TObject;
771 Node: TTreeNode; var AllowCollapse: Boolean);
772begin
773 if(assigned(Node)) then
774 begin
775 if(Dragging) then EndDrag(FALSE);
776 if(not FInternalExpand) then
777 begin
778 if(TTemplate(Node.Data).RealType = ttGroup) then
779 begin
780 FAsk := TRUE;
781 FAskExp := FALSE;
782 AllowCollapse := FALSE;
783 FAskNode := Node;
784 end;
785 end;
786 if(AllowCollapse) then
787 FClickOccurred := FALSE;
788 end;
789 //vw mod for template callup. Checks in test
790
791 //Application.MessageBox(PChar('Node='+IntToStr(Node.Index)+' tvtemplates.VertScrollPos='+IntToStr(tvTemplates.VertScrollPos)),PChar(Application.Title),MB_ICONINFORMATION);
792// sbTemplates.Caption := 'Templates '+ 'Node='+IntToStr(Node.Index)+' VertScrollPos='+IntToStr(tvTemplates.VertScrollPos) ; <-- original line. //kt 7/15/2007
793 sbTemplates.Caption := DKLangConstW('fDrawers_Templates')+ DKLangConstW('fDrawers_Nodex')+IntToStr(Node.Index)+DKLangConstW('fDrawers_VertScrollPosx')+IntToStr(tvTemplates.VertScrollPos) ; //kt added 7/15/2007
794 //end vw mod
795end;
796
797procedure TfrmDrawers.tvTemplatesKeyDown(Sender: TObject; var Key: Word;
798 Shift: TShiftState);
799begin
800 CheckAsk;
801 case Key of
802 VK_SPACE, VK_RETURN:
803 begin
804 InsertText;
805 Key := 0;
806 end;
807 end;
808end;
809
810procedure TfrmDrawers.tvTemplatesKeyUp(Sender: TObject; var Key: Word;
811 Shift: TShiftState);
812begin
813 CheckAsk;
814end;
815
816procedure TfrmDrawers.SetRichEditControl(const Value: TRichEdit);
817begin
818 if(FRichEditControl <> Value) then
819 begin
820 if(assigned(FRichEditControl)) then
821 begin
822 FRichEditControl.OnDragDrop := FOldDragDrop;
823 FRichEditControl.OnDragOver := FOldDragOver;
824 end;
825 FRichEditControl := Value;
826 if(assigned(FRichEditControl)) then
827 begin
828 FOldDragDrop := FRichEditControl.OnDragDrop;
829 FOldDragOver := FRichEditControl.OnDragOver;
830 FRichEditControl.OnDragDrop := NewRECDragDrop;
831 FRichEditControl.OnDragOver := NewRECDragOver;
832 end;
833 end;
834end;
835
836
837procedure TfrmDrawers.MoveCaret(X, Y: integer);
838var
839 pt: TPoint;
840
841begin
842 FRichEditControl.SetFocus;
843 pt := Point(x, y);
844 FRichEditControl.SelStart := FRichEditControl.Perform(EM_CHARFROMPOS,0,LParam(@pt));
845end;
846
847
848procedure TfrmDrawers.NewRECDragDrop(Sender, Source: TObject; X,
849 Y: Integer);
850begin
851 if(Source = tvTemplates) then
852 begin
853 MoveCaret(X, Y);
854 InsertText;
855 end
856 else
857 if(assigned(FOldDragDrop)) then
858 FOldDragDrop(Sender, Source, X, Y);
859end;
860
861procedure TfrmDrawers.NewRECDragOver(Sender, Source: TObject; X,
862 Y: Integer; State: TDragState; var Accept: Boolean);
863
864begin
865 Accept := FALSE;
866 if(Source = tvTemplates) then
867 begin
868 if(assigned(FDragNode)) and (TTemplate(FDragNode.Data).RealType in [ttDoc, ttGroup]) then
869 begin
870 Accept := TRUE;
871 MoveCaret(X, Y);
872 end;
873 end
874 else
875 if(assigned(FOldDragOver)) then
876 FOldDragOver(Sender, Source, X, Y, State, Accept);
877end;
878
879procedure TfrmDrawers.InsertText;
880var
881 BeforeLine, AfterTop: integer;
882 txt, DocInfo: string;
883 Template: TTemplate;
884
885begin
886 DocInfo := '';
887 if InsertOK(TRUE) and (dmodShared.TemplateOK(tvTemplates.Selected.Data)) then
888 begin
889 Template := TTemplate(tvTemplates.Selected.Data);
890 Template.TemplatePreviewMode := FALSE;
891 if Template.IsReminderDialog then
892 Template.ExecuteReminderDialog(TForm(Owner))
893 else
894 begin
895 if Template.IsCOMObject then
896 txt := Template.COMObjectText('', DocInfo)
897 else
898 txt := Template.Text;
899 if(txt <> '') then
900 begin
901// CheckBoilerplate4Fields(txt, 'Template: ' + Template.PrintName); <-- original line. //kt 7/15/2007
902 CheckBoilerplate4Fields(txt, DKLangConstW('fDrawers_Templatex') + Template.PrintName); //kt added 7/15/2007
903 BeforeLine := SendMessage(FRichEditControl.Handle, EM_EXLINEFROMCHAR, 0, FRichEditControl.SelStart);
904 FRichEditControl.SelText := txt;
905 FRichEditControl.SetFocus;
906 SendMessage(FRichEditControl.Handle, EM_SCROLLCARET, 0, 0);
907 AfterTop := SendMessage(FRichEditControl.Handle, EM_GETFIRSTVISIBLELINE, 0, 0);
908 SendMessage(FRichEditControl.Handle, EM_LINESCROLL, 0, -1 * (AfterTop - BeforeLine));
909 end;
910 end;
911 end;
912end;
913
914procedure TfrmDrawers.popTemplatesPopup(Sender: TObject);
915var
916 Node: TTreeNode;
917 ok, ok2, NodeFound: boolean;
918 Def: string;
919
920begin
921 ok := FALSE;
922 ok2 := FALSE;
923 if(FOpenDrawer = odTemplates) then
924 begin
925 Node := tvTemplates.Selected;
926 tvTemplates.Selected := Node; // This line prevents selected from changing after menu closes
927 NodeFound := (assigned(Node));
928 if(NodeFound) then
929 begin
930 with TTemplate(Node.Data) do
931 begin
932 ok := (RealType in [ttDoc, ttGroup]);
933 ok2 := ok and (not IsReminderDialog) and (not IsCOMObject);
934 end;
935 end;
936 Def := Piece(GetUserTemplateDefaults, '/', FDefTempPiece);
937 mnuGotoDefault.Enabled := (Def <> '');
938 mnuViewNotes.Enabled := NodeFound and (TTemplate(Node.Data).Description <> '');
939 mnuDefault.Enabled := NodeFound;
940 mnuDefault.Checked := NodeFound and (tvTemplates.GetNodeID(TORTreeNode(Node), 1, ';') = Def);
941 end
942 else
943 begin
944 mnuDefault.Enabled := FALSE;
945 mnuGotoDefault.Enabled := FALSE;
946 mnuViewNotes.Enabled := FALSE;
947 end;
948 mnuPreviewTemplate.Enabled := ok2;
949 mnuCopyTemplate.Enabled := ok2;
950 mnuInsertTemplate.Enabled := ok and InsertOK(FALSE);
951 mnuFindTemplates.Enabled := (FOpenDrawer = odTemplates);
952 mnuCollapseTree.Enabled := ((FOpenDrawer = odTemplates) and
953 (dmodShared.NeedsCollapsing(tvTemplates)));
954 mnuEditTemplates.Enabled := (UserTemplateAccessLevel in [taAll, taEditor]);
955 mnuNewTemplate.Enabled := (UserTemplateAccessLevel in [taAll, taEditor]);
956end;
957
958procedure TfrmDrawers.mnuPreviewTemplateClick(Sender: TObject);
959var
960 tmpl: TTemplate;
961 txt: String;
962
963begin
964 if(assigned(tvTemplates.Selected)) then
965 begin
966// if(dmodShared.TemplateOK(tvTemplates.Selected.Data,'template preview')) then <-- original line. //kt 7/15/2007
967 if(dmodShared.TemplateOK(tvTemplates.Selected.Data,DKLangConstW('fDrawers_template_preview'))) then //kt added 7/15/2007
968 begin
969 tmpl := TTemplate(tvTemplates.Selected.Data);
970 tmpl.TemplatePreviewMode := TRUE; // Prevents "Are you sure?" dialog when canceling
971 txt := tmpl.Text;
972 if(not tmpl.DialogAborted) then
973 ShowTemplateData(Self, tmpl.PrintName, txt);
974 end;
975 end;
976end;
977
978procedure TfrmDrawers.FormDestroy(Sender: TObject);
979begin
980 TAccessibleTreeView.UnwrapControl(tvReminders);
981 dmodShared.RemoveDrawerTree(Self);
982 KillObj(@FRemNotifyList);
983end;
984
985procedure TfrmDrawers.mnuCollapseTreeClick(Sender: TObject);
986begin
987 tvTemplates.Selected := nil;
988 tvTemplates.FullCollapse;
989end;
990
991procedure TfrmDrawers.ReloadTemplates;
992begin
993 LoadTemplateData;
994 if(UserTemplateAccessLevel <> taNone) and (assigned(MyTemplate)) and
995 (MyTemplate.Children in [tcActive, tcBoth]) then
996 begin
997 AddTemplateNode(MyTemplate);
998 FHasPersonalTemplates := TRUE;
999 end;
1000 AddTemplateNode(RootTemplate);
1001 OpenToNode;
1002end;
1003
1004procedure TfrmDrawers.btnFindClick(Sender: TObject);
1005var
1006 TmpNode: TTreeNode;
1007 Found: boolean;
1008 S1,S2: string;
1009
1010begin
1011 if(edtSearch.text <> '') then
1012 begin
1013 if(FEmptyNodeCount > 0) then
1014 begin
1015 FInternalExpand := TRUE;
1016 FInternalHiddenExpand := TRUE;
1017 try
1018 TmpNode := tvTemplates.Items.GetFirstNode;
1019 while(assigned(TmpNode)) do
1020 begin
1021 TmpNode.Expand(TRUE);
1022 TmpNode := TmpNode.GetNextSibling;
1023 end;
1024 finally
1025 FInternalExpand := FALSE;
1026 FInternalHiddenExpand := FALSE;
1027 end;
1028 end;
1029 if((FFindNext) and assigned (FLastFoundNode)) then
1030 TmpNode := FLastFoundNode.GetNext
1031 else
1032 TmpNode := tvTemplates.Items.GetFirstNode;
1033 Found := FALSE;
1034 if(assigned(TmpNode)) then
1035 begin
1036 S1 := edtSearch.Text;
1037 if(not cbMatchCase.Checked) then
1038 S1 := UpperCase(S1);
1039 while (assigned(TmpNode) and (not Found)) do
1040 begin
1041 S2 := TmpNode.Text;
1042 if(not cbMatchCase.Checked) then
1043 S2 := UpperCase(S2);
1044 Found := SearchMatch(S1, S2, cbWholeWords.Checked);
1045 if(not Found) then
1046 TmpNode := TmpNode.GetNext;
1047 end;
1048 end;
1049 if(Found) then
1050 begin
1051 FLastFoundNode := TmpNode;
1052 SetFindNext(TRUE);
1053 FInternalExpand := TRUE;
1054 try
1055 tvTemplates.Selected := TmpNode;
1056 finally
1057 FInternalExpand := FALSE;
1058 end;
1059 end
1060 else
1061 begin
1062 if(FFindNext) then
1063 S1 := ''
1064 else
1065// S1 := ' "' + edtSearch.Text + '" was not Found.'; <-- original line. //kt 7/15/2007
1066 S1 := ' "' + edtSearch.Text + '"' + DKLangConstW('fDrawers_was_not_Foundx'); //kt added 7/15/2007
1067 SetFindNext(FALSE);
1068// InfoBox('Search Complete.' + S1, 'Information', MB_OK or MB_ICONINFORMATION); <-- original line. //kt 7/15/2007
1069 InfoBox(DKLangConstW('fDrawers_Search_Completex') + S1, DKLangConstW('fDrawers_Information'), MB_OK or MB_ICONINFORMATION); //kt added 7/15/2007
1070 end;
1071 end;
1072 edtSearch.SetFocus;
1073end;
1074
1075procedure TfrmDrawers.SetFindNext(const Value: boolean);
1076begin
1077 if(FFindNext <> Value) then
1078 begin
1079 FFindNext := Value;
1080 if(FFindNext) then btnFind.Caption := FindNextText
1081// else btnFind.Caption := 'Find'; <-- original line. //kt 7/15/2007
1082 else btnFind.Caption := DKLangConstW('fDrawers_Find'); //kt added 7/15/2007
1083 end;
1084end;
1085
1086procedure TfrmDrawers.edtSearchChange(Sender: TObject);
1087begin
1088 btnFind.Enabled := (edtSearch.Text <> '');
1089 SetFindNext(FALSE);
1090end;
1091
1092procedure TfrmDrawers.ToggleMenuItem(Sender: TObject);
1093var
1094 TmpMI: TMenuItem;
1095
1096begin
1097 TmpMI := (Sender as TMenuItem);
1098 TmpMI.Checked := not TmpMI.Checked;
1099 SetFindNext(FALSE);
1100 if(pnlTemplateSearch.Visible) then edtSearch.SetFocus;
1101end;
1102
1103procedure TfrmDrawers.edtSearchEnter(Sender: TObject);
1104begin
1105 btnFind.Default := TRUE;
1106end;
1107
1108procedure TfrmDrawers.edtSearchExit(Sender: TObject);
1109begin
1110 btnFind.Default := FALSE;
1111end;
1112
1113procedure TfrmDrawers.mnuFindTemplatesClick(Sender: TObject);
1114var
1115 FindOn: boolean;
1116
1117begin
1118 mnuFindTemplates.Checked := not mnuFindTemplates.Checked;
1119 FindOn := mnuFindTemplates.Checked;
1120 pnlTemplateSearch.Visible := FindOn;
1121 if(FindOn) and (FOpenDrawer = odTemplates) then
1122 edtSearch.SetFocus;
1123end;
1124
1125procedure TfrmDrawers.tvTemplatesDragging(Sender: TObject; Node: TTreeNode;
1126 var CanDrag: Boolean);
1127
1128begin
1129 if(TTemplate(Node.Data).RealType in [ttDoc, ttGroup]) then
1130 begin
1131 FDragNode := Node;
1132 CanDrag := TRUE;
1133 end
1134 else
1135 begin
1136 FDragNode := nil;
1137 CanDrag := FALSE;
1138 end;
1139end;
1140
1141procedure TfrmDrawers.mnuEditTemplatesClick(Sender: TObject);
1142begin
1143 EditTemplates(Self);
1144end;
1145
1146procedure TfrmDrawers.mnuNewTemplateClick(Sender: TObject);
1147begin
1148 EditTemplates(Self, TRUE);
1149end;
1150
1151procedure TfrmDrawers.FormCreate(Sender: TObject);
1152begin
1153 dmodShared.AddDrawerTree(Self);
1154 FHasPersonalTemplates := FALSE;
1155 TAccessibleTreeView.WrapControl(tvReminders);
1156end;
1157
1158procedure TfrmDrawers.ExternalReloadTemplates;
1159begin
1160 if(FOpenToNode = '') and (assigned(tvTemplates.Selected)) then
1161 FOpenToNode := tvTemplates.GetNodeID(TORTreeNode(tvTemplates.Selected),1,';');
1162 tvTemplates.Items.Clear;
1163 FHasPersonalTemplates := FALSE;
1164 FEmptyNodeCount := 0;
1165 ReloadTemplates;
1166end;
1167
1168procedure TfrmDrawers.DisplayDrawers(Show: Boolean);
1169begin
1170 DisplayDrawers(Show, [], []);
1171end;
1172
1173procedure TfrmDrawers.DisplayDrawers(Show: Boolean; AEnable, ADisplay: TDrawers);
1174begin
1175 if(not (csLoading in ComponentState)) then
1176 begin
1177 if Show then
1178 begin
1179 EnableDrawers(AEnable);
1180 ShowDrawers(ADisplay);
1181 end
1182 else
1183 begin
1184 ShowDrawers([]);
1185 end;
1186 if(assigned(FSplitter)) then
1187 begin
1188 if(Show and (FOpenDrawer <> odNone)) then
1189 SetSplitterActive(TRUE)
1190 else
1191 SetSplitterActive(FALSE);
1192 end;
1193 end;
1194end;
1195
1196function TfrmDrawers.CanEditTemplates: boolean;
1197begin
1198 Result := (UserTemplateAccessLevel in [taAll, taEditor]);
1199end;
1200
1201function TfrmDrawers.CanEditShared: boolean;
1202begin
1203 Result := (UserTemplateAccessLevel = taEditor);
1204end;
1205
1206procedure TfrmDrawers.pnlTemplateSearchResize(Sender: TObject);
1207begin
1208 if((cbMatchCase.Width + cbWholeWords.Width) > pnlTemplateSearch.Width) then
1209 cbWholeWords.Left := cbMatchCase.Width
1210 else
1211 cbWholeWords.Left := pnlTemplateSearch.Width - cbWholeWords.Width;
1212end;
1213
1214procedure TfrmDrawers.cbFindOptionClick(Sender: TObject);
1215begin
1216 SetFindNext(FALSE);
1217 if(pnlTemplateSearch.Visible) then edtSearch.SetFocus;
1218end;
1219
1220procedure TfrmDrawers.mnuInsertTemplateClick(Sender: TObject);
1221begin
1222 if((assigned(tvTemplates.Selected)) and
1223 (TTemplate(tvTemplates.Selected.Data).RealType in [ttDoc, ttGroup])) then
1224 InsertText;
1225end;
1226
1227procedure TfrmDrawers.SetSplitter(const Value: TSplitter);
1228begin
1229 if(FSplitter <> Value) then
1230 begin
1231 if(assigned(FSplitter)) then
1232 FSplitter.OnCanResize := FOldCanResize;
1233 FSplitter := Value;
1234 if(assigned(FSplitter)) then
1235 begin
1236 FOldCanResize := FSplitter.OnCanResize;
1237 FSplitter.OnCanResize := SplitterCanResize;
1238 SetSplitterActive(FSplitterActive);
1239 end;
1240 end;
1241end;
1242
1243procedure TfrmDrawers.SplitterCanResize(Sender: TObject; var NewSize: Integer; var Accept: Boolean);
1244begin
1245 Accept := FSplitterActive;
1246end;
1247
1248procedure TfrmDrawers.SetSplitterActive(Active: boolean);
1249begin
1250 FSplitterActive := Active;
1251 if(Active) then
1252 begin
1253 FSplitter.Cursor := crVSplit;
1254 FSplitter.ResizeStyle := rsPattern;
1255 end
1256 else
1257 begin
1258 FSplitter.Cursor := crDefault;
1259 FSplitter.ResizeStyle := ExtCtrls.rsNone;
1260 end;
1261end;
1262
1263procedure TfrmDrawers.UpdatePersonalTemplates;
1264var
1265 NeedPersonal: boolean;
1266 Node: TTreeNode;
1267
1268 function FindNode: TTreeNode;
1269 begin
1270 Result := tvTemplates.Items.GetFirstNode;
1271 while assigned(Result) do
1272 begin
1273 if(Result.Data = MyTemplate) then exit;
1274 Result := Result.getNextSibling;
1275 end;
1276 end;
1277
1278begin
1279 NeedPersonal := (UserTemplateAccessLevel <> taNone);
1280 if(NeedPersonal <> FHasPersonalTemplates) then
1281 begin
1282 if(NeedPersonal) then
1283 begin
1284 if(assigned(MyTemplate)) and (MyTemplate.Children in [tcActive, tcBoth]) then
1285 begin
1286 AddTemplateNode(MyTemplate);
1287 FHasPersonalTemplates := TRUE;
1288 if(assigned(MyTemplate)) then
1289 begin
1290 Node := FindNode;
1291 if(assigned(Node)) then
1292 Node.MoveTo(nil, naAddFirst);
1293 end;
1294 end;
1295 end
1296 else
1297 begin
1298 if(assigned(MyTemplate)) then
1299 begin
1300 Node := FindNode;
1301 if(assigned(Node)) then Node.Delete;
1302 end;
1303 FHasPersonalTemplates := FALSE;
1304 end;
1305 end;
1306end;
1307
1308procedure TfrmDrawers.RemindersChanged(Sender: TObject);
1309begin
1310 inc(FHoldResize);
1311 try
1312 if(EnableDrawer(odReminders, (GetReminderStatus <> rsNone))) then
1313 begin
1314 BuildReminderTree(tvReminders);
1315 FOldMouseUp := tvReminders.OnMouseUp;
1316 end
1317 else
1318 begin
1319 FOldMouseUp := nil;
1320 tvReminders.PopupMenu := nil;
1321 end;
1322 tvReminders.OnMouseUp := tvRemindersMouseUp;
1323 finally
1324 dec(FHoldResize);
1325 end;
1326end;
1327
1328procedure TfrmDrawers.tvRemindersMouseUp(Sender: TObject;
1329 Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
1330begin
1331 if(Button = mbLeft) and (assigned(tvReminders.Selected)) and
1332 (htOnItem in tvReminders.GetHitTestInfoAt(X, Y)) then
1333 ViewReminderDialog(ReminderNode(tvReminders.Selected));
1334end;
1335
1336procedure TfrmDrawers.PositionToReminder(Sender: TObject);
1337var
1338 Rem: TReminder;
1339
1340begin
1341 if(assigned(Sender)) then
1342 begin
1343 if(Sender is TReminder) then
1344 begin
1345 Rem := TReminder(Sender);
1346 if(Rem.CurrentNodeID <> '') then
1347 tvReminders.Selected := tvReminders.FindPieceNode(Rem.CurrentNodeID, 1, IncludeParentID)
1348 else
1349 begin
1350 tvReminders.Selected := tvReminders.FindPieceNode(RemCode + (Sender as TReminder).IEN, 1);
1351 if(assigned(tvReminders.Selected)) then
1352 TORTreeNode(tvReminders.Selected).EnsureVisible;
1353 end;
1354 Rem.CurrentNodeID := '';
1355 end;
1356 end
1357 else
1358 tvReminders.Selected := nil;
1359end;
1360
1361procedure TfrmDrawers.tvRemindersCurListChanged(Sender: TObject;
1362 Node: TTreeNode);
1363begin
1364 if(assigned(FRemNotifyList)) then
1365 FRemNotifyList.Notify(Node);
1366end;
1367
1368procedure TfrmDrawers.NotifyWhenRemTreeChanges(Proc: TNotifyEvent);
1369begin
1370 if(not assigned(FRemNotifyList)) then
1371 FRemNotifyList := TORNotifyList.Create;
1372 FRemNotifyList.Add(Proc);
1373end;
1374
1375procedure TfrmDrawers.RemoveNotifyWhenRemTreeChanges(Proc: TNotifyEvent);
1376begin
1377 if(assigned(FRemNotifyList)) then
1378 FRemNotifyList.Remove(Proc);
1379end;
1380
1381function TfrmDrawers.GetAlign: TAlign;
1382begin
1383 Result := inherited Align;
1384end;
1385
1386procedure TfrmDrawers.SetAlign(const Value: TAlign);
1387begin
1388 inherited Align := Value;
1389 ResizeToVisible;
1390end;
1391
1392procedure TfrmDrawers.ResetTemplates;
1393begin
1394 FOpenToNode := Piece(GetUserTemplateDefaults, '/', FDefTempPiece);
1395end;
1396
1397procedure TfrmDrawers.mnuDefaultClick(Sender: TObject);
1398var
1399 NodeID: string;
1400 UserTempDefNode: string;
1401begin
1402 NodeID := tvTemplates.GetNodeID(TORTreeNode(tvTemplates.Selected), 1, ';');
1403 UserTempDefNode := Piece(GetUserTemplateDefaults, '/', FDefTempPiece);
1404 if NodeID <> UserTempDefNode then
1405 SetUserTemplateDefaults(tvTemplates.GetNodeID(TORTreeNode(tvTemplates.Selected), 1, ';'),
1406 FDefTempPiece)
1407 else SetUserTemplateDefaults('', FDefTempPiece);
1408end;
1409
1410procedure TfrmDrawers.OpenToNode(Path: string = '');
1411var
1412 OldInternalHE, OldInternalEX: boolean;
1413
1414begin
1415 if(Path <> '') then
1416 FOpenToNode := PATH;
1417 if(FOpenToNode <> '') then
1418 begin
1419 OldInternalHE := FInternalHiddenExpand;
1420 OldInternalEX := FInternalExpand;
1421 try
1422 FInternalExpand := TRUE;
1423 FInternalHiddenExpand := FALSE;
1424 dmodShared.SelectNode(tvTemplates, FOpenToNode, FEmptyNodeCount);
1425 finally
1426 FInternalHiddenExpand := OldInternalHE;
1427 FInternalExpand := OldInternalEX;
1428 end;
1429 FOpenToNode := '';
1430 end;
1431end;
1432
1433procedure TfrmDrawers.mnuGotoDefaultClick(Sender: TObject);
1434begin
1435 OpenToNode(Piece(GetUserTemplateDefaults, '/', FDefTempPiece));
1436end;
1437
1438procedure TfrmDrawers.mnuViewNotesClick(Sender: TObject);
1439var
1440 tmpl: TTemplate;
1441 tmpSL: TStringList;
1442
1443begin
1444 if(assigned(tvTemplates.Selected)) then
1445 begin
1446 tmpl := TTemplate(tvTemplates.Selected.Data);
1447 if(tmpl.Description = '') then
1448// ShowMessage('No notes found for ' + tmpl.PrintName) <-- original line. //kt 7/15/2007
1449 ShowMessage(DKLangConstW('fDrawers_No_notes_found_for') + tmpl.PrintName) //kt added 7/15/2007
1450 else
1451 begin
1452 tmpSL := TStringList.Create;
1453 try
1454 tmpSL.Text := tmpl.Description;
1455// ReportBox(tmpSL, tmpl.PrintName + ' Notes:', TRUE); <-- original line. //kt 7/15/2007
1456 ReportBox(tmpSL, tmpl.PrintName + DKLangConstW('fDrawers_Notesx'), TRUE); //kt added 7/15/2007
1457 finally
1458 tmpSL.Free;
1459 end;
1460 end;
1461 end;
1462end;
1463
1464procedure TfrmDrawers.mnuCopyTemplateClick(Sender: TObject);
1465var
1466 txt: string;
1467 Template: TTemplate;
1468
1469begin
1470 txt := '';
1471 if((assigned(tvTemplates.Selected)) and
1472 (TTemplate(tvTemplates.Selected.Data).RealType in [ttDoc, ttGroup])) and
1473 (dmodShared.TemplateOK(tvTemplates.Selected.Data)) then
1474 begin
1475 Template := TTemplate(tvTemplates.Selected.Data);
1476 txt := Template.Text;
1477// CheckBoilerplate4Fields(txt, 'Template: ' + Template.PrintName); <-- original line. //kt 7/15/2007
1478 CheckBoilerplate4Fields(txt, DKLangConstW('fDrawers_Templatex') + Template.PrintName); //kt added 7/15/2007
1479 if txt <> '' then
1480 Clipboard.SetTextBuf(PChar(txt));
1481 end;
1482 if txt <> '' then
1483// StatusText('Templated Text copied to clipboard.'); <-- original line. //kt 7/15/2007
1484 StatusText(DKLangConstW('fDrawers_Templated_Text_copied_to_clipboardx')); //kt added 7/15/2007
1485end;
1486
1487function TfrmDrawers.InsertOK(Ask: boolean): boolean;
1488
1489 function REOK: boolean;
1490 begin
1491 Result := assigned(FRichEditControl) and
1492 FRichEditControl.Visible and
1493 FRichEditControl.Parent.Visible;
1494 end;
1495
1496begin
1497 Result := REOK;
1498 if (not ask) and (not Result) and (assigned(FNewNoteButton)) then
1499 Result := TRUE
1500 else
1501 if ask and (not Result) and assigned(FNewNoteButton) and
1502 FNewNoteButton.Visible and FNewNoteButton.Enabled then
1503 begin
1504 FNewNoteButton.Click;
1505 Result := REOK;
1506 end;
1507end;
1508
1509procedure TfrmDrawers.mnuViewTemplateIconLegendClick(Sender: TObject);
1510begin
1511 ShowIconLegend(ilTemplates);
1512end;
1513
1514procedure TfrmDrawers.pnlTemplatesButtonEnter(Sender: TObject);
1515begin
1516 with Sender as TPanel do
1517 if (ControlCount > 0) and (Controls[0] is TSpeedButton) and (TSpeedButton(Controls[0]).Down)
1518 then
1519 BevelOuter := bvLowered
1520 else
1521 BevelOuter := bvRaised;
1522end;
1523
1524procedure TfrmDrawers.pnlTemplatesButtonExit(Sender: TObject);
1525begin
1526 with Sender as TPanel do
1527 BevelOuter := bvNone;
1528 DisableArrowKeyMove(Sender);
1529end;
1530
1531procedure TfrmDrawers.tvRemindersKeyDown(Sender: TObject; var Key: Word;
1532 Shift: TShiftState);
1533begin
1534 case Key of
1535 VK_RETURN, VK_SPACE:
1536 begin
1537 ViewReminderDialog(ReminderNode(tvReminders.Selected));
1538 Key := 0;
1539 end;
1540 end;
1541end;
1542
1543procedure TfrmDrawers.tvRemindersNodeCaptioning(Sender: TObject;
1544 var Caption: String);
1545var
1546 StringData: string;
1547begin
1548 StringData := (Sender as TORTreeNode).StringData;
1549 if (Length(StringData) > 0) and (StringData[1] = 'R') then //Only tag reminder statuses
1550 case StrToIntDef(Piece(StringData,'^',6 {Due}),-1) of
1551// 0: Caption := Caption + ' -- Applicable'; <-- original line. //kt 7/15/2007
1552 0: Caption := Caption + DKLangConstW('fDrawers_xx_Applicable'); //kt added 7/15/2007
1553// 1: Caption := Caption + ' -- DUE'; <-- original line. //kt 7/15/2007
1554 1: Caption := Caption + DKLangConstW('fDrawers_xx_DUE'); //kt added 7/15/2007
1555// 2: Caption := Caption + ' -- Not Applicable'; <-- original line. //kt 7/15/2007
1556 2: Caption := Caption + DKLangConstW('fDrawers_xx_Not_Applicable'); //kt added 7/15/2007
1557// else Caption := Caption + ' -- Not Evaluated'; <-- original line. //kt 7/15/2007
1558 else Caption := Caption + DKLangConstW('fDrawers_xx_Not_Evaluated'); //kt added 7/15/2007
1559 end;
1560end;
1561
1562procedure TfrmDrawers.tvRemindersAddition(Sender: TObject;
1563 Node: TTreeNode);
1564begin
1565 TAccessibleTreeNode.WrapControl(Node as TORTreeNode);
1566end;
1567
1568procedure TfrmDrawers.tvRemindersDeletion(Sender: TObject;
1569 Node: TTreeNode);
1570begin
1571 TAccessibleTreeNode.UnwrapControl(Node as TORTreeNode);
1572end;
1573
1574procedure TfrmDrawers.DisableArrowKeyMove(Sender: TObject);
1575var
1576 CurrPanel : TKeyClickPanel;
1577begin
1578 if Sender is TKeyClickPanel then
1579 begin
1580 CurrPanel := Sender as TKeyClickPanel;
1581 If Boolean(Hi(GetKeyState(VK_UP)))
1582 OR Boolean(Hi(GetKeyState(VK_DOWN)))
1583 OR Boolean(Hi(GetKeyState(VK_LEFT)))
1584 OR Boolean(Hi(GetKeyState(VK_RIGHT))) then
1585 begin
1586 if Assigned(CurrPanel) then
1587 CurrPanel.SetFocus;
1588 end;
1589 end;
1590end;
1591
1592end.
1593
Note: See TracBrowser for help on using the repository browser.