Changeset 829 for cprs/trunk/CPRS-Lib/ORDtTm.pas
- Timestamp:
- Jul 7, 2010, 4:31:10 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cprs/trunk/CPRS-Lib/ORDtTm.pas
r456 r829 7 7 uses 8 8 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Buttons, 9 Grids, Calendar, ExtCtrls, ORFn, ORNet, ORDtTmCal, Mask, ComCtrls, ORCtrls; 9 Grids, Calendar, ExtCtrls, ORFn, ORNet, ORDtTmCal, Mask, ComCtrls, OR2006Compatibility, 10 ORCtrls, VAClasses; 10 11 11 12 type 12 TORfrmDtTm = class(T Form)13 TORfrmDtTm = class(Tfrm2006Compatibility) 13 14 bvlFrame: TBevel; 14 15 lblDate: TPanel; … … 51 52 FNowPressed: Boolean; 52 53 TimeIsRequired: Boolean; 54 protected 55 procedure Loaded; override; 53 56 end; 54 57 … … 75 78 end; 76 79 80 // 508 class 81 TORDateButton = class (TBitBtn); 82 77 83 { TORDateBox } 78 84 … … 82 88 end; 83 89 84 TORDateBox = class(TORDateEdit )90 TORDateBox = class(TORDateEdit, IVADynamicProperty, IORBlackColorModeCompatible) 85 91 private 86 92 FFMDateTime: TFMDateTime; 87 93 FDateOnly: Boolean; 88 94 FRequireTime: Boolean; 89 FButton: T BitBtn;95 FButton: TORDateButton; 90 96 FFormat: string; 91 97 FTimeIsNow: Boolean; 92 98 FTemplateField: boolean; 93 99 FCaption: TStaticText; 100 FBlackColorMode: boolean; 94 101 procedure ButtonClick(Sender: TObject); 95 102 function GetFMDateTime: TFMDateTime; … … 104 111 procedure SetCaption(const Value: string); 105 112 function GetCaption(): string; 106 107 113 protected 108 114 procedure Change; override; 109 115 procedure KeyDown(var Key: Word; Shift: TShiftState); override; 116 property DateButton: TORDateButton read FButton; 110 117 public 111 118 constructor Create(AOwner: TComponent); override; 112 119 function IsValid: Boolean; 113 120 procedure Validate(var ErrMsg: string); 121 procedure SetBlackColorMode(Value: boolean); 122 function SupportsDynamicProperty(PropertyID: integer): boolean; 123 function GetDynamicProperty(PropertyID: integer): string; 114 124 property Format: string read FFormat write FFormat; 115 125 property RelativeTime: string read GetRelativeTime; … … 122 132 end; 123 133 124 TORDateCombo = class(TCustomPanel) 134 // 508 classes 135 TORDayCombo = class (TORComboBox); 136 TORMonthCombo = class (TORComboBox); 137 TORYearEdit = class(TMaskEdit) 138 private 139 FTemplateField: boolean; 140 procedure SetTemplateField(const Value: boolean); 141 protected 142 property TemplateField: boolean read FTemplateField write SetTemplateField; 143 end; 144 145 TORYearEditClass = Class of TORYearEdit; 146 147 TORDateCombo = class(TCustomPanel, IORBlackColorModeCompatible) 125 148 private 126 149 FYearChanging: boolean; 127 FMonthCombo: TOR ComboBox;128 FDayCombo: TOR ComboBox;129 FYearEdit: T MaskEdit;150 FMonthCombo: TORMonthCombo; 151 FDayCombo: TORDayCombo; 152 FYearEdit: TORYearEdit; 130 153 FYearUD: TUpDown; 131 FCalBtn: T SpeedButton;154 FCalBtn: TORDateButton; 132 155 FIncludeMonth: boolean; 133 156 FIncludeDay: boolean; … … 141 164 FRebuilding: boolean; 142 165 FTemplateField: boolean; 166 FBlackColorMode: boolean; 167 FORYearEditClass: TORYearEditClass; 143 168 procedure SetIncludeBtn(const Value: boolean); 144 169 procedure SetIncludeDay(Value: boolean); … … 153 178 procedure SetTemplateField(const Value: boolean); 154 179 protected 155 procedure Rebuild; 180 procedure Rebuild; virtual; 156 181 function InitDays(GetSize: boolean): integer; 157 182 function InitMonths(GetSize: boolean): integer; … … 169 194 procedure Paint; override; 170 195 procedure Resized(Sender: TObject); 196 property MonthCombo: TORMonthCombo read FMonthCombo; 197 property DayCombo: TORDayCombo read FDayCombo; 198 property YearEdit: TORYearEdit read FYearEdit; 199 property YearUD: TUpDown read FYearUD; 200 property CalBtn: TORDateButton read FCalBtn; 201 property ORYearEditClass: TORYearEditClass read FORYearEditClass write FORYearEditClass; 171 202 public 172 203 constructor Create(AOwner: TComponent); override; 173 204 destructor Destroy; override; 174 205 function DateText: string; 206 procedure SetBlackColorMode(Value: boolean); 175 207 property TemplateField: boolean read FTemplateField write SetTemplateField; 176 208 property FMDate: TFMDateTime read GetFMDate write SetFMDate; … … 280 312 end; 281 313 314 procedure LoadEllipsis(bitmap: TBitMap; BlackColorMode: boolean); 315 var 316 ResName: string; 317 begin 318 if BlackColorMode then 319 ResName := 'BLACK_BMP_ELLIPSIS' 320 else 321 ResName := 'BMP_ELLIPSIS'; 322 bitmap.LoadFromResourceName(hInstance, ResName); 323 end; 324 282 325 { TfrmORDtTm -------------------------------------------------------------------------------- } 283 326 … … 351 394 procedure TORfrmDtTm.lstHourClick(Sender: TObject); 352 395 begin 396 if lstHour.ItemIndex = 0 then lstMinute.Items[0] := ':01 --' else lstMinute.Items[0] := ':00 --'; //<------ NEW CODE 353 397 if lstMinute.ItemIndex < 0 then lstMinute.ItemIndex := 0; 354 398 lstMinuteClick(Self); … … 374 418 375 419 AMinute := lstMinute.ItemIndex * 5; 420 if (AnHour = 0) and (AMinute = 0) then AMinute := 1; //<-------------- NEW CODE 376 421 FFromSelf := True; 377 422 // if ampm time - … … 410 455 begin 411 456 x := Trim(txtTime.Text); 412 if (x='00:00') or (x='0:00') or (x='00:00:00') or (x='0:00:00') then x := '00:00:01'; 457 //if (x='00:00') or (x='0:00') or (x='00:00:00') or (x='0:00:00') then x := '00:00:01'; 458 if (x='00:00') or (x='0:00') or (x='00:00:00') or (x='0:00:00') then x := '00:01'; //<------- CHANGED CODE 413 459 StrToTime(x); 414 460 txtTime.Text := x; … … 420 466 begin 421 467 ModalResult := mrCancel; 468 end; 469 470 procedure TORfrmDtTm.Loaded; 471 begin 472 inherited Loaded; 473 UpdateColorsFor508Compliance(Self); 422 474 end; 423 475 … … 515 567 begin 516 568 inherited Create(AOwner); 517 FButton := T BitBtn.Create(Self);569 FButton := TORDateButton.Create(Self); 518 570 FButton.Parent := Self; 519 571 FButton.Width := 18; … … 521 573 FButton.OnClick := ButtonClick; 522 574 FButton.TabStop := False; 523 FButton.Glyph.LoadFromResourceName(hInstance, 'BMP_ELLIPSIS'); 575 FBlackColorMode := False; 576 LoadEllipsis(FButton.Glyph, FALSE); 524 577 FButton.Visible := True; 525 578 FFormat := FMT_DATETIME; … … 567 620 end; 568 621 622 function TORDateBox.SupportsDynamicProperty(PropertyID: integer): boolean; 623 begin 624 Result := (PropertyID = DynaPropAccesibilityCaption); 625 end; 626 569 627 procedure TORDateBox.ButtonClick(Sender: TObject); 570 628 var … … 696 754 if Length(x) = 0 then Result := True else Result := False; 697 755 if Length(Text) = 0 then Result := False; 756 end; 757 758 procedure TORDateBox.SetBlackColorMode(Value: boolean); 759 begin 760 if FBlackColorMode <> Value then 761 begin 762 FBlackColorMode := Value; 763 LoadEllipsis(FButton.Glyph, FBlackColorMode); 764 end; 698 765 end; 699 766 … … 717 784 end; 718 785 786 function TORDateBox.GetDynamicProperty(PropertyID: integer): string; 787 begin 788 if PropertyID = DynaPropAccesibilityCaption then 789 Result := GetCaption 790 else 791 Result := ''; 792 end; 793 719 794 function IsLeapYear(AYear: Integer): Boolean; 720 795 begin … … 745 820 LastYear = 2200; 746 821 747 type748 TORDateComboEdit = class(TMaskEdit)749 private750 FTemplateField: boolean;751 procedure SetTemplateField(const Value: boolean);752 protected753 property TemplateField: boolean read FTemplateField write SetTemplateField;754 end;755 756 822 { TORDateComboEdit } 757 823 758 procedure TOR DateComboEdit.SetTemplateField(const Value: boolean);824 procedure TORYearEdit.SetTemplateField(const Value: boolean); 759 825 begin 760 826 if(FTemplateField <> Value) then … … 779 845 FIncludeBtn := TRUE; 780 846 OnResize := Resized; 847 FORYearEditClass := TORYearEdit; 781 848 end; 782 849 … … 868 935 if(not assigned(FMonthCombo)) then 869 936 begin 870 FMonthCombo := TOR ComboBox.Create(Self);937 FMonthCombo := TORMonthCombo.Create(Self); 871 938 FMonthCombo.Parent := Self; 872 939 FMonthCombo.Top := 0; … … 874 941 FMonthCombo.Style := orcsDropDown; 875 942 FMonthCombo.DropDownCount := 13; 943 FMonthCombo.ListItemsOnly := True; 876 944 FMonthCombo.OnChange := MonthChanged; 877 945 end; … … 888 956 if(not assigned(FDayCombo)) then 889 957 begin 890 FDayCombo := TOR ComboBox.Create(Self);958 FDayCombo := TORDayCombo.Create(Self); 891 959 FDayCombo.Parent := Self; 892 960 FDayCombo.Top := 0; 893 961 FDayCombo.Style := orcsDropDown; 962 FDayCombo.ListItemsOnly := True; 894 963 FDayCombo.OnChange := DayChanged; 895 964 FDayCombo.DropDownCount := 11; … … 914 983 if(not assigned(FYearEdit)) then 915 984 begin 916 FYearEdit := TORDateComboEdit.Create(Self);985 FYearEdit := FORYearEditClass.Create(Self); 917 986 FYearEdit.Parent := Self; 918 987 FYearEdit.Top := 0; … … 922 991 end; 923 992 FYearEdit.Font := Font; 924 TORDateComboEdit(FYearEdit).TemplateField := FTemplateField;993 FYearEdit.TemplateField := FTemplateField; 925 994 Wide := GetYearSize; 926 995 FYearEdit.Width := Wide; … … 947 1016 if(not assigned(FCalBtn)) then 948 1017 begin 949 FCalBtn := TSpeedButton.Create(Self); 1018 FCalBtn := TORDateButton.Create(Self); 1019 FCalBtn.TabStop := FALSE; 950 1020 FCalBtn.Parent := Self; 951 1021 FCalBtn.Top := 0; 952 FCalBtn.Glyph.LoadFromResourceName(hInstance, 'BMP_ELLIPSIS');1022 LoadEllipsis(FCalBtn.Glyph, FBlackColorMode); 953 1023 FCalBtn.OnClick := BtnClicked; 954 1024 end; … … 973 1043 FRebuilding := FALSE; 974 1044 end; 1045 end; 1046 end; 1047 1048 procedure TORDateCombo.SetBlackColorMode(Value: boolean); 1049 begin 1050 if FBlackColorMode <> Value then 1051 begin 1052 FBlackColorMode := Value; 1053 if assigned(FCalBtn) then 1054 LoadEllipsis(FCalBtn.Glyph, FBlackColorMode); 975 1055 end; 976 1056 end;
Note:
See TracChangeset
for help on using the changeset viewer.