diff --git a/components/rx/trunk/demos/RxDateEdit/project1.lpi b/components/rx/trunk/demos/RxDateEdit/project1.lpi index 2011f50ad..3dba85243 100644 --- a/components/rx/trunk/demos/RxDateEdit/project1.lpi +++ b/components/rx/trunk/demos/RxDateEdit/project1.lpi @@ -1,7 +1,7 @@ - + @@ -22,10 +22,14 @@ - - - - + + + + + + + + @@ -43,7 +47,7 @@ - + @@ -57,9 +61,8 @@ - - - + + @@ -173,7 +176,7 @@ - + @@ -204,133 +207,168 @@ + + + + + + + + + - - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - + - - + + @@ -357,7 +395,16 @@ - + + + + + + + + + + @@ -367,6 +414,9 @@ + + + diff --git a/components/rx/trunk/demos/RxDateEdit/unit1.lfm b/components/rx/trunk/demos/RxDateEdit/unit1.lfm index d8e5e8f35..da957ba8c 100644 --- a/components/rx/trunk/demos/RxDateEdit/unit1.lfm +++ b/components/rx/trunk/demos/RxDateEdit/unit1.lfm @@ -13,21 +13,21 @@ object Form1: TForm1 Height = 397 Top = 0 Width = 590 - ActivePage = TabSheet2 + ActivePage = TabSheet3 Align = alClient - TabIndex = 1 + TabIndex = 2 TabOrder = 0 object TabSheet1: TTabSheet Caption = 'RxDBDateEdit demo' - ClientHeight = 363 + ClientHeight = 366 ClientWidth = 580 object Label1: TLabel AnchorSideLeft.Control = Owner AnchorSideTop.Control = Owner Left = 6 - Height = 20 + Height = 17 Top = 6 - Width = 42 + Width = 38 Caption = 'Label1' ParentColor = False end @@ -36,14 +36,13 @@ object Form1: TForm1 AnchorSideTop.Control = Label1 AnchorSideTop.Side = asrBottom Left = 12 - Height = 37 + Height = 34 Top = 32 Width = 151 BorderSpacing.Around = 6 ButtonWidth = 23 Enabled = False MaxLength = 10 - NumGlyphs = 2 PasswordChar = #0 PopupColor = clWindow TabOrder = 0 @@ -56,9 +55,9 @@ object Form1: TForm1 AnchorSideTop.Control = RxDBDateEdit1 AnchorSideTop.Side = asrBottom Left = 6 - Height = 20 + Height = 17 Top = 75 - Width = 85 + Width = 77 BorderSpacing.Around = 6 Caption = 'Currency edit' ParentColor = False @@ -68,24 +67,20 @@ object Form1: TForm1 AnchorSideTop.Control = Label2 AnchorSideTop.Side = asrBottom Left = 12 - Height = 37 + Height = 34 Top = 101 Width = 148 Alignment = taCenter BorderSpacing.Around = 6 - MaxValue = 0 - MinValue = 0 TabOrder = 1 - Value = 0 end object RxDateEdit1: TRxDateEdit Left = 12 - Height = 37 + Height = 34 Top = 160 Width = 80 ButtonWidth = 23 MaxLength = 10 - NumGlyphs = 2 PasswordChar = #0 PopupColor = clWindow TabOrder = 2 @@ -93,9 +88,9 @@ object Form1: TForm1 end object Button1: TButton Left = 248 - Height = 36 + Height = 33 Top = 80 - Width = 77 + Width = 69 AutoSize = True Caption = 'Invalidate' OnClick = Button1Click @@ -104,15 +99,15 @@ object Form1: TForm1 end object TabSheet2: TTabSheet Caption = 'RxDateRangeEdit demo' - ClientHeight = 363 + ClientHeight = 366 ClientWidth = 580 object CheckBox1: TCheckBox AnchorSideLeft.Control = TabSheet2 AnchorSideTop.Control = TabSheet2 Left = 6 - Height = 24 + Height = 23 Top = 6 - Width = 88 + Width = 84 BorderSpacing.Around = 6 Caption = 'reoMonth' Checked = True @@ -126,8 +121,8 @@ object Form1: TForm1 AnchorSideTop.Control = CheckBox3 AnchorSideTop.Side = asrBottom Left = 159 - Height = 37 - Top = 96 + Height = 34 + Top = 93 Width = 262 BorderSpacing.Around = 6 Month = 5 @@ -140,9 +135,9 @@ object Form1: TForm1 AnchorSideTop.Control = CheckBox1 AnchorSideTop.Side = asrBottom Left = 6 - Height = 24 - Top = 36 - Width = 96 + Height = 23 + Top = 35 + Width = 91 BorderSpacing.Around = 6 Caption = 'reoQuarter' Checked = True @@ -155,9 +150,9 @@ object Form1: TForm1 AnchorSideTop.Control = CheckBox2 AnchorSideTop.Side = asrBottom Left = 6 - Height = 24 - Top = 66 - Width = 102 + Height = 23 + Top = 64 + Width = 95 BorderSpacing.Around = 6 Caption = 'reoHalfYear' Checked = True @@ -170,9 +165,9 @@ object Form1: TForm1 AnchorSideTop.Control = RxDateRangeEdit1 AnchorSideTop.Side = asrBottom Left = 6 - Height = 20 - Top = 139 - Width = 92 + Height = 17 + Top = 133 + Width = 87 BorderSpacing.Around = 6 Caption = 'Start of period' ParentColor = False @@ -183,8 +178,8 @@ object Form1: TForm1 AnchorSideTop.Side = asrBottom AnchorSideRight.Control = Label5 Left = 12 - Height = 37 - Top = 165 + Height = 34 + Top = 156 Width = 272 Anchors = [akTop, akLeft, akRight] BorderSpacing.Around = 6 @@ -197,9 +192,9 @@ object Form1: TForm1 AnchorSideTop.Control = RxDateRangeEdit1 AnchorSideTop.Side = asrBottom Left = 296 - Height = 20 - Top = 139 - Width = 85 + Height = 17 + Top = 133 + Width = 79 BorderSpacing.Around = 6 Caption = 'End of period' ParentColor = False @@ -211,8 +206,8 @@ object Form1: TForm1 AnchorSideRight.Control = TabSheet2 AnchorSideRight.Side = asrBottom Left = 302 - Height = 37 - Top = 165 + Height = 34 + Top = 156 Width = 272 Anchors = [akTop, akLeft, akRight] BorderSpacing.Around = 6 @@ -231,6 +226,53 @@ object Form1: TForm1 ParentColor = False end end + object TabSheet3: TTabSheet + Caption = 'RxTimeEdit demo' + ClientHeight = 366 + ClientWidth = 580 + object Label6: TLabel + AnchorSideLeft.Control = TabSheet3 + AnchorSideTop.Control = TabSheet3 + Left = 6 + Height = 17 + Top = 6 + Width = 65 + BorderSpacing.Around = 6 + Caption = 'RxTimeEdit' + ParentColor = False + end + object CheckBox4: TCheckBox + AnchorSideLeft.Control = RxTimeEdit1 + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = RxTimeEdit1 + Left = 154 + Height = 23 + Top = 35 + Width = 104 + BorderSpacing.Left = 32 + BorderSpacing.Around = 6 + Caption = 'Show second' + Checked = True + OnChange = CheckBox4Change + State = cbChecked + TabOrder = 0 + end + object RxTimeEdit1: TRxTimeEdit + AnchorSideLeft.Control = Label6 + AnchorSideTop.Control = Label6 + AnchorSideTop.Side = asrBottom + Left = 12 + Height = 34 + Top = 29 + Width = 104 + ShowSecond = True + BorderSpacing.Left = 6 + BorderSpacing.Top = 6 + CharCase = ecNormal + MaxLength = 8 + TabOrder = 1 + end + end end object dsData: TDataSource DataSet = rxData diff --git a/components/rx/trunk/demos/RxDateEdit/unit1.pas b/components/rx/trunk/demos/RxDateEdit/unit1.pas index 04e4933ed..7dfb79f6d 100644 --- a/components/rx/trunk/demos/RxDateEdit/unit1.pas +++ b/components/rx/trunk/demos/RxDateEdit/unit1.pas @@ -7,7 +7,7 @@ interface uses Classes, SysUtils, db, FileUtil, DividerBevel, LResources, Forms, Controls, Graphics, Dialogs, StdCtrls, ComCtrls, rxmemds, rxdbdateedit, rxcurredit, - rxtooledit, rxDateRangeEditUnit; + rxtooledit, rxDateRangeEditUnit, RxTimeEdit; type @@ -18,6 +18,7 @@ type CheckBox1: TCheckBox; CheckBox2: TCheckBox; CheckBox3: TCheckBox; + CheckBox4: TCheckBox; CurrencyEdit1: TCurrencyEdit; dsData: TDatasource; Edit1: TEdit; @@ -27,16 +28,20 @@ type Label3: TLabel; Label4: TLabel; Label5: TLabel; + Label6: TLabel; PageControl1: TPageControl; rxData: TRxMemoryData; rxDataDOC_DATE: TDateField; RxDateEdit1: TRxDateEdit; RxDateRangeEdit1: TRxDateRangeEdit; RxDBDateEdit1: TRxDBDateEdit; + RxTimeEdit1: TRxTimeEdit; TabSheet1: TTabSheet; TabSheet2: TTabSheet; + TabSheet3: TTabSheet; procedure Button1Click(Sender: TObject); procedure CheckBox1Change(Sender: TObject); + procedure CheckBox4Change(Sender: TObject); procedure FormCreate(Sender: TObject); procedure RxDateRangeEdit1Change(Sender: TObject); private @@ -89,5 +94,10 @@ begin RxDateRangeEdit1.Options:=R; end; +procedure TForm1.CheckBox4Change(Sender: TObject); +begin + RxTimeEdit1.ShowSecond:=CheckBox4.Checked; +end; + end. diff --git a/components/rx/trunk/rxcontrols/rxtimeedit.pas b/components/rx/trunk/rxcontrols/rxtimeedit.pas index e8f39c7c4..d8e942363 100644 --- a/components/rx/trunk/rxcontrols/rxtimeedit.pas +++ b/components/rx/trunk/rxcontrols/rxtimeedit.pas @@ -48,17 +48,21 @@ type FButton: TRxSpinButton; FButtonNeedsFocus: Boolean; FOnButtonClick : TNotifyEvent; + FShowSecond: boolean; + FDisplayFormat:string; procedure CheckButtonVisible; function GetButtonHint: TTranslateString; function GetTime: TTime; procedure SetButtonHint(const AValue: TTranslateString); procedure SetButtonNeedsFocus(const AValue: Boolean); + procedure SetShowSecond(AValue: boolean); procedure SetTime(const AValue: TTime); procedure DoChangeValue(AValue:integer); procedure WMSetFocus(var Message: TLMSetFocus); message LM_SETFOCUS; procedure WMKillFocus(var Message: TLMKillFocus); message LM_KILLFOCUS; procedure SetEnabled(Value: Boolean); override; protected + procedure UpdateEditFormat; procedure SetParent(AParent: TWinControl); override; procedure DoPositionButton; virtual; procedure UpClick(Sender: TObject); virtual; @@ -66,6 +70,7 @@ type property ButtonOnlyWhenFocused: Boolean read FButtonNeedsFocus write SetButtonNeedsFocus default False; property OnButtonClick : TNotifyEvent read FOnButtonClick write FOnButtonClick; property ButtonHint: TTranslateString read GetButtonHint write SetButtonHint; + property ShowSecond:boolean read FShowSecond write SetShowSecond; public constructor Create(AOwner: TComponent); override; destructor Destroy; override; @@ -74,7 +79,10 @@ type type TRxTimeEdit = class(TCustomRxTimeEdit) + public + property Text; published + property ShowSecond; property AutoSize; property AutoSelect; property Align; @@ -124,7 +132,6 @@ type property ShowHint; property TabOrder; property TabStop; - property Text; property Visible; end; @@ -167,9 +174,20 @@ begin end; end; -procedure TCustomRxTimeEdit.SetTime(const AValue: TTime); +procedure TCustomRxTimeEdit.SetShowSecond(AValue: boolean); begin - Text:=TimeToStr(AValue); + if FShowSecond=AValue then Exit; + FShowSecond:=AValue; + UpdateEditFormat; +end; + +procedure TCustomRxTimeEdit.SetTime(const AValue: TTime); +var + H, M, S, MS: word; +begin + DecodeTime(AValue, H, M, S, MS); + Text:=Format(FDisplayFormat, [H, M, S, MS]); + //Text:=TimeToStr(AValue); end; procedure TCustomRxTimeEdit.DoChangeValue(AValue: integer); @@ -222,13 +240,19 @@ begin H1:=StrToInt(S[1]+S[2]); M2:=StrToInt(S[4]+S[5]); - S3:=StrToInt(S[7]+S[8]); + if FShowSecond then + S3:=StrToInt(S[7]+S[8]); P:=GetSelStart; - if P < 3 then IncHour + if P < 3 then + IncHour else - if P < 6 then IncMin - else IncSec; - Text:=Format('%2.2d'+ DefaultFormatSettings.TimeSeparator +'%2.2d'+ DefaultFormatSettings.TimeSeparator +'%2.2d', [H1, M2, S3]); + if P < 6 then + IncMin + else + if FShowSecond then + IncSec; + //Text:=Format('%2.2d'+ DefaultFormatSettings.TimeSeparator +'%2.2d'+ DefaultFormatSettings.TimeSeparator +'%2.2d', [H1, M2, S3]); + SetTime(EncodeTime(H1, M2, S3, 0)); SetSelStart(P); end; @@ -251,6 +275,24 @@ begin FButton.Enabled:=Value; end; +procedure TCustomRxTimeEdit.UpdateEditFormat; +var + FOldTime: TTime; +begin + FOldTime:=GetTime; + if FShowSecond then + begin + EditMask:='!#0'+DefaultFormatSettings.TimeSeparator + '00'+DefaultFormatSettings.TimeSeparator + '00;1;_'; + FDisplayFormat:='%2.2d'+ DefaultFormatSettings.TimeSeparator +'%2.2d'+ DefaultFormatSettings.TimeSeparator +'%2.2d'; + end + else + begin + EditMask:='!#0'+DefaultFormatSettings.TimeSeparator + '00;1;_'; + FDisplayFormat:='%2.2d'+ DefaultFormatSettings.TimeSeparator +'%2.2d'; + end; + SetTime(FOldTime); +end; + procedure TCustomRxTimeEdit.SetParent(AParent: TWinControl); begin inherited SetParent(AParent); @@ -294,6 +336,7 @@ end; constructor TCustomRxTimeEdit.Create(AOwner: TComponent); begin inherited Create(AOwner); + FShowSecond:=true; FButton := TRxSpinButton.Create(Self); FButton.FocusControl := Self; FButton.Width := Self.Height; @@ -303,7 +346,7 @@ begin FButton.OnTopClick := @UpClick; FButton.OnBottomClick := @DownClick; - EditMask:='!#0'+DefaultFormatSettings.TimeSeparator + '00'+DefaultFormatSettings.TimeSeparator + '00;1;_'; + UpdateEditFormat; end; destructor TCustomRxTimeEdit.Destroy; @@ -313,4 +356,6 @@ begin inherited Destroy; end; +initialization + RegisterPropertyToSkip(TRxTimeEdit, 'Text', '', ''); end.