mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-08 08:38:19 +02:00
LCL: Implement TCustomCalendar.GetCalendarView. Patch by Zoran Vučenović.
git-svn-id: trunk@51694 -
This commit is contained in:
parent
82df661d71
commit
d0a37e168d
@ -55,6 +55,16 @@ type
|
||||
cpTitleYear // year value in the title
|
||||
);
|
||||
|
||||
{ In Windows since Vista native calendar control has four possible views.
|
||||
In other widgetsets, as well as in older windows, calendar can only have
|
||||
standard "month view" - grid with days representing a month. }
|
||||
TCalendarView = (
|
||||
cvMonth, // grid with days in one month
|
||||
cvYear, // grid with months in one year
|
||||
cvDecade, // grid with years from one decade
|
||||
cvCentury // grid with decades of one century
|
||||
);
|
||||
|
||||
EInvalidDate = class(Exception);
|
||||
|
||||
{ TCustomCalendar }
|
||||
@ -90,6 +100,7 @@ type
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
function HitTest(APoint: TPoint): TCalendarPart;
|
||||
function GetCalendarView: TCalendarView;
|
||||
property Date: String read GetDate write SetDate stored False;
|
||||
property DateTime: TDateTime read GetDateTime write SetDateTime;
|
||||
property DisplaySettings: TDisplaySettings read GetDisplaySettings
|
||||
@ -173,6 +184,14 @@ begin
|
||||
Result := cpNoWhere;
|
||||
end;
|
||||
|
||||
function TCustomCalendar.GetCalendarView: TCalendarView;
|
||||
begin
|
||||
if HandleAllocated then
|
||||
Result := TWSCustomCalendarClass(WidgetSetClass).GetCurrentView(Self)
|
||||
else
|
||||
Result := cvMonth;
|
||||
end;
|
||||
|
||||
procedure TCustomCalendar.Loaded;
|
||||
begin
|
||||
inherited Loaded;
|
||||
|
@ -46,6 +46,7 @@ type
|
||||
const AConstraints: TObject): Boolean; override;
|
||||
class function GetDateTime(const ACalendar: TCustomCalendar): TDateTime; override;
|
||||
class function HitTest(const ACalendar: TCustomCalendar; const APoint: TPoint): TCalendarPart; override;
|
||||
class function GetCurrentView(const ACalendar: TCustomCalendar): TCalendarView; override;
|
||||
class procedure SetDateTime(const ACalendar: TCustomCalendar; const ADateTime: TDateTime); override;
|
||||
class procedure SetDisplaySettings(const ACalendar: TCustomCalendar; const ASettings: TDisplaySettings); override;
|
||||
end;
|
||||
@ -159,6 +160,26 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
class function TWin32WSCustomCalendar.GetCurrentView(
|
||||
const ACalendar: TCustomCalendar): TCalendarView;
|
||||
var
|
||||
CurrentView: LRESULT;
|
||||
begin
|
||||
Result := inherited GetCurrentView(ACalendar);
|
||||
if WindowsVersion >= wvVista then begin
|
||||
if not WSCheckHandleAllocated(ACalendar, 'TWin32WSCustomCalendar.GetCurrentView') then
|
||||
Exit;
|
||||
|
||||
CurrentView := SendMessage(ACalendar.Handle, MCM_GETCURRENTVIEW, 0, 0);
|
||||
case CurrentView of
|
||||
MCMV_MONTH: Result := cvMonth;
|
||||
MCMV_YEAR: Result := cvYear;
|
||||
MCMV_DECADE: Result := cvDecade;
|
||||
MCMV_CENTURY: Result := cvCentury;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
class procedure TWin32WSCustomCalendar.SetDateTime(const ACalendar: TCustomCalendar; const ADateTime: TDateTime);
|
||||
var
|
||||
ST: SystemTime;
|
||||
|
@ -49,6 +49,7 @@ type
|
||||
published
|
||||
class function GetDateTime(const ACalendar: TCustomCalendar): TDateTime; virtual;
|
||||
class function HitTest(const ACalendar: TCustomCalendar; const APoint: TPoint): TCalendarPart; virtual;
|
||||
class function GetCurrentView(const ACalendar: TCustomCalendar): TCalendarView; virtual;
|
||||
class procedure SetDateTime(const ACalendar: TCustomCalendar; const ADateTime: TDateTime); virtual;
|
||||
class procedure SetDisplaySettings(const ACalendar: TCustomCalendar;
|
||||
const ADisplaySettings: TDisplaySettings); virtual;
|
||||
@ -74,6 +75,12 @@ begin
|
||||
Result := cpNoWhere;
|
||||
end;
|
||||
|
||||
class function TWSCustomCalendar.GetCurrentView(const ACalendar: TCustomCalendar
|
||||
): TCalendarView;
|
||||
begin
|
||||
Result := cvMonth;
|
||||
end;
|
||||
|
||||
class procedure TWSCustomCalendar.SetDateTime(const ACalendar: TCustomCalendar; const ADateTime: TDateTime);
|
||||
begin
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user