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