Ignore:
Timestamp:
Jul 7, 2010, 4:31:10 PM (14 years ago)
Author:
Kevin Toppenberg
Message:

Upgrade to version 27

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cprs/trunk/CPRS-Lib/ORDtTm.pas

    r456 r829  
    77uses
    88  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;
    1011
    1112type
    12   TORfrmDtTm = class(TForm)
     13  TORfrmDtTm = class(Tfrm2006Compatibility)
    1314    bvlFrame: TBevel;
    1415    lblDate: TPanel;
     
    5152    FNowPressed:  Boolean;
    5253    TimeIsRequired: Boolean;
     54  protected
     55    procedure Loaded; override;
    5356  end;
    5457
     
    7578  end;
    7679
     80  // 508 class
     81  TORDateButton = class (TBitBtn);
     82
    7783  { TORDateBox }
    7884
     
    8288  end;
    8389
    84   TORDateBox = class(TORDateEdit)
     90  TORDateBox = class(TORDateEdit, IVADynamicProperty, IORBlackColorModeCompatible)
    8591  private
    8692    FFMDateTime: TFMDateTime;
    8793    FDateOnly: Boolean;
    8894    FRequireTime: Boolean;
    89     FButton: TBitBtn;
     95    FButton: TORDateButton;
    9096    FFormat: string;
    9197    FTimeIsNow: Boolean;
    9298    FTemplateField: boolean;
    9399    FCaption: TStaticText;
     100    FBlackColorMode: boolean;
    94101    procedure ButtonClick(Sender: TObject);
    95102    function GetFMDateTime: TFMDateTime;
     
    104111    procedure SetCaption(const Value: string);
    105112    function  GetCaption(): string;
    106                                                              
    107113  protected
    108114    procedure Change; override;
    109115    procedure KeyDown(var Key: Word; Shift: TShiftState); override;
     116    property DateButton: TORDateButton read FButton;
    110117  public
    111118    constructor Create(AOwner: TComponent); override;
    112119    function IsValid: Boolean;
    113120    procedure Validate(var ErrMsg: string);
     121    procedure SetBlackColorMode(Value: boolean);
     122    function SupportsDynamicProperty(PropertyID: integer): boolean;
     123    function GetDynamicProperty(PropertyID: integer): string;
    114124    property Format: string read FFormat write FFormat;
    115125    property RelativeTime: string     read GetRelativeTime;
     
    122132  end;
    123133
    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)
    125148  private
    126149    FYearChanging: boolean;
    127     FMonthCombo: TORComboBox;
    128     FDayCombo: TORComboBox;
    129     FYearEdit: TMaskEdit;
     150    FMonthCombo: TORMonthCombo;
     151    FDayCombo: TORDayCombo;
     152    FYearEdit: TORYearEdit;
    130153    FYearUD: TUpDown;
    131     FCalBtn: TSpeedButton;
     154    FCalBtn: TORDateButton;
    132155    FIncludeMonth: boolean;
    133156    FIncludeDay: boolean;
     
    141164    FRebuilding: boolean;
    142165    FTemplateField: boolean;
     166    FBlackColorMode: boolean;
     167    FORYearEditClass: TORYearEditClass;
    143168    procedure SetIncludeBtn(const Value: boolean);
    144169    procedure SetIncludeDay(Value: boolean);
     
    153178    procedure SetTemplateField(const Value: boolean);
    154179  protected
    155     procedure Rebuild;
     180    procedure Rebuild; virtual;
    156181    function InitDays(GetSize: boolean): integer;
    157182    function InitMonths(GetSize: boolean): integer;
     
    169194    procedure Paint; override;
    170195    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;
    171202  public
    172203    constructor Create(AOwner: TComponent); override;
    173204    destructor Destroy; override;
    174205    function DateText: string;
     206    procedure SetBlackColorMode(Value: boolean);
    175207    property TemplateField: boolean read FTemplateField write SetTemplateField;
    176208    property FMDate: TFMDateTime read GetFMDate write SetFMDate;
     
    280312end;
    281313
     314procedure LoadEllipsis(bitmap: TBitMap; BlackColorMode: boolean);
     315var
     316  ResName: string;
     317begin
     318  if BlackColorMode then
     319    ResName := 'BLACK_BMP_ELLIPSIS'
     320  else
     321    ResName := 'BMP_ELLIPSIS';
     322  bitmap.LoadFromResourceName(hInstance, ResName);
     323end;
     324
    282325{ TfrmORDtTm -------------------------------------------------------------------------------- }
    283326
     
    351394procedure TORfrmDtTm.lstHourClick(Sender: TObject);
    352395begin
     396  if lstHour.ItemIndex = 0 then lstMinute.Items[0] := ':01  --' else lstMinute.Items[0] := ':00  --'; //<------ NEW CODE
    353397  if lstMinute.ItemIndex < 0 then lstMinute.ItemIndex := 0;
    354398  lstMinuteClick(Self);
     
    374418
    375419  AMinute := lstMinute.ItemIndex * 5;
     420  if (AnHour = 0) and (AMinute = 0) then AMinute := 1;  //<-------------- NEW CODE
    376421  FFromSelf := True;
    377422  // if ampm time -
     
    410455  begin
    411456    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
    413459    StrToTime(x);
    414460    txtTime.Text := x;
     
    420466begin
    421467  ModalResult := mrCancel;
     468end;
     469
     470procedure TORfrmDtTm.Loaded;
     471begin
     472  inherited Loaded;
     473  UpdateColorsFor508Compliance(Self);
    422474end;
    423475
     
    515567begin
    516568  inherited Create(AOwner);
    517   FButton := TBitBtn.Create(Self);
     569  FButton := TORDateButton.Create(Self);
    518570  FButton.Parent := Self;
    519571  FButton.Width := 18;
     
    521573  FButton.OnClick := ButtonClick;
    522574  FButton.TabStop := False;
    523   FButton.Glyph.LoadFromResourceName(hInstance, 'BMP_ELLIPSIS');
     575  FBlackColorMode := False;
     576  LoadEllipsis(FButton.Glyph, FALSE);
    524577  FButton.Visible := True;
    525578  FFormat := FMT_DATETIME;
     
    567620end;
    568621
     622function TORDateBox.SupportsDynamicProperty(PropertyID: integer): boolean;
     623begin
     624  Result := (PropertyID = DynaPropAccesibilityCaption);
     625end;
     626
    569627procedure TORDateBox.ButtonClick(Sender: TObject);
    570628var
     
    696754  if Length(x) = 0 then Result := True else Result := False;
    697755  if Length(Text) = 0 then Result := False;
     756end;
     757
     758procedure TORDateBox.SetBlackColorMode(Value: boolean);
     759begin
     760  if FBlackColorMode <> Value then
     761  begin
     762    FBlackColorMode := Value;
     763    LoadEllipsis(FButton.Glyph, FBlackColorMode);
     764  end;
    698765end;
    699766
     
    717784end;
    718785
     786function TORDateBox.GetDynamicProperty(PropertyID: integer): string;
     787begin
     788  if PropertyID = DynaPropAccesibilityCaption then
     789    Result := GetCaption
     790  else
     791    Result := '';
     792end;
     793
    719794function IsLeapYear(AYear: Integer): Boolean;
    720795begin
     
    745820  LastYear = 2200;
    746821
    747 type
    748   TORDateComboEdit = class(TMaskEdit)
    749   private
    750     FTemplateField: boolean;
    751     procedure SetTemplateField(const Value: boolean);
    752   protected
    753     property TemplateField: boolean read FTemplateField write SetTemplateField;
    754   end;
    755 
    756822{ TORDateComboEdit }
    757823
    758 procedure TORDateComboEdit.SetTemplateField(const Value: boolean);
     824procedure TORYearEdit.SetTemplateField(const Value: boolean);
    759825begin
    760826  if(FTemplateField <> Value) then
     
    779845  FIncludeBtn := TRUE;
    780846  OnResize := Resized;
     847  FORYearEditClass := TORYearEdit;
    781848end;
    782849
     
    868935          if(not assigned(FMonthCombo)) then
    869936          begin
    870             FMonthCombo := TORComboBox.Create(Self);
     937            FMonthCombo := TORMonthCombo.Create(Self);
    871938            FMonthCombo.Parent := Self;
    872939            FMonthCombo.Top := 0;
     
    874941            FMonthCombo.Style := orcsDropDown;
    875942            FMonthCombo.DropDownCount := 13;
     943            FMonthCombo.ListItemsOnly := True;
    876944            FMonthCombo.OnChange := MonthChanged;
    877945          end;
     
    888956            if(not assigned(FDayCombo)) then
    889957            begin
    890               FDayCombo := TORComboBox.Create(Self);
     958              FDayCombo := TORDayCombo.Create(Self);
    891959              FDayCombo.Parent := Self;
    892960              FDayCombo.Top := 0;
    893961              FDayCombo.Style := orcsDropDown;
     962              FDayCombo.ListItemsOnly := True;
    894963              FDayCombo.OnChange := DayChanged;
    895964              FDayCombo.DropDownCount := 11;
     
    914983        if(not assigned(FYearEdit)) then
    915984        begin
    916           FYearEdit := TORDateComboEdit.Create(Self);
     985          FYearEdit := FORYearEditClass.Create(Self);
    917986          FYearEdit.Parent := Self;
    918987          FYearEdit.Top := 0;
     
    922991        end;
    923992        FYearEdit.Font := Font;
    924         TORDateComboEdit(FYearEdit).TemplateField := FTemplateField;
     993        FYearEdit.TemplateField := FTemplateField;
    925994        Wide := GetYearSize;
    926995        FYearEdit.Width := Wide;
     
    9471016          if(not assigned(FCalBtn)) then
    9481017          begin
    949             FCalBtn := TSpeedButton.Create(Self);
     1018            FCalBtn := TORDateButton.Create(Self);
     1019            FCalBtn.TabStop := FALSE;
    9501020            FCalBtn.Parent := Self;
    9511021            FCalBtn.Top := 0;
    952             FCalBtn.Glyph.LoadFromResourceName(hInstance, 'BMP_ELLIPSIS');
     1022            LoadEllipsis(FCalBtn.Glyph, FBlackColorMode);
    9531023            FCalBtn.OnClick := BtnClicked;
    9541024          end;
     
    9731043      FRebuilding := FALSE;
    9741044    end;
     1045  end;
     1046end;
     1047
     1048procedure TORDateCombo.SetBlackColorMode(Value: boolean);
     1049begin
     1050  if FBlackColorMode <> Value then
     1051  begin
     1052    FBlackColorMode := Value;
     1053    if assigned(FCalBtn) then   
     1054      LoadEllipsis(FCalBtn.Glyph, FBlackColorMode);
    9751055  end;
    9761056end;
Note: See TracChangeset for help on using the changeset viewer.