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