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