You've already forked lazarus-ccr
CalLite: Add keyboard support. Some refactoring.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5314 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@@ -5,22 +5,14 @@ unit main;
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
|
||||
LclType, Buttons, StdCtrls, DateUtils, CalendarLite;
|
||||
SysUtils, Forms, Controls, CalendarLite;
|
||||
|
||||
type
|
||||
|
||||
{ TForm1 }
|
||||
|
||||
TForm1 = class(TForm)
|
||||
edtYear: TEdit;
|
||||
edtMonth: TEdit;
|
||||
Label1: TLabel;
|
||||
procedure btnCloseClick(Sender: TObject);
|
||||
procedure edtYearKeyDown(Sender: TObject; var Key: Word; {%H-}Shift: TShiftState);
|
||||
procedure edtMonthKeyDown(Sender: TObject; var Key: Word; {%H-}Shift: TShiftState);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure FormResize(Sender: TObject);
|
||||
private
|
||||
{ private declarations }
|
||||
CalendarLite1: TCalendarLite;
|
||||
@@ -35,14 +27,8 @@ implementation
|
||||
|
||||
{$R *.lfm}
|
||||
|
||||
|
||||
{ TForm1 }
|
||||
|
||||
var
|
||||
AYear: Integer;
|
||||
AMonth: Integer;
|
||||
MonthsList: TStringList;
|
||||
|
||||
procedure TForm1.FormCreate(Sender: TObject);
|
||||
var
|
||||
I: Integer;
|
||||
@@ -50,65 +36,15 @@ begin
|
||||
CalendarLite1 := TCalendarLite.Create(self);
|
||||
with CalendarLite1 do begin
|
||||
Parent := self;
|
||||
Left := 20;
|
||||
// Height := 160;
|
||||
Top := 40;
|
||||
Left := 10;
|
||||
Top := 10;
|
||||
Width := self.Width - 2*Left;
|
||||
Height := label1.Top - Top - 20;
|
||||
ParentColor := false;
|
||||
Date := 41574;
|
||||
Height := self.Height - 2*Top;
|
||||
Date := Now();
|
||||
DisplayTexts := '"Today is",dd/mm/yyyy,"Holidays during","There are no holidays set for"';
|
||||
WeekendDays := [dowSaturday];
|
||||
Anchors := [akLeft, akTop, akRight, akBottom];
|
||||
end;
|
||||
|
||||
MonthsList:= TStringList.Create;
|
||||
for I:= 0 to 11 do begin
|
||||
MonthsList.Add(AnsiToUTF8(FormatSettings.ShortMonthNames[I+1]));
|
||||
end;
|
||||
|
||||
AYear:= YearOf(Now);
|
||||
AMonth:= MonthOf(Now)-1;
|
||||
edtYear.Caption := IntToStr(AYear);
|
||||
edtMonth.Caption := MonthsList[AMonth];
|
||||
end;
|
||||
|
||||
procedure TForm1.FormResize(Sender: TObject);
|
||||
begin
|
||||
edtMonth.Left := Width div 2 - edtMonth.Width - 2;
|
||||
edtYear.Left := Width div 2 + 2;
|
||||
end;
|
||||
|
||||
procedure TForm1.btnCloseClick(Sender: TObject);
|
||||
begin
|
||||
FreeAndNil(MonthsList);
|
||||
Close;
|
||||
end;
|
||||
|
||||
procedure TForm1.edtYearKeyDown(Sender: TObject; var Key: Word;
|
||||
Shift: TShiftState);
|
||||
begin
|
||||
case Key of
|
||||
VK_Up : Inc(AYear);
|
||||
VK_Down : Dec(AYear);
|
||||
end;
|
||||
edtYear.Caption := IntToStr(AYear);
|
||||
CalendarLite1.Date := RecodeYear(CalendarLite1.Date,AYear);
|
||||
end;
|
||||
|
||||
procedure TForm1.edtMonthKeyDown(Sender: TObject; var Key: Word;
|
||||
Shift: TShiftState);
|
||||
begin
|
||||
case Key of
|
||||
VK_Up : Inc(AMonth);
|
||||
VK_Down : Dec(AMonth);
|
||||
end;
|
||||
case AMonth of
|
||||
-1: AMonth := 11;
|
||||
12: AMonth := 0;
|
||||
end;
|
||||
edtMonth.Text:= MonthsList[AMonth];
|
||||
CalendarLite1.Date:= RecodeMonth(CalendarLite1.Date,AMonth+1);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
Reference in New Issue
Block a user