| 1 | unit uDlgComponents;
|
|---|
| 2 |
|
|---|
| 3 | interface
|
|---|
| 4 |
|
|---|
| 5 | uses
|
|---|
| 6 | SysUtils, Windows, Messages, Classes, Controls, StdCtrls, ComCtrls, ExtCtrls, uReminders,
|
|---|
| 7 | TypInfo, StrUtils, ORCtrls, ORDtTm, Forms, Graphics, Dialogs, RTLConsts, Buttons,
|
|---|
| 8 | VA508AccessibilityManager;
|
|---|
| 9 |
|
|---|
| 10 | type
|
|---|
| 11 | ICPRSDialogComponent = interface(IInterface)
|
|---|
| 12 | ['{C4DBA10A-2A8D-4F71-AE20-5BA350D48551}']
|
|---|
| 13 | function Component: TControl;
|
|---|
| 14 | function GetBeforeText: string;
|
|---|
| 15 | procedure SetBeforeText(Value: string);
|
|---|
| 16 | function GetAfterText: string;
|
|---|
| 17 | procedure SetAfterText(value: string);
|
|---|
| 18 | function GetRequiredField: boolean;
|
|---|
| 19 | procedure SetRequiredField(Value: boolean);
|
|---|
| 20 | function AccessText: string;
|
|---|
| 21 | function GetSRBreak: boolean;
|
|---|
| 22 | procedure SetSRBreak(Value: boolean);
|
|---|
| 23 | property BeforeText: string read GetBeforeText write SetBeforeText;
|
|---|
| 24 | property AfterText: string read GetAfterText write SetAfterText;
|
|---|
| 25 | property SRBreak: boolean read GetSRBreak write SetSRBreak;
|
|---|
| 26 | property RequiredField: boolean read GetRequiredField write SetRequiredField;
|
|---|
| 27 | end;
|
|---|
| 28 |
|
|---|
| 29 | TCPRSDialogComponent = class(TInterfacedObject, ICPRSDialogComponent)
|
|---|
| 30 | private
|
|---|
| 31 | FRequiredField: boolean;
|
|---|
| 32 | FComponent: TControl;
|
|---|
| 33 | FBeforeText: string;
|
|---|
| 34 | FAfterText: string;
|
|---|
| 35 | FSRBreak: boolean;
|
|---|
| 36 | FComponentName: string;
|
|---|
| 37 | FFollowOnCaption: string;
|
|---|
| 38 | public
|
|---|
| 39 | constructor Create(AComponent: TControl; AComponentName: string;
|
|---|
| 40 | FollowOnCaption: string = '');
|
|---|
| 41 | function Component: TControl;
|
|---|
| 42 | function GetBeforeText: string;
|
|---|
| 43 | procedure SetBeforeText(Value: string);
|
|---|
| 44 | function GetAfterText: string;
|
|---|
| 45 | procedure SetAfterText(value: string);
|
|---|
| 46 | function GetRequiredField: boolean;
|
|---|
| 47 | procedure SetRequiredField(Value: boolean);
|
|---|
| 48 | function AccessText: string;
|
|---|
| 49 | function GetSRBreak: boolean;
|
|---|
| 50 | procedure SetSRBreak(Value: boolean);
|
|---|
| 51 | property BeforeText: string read GetBeforeText write SetBeforeText;
|
|---|
| 52 | property AfterText: string read GetAfterText write SetAfterText;
|
|---|
| 53 | property SRBreak: boolean read GetSRBreak write SetSRBreak;
|
|---|
| 54 | property RequiredField: boolean read GetRequiredField write SetRequiredField;
|
|---|
| 55 | end;
|
|---|
| 56 |
|
|---|
| 57 | TCPRSDialogStaticLabel = class(TVA508StaticText);
|
|---|
| 58 |
|
|---|
| 59 | TCPRSDialogParentCheckBox = class(TORCheckBox)
|
|---|
| 60 | private
|
|---|
| 61 | FAccessText: string;
|
|---|
| 62 | public
|
|---|
| 63 | property AccessText: string read FAccessText write FAccessText;
|
|---|
| 64 | end;
|
|---|
| 65 |
|
|---|
| 66 | TCPRSDialogFieldEdit = class(TEdit, ICPRSDialogComponent)
|
|---|
| 67 | private
|
|---|
| 68 | FCPRSDialogData: ICPRSDialogComponent;
|
|---|
| 69 | public
|
|---|
| 70 | constructor Create(AOwner: TComponent); override;
|
|---|
| 71 | destructor Destroy; override;
|
|---|
| 72 | property CPRSDialogData: ICPRSDialogComponent read FCPRSDialogData implements ICPRSDialogComponent;
|
|---|
| 73 | end;
|
|---|
| 74 |
|
|---|
| 75 | TCPRSDialogComboBox = class(TORComboBox, ICPRSDialogComponent)
|
|---|
| 76 | private
|
|---|
| 77 | FCPRSDialogData: ICPRSDialogComponent;
|
|---|
| 78 | public
|
|---|
| 79 | constructor Create(AOwner: TComponent); override;
|
|---|
| 80 | destructor Destroy; override;
|
|---|
| 81 | property CPRSDialogData: ICPRSDialogComponent read FCPRSDialogData implements ICPRSDialogComponent;
|
|---|
| 82 | end;
|
|---|
| 83 |
|
|---|
| 84 | TCPRSDialogCheckBox = class(TORCheckBox, ICPRSDialogComponent)
|
|---|
| 85 | private
|
|---|
| 86 | FCPRSDialogData: ICPRSDialogComponent;
|
|---|
| 87 | public
|
|---|
| 88 | constructor Create(AOwner: TComponent); override;
|
|---|
| 89 | destructor Destroy; override;
|
|---|
| 90 | property CPRSDialogData: ICPRSDialogComponent read FCPRSDialogData implements ICPRSDialogComponent;
|
|---|
| 91 | end;
|
|---|
| 92 |
|
|---|
| 93 | TCPRSDialogButton = class(TButton, ICPRSDialogComponent)
|
|---|
| 94 | private
|
|---|
| 95 | FCPRSDialogData: ICPRSDialogComponent;
|
|---|
| 96 | public
|
|---|
| 97 | constructor Create(AOwner: TComponent); override;
|
|---|
| 98 | destructor Destroy; override;
|
|---|
| 99 | property CPRSDialogData: ICPRSDialogComponent read FCPRSDialogData implements ICPRSDialogComponent;
|
|---|
| 100 | end;
|
|---|
| 101 |
|
|---|
| 102 | TCPRSDialogYearEdit = class(TORYearEdit);
|
|---|
| 103 |
|
|---|
| 104 | TCPRSDialogDateCombo = class(TORDateCombo, ICPRSDialogComponent)
|
|---|
| 105 | private
|
|---|
| 106 | FCPRSDialogInfo: ICPRSDialogComponent;
|
|---|
| 107 | protected
|
|---|
| 108 | public
|
|---|
| 109 | constructor Create(AOwner: TComponent); override;
|
|---|
| 110 | destructor Destroy; override;
|
|---|
| 111 | property CPRSDialogData: ICPRSDialogComponent read FCPRSDialogInfo implements ICPRSDialogComponent;
|
|---|
| 112 | end;
|
|---|
| 113 |
|
|---|
| 114 | TCPRSDialogDateBox = class(TORDateBox, ICPRSDialogComponent)
|
|---|
| 115 | private
|
|---|
| 116 | FCPRSDialogInfo: ICPRSDialogComponent;
|
|---|
| 117 | public
|
|---|
| 118 | constructor Create(AOwner: TComponent); override;
|
|---|
| 119 | destructor Destroy; override;
|
|---|
| 120 | property CPRSDialogData: ICPRSDialogComponent read FCPRSDialogInfo implements ICPRSDialogComponent;
|
|---|
| 121 | end;
|
|---|
| 122 |
|
|---|
| 123 | TCPRSNumberField = class(TEdit);
|
|---|
| 124 |
|
|---|
| 125 | TCPRSDialogNumber = class(TPanel, ICPRSDialogComponent)
|
|---|
| 126 | private
|
|---|
| 127 | FCPRSDialogInfo: ICPRSDialogComponent;
|
|---|
| 128 | FEdit: TCPRSNumberField;
|
|---|
| 129 | FUpDown: TUpDown;
|
|---|
| 130 | public
|
|---|
| 131 | constructor CreatePanel(AOwner: TComponent);
|
|---|
| 132 | destructor Destroy; override;
|
|---|
| 133 | property CPRSDialogData: ICPRSDialogComponent read FCPRSDialogInfo implements ICPRSDialogComponent;
|
|---|
| 134 | property Edit: TCPRSNumberField read FEdit;
|
|---|
| 135 | property UpDown: TUpDown read FUpDown;
|
|---|
| 136 | end;
|
|---|
| 137 |
|
|---|
| 138 | TCPRSTemplateFieldLabel = class(TCPRSDialogStaticLabel)
|
|---|
| 139 | private
|
|---|
| 140 | FExclude: boolean;
|
|---|
| 141 | public
|
|---|
| 142 | property Exclude: boolean read FExclude write FExclude;
|
|---|
| 143 | end;
|
|---|
| 144 |
|
|---|
| 145 | TCPRSDialogHyperlinkLabel = class(TCPRSTemplateFieldLabel, ICPRSDialogComponent)
|
|---|
| 146 | private
|
|---|
| 147 | FURL: string;
|
|---|
| 148 | FCPRSDialogInfo: ICPRSDialogComponent;
|
|---|
| 149 | protected
|
|---|
| 150 | procedure Clicked(Sender: TObject);
|
|---|
| 151 | procedure KeyPressed(Sender: TObject; var Key: Char);
|
|---|
| 152 | public
|
|---|
| 153 | constructor Create(AOwner: TComponent); override;
|
|---|
| 154 | destructor Destroy; override;
|
|---|
| 155 | procedure Init(Addr: string);
|
|---|
| 156 | property CPRSDialogData: ICPRSDialogComponent read FCPRSDialogInfo implements ICPRSDialogComponent;
|
|---|
| 157 | end;
|
|---|
| 158 |
|
|---|
| 159 | TCPRSDialogRichEdit = class(TRichEdit, ICPRSDialogComponent)
|
|---|
| 160 | private
|
|---|
| 161 | FCPRSDialogData: ICPRSDialogComponent;
|
|---|
| 162 | public
|
|---|
| 163 | constructor Create(AOwner: TComponent); override;
|
|---|
| 164 | destructor Destroy; override;
|
|---|
| 165 | property CPRSDialogData: ICPRSDialogComponent read FCPRSDialogData implements ICPRSDialogComponent;
|
|---|
| 166 | end;
|
|---|
| 167 |
|
|---|
| 168 | {This is the panel associated with child items in template and reminders dialogs}
|
|---|
| 169 | TDlgFieldPanel = class(TPanel)
|
|---|
| 170 | private
|
|---|
| 171 | FOnDestroy: TNotifyEvent;
|
|---|
| 172 | FCanvas: TControlCanvas; {used to draw focus rect}
|
|---|
| 173 | FCurrentPos: TPoint;
|
|---|
| 174 | FChildren: TInterfaceList;
|
|---|
| 175 | function GetFocus: boolean;
|
|---|
| 176 | procedure SetTheFocus(const Value: boolean);
|
|---|
| 177 | protected {used to draw focus rect}
|
|---|
| 178 | procedure Paint; override; {used to draw focus rect}
|
|---|
| 179 | public
|
|---|
| 180 | constructor Create(AOwner: TComponent); override;
|
|---|
| 181 | destructor Destroy; override;
|
|---|
| 182 | function GetFirstComponent: ICPRSDialogComponent;
|
|---|
| 183 | function GetNextComponent: ICPRSDialogComponent;
|
|---|
| 184 | property OnDestroy: TNotifyEvent read FOnDestroy write FOnDestroy;
|
|---|
| 185 | property Focus: boolean read GetFocus write SetTheFocus; {to draw focus rect}
|
|---|
| 186 | property OnKeyPress; {to click the checkbox when spacebar is pressed}
|
|---|
| 187 | end;
|
|---|
| 188 |
|
|---|
| 189 | TVitalComboBox = class;
|
|---|
| 190 |
|
|---|
| 191 | TVitalEdit = class(TEdit, ICPRSDialogComponent)
|
|---|
| 192 | private
|
|---|
| 193 | FLinkedCombo: TVitalComboBox;
|
|---|
| 194 | FCPRSDialogInfo: ICPRSDialogComponent;
|
|---|
| 195 | public
|
|---|
| 196 | constructor Create(AOwner: TComponent); override;
|
|---|
| 197 | destructor Destroy; override;
|
|---|
| 198 | property CPRSDialogData: ICPRSDialogComponent read FCPRSDialogInfo implements ICPRSDialogComponent;
|
|---|
| 199 | property LinkedCombo: TVitalComboBox read FLinkedCombo write FLinkedCombo;
|
|---|
| 200 | end;
|
|---|
| 201 |
|
|---|
| 202 | TVitalComboBox = class(TComboBox, ICPRSDialogComponent)
|
|---|
| 203 | private
|
|---|
| 204 | FLinkedEdit: TVitalEdit;
|
|---|
| 205 | FCPRSDialogInfo: ICPRSDialogComponent;
|
|---|
| 206 | public
|
|---|
| 207 | constructor Create(AOwner: TComponent); override;
|
|---|
| 208 | destructor Destroy; override;
|
|---|
| 209 | procedure SelectByID(Value: string);
|
|---|
| 210 | property LinkedEdit: TVitalEdit read FLinkedEdit write FLinkedEdit;
|
|---|
| 211 | property CPRSDialogData: ICPRSDialogComponent read FCPRSDialogInfo implements ICPRSDialogComponent;
|
|---|
| 212 | end;
|
|---|
| 213 |
|
|---|
| 214 | TMentalHealthMemo = class(TMemo);
|
|---|
| 215 |
|
|---|
| 216 | procedure ScreenReaderSystem_CurrentCheckBox(CheckBox: TCPRSDialogParentCheckBox);
|
|---|
| 217 | procedure ScreenReaderSystem_CurrentLabel(lbl: TCPRSDialogStaticLabel);
|
|---|
| 218 | procedure ScreenReaderSystem_CurrentComponent(component: ICPRSDialogComponent);
|
|---|
| 219 | procedure ScreenReaderSystem_AddText(text: string);
|
|---|
| 220 | procedure ScreenReaderSystem_Continue;
|
|---|
| 221 | procedure ScreenReaderSystem_Stop;
|
|---|
| 222 | procedure ScreenReaderSystem_Clear;
|
|---|
| 223 | //function ScreenReaderSystem_GetPendingText: string;
|
|---|
| 224 |
|
|---|
| 225 | const
|
|---|
| 226 | // Screen Reader will stop reading in a TDlgFieldPanel at all classes except these:
|
|---|
| 227 | ReminderScreenReaderReadThroughClasses: array[1..3] of TClass =
|
|---|
| 228 | (TUpDown, TLabel, TVitalComboBox);
|
|---|
| 229 |
|
|---|
| 230 | implementation
|
|---|
| 231 |
|
|---|
| 232 | uses uCore, ORClasses, ORFn, VA508AccessibilityRouter, uTemplateFields;
|
|---|
| 233 |
|
|---|
| 234 | var
|
|---|
| 235 | SRCheckBox: TCPRSDialogParentCheckBox = nil;
|
|---|
| 236 | SRLabel: TCPRSDialogStaticLabel = nil;
|
|---|
| 237 | SRComp: ICPRSDialogComponent = nil;
|
|---|
| 238 | SRText: string = '';
|
|---|
| 239 | SRContinuePending: boolean = FALSE;
|
|---|
| 240 |
|
|---|
| 241 | procedure UpdatePending;
|
|---|
| 242 | begin
|
|---|
| 243 | if SRContinuePending then
|
|---|
| 244 | begin
|
|---|
| 245 | if assigned(SRComp) then
|
|---|
| 246 | begin
|
|---|
| 247 | SRComp.AfterText := SRText;
|
|---|
| 248 | SRText := '';
|
|---|
| 249 | if assigned(SRLabel) then
|
|---|
| 250 | begin
|
|---|
| 251 | SRLabel.TabStop := FALSE;
|
|---|
| 252 | SRLabel := nil;
|
|---|
| 253 | end;
|
|---|
| 254 | end;
|
|---|
| 255 | SRComp := nil;
|
|---|
| 256 | SRContinuePending := FALSE;
|
|---|
| 257 | end;
|
|---|
| 258 | end;
|
|---|
| 259 |
|
|---|
| 260 | procedure UpdateCheckBox;
|
|---|
| 261 | begin
|
|---|
| 262 | if assigned(SRCheckBox) then
|
|---|
| 263 | begin
|
|---|
| 264 | SRCheckBox.AccessText := SRText;
|
|---|
| 265 | SRText := '';
|
|---|
| 266 | if assigned(SRLabel) then
|
|---|
| 267 | SRLabel.TabStop := false;
|
|---|
| 268 | SRLabel := nil;
|
|---|
| 269 | SRCheckBox := nil;
|
|---|
| 270 | end;
|
|---|
| 271 | end;
|
|---|
| 272 |
|
|---|
| 273 | procedure ScreenReaderSystem_CurrentCheckBox(CheckBox: TCPRSDialogParentCheckBox);
|
|---|
| 274 | begin
|
|---|
| 275 | ScreenReaderSystem_Stop;
|
|---|
| 276 | SRCheckBox := CheckBox;
|
|---|
| 277 | end;
|
|---|
| 278 |
|
|---|
| 279 | procedure ScreenReaderSystem_CurrentLabel(lbl: TCPRSDialogStaticLabel);
|
|---|
| 280 | begin
|
|---|
| 281 | if assigned(SRLabel) then
|
|---|
| 282 | ScreenReaderSystem_Stop;
|
|---|
| 283 | SRLabel := lbl;
|
|---|
| 284 | end;
|
|---|
| 285 |
|
|---|
| 286 | procedure ScreenReaderSystem_CurrentComponent(component: ICPRSDialogComponent);
|
|---|
| 287 | begin
|
|---|
| 288 | UpdateCheckBox;
|
|---|
| 289 | UpdatePending;
|
|---|
| 290 | if component.RequiredField then
|
|---|
| 291 | begin
|
|---|
| 292 | if SRText <> '' then
|
|---|
| 293 | SRText := SRText + ' ';
|
|---|
| 294 | SRText := SRText + 'required field';
|
|---|
| 295 | end;
|
|---|
| 296 | if (SRText <> '') and (component.Component is TCPRSDialogCheckBox) then
|
|---|
| 297 | ScreenReaderSystem_Stop;
|
|---|
| 298 | SRComp := component;
|
|---|
| 299 | if SRText = '' then
|
|---|
| 300 | SRComp.BeforeText := ' '
|
|---|
| 301 | else
|
|---|
| 302 | SRComp.BeforeText := SRText;
|
|---|
| 303 | SRText := '';
|
|---|
| 304 | if assigned(SRLabel) then
|
|---|
| 305 | begin
|
|---|
| 306 | SRLabel.TabStop := FALSE;
|
|---|
| 307 | SRLabel := nil;
|
|---|
| 308 | end;
|
|---|
| 309 | end;
|
|---|
| 310 |
|
|---|
| 311 | procedure ScreenReaderSystem_AddText(text: string);
|
|---|
| 312 | begin
|
|---|
| 313 | if RightStr(Text,1) = '*' then
|
|---|
| 314 | delete(text, length(text),1);
|
|---|
| 315 | if Text <> '' then
|
|---|
| 316 | begin
|
|---|
| 317 | if SRText <> '' then
|
|---|
| 318 | SRText := SRText + ' ';
|
|---|
| 319 | SRText := SRText + text;
|
|---|
| 320 | end;
|
|---|
| 321 | end;
|
|---|
| 322 |
|
|---|
| 323 | procedure ScreenReaderSystem_Continue;
|
|---|
| 324 | begin
|
|---|
| 325 | if assigned(SRComp) then
|
|---|
| 326 | SRContinuePending := TRUE
|
|---|
| 327 | else
|
|---|
| 328 | SRContinuePending := FALSE;
|
|---|
| 329 | end;
|
|---|
| 330 |
|
|---|
| 331 | procedure ScreenReaderSystem_Stop;
|
|---|
| 332 | begin
|
|---|
| 333 | UpdateCheckBox;
|
|---|
| 334 | UpdatePending;
|
|---|
| 335 | ScreenReaderSystem_Clear;
|
|---|
| 336 | end;
|
|---|
| 337 |
|
|---|
| 338 | procedure ScreenReaderSystem_Clear;
|
|---|
| 339 | begin
|
|---|
| 340 | SRCheckBox := nil;
|
|---|
| 341 | if assigned(SRLabel) and (trim(SRLabel.Caption) = '') then
|
|---|
| 342 | SRLabel.TabStop := false;
|
|---|
| 343 | SRLabel := nil;
|
|---|
| 344 | SRComp := nil;
|
|---|
| 345 | SRText := '';
|
|---|
| 346 | SRContinuePending := FALSE;
|
|---|
| 347 | end;
|
|---|
| 348 |
|
|---|
| 349 | function ScreenReaderSystem_GetPendingText: string;
|
|---|
| 350 | begin
|
|---|
| 351 | Result := SRText;
|
|---|
| 352 | SRText := '';
|
|---|
| 353 | end;
|
|---|
| 354 |
|
|---|
| 355 | function GetDialogControlText(Control: TControl): string;
|
|---|
| 356 | var
|
|---|
| 357 | Len: Integer;
|
|---|
| 358 | begin
|
|---|
| 359 | if Control is TButton then
|
|---|
| 360 | Result := TButton(Control).Caption
|
|---|
| 361 | else
|
|---|
| 362 | begin
|
|---|
| 363 | Len := Control.GetTextLen;
|
|---|
| 364 | SetString(Result, PChar(nil), Len);
|
|---|
| 365 | if Len <> 0 then Control.GetTextBuf(Pointer(Result), Len + 1);
|
|---|
| 366 | end;
|
|---|
| 367 | end;
|
|---|
| 368 |
|
|---|
| 369 | constructor TDlgFieldPanel.Create(AOwner: TComponent);
|
|---|
| 370 | begin
|
|---|
| 371 | inherited Create(AOwner);
|
|---|
| 372 | FChildren := TInterfaceList.Create;
|
|---|
| 373 | end;
|
|---|
| 374 |
|
|---|
| 375 | destructor TDlgFieldPanel.Destroy;
|
|---|
| 376 | begin
|
|---|
| 377 | if(assigned(FOnDestroy)) then
|
|---|
| 378 | FOnDestroy(Self);
|
|---|
| 379 | FreeAndNil(FChildren);
|
|---|
| 380 | inherited;
|
|---|
| 381 | end;
|
|---|
| 382 |
|
|---|
| 383 | function TDlgFieldPanel.GetFirstComponent: ICPRSDialogComponent;
|
|---|
| 384 | begin
|
|---|
| 385 | FCurrentPos := Point(-1,-1);
|
|---|
| 386 | Result := GetNextComponent;
|
|---|
| 387 | end;
|
|---|
| 388 |
|
|---|
| 389 | function TDlgFieldPanel.GetFocus: boolean;
|
|---|
| 390 | begin
|
|---|
| 391 | result := Focused;
|
|---|
| 392 | end;
|
|---|
| 393 |
|
|---|
| 394 |
|
|---|
| 395 | function TDlgFieldPanel.GetNextComponent: ICPRSDialogComponent;
|
|---|
| 396 | var
|
|---|
| 397 | Comp: ICPRSDialogComponent;
|
|---|
| 398 | Control: TControl;
|
|---|
| 399 | i: integer;
|
|---|
| 400 | MinLeft, MinTop, MinXGap, MinYGap, gap: Integer;
|
|---|
| 401 | ok: boolean;
|
|---|
| 402 |
|
|---|
| 403 | begin
|
|---|
| 404 | MinLeft := FCurrentPos.x;
|
|---|
| 405 | MinTop := FCurrentPos.Y;
|
|---|
| 406 | MinXGap := MaxInt;
|
|---|
| 407 | MinYGap := MaxInt;
|
|---|
| 408 | Result := nil;
|
|---|
| 409 | for I := 0 to FChildren.Count - 1 do
|
|---|
| 410 | begin
|
|---|
| 411 | Comp := ICPRSDialogComponent(FChildren[i]);
|
|---|
| 412 | try
|
|---|
| 413 | Control := Comp.Component;
|
|---|
| 414 | if assigned(Control) then
|
|---|
| 415 | begin
|
|---|
| 416 | ok := (Control.Top > MinTop);
|
|---|
| 417 | if (not ok) and (Control.Top = MinTop) and (Control.Left > MinLeft) then
|
|---|
| 418 | ok := TRUE;
|
|---|
| 419 | if ok then
|
|---|
| 420 | begin
|
|---|
| 421 | ok := FALSE;
|
|---|
| 422 | gap := Control.Top - MinTop;
|
|---|
| 423 | if gap < MinYGap then
|
|---|
| 424 | begin
|
|---|
| 425 | MinYGap := gap;
|
|---|
| 426 | MinXGap := Control.Left;
|
|---|
| 427 | ok := true;
|
|---|
| 428 | end
|
|---|
| 429 | else
|
|---|
| 430 | if (MinYGap = gap) and (Control.Left < MinXGap) then
|
|---|
| 431 | begin
|
|---|
| 432 | MinXGap := Control.Left;
|
|---|
| 433 | ok := TRUE;
|
|---|
| 434 | end;
|
|---|
| 435 | if ok then
|
|---|
| 436 | begin
|
|---|
| 437 | Result := Comp;
|
|---|
| 438 | end;
|
|---|
| 439 | end;
|
|---|
| 440 | end;
|
|---|
| 441 | finally
|
|---|
| 442 | Comp := nil;
|
|---|
| 443 | end;
|
|---|
| 444 | end;
|
|---|
| 445 | if assigned(Result) then
|
|---|
| 446 | begin
|
|---|
| 447 | FCurrentPos.x := Result.Component.Left;
|
|---|
| 448 | FCurrentPos.Y := Result.Component.Top;
|
|---|
| 449 | end;
|
|---|
| 450 | end;
|
|---|
| 451 |
|
|---|
| 452 | procedure TDlgFieldPanel.Paint;
|
|---|
| 453 | var
|
|---|
| 454 | DC: HDC;
|
|---|
| 455 | R: TRect;
|
|---|
| 456 |
|
|---|
| 457 | begin
|
|---|
| 458 | inherited;
|
|---|
| 459 | if(Focused) then
|
|---|
| 460 | begin
|
|---|
| 461 | if(not assigned(FCanvas)) then
|
|---|
| 462 | FCanvas := TControlCanvas.Create;
|
|---|
| 463 | DC := GetWindowDC(Handle);
|
|---|
| 464 | try
|
|---|
| 465 | FCanvas.Handle := DC;
|
|---|
| 466 | R := ClientRect;
|
|---|
| 467 | InflateRect(R, -1, -1);
|
|---|
| 468 | FCanvas.DrawFocusRect(R);
|
|---|
| 469 | finally
|
|---|
| 470 | ReleaseDC(Handle, DC);
|
|---|
| 471 | end;
|
|---|
| 472 | end;
|
|---|
| 473 | end;
|
|---|
| 474 |
|
|---|
| 475 | procedure TDlgFieldPanel.SetTheFocus(const Value: boolean);
|
|---|
| 476 | begin
|
|---|
| 477 | if Value then
|
|---|
| 478 | SetFocus;
|
|---|
| 479 | end;
|
|---|
| 480 |
|
|---|
| 481 | { TVitalComboBox }
|
|---|
| 482 |
|
|---|
| 483 | constructor TVitalComboBox.Create(AOwner: TComponent);
|
|---|
| 484 | begin
|
|---|
| 485 | inherited Create(AOwner);
|
|---|
| 486 | FCPRSDialogInfo := TCPRSDialogComponent.Create(Self, 'Edit Combo');
|
|---|
| 487 | end;
|
|---|
| 488 |
|
|---|
| 489 | destructor TVitalComboBox.Destroy;
|
|---|
| 490 | begin
|
|---|
| 491 | FCPRSDialogInfo := nil;
|
|---|
| 492 | inherited;
|
|---|
| 493 | end;
|
|---|
| 494 |
|
|---|
| 495 | procedure TVitalComboBox.SelectByID(Value: string);
|
|---|
| 496 | var
|
|---|
| 497 | i: integer;
|
|---|
| 498 |
|
|---|
| 499 | begin
|
|---|
| 500 | for i := 0 to Items.Count-1 do
|
|---|
| 501 | if(Value = Items[i]) then
|
|---|
| 502 | begin
|
|---|
| 503 | ItemIndex := i;
|
|---|
| 504 | break;
|
|---|
| 505 | end;
|
|---|
| 506 | end;
|
|---|
| 507 |
|
|---|
| 508 | { TCPRSTemplateFieldEdit }
|
|---|
| 509 |
|
|---|
| 510 | constructor TCPRSDialogFieldEdit.Create(AOwner: TComponent);
|
|---|
| 511 | begin
|
|---|
| 512 | inherited Create(AOwner);
|
|---|
| 513 | FCPRSDialogData := TCPRSDialogComponent.Create(Self, 'Edit');
|
|---|
| 514 | end;
|
|---|
| 515 |
|
|---|
| 516 | destructor TCPRSDialogFieldEdit.Destroy;
|
|---|
| 517 | begin
|
|---|
| 518 | FCPRSDialogData := nil;
|
|---|
| 519 | inherited;
|
|---|
| 520 | end;
|
|---|
| 521 |
|
|---|
| 522 | { TCPRSTemplateFieldComboBox }
|
|---|
| 523 |
|
|---|
| 524 | constructor TCPRSDialogComboBox.Create(AOwner: TComponent);
|
|---|
| 525 | begin
|
|---|
| 526 | inherited Create(AOwner);
|
|---|
| 527 | FCPRSDialogData := TCPRSDialogComponent.Create(Self, 'Edit Combo');
|
|---|
| 528 | end;
|
|---|
| 529 |
|
|---|
| 530 | destructor TCPRSDialogComboBox.Destroy;
|
|---|
| 531 | begin
|
|---|
| 532 | FCPRSDialogData := nil;
|
|---|
| 533 | inherited;
|
|---|
| 534 | end;
|
|---|
| 535 |
|
|---|
| 536 | { TCPRSTemplateFieldCheckBox }
|
|---|
| 537 |
|
|---|
| 538 | constructor TCPRSDialogCheckBox.Create(AOwner: TComponent);
|
|---|
| 539 | begin
|
|---|
| 540 | inherited Create(AOwner);
|
|---|
| 541 | FCPRSDialogData := TCPRSDialogComponent.Create(Self, 'Check Box');
|
|---|
| 542 | end;
|
|---|
| 543 |
|
|---|
| 544 | destructor TCPRSDialogCheckBox.Destroy;
|
|---|
| 545 | begin
|
|---|
| 546 | FCPRSDialogData := nil;
|
|---|
| 547 | inherited;
|
|---|
| 548 | end;
|
|---|
| 549 |
|
|---|
| 550 | { TCPRSDialogButton }
|
|---|
| 551 |
|
|---|
| 552 | constructor TCPRSDialogButton.Create(AOwner: TComponent);
|
|---|
| 553 | begin
|
|---|
| 554 | inherited Create(AOwner);
|
|---|
| 555 | FCPRSDialogData := TCPRSDialogComponent.Create(Self, 'Button');
|
|---|
| 556 | end;
|
|---|
| 557 |
|
|---|
| 558 | destructor TCPRSDialogButton.Destroy;
|
|---|
| 559 | begin
|
|---|
| 560 | FCPRSDialogData := nil;
|
|---|
| 561 | inherited;
|
|---|
| 562 | end;
|
|---|
| 563 |
|
|---|
| 564 | { TCPRSTemplateFieldDateCombo }
|
|---|
| 565 |
|
|---|
| 566 | constructor TCPRSDialogDateCombo.Create(AOwner: TComponent);
|
|---|
| 567 | begin
|
|---|
| 568 | inherited Create(AOwner);
|
|---|
| 569 | ORYearEditClass := TCPRSDialogYearEdit;
|
|---|
| 570 | FCPRSDialogInfo := TCPRSDialogComponent.Create(Self, 'Date Fields','Year');
|
|---|
| 571 | end;
|
|---|
| 572 |
|
|---|
| 573 | destructor TCPRSDialogDateCombo.Destroy;
|
|---|
| 574 | begin
|
|---|
| 575 | FCPRSDialogInfo := nil;
|
|---|
| 576 | inherited;
|
|---|
| 577 | end;
|
|---|
| 578 |
|
|---|
| 579 | { TCPRSTemplateFieldDateBox }
|
|---|
| 580 |
|
|---|
| 581 | constructor TCPRSDialogDateBox.Create(AOwner: TComponent);
|
|---|
| 582 | //var
|
|---|
| 583 | // i: integer;
|
|---|
| 584 | // btn: TORDateButton;
|
|---|
| 585 |
|
|---|
| 586 | begin
|
|---|
| 587 | inherited Create(AOwner);
|
|---|
| 588 | { for i := 0 to ControlCount - 1 do
|
|---|
| 589 | begin
|
|---|
| 590 | if Controls[i] is TORDateButton then
|
|---|
| 591 | begin
|
|---|
| 592 | btn := TORDateButton(Controls[i]);
|
|---|
| 593 | if ScreenReaderSystemActive then
|
|---|
| 594 | btn.TabStop := TRUE;
|
|---|
| 595 | break;
|
|---|
| 596 | end;
|
|---|
| 597 | end;}
|
|---|
| 598 | FCPRSDialogInfo := TCPRSDialogComponent.Create(Self, 'Date Edit', 'Date');
|
|---|
| 599 | end;
|
|---|
| 600 |
|
|---|
| 601 | destructor TCPRSDialogDateBox.Destroy;
|
|---|
| 602 | begin
|
|---|
| 603 | FCPRSDialogInfo := nil;
|
|---|
| 604 | inherited;
|
|---|
| 605 | end;
|
|---|
| 606 |
|
|---|
| 607 | { TCPRSTemplateFieldNumber }
|
|---|
| 608 |
|
|---|
| 609 | constructor TCPRSDialogNumber.CreatePanel(AOwner: TComponent);
|
|---|
| 610 | begin
|
|---|
| 611 | inherited Create(AOwner);
|
|---|
| 612 | FEdit := TCPRSNumberField.Create(Self);
|
|---|
| 613 | FEdit.Parent := Self;
|
|---|
| 614 | FEdit.BorderStyle := bsNone;
|
|---|
| 615 | FEdit.Top := 0;
|
|---|
| 616 | FEdit.Left := 0;
|
|---|
| 617 | FEdit.AutoSelect := True;
|
|---|
| 618 | FUpDown := TUpDown.Create(Self);
|
|---|
| 619 | FUpDown.Parent := Self;
|
|---|
| 620 | FUpDown.Associate := FEdit;
|
|---|
| 621 | FUpDown.Thousands := FALSE;
|
|---|
| 622 | FEdit.Tag := Integer(FUpDown);
|
|---|
| 623 | FCPRSDialogInfo := TCPRSDialogComponent.Create(Self, 'Numeric Edit', 'Numeric');
|
|---|
| 624 | end;
|
|---|
| 625 |
|
|---|
| 626 | destructor TCPRSDialogNumber.Destroy;
|
|---|
| 627 | begin
|
|---|
| 628 | FCPRSDialogInfo := nil;
|
|---|
| 629 | inherited;
|
|---|
| 630 | end;
|
|---|
| 631 |
|
|---|
| 632 | { TCPRSTemplateWebLabel }
|
|---|
| 633 |
|
|---|
| 634 | procedure TCPRSDialogHyperlinkLabel.Clicked(Sender: TObject);
|
|---|
| 635 | begin
|
|---|
| 636 | GotoWebPage(FURL);
|
|---|
| 637 | end;
|
|---|
| 638 |
|
|---|
| 639 | type
|
|---|
| 640 | TFontFriend = class(TFont);
|
|---|
| 641 |
|
|---|
| 642 | constructor TCPRSDialogHyperlinkLabel.Create(AOwner: TComponent);
|
|---|
| 643 | begin
|
|---|
| 644 | inherited Create(AOwner);
|
|---|
| 645 | FCPRSDialogInfo := TCPRSDialogComponent.Create(Self, 'Hyper Link', 'Hyper Link');
|
|---|
| 646 | OnKeyPress := KeyPressed;
|
|---|
| 647 | end;
|
|---|
| 648 |
|
|---|
| 649 | destructor TCPRSDialogHyperlinkLabel.Destroy;
|
|---|
| 650 | begin
|
|---|
| 651 | FCPRSDialogInfo := nil;
|
|---|
| 652 | inherited;
|
|---|
| 653 | end;
|
|---|
| 654 |
|
|---|
| 655 | procedure TCPRSDialogHyperlinkLabel.Init(Addr: string);
|
|---|
| 656 | begin
|
|---|
| 657 | FURL := Addr;
|
|---|
| 658 | OnClick := Clicked;
|
|---|
| 659 | StaticLabel.OnClick := Clicked;
|
|---|
| 660 | Font.Assign(TORExposedControl(Parent).Font);
|
|---|
| 661 | Font.Color := Get508CompliantColor(clBlue);
|
|---|
| 662 | Font.Style := Font.Style + [fsUnderline];
|
|---|
| 663 | TFontFriend(Font).Changed; // AdjustBounds; // make sure we have the right width
|
|---|
| 664 | AutoSize := FALSE;
|
|---|
| 665 | Height := Height + 1; // Courier New doesn't support underline unless it's higher
|
|---|
| 666 | Cursor := crHandPoint;
|
|---|
| 667 | end;
|
|---|
| 668 |
|
|---|
| 669 | procedure TCPRSDialogHyperlinkLabel.KeyPressed(Sender: TObject;
|
|---|
| 670 | var Key: Char);
|
|---|
| 671 | begin
|
|---|
| 672 | if ord(Key) = VK_SPACE then
|
|---|
| 673 | Clicked(Self);
|
|---|
| 674 | end;
|
|---|
| 675 |
|
|---|
| 676 | { TCPRSTemplateFieldRichEdit }
|
|---|
| 677 |
|
|---|
| 678 | constructor TCPRSDialogRichEdit.Create(AOwner: TComponent);
|
|---|
| 679 | begin
|
|---|
| 680 | inherited Create(AOwner);
|
|---|
| 681 | FCPRSDialogData := TCPRSDialogComponent.Create(Self, 'Edit');
|
|---|
| 682 | end;
|
|---|
| 683 |
|
|---|
| 684 | destructor TCPRSDialogRichEdit.Destroy;
|
|---|
| 685 | begin
|
|---|
| 686 | FCPRSDialogData := nil;
|
|---|
| 687 | inherited;
|
|---|
| 688 | end;
|
|---|
| 689 |
|
|---|
| 690 | { TCPRSDialogData }
|
|---|
| 691 |
|
|---|
| 692 | function TCPRSDialogComponent.Component: TControl;
|
|---|
| 693 | begin
|
|---|
| 694 | Result := FComponent;
|
|---|
| 695 | end;
|
|---|
| 696 |
|
|---|
| 697 | constructor TCPRSDialogComponent.Create(AComponent: TControl; AComponentName: string;
|
|---|
| 698 | FollowOnCaption: string = '');
|
|---|
| 699 | begin
|
|---|
| 700 | inherited Create;
|
|---|
| 701 | FComponent := AComponent;
|
|---|
| 702 | FSRBreak := TRUE;
|
|---|
| 703 | FComponentName := AComponentName;
|
|---|
| 704 | FFollowOnCaption := FollowOnCaption;
|
|---|
| 705 | FRequiredField := FALSE;
|
|---|
| 706 | end;
|
|---|
| 707 |
|
|---|
| 708 | function TCPRSDialogComponent.AccessText: string;
|
|---|
| 709 | begin
|
|---|
| 710 | if FAfterText = '' then
|
|---|
| 711 | Result := FBeforeText
|
|---|
| 712 | else if FBeforeText = '' then
|
|---|
| 713 | begin
|
|---|
| 714 | if FAfterText <> '' then
|
|---|
| 715 | Result := FComponentName + ', ' + FAfterText + ','
|
|---|
| 716 | else
|
|---|
| 717 | Result := '';
|
|---|
| 718 | end
|
|---|
| 719 | else
|
|---|
| 720 | Result := FBeforeText + ', ' + FComponentName + ', ' + FAfterText + ',';
|
|---|
| 721 | if FFollowOnCaption <> '' then
|
|---|
| 722 | begin
|
|---|
| 723 | if Result <> '' then
|
|---|
| 724 | Result := Result + ' ';
|
|---|
| 725 | Result := Result + ' ' + FFollowOnCaption;
|
|---|
| 726 | end;
|
|---|
| 727 | end;
|
|---|
| 728 |
|
|---|
| 729 | function TCPRSDialogComponent.GetAfterText: string;
|
|---|
| 730 | begin
|
|---|
| 731 | Result := FAfterText;
|
|---|
| 732 | end;
|
|---|
| 733 |
|
|---|
| 734 | function TCPRSDialogComponent.GetBeforeText: string;
|
|---|
| 735 | begin
|
|---|
| 736 | Result := FBeforeText;
|
|---|
| 737 | end;
|
|---|
| 738 |
|
|---|
| 739 | function TCPRSDialogComponent.GetRequiredField: boolean;
|
|---|
| 740 | begin
|
|---|
| 741 | Result := FRequiredField;
|
|---|
| 742 | end;
|
|---|
| 743 |
|
|---|
| 744 | function TCPRSDialogComponent.GetSRBreak: boolean;
|
|---|
| 745 | begin
|
|---|
| 746 | Result := FSRBreak;
|
|---|
| 747 | end;
|
|---|
| 748 |
|
|---|
| 749 | procedure TCPRSDialogComponent.SetAfterText(value: string);
|
|---|
| 750 | begin
|
|---|
| 751 | FAfterText := Value;
|
|---|
| 752 | end;
|
|---|
| 753 |
|
|---|
| 754 | procedure TCPRSDialogComponent.SetBeforeText(Value: string);
|
|---|
| 755 | begin
|
|---|
| 756 | FBeforeText := Value;
|
|---|
| 757 | end;
|
|---|
| 758 |
|
|---|
| 759 | procedure TCPRSDialogComponent.SetRequiredField(Value: boolean);
|
|---|
| 760 | begin
|
|---|
| 761 | FRequiredField := Value;
|
|---|
| 762 | end;
|
|---|
| 763 |
|
|---|
| 764 | procedure TCPRSDialogComponent.SetSRBreak(Value: boolean);
|
|---|
| 765 | begin
|
|---|
| 766 | FSRBreak := Value;
|
|---|
| 767 | end;
|
|---|
| 768 |
|
|---|
| 769 | { TVitalEdit }
|
|---|
| 770 |
|
|---|
| 771 | constructor TVitalEdit.Create(AOwner: TComponent);
|
|---|
| 772 | begin
|
|---|
| 773 | inherited Create(AOwner);
|
|---|
| 774 | FCPRSDialogInfo := TCPRSDialogComponent.Create(Self, 'Vital Edit','Vital');
|
|---|
| 775 | end;
|
|---|
| 776 |
|
|---|
| 777 | destructor TVitalEdit.Destroy;
|
|---|
| 778 | begin
|
|---|
| 779 | FCPRSDialogInfo := nil;
|
|---|
| 780 | inherited;
|
|---|
| 781 | end;
|
|---|
| 782 |
|
|---|
| 783 | initialization
|
|---|
| 784 |
|
|---|
| 785 | finalization
|
|---|
| 786 | ScreenReaderSystem_Clear;
|
|---|
| 787 |
|
|---|
| 788 | end.
|
|---|