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