From d402565a9ae7d37c238ff6a5c0ec877b443560ee Mon Sep 17 00:00:00 2001 From: alexs75 Date: Fri, 23 Apr 2010 16:32:38 +0000 Subject: [PATCH] fix RxDateEdit git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1203 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/rx/rxlookup.pas | 3 ++- components/rx/rxtoolbar.pas | 3 ++- components/rx/tooledit.pas | 34 +++++++++++++++++++++++++++------- 3 files changed, 31 insertions(+), 9 deletions(-) diff --git a/components/rx/rxlookup.pas b/components/rx/rxlookup.pas index 24cb94170..f12b48270 100644 --- a/components/rx/rxlookup.pas +++ b/components/rx/rxlookup.pas @@ -1513,8 +1513,9 @@ var ArrowBmp:TBitmap; begin inherited Create(AOwner); - Height := 23; + //Height := 23; Width := 100; + AutoSize:=true; FUnfindedValue:=rxufNone; FFieldList := TStringList.Create; FValuesList:= TStringList.Create; diff --git a/components/rx/rxtoolbar.pas b/components/rx/rxtoolbar.pas index 3034e85fc..32b497d7c 100644 --- a/components/rx/rxtoolbar.pas +++ b/components/rx/rxtoolbar.pas @@ -235,7 +235,7 @@ type property ToolBarStyle:TToolBarStyle read FToolBarStyle write SetToolBarStyle default tbsStandart; property Options:TToolPanelOptions read FOptions write SetOptions; property Version: Integer read FVersion write FVersion default 0; - property ButtonAllign:TToolButtonAllign read FButtonAllign write SetButtonAllign; + property ButtonAllign:TToolButtonAllign read FButtonAllign write SetButtonAllign default tbaLeft; property Align; property Alignment; @@ -1156,6 +1156,7 @@ begin inherited Create(AOwner); FArrowBmp:=CreateArrowBitmap; AutoSize:=false; + FButtonAllign:=tbaLeft; FToolbarItems:=TToolbarItems.Create(Self); if Assigned(AOwner) and not (csLoading in AOwner.ComponentState) then Align:=alTop; diff --git a/components/rx/tooledit.pas b/components/rx/tooledit.pas index 9971ed070..ef0d70a77 100644 --- a/components/rx/tooledit.pas +++ b/components/rx/tooledit.pas @@ -76,7 +76,8 @@ type FFormatting: Boolean; FPopupVisible: Boolean; FPopupAlign: TPopupAlign; - function GetCalendarStyle: TCalendarStyle; + FCalendarStyle: TCalendarStyle; + //function GetCalendarStyle: TCalendarStyle; function GetDate: TDateTime; function GetPopupColor: TColor; function GetPopupVisible: Boolean; @@ -110,6 +111,7 @@ type procedure KeyPress(var Key: Char); override; procedure DoButtonClick (Sender: TObject); override; function GetDefaultGlyphName: String; override; + function CreatePopupForm:TPopupCalendar; property BlanksChar: Char read FBlanksChar write SetBlanksChar default ' '; property DialogTitle:TCaption Read FDialogTitle Write FDialogTitle Stored IsStoreTitle; @@ -124,7 +126,7 @@ type property YearDigits: TYearDigits read FYearDigits write SetYearDigits default dyDefault; property PopupColor: TColor read GetPopupColor write SetPopupColor default clBtnFace; - property CalendarStyle: TCalendarStyle read GetCalendarStyle + property CalendarStyle: TCalendarStyle read FCalendarStyle//GetCalendarStyle write SetCalendarStyle default dcsDefault; property PopupVisible: Boolean read GetPopupVisible; property PopupAlign: TPopupAlign read FPopupAlign write FPopupAlign default epaLeft; @@ -368,6 +370,7 @@ begin UpdateMask; end; +{ function TCustomRxDateEdit.GetCalendarStyle: TCalendarStyle; begin if FPopup <> nil then @@ -375,7 +378,7 @@ begin else Result := csDialog; end; - +} function TCustomRxDateEdit.GetDate: TDateTime; begin if DefaultToday then Result := SysUtils.Date @@ -407,9 +410,10 @@ end; procedure TCustomRxDateEdit.SetCalendarStyle(const AValue: TCalendarStyle); begin - if AValue <> CalendarStyle then + if AValue <> FCalendarStyle then begin - case AValue of + FCalendarStyle:=AValue; +{ case AValue of csPopup: begin if FPopup = nil then @@ -425,7 +429,7 @@ begin FPopup.Free; FPopup := nil; end; - end; + end;} end; end; @@ -567,6 +571,8 @@ begin end; begin + if not Assigned(FPopup) then + FPopup:=CreatePopupForm; if (FPopup <> nil) and not (ReadOnly {or FPopupVisible}) then begin P := Parent.ClientToScreen(Point(Left, Top)); @@ -645,6 +651,8 @@ procedure TCustomRxDateEdit.ShowPopup(AOrigin: TPoint); var FAccept:boolean; begin + if not Assigned(FPopup) then + FPopup:=CreatePopupForm; FPopup.Left:=AOrigin.X; FPopup.Top:=AOrigin.Y; FPopup.AutoSizeForm; @@ -734,7 +742,8 @@ var A: Boolean; begin inherited DoButtonClick(Sender); - if FPopup <> nil then + if CalendarStyle <> csDialog then +// if FPopup <> nil then begin { if FPopupVisible then PopupCloseUp(FPopup, True) @@ -766,6 +775,14 @@ begin Result:='picDateEdit'; end; +function TCustomRxDateEdit.CreatePopupForm: TPopupCalendar; +begin + Result := CreatePopupCalendar(Self {$IFDEF USED_BiDi}, BiDiMode {$ENDIF}); + Result.OnCloseUp := @PopupCloseUp; + Result.Color := FPopupColor; + TRxCalendarGrid(Result.Calendar).NotInThisMonthColor:=FNotInThisMonthColor; +end; + constructor TCustomRxDateEdit.Create(AOwner: TComponent); begin inherited Create(AOwner); @@ -783,6 +800,7 @@ begin ControlState := ControlState + [csCreating]; try UpdateFormat; +(* {$IFDEF DEFAULT_POPUP_CALENDAR} FPopup := CreatePopupCalendar(Self {$IFDEF USED_BiDi}, BiDiMode {$ENDIF}); FPopup.OnCloseUp := @PopupCloseUp; @@ -791,6 +809,8 @@ begin {$ELSE} FPopup:=nil; {$ENDIF DEFAULT_POPUP_CALENDAR} +*) + FPopup:=nil; // GlyphKind := gkDefault; { force update } finally ControlState := ControlState - [csCreating];