You've already forked lazarus-ccr
tvplanit: Replace TVpWeekView's updown control by 4 speedbuttons for navigation to prev/next month/week, issue #39035.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8388 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -1299,30 +1299,22 @@ end;
|
||||
|
||||
procedure TVpMonthView.PopupNextMonth(Sender: TObject);
|
||||
begin
|
||||
SpinButtonClick(FNextMonthBtn);
|
||||
Date := IncMonth(Date, +1);
|
||||
end;
|
||||
|
||||
procedure TVpMonthView.PopupPrevMonth(Sender: TObject);
|
||||
begin
|
||||
SpinButtonClick(FPrevMonthBtn);
|
||||
Date := IncMonth(Date, -1);
|
||||
end;
|
||||
|
||||
procedure TVpMonthView.PopupNextYear(Sender: TObject);
|
||||
//var
|
||||
// M, D, Y: Word;
|
||||
begin
|
||||
SpinButtonClick(FNextYearBtn);
|
||||
// DecodeDate(Date, Y, M, D);
|
||||
// Date := EncodeDate(Y + 1, M, 1);
|
||||
Date := IncYear(Date, +1);
|
||||
end;
|
||||
|
||||
procedure TVpMonthView.PopupPrevYear(Sender: TObject);
|
||||
//var
|
||||
// M, D, Y: Word;
|
||||
begin
|
||||
SpinButtonClick(FPrevYearBtn);
|
||||
// DecodeDate(Date, Y, M, D);
|
||||
// Date := EncodeDate(Y - 1, M, 1);
|
||||
Date := IncYear(Date, -1);
|
||||
end;
|
||||
|
||||
procedure TVpMonthView.PopupCustomDate(Sender: TObject);
|
||||
|
@ -59,7 +59,7 @@ uses
|
||||
{$ELSE}
|
||||
Windows, Messages,
|
||||
{$ENDIF}
|
||||
Classes, Graphics, Controls, ComCtrls, ExtCtrls, StdCtrls, Forms, Menus,
|
||||
Classes, Graphics, Controls, ComCtrls, ExtCtrls, StdCtrls, Buttons, Forms, Menus,
|
||||
VpConst, VpBase, VpBaseDS, VpMisc, VpData, VpSR, VpCanvasUtils, VpDayView;
|
||||
|
||||
type
|
||||
@ -158,6 +158,11 @@ type
|
||||
FAllowDragAndDrop: Boolean;
|
||||
FApplyCategoryInfos: Boolean;
|
||||
FDragDropTransparent: Boolean;
|
||||
FPrevWeekBtn: TSpeedButton;
|
||||
FPrevMonthBtn: TSpeedButton;
|
||||
FNextMonthBtn: TSpeedButton;
|
||||
FNextWeekBtn: TSpeedButton;
|
||||
|
||||
{ event variables }
|
||||
FBeforeEdit: TVpBeforeEditEvent;
|
||||
FAfterEdit: TVpAfterEditEvent;
|
||||
@ -173,7 +178,6 @@ type
|
||||
// wvDayHeadHeight: Integer;
|
||||
wvHeaderHeight: Integer;
|
||||
wvStartDate: TDateTime;
|
||||
wvSpinButtons: TUpDown;
|
||||
wvEventList: TList;
|
||||
wvEventArray: TVpEventArray;
|
||||
wvWeekdayArray: TVpWeekdayArray;
|
||||
@ -215,10 +219,10 @@ type
|
||||
procedure InitializeDefaultPopup;
|
||||
|
||||
{ internal methods }
|
||||
procedure SpinButtonClick(Sender: TObject);
|
||||
procedure wvEditInPlace(Sender: TObject);
|
||||
procedure wvHookUp;
|
||||
procedure wvPopulate;
|
||||
procedure wvSpinButtonClick(Sender: TObject; Button: TUDBtnType);
|
||||
|
||||
{ event related methods }
|
||||
procedure EditEvent;
|
||||
@ -474,17 +478,38 @@ begin
|
||||
FHeadAttr := TVpWvHeadAttributes.Create(self);
|
||||
FAllDayEventAttr := TVpAllDayEventAttributes.Create(self);
|
||||
|
||||
FPrevMonthBtn := TSpeedButton.Create(self);
|
||||
FPrevMonthBtn.Hint := RSPrevMonth;
|
||||
FPrevMonthBtn.OnClick := SpinButtonClick;
|
||||
FPrevWeekBtn := TSpeedButton.Create(self);
|
||||
FPrevWeekBtn.Hint := RSPrevWeek;
|
||||
FPrevWeekBtn.OnClick := SpinButtonClick;
|
||||
FNextWeekBtn := TSpeedButton.Create(self);
|
||||
FNextWeekBtn.Hint := RSNextWeek;
|
||||
FNextWeekBtn.OnClick := SpinButtonClick;
|
||||
FNextMonthBtn := TSpeedButton.Create(self);
|
||||
FNextMonthBtn.Hint := RSNextMonth;
|
||||
FNextMonthBtn.OnClick := SpinButtonClick;
|
||||
|
||||
// Speedbutton glyphs
|
||||
{$IFDEF NEW_ICONS}
|
||||
LoadGlyphFromRCDATA(FPrevMonthBtn.Glyph, 'VpLArrows', 16, 24, 32);
|
||||
LoadGlyphFromRCDATA(FPrevWeekBtn.Glyph, 'VpLArrow', 16, 24, 32);
|
||||
LoadGlyphFromRCDATA(FNextWeekBtn.Glyph, 'VpRArrow', 16, 24, 32);
|
||||
LoadGlyphFromRCDATA(FNextMonthBtn.Glyph, 'VpRArrows', 16, 24, 32);
|
||||
{$ELSE}
|
||||
FPrevMonthBtn.Glyph.LoadFromResourceName(HINSTANCE, 'VPLEFTARROWS');
|
||||
FPrevWeekBtn.Glyph.LoadFromResourceName(HINSTANCE, 'VPLEFTARROW');
|
||||
FNextWeekBtn.Glyph.LoadFromResourceName(HINSTANCE, 'VPRIGHTARROW');
|
||||
FNextMonthUpBtn.Glyph.LoadFromResourceName(HINSTANCE, 'VPRIGHTARROWS');
|
||||
{$ENDIF}
|
||||
|
||||
FEventFont := TVpFont.Create(self);
|
||||
FEventFont.Assign(Font);
|
||||
FShowEventTime := true;
|
||||
wvInLinkHandler := false;
|
||||
wvEventList := TList.Create;
|
||||
wvClickTimer := TTimer.Create(self);
|
||||
wvSpinButtons := TUpDown.Create(self);
|
||||
wvSpinButtons.OnClick := wvSpinButtonClick;
|
||||
wvSpinButtons.Orientation := udHorizontal;
|
||||
wvSpinButtons.Min := -32768;
|
||||
wvSpinButtons.Max := 32767;
|
||||
wvHotPoint := Point(0, 0);
|
||||
wvDragging := false;
|
||||
wvMouseDownPoint := Point(0, 0);
|
||||
@ -547,7 +572,6 @@ begin
|
||||
FHeadAttr.Free;
|
||||
wvClickTimer.Free;
|
||||
FEventFont.Free;
|
||||
wvSpinButtons.Free;
|
||||
wvEventList.Free;
|
||||
FDefaultPopup.Free;
|
||||
inherited;
|
||||
@ -787,16 +811,18 @@ begin
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
{=====}
|
||||
|
||||
procedure TVpWeekView.wvSpinButtonClick(Sender: TObject; Button: TUDBtnType);
|
||||
procedure TVpWeekView.SpinButtonClick(Sender: TObject);
|
||||
begin
|
||||
if Button = btNext then
|
||||
Date := Date + 7
|
||||
else
|
||||
Date := Date - 7;
|
||||
if Sender = FPrevWeekBtn then
|
||||
Date := IncWeek(Date, -1)
|
||||
else if Sender = FNextWeekBtn then
|
||||
Date := IncWeek(Date, +1)
|
||||
else if Sender = FPrevMonthBtn then
|
||||
Date := IncMonth(Date, -1)
|
||||
else if Sender = FNextMonthBtn then
|
||||
Date := IncMonth(Date, +1);
|
||||
end;
|
||||
{=====}
|
||||
|
||||
procedure TVpWeekView.SetColor(Value: TColor);
|
||||
begin
|
||||
@ -805,7 +831,6 @@ begin
|
||||
Invalidate;
|
||||
end;
|
||||
end;
|
||||
{=====}
|
||||
|
||||
procedure TVpWeekView.SetActiveEvent(AValue: TVpEvent);
|
||||
begin
|
||||
@ -829,7 +854,6 @@ begin
|
||||
Invalidate;
|
||||
end;
|
||||
end;
|
||||
{=====}
|
||||
|
||||
procedure TVpWeekView.SetLineColor(Value: TColor);
|
||||
begin
|
||||
@ -857,7 +881,6 @@ begin
|
||||
FEventFont.Assign(Value);
|
||||
Invalidate;
|
||||
end;
|
||||
{=====}
|
||||
|
||||
procedure TVpWeekView.SetLayout(AValue: TVpWeekviewLayout);
|
||||
begin
|
||||
@ -874,7 +897,6 @@ begin
|
||||
Invalidate;
|
||||
end;
|
||||
end;
|
||||
{=====}
|
||||
|
||||
procedure TVpWeekView.SetTimeFormat(Value: TVpTimeFormat);
|
||||
begin
|
||||
@ -883,7 +905,6 @@ begin
|
||||
Invalidate;
|
||||
end;
|
||||
end;
|
||||
{=====}
|
||||
|
||||
procedure TVpWeekView.SetActiveDate(Value: TDateTime);
|
||||
begin
|
||||
@ -905,7 +926,6 @@ begin
|
||||
ControlLink.Notify(self, neDateChange, FActiveDate);
|
||||
end;
|
||||
end;
|
||||
{=====}
|
||||
|
||||
procedure TVpWeekView.SetWeekStartsOn(Value: TVpDayType);
|
||||
begin
|
||||
@ -914,7 +934,6 @@ begin
|
||||
Invalidate;
|
||||
end;
|
||||
end;
|
||||
{=====}
|
||||
|
||||
{$IFNDEF LCL}
|
||||
procedure TVpWeekView.WMSize(var Msg: TWMSize);
|
||||
@ -926,7 +945,6 @@ begin
|
||||
{ force a repaint on resize }
|
||||
Invalidate;
|
||||
end;
|
||||
{=====}
|
||||
|
||||
procedure TVpWeekView.CreateParams(var Params: TCreateParams);
|
||||
begin
|
||||
@ -939,14 +957,15 @@ begin
|
||||
{$ENDIF}
|
||||
end;
|
||||
end;
|
||||
{=====}
|
||||
|
||||
procedure TVpWeekView.CreateWnd;
|
||||
begin
|
||||
inherited;
|
||||
wvSpinButtons.Parent := self;
|
||||
FPrevMonthBtn.Parent := Self;
|
||||
FPrevWeekBtn.Parent := Self;
|
||||
FNextWeekBtn.Parent := Self;
|
||||
FNextMonthBtn.Parent := Self;
|
||||
end;
|
||||
{=====}
|
||||
|
||||
procedure TVpWeekView.DoEndDrag(Target: TObject; X, Y: Integer);
|
||||
begin
|
||||
@ -1369,69 +1388,35 @@ procedure TVpWeekView.PopupToday(Sender: TObject);
|
||||
begin
|
||||
Date := Now;
|
||||
end;
|
||||
{=====}
|
||||
|
||||
procedure TVpWeekView.PopupNextWeek(Sender: TObject);
|
||||
begin
|
||||
Date := Date + 7;
|
||||
end;
|
||||
{=====}
|
||||
|
||||
procedure TVpWeekView.PopupPrevWeek(Sender: TObject);
|
||||
begin
|
||||
Date := Date - 7;
|
||||
end;
|
||||
{=====}
|
||||
|
||||
procedure TVpWeekView.PopupNextMonth(Sender: TObject);
|
||||
var
|
||||
M, D, Y: Word;
|
||||
begin
|
||||
DecodeDate(Date, Y, M, D);
|
||||
if M = 12 then begin
|
||||
M := 1;
|
||||
Y := Y + 1;
|
||||
end else
|
||||
M := M + 1;
|
||||
if (D > DaysInAMonth(Y, M)) then
|
||||
D := DaysInAMonth(Y, M);
|
||||
|
||||
Date := EncodeDate(Y, M, D);
|
||||
Date := IncMonth(Date, 1);
|
||||
end;
|
||||
{=====}
|
||||
|
||||
procedure TVpWeekView.PopupPrevMonth(Sender : TObject);
|
||||
var
|
||||
M, D, Y: Word;
|
||||
begin
|
||||
DecodeDate(Date, Y, M, D);
|
||||
if M = 1 then begin
|
||||
M := 12;
|
||||
Y := Y - 1;
|
||||
end else
|
||||
M := M - 1;
|
||||
if (D > DaysInAMonth(Y, M)) then
|
||||
D := DaysInAMonth(Y, M);
|
||||
|
||||
Date := EncodeDate(Y, M, D);
|
||||
Date := IncMonth(Date, -1);
|
||||
end;
|
||||
{=====}
|
||||
|
||||
procedure TVpWeekView.PopupNextYear(Sender: TObject);
|
||||
var
|
||||
M, D, Y: Word;
|
||||
begin
|
||||
DecodeDate(Date, Y, M, D);
|
||||
Date := EncodeDate(Y + 1, M, 1);
|
||||
Date := IncYear(Date, +1);
|
||||
end;
|
||||
{=====}
|
||||
|
||||
procedure TVpWeekView.PopupPrevYear(Sender: TObject);
|
||||
var
|
||||
M, D, Y : Word;
|
||||
begin
|
||||
DecodeDate(Date, Y, M, D);
|
||||
Date := EncodeDate(Y - 1, M, 1);
|
||||
Date := IncYear(Date, -1);
|
||||
end;
|
||||
|
||||
procedure TVpWeekView.PopupCustomDate(Sender: TObject);
|
||||
|
@ -600,6 +600,7 @@ var
|
||||
HeadStrLen: Integer;
|
||||
weekNo: Integer;
|
||||
startStr, endStr: String;
|
||||
txtStart: Integer;
|
||||
begin
|
||||
RenderCanvas.Brush.Color := RealHeadAttrColor;
|
||||
RenderCanvas.Font.Assign(TFont(FWeekView.HeadAttributes.Font));
|
||||
@ -657,16 +658,34 @@ begin
|
||||
HeadTextRect.Right - HeadTextRect.Left - TextMargin );
|
||||
end;
|
||||
|
||||
{ position the spinner }
|
||||
{ Position the spinner }
|
||||
with TVpWeekViewOpener(FWeekView) do begin
|
||||
wvSpinButtons.Height := Trunc(wvHeaderHeight * 0.8);
|
||||
wvSpinButtons.Width := wvSpinButtons.Height * 2;
|
||||
wvSpinButtons.Left := TextMargin;
|
||||
wvSpinButtons.Top := (wvHeaderHeight - wvSpinButtons.Height) div 2 + 2;
|
||||
FPrevMonthBtn.Height := Trunc(wvHeaderHeight * 0.8);;
|
||||
FPrevMonthBtn.Width := FPrevMonthBtn.Height;
|
||||
FPrevMonthBtn.Left := TextMargin;
|
||||
FPrevMonthBtn.Top := (wvHeaderHeight - FPrevMonthBtn.Height) div 2 + 2;
|
||||
|
||||
FPrevWeekBtn.Height := FPrevMonthBtn.Height;
|
||||
FPrevWeekBtn.Width := FPrevMonthBtn.Height;
|
||||
FPrevWeekBtn.Left := FPrevMonthBtn.Left + FPrevMonthBtn.Width;
|
||||
FPrevWeekBtn.Top := FPrevMonthBtn.Top;
|
||||
|
||||
FNextWeekBtn.Height := FPrevMonthBtn.Height;
|
||||
FNextWeekBtn.Width := FPrevMonthBtn.Height;
|
||||
FNextWeekBtn.Left := FPrevWeekBtn.Left + FPrevWeekBtn.Width;
|
||||
FNextWeekBtn.Top := FPrevMonthBtn.Top;
|
||||
|
||||
FNextMonthBtn.Height := FPrevMonthBtn.Height;
|
||||
FNextMonthBtn.Width := FPrevMonthBtn.Height;
|
||||
FNextMonthBtn.Left := FNextWeekBtn.Left + FNextWeekBtn.Width;
|
||||
FNextMonthBtn.Top := FPrevMonthBtn.Top;
|
||||
|
||||
txtStart := FNextMonthBtn.Left + FNextMonthBtn.Width + TextMargin;
|
||||
end;
|
||||
|
||||
TPSTextOut(RenderCanvas, Angle, RenderIn,
|
||||
HeadTextRect.Left + TextMargin,
|
||||
(HeadTextRect.Top + HeadTextRect.Bottom - RenderCanvas.TextHeight('Tg')) div 2, //HeadTextRect.Top + TextMargin,
|
||||
txtStart,
|
||||
(HeadTextRect.Top + HeadTextRect.Bottom - RenderCanvas.TextHeight('Tg')) div 2,
|
||||
HeadStr
|
||||
);
|
||||
end;
|
||||
|
Reference in New Issue
Block a user