From: <ob...@us...> - 2012-02-23 09:58:52
|
Revision: 13204 http://jvcl.svn.sourceforge.net/jvcl/?rev=13204&view=rev Author: obones Date: 2012-02-23 09:58:45 +0000 (Thu, 23 Feb 2012) Log Message: ----------- Mantis 5581 : Added ShowNullDate to force showing the date even if it's zero. For TJvDBDateEdit, if the field is null, the date is never displayed so that one can distinguish between null and zero when setting ShowNullDate to True Modified Paths: -------------- trunk/jvcl/run/JvDBControls.pas trunk/jvcl/run/JvToolEdit.pas Modified: trunk/jvcl/run/JvDBControls.pas =================================================================== --- trunk/jvcl/run/JvDBControls.pas 2012-02-23 09:40:47 UTC (rev 13203) +++ trunk/jvcl/run/JvDBControls.pas 2012-02-23 09:58:45 UTC (rev 13204) @@ -338,6 +338,7 @@ procedure KeyPress(var Key: Char); override; procedure Notification(AComponent: TComponent; Operation: TOperation); override; procedure Reset; override; + function DisplayNullDateAsEmptyText: Boolean; override; // Polaris procedure SetDate(Value: TDateTime); override; function IsValidDate(Value: TDateTime): Boolean; @@ -414,6 +415,7 @@ property PopupMenu; property ShowHint; property CalendarStyle; + property ShowNullDate; property StartOfWeek; property Weekends; property WeekendColor; @@ -1395,6 +1397,15 @@ FCanvas.Free; end; +function TJvDBDateEdit.DisplayNullDateAsEmptyText: Boolean; +begin + Result := inherited DisplayNullDateAsEmptyText; + + if FDataLink.Field <> nil then + if FDataLink.Field.IsNull then + Result := True; +end; + procedure TJvDBDateEdit.AfterPopup(Sender: TObject; var Date: TDateTime; var Action: Boolean); begin Modified: trunk/jvcl/run/JvToolEdit.pas =================================================================== --- trunk/jvcl/run/JvToolEdit.pas 2012-02-23 09:40:47 UTC (rev 13203) +++ trunk/jvcl/run/JvToolEdit.pas 2012-02-23 09:58:45 UTC (rev 13204) @@ -878,6 +878,7 @@ FDateFormat: string; FDateFormat2: string; FFormatting: Boolean; + FShowNullDate: Boolean; procedure SetMinDate(Value: TDateTime); procedure SetMaxDate(Value: TDateTime); function GetDate: TDateTime; @@ -906,6 +907,7 @@ function StoreMaxDate: Boolean; function FourDigitYear: Boolean; procedure WMContextMenu(var Msg: TWMContextMenu); message WM_CONTEXTMENU; + procedure SetShowNullDate(const Value: Boolean); protected FDateAutoBetween: Boolean; procedure SetDate(Value: TDateTime); virtual; @@ -929,6 +931,7 @@ function GetDefaultDateFormat: string; virtual; function GetDefaultDateFormatPreferred: TPreferredDateFormat; virtual; function CreateDataConnector: TJvCustomComboEditDataConnector; override; + function DisplayNullDateAsEmptyText: Boolean; virtual; property BlanksChar: Char read FBlanksChar write SetBlanksChar default ' '; property CalendarHints: TStrings read GetCalendarHints write SetCalendarHints; @@ -953,6 +956,7 @@ property MaxLength stored False; { Text is already stored via Date property } property Text stored False; + property ShowNullDate: Boolean read FShowNullDate write SetShowNullDate; public constructor Create(AOwner: TComponent); override; destructor Destroy; override; @@ -1039,6 +1043,7 @@ property ShowHint; property ShowButton; property CalendarStyle; + property ShowNullDate; property StartOfWeek; property Weekends; property WeekendColor; @@ -3356,6 +3361,11 @@ inherited Destroy; end; +function TJvCustomDateEdit.DisplayNullDateAsEmptyText: Boolean; +begin + Result := not ShowNullDate; +end; + function TJvCustomDateEdit.CreateDataConnector: TJvCustomComboEditDataConnector; begin Result := TJvCustomDateEditDataConnector.Create(Self); @@ -3699,7 +3709,7 @@ D := Self.Date; SavedModified := Modified; TestDateBetween(Value); - if Value = NullDate then + if (Value = NullDate) and DisplayNullDateAsEmptyText then Text := '' else Text := FormatDateTime(FDateFormat, Value); @@ -3780,6 +3790,15 @@ inherited SetPopupValue(StrToDateFmtDef(FDateFormat, VarToStr(Value), SysUtils.Date)); end; +procedure TJvCustomDateEdit.SetShowNullDate(const Value: Boolean); +begin + if FShowNullDate <> Value then + begin + FShowNullDate := Value; + SetDate(Date); + end; +end; + procedure TJvCustomDateEdit.SetStartOfWeek(Value: TDayOfWeekName); begin if Value <> FStartOfWeek then This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |