You've already forked lazarus-ccr
tvplanit: Some elemental code for VpGanttView (cooperation with control link and datastore).
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8415 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -32,7 +32,7 @@ Portions created by TurboPower Software Inc. are Copyright (C) 2002 TurboPower S
|
||||
|
||||
Contributor(s): "/>
|
||||
<Version Major="1" Minor="7"/>
|
||||
<Files Count="68">
|
||||
<Files Count="69">
|
||||
<Item1>
|
||||
<Filename Value="source\vpbase.pas"/>
|
||||
<UnitName Value="VpBase"/>
|
||||
@ -299,12 +299,16 @@ Contributor(s): "/>
|
||||
</Item66>
|
||||
<Item67>
|
||||
<Filename Value="source\vpganttview.pas"/>
|
||||
<UnitName Value="vpganttview"/>
|
||||
<UnitName Value="VpGanttView"/>
|
||||
</Item67>
|
||||
<Item68>
|
||||
<Filename Value="source\vpganttview.pas"/>
|
||||
<UnitName Value="vpganttview"/>
|
||||
<UnitName Value="VpGanttView"/>
|
||||
</Item68>
|
||||
<Item69>
|
||||
<Filename Value="source\vpganttviewpainter.pas"/>
|
||||
<UnitName Value="vpganttviewpainter"/>
|
||||
</Item69>
|
||||
</Files>
|
||||
<CompatibilityMode Value="True"/>
|
||||
<i18n>
|
||||
|
@ -176,6 +176,7 @@ uses
|
||||
VpMonthView, { Month View Component }
|
||||
VpContactGrid, { ContactGrid Component }
|
||||
VpTaskList, { Task List Component }
|
||||
VpGanttView, { Gantt View Component }
|
||||
{$IFDEF DELPHI}
|
||||
VpBDEDS, { DataStore Component }
|
||||
VpDateEdit, { DateEdit Component }
|
||||
@ -676,6 +677,7 @@ begin
|
||||
TVpTaskList,
|
||||
TVpContactGrid,
|
||||
TVpContactButtonBar,
|
||||
TVpGanttView,
|
||||
TVpResourceCombo,
|
||||
TVpPrintFormatComboBox,
|
||||
TVpResourceEditDialog,
|
||||
|
@ -1938,7 +1938,7 @@ end;
|
||||
procedure TVpDayView.CreateWnd;
|
||||
begin
|
||||
inherited;
|
||||
PostMessage (Handle, Vp_DayViewInit, 0, 0);
|
||||
PostMessage(Handle, Vp_DayViewInit, 0, 0);
|
||||
end;
|
||||
|
||||
procedure TVpDayView.MouseEnter;
|
||||
|
@ -5,16 +5,38 @@ unit VpGanttView;
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils,
|
||||
VpBaseDS, VpData;
|
||||
Classes, SysUtils, Graphics,
|
||||
VpBase, VpBaseDS, VpData;
|
||||
|
||||
type
|
||||
TVpGanttView = class(TVpLinkableControl)
|
||||
private
|
||||
FDate: TDateTime;
|
||||
FInLinkHandler: Boolean;
|
||||
FLoaded: Boolean;
|
||||
FPainting: Boolean;
|
||||
FStartDate: TDateTime;
|
||||
procedure SetDate(AValue: TDateTime);
|
||||
|
||||
protected
|
||||
{ internal methods }
|
||||
procedure Hookup;
|
||||
procedure Populate;
|
||||
|
||||
{ inherited methods }
|
||||
procedure Loaded; override;
|
||||
procedure Paint; override;
|
||||
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
procedure LinkHandler(Sender: TComponent;
|
||||
NotificationType: TVpNotificationType; const Value: Variant); override;
|
||||
procedure RenderToCanvas(RenderCanvas: TCanvas; RenderIn: TRect;
|
||||
Angle: TVpRotationAngle; Scale: Extended; RenderDate: TDateTime;
|
||||
StartLine, StopLine: Integer; UseGran: TVpGranularity;
|
||||
DisplayOnly: Boolean); override;
|
||||
|
||||
property Date: TDateTime read FDate write SetDate;
|
||||
|
||||
published
|
||||
|
||||
@ -22,5 +44,117 @@ type
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
VpGanttViewPainter;
|
||||
|
||||
constructor TVpGanttView.Create(AOwner: TComponent);
|
||||
begin
|
||||
inherited;
|
||||
|
||||
FInLinkHandler := false;
|
||||
FLoaded := false;
|
||||
FPainting := false;
|
||||
|
||||
SetDate(Now);
|
||||
FStartDate := FDate;
|
||||
end;
|
||||
|
||||
{ If the component is being dropped on a form at designtime, then
|
||||
automatically hook up to the first datastore component found. }
|
||||
procedure TVpGanttView.HookUp;
|
||||
var
|
||||
I: Integer;
|
||||
begin
|
||||
if csDesigning in ComponentState then
|
||||
for I := 0 to pred(Owner.ComponentCount) do begin
|
||||
if (Owner.Components[I] is TVpCustomDataStore) then begin
|
||||
DataStore := TVpCustomDataStore(Owner.Components[I]);
|
||||
Exit;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TVpGanttView.LinkHandler(Sender: TComponent;
|
||||
NotificationType: TVpNotificationType; const Value: Variant);
|
||||
begin
|
||||
FInLinkHandler := true;
|
||||
try
|
||||
case NotificationType of
|
||||
neDateChange : Date := Value;
|
||||
neDataStoreChange : Invalidate;
|
||||
neInvalidate : Invalidate;
|
||||
end;
|
||||
finally
|
||||
FInLinkHandler := false;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TVpGanttView.Loaded;
|
||||
begin
|
||||
inherited;
|
||||
FLoaded := true;
|
||||
Populate;
|
||||
end;
|
||||
|
||||
procedure TVpGanttView.Populate;
|
||||
begin
|
||||
if DataStore <> nil then
|
||||
DataStore.Date := FDate;
|
||||
end;
|
||||
|
||||
procedure TVpGanttView.Paint;
|
||||
begin
|
||||
RenderToCanvas(
|
||||
Canvas, // Paint Canvas
|
||||
Rect(0, 0, Width, Height), // Paint Rectangle
|
||||
ra0, // Rotation angle: none
|
||||
1, // Scale
|
||||
FStartDate, // Date
|
||||
-1, // Start At
|
||||
-1, // End At
|
||||
gr30Min, // Granularity
|
||||
False // Display Only
|
||||
);
|
||||
end;
|
||||
|
||||
procedure TVpGanttView.RenderToCanvas(RenderCanvas: TCanvas; RenderIn: TRect;
|
||||
Angle: TVpRotationAngle; Scale: Extended; RenderDate: TDateTime;
|
||||
StartLine, StopLine: Integer; UseGran: TVpGranularity; DisplayOnly: Boolean);
|
||||
var
|
||||
painter: TVpGanttViewPainter;
|
||||
begin
|
||||
FPainting := true;
|
||||
painter := TVpGanttViewPainter.Create(Self, RenderCanvas);
|
||||
try
|
||||
painter.RenderToCanvas(RenderIn, Angle, Scale, RenderDate, StartLine,
|
||||
StopLine, UseGran, DisplayOnly);
|
||||
finally
|
||||
painter.Free;
|
||||
FPainting := false;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TVpGanttView.SetDate(AValue: TDateTime);
|
||||
begin
|
||||
if FDate <> AValue then begin
|
||||
FDate := AValue;
|
||||
(*
|
||||
if (AValue < wvStartDate) or (Value >= wvStartDate + 7) then
|
||||
wvStartDate := Trunc(GetStartOfWeek(Value, FWeekStartsOn));
|
||||
|
||||
if wvStartDate > Value then
|
||||
wvStartDate := wvStartDate - 7;
|
||||
*)
|
||||
|
||||
if FLoaded then
|
||||
Populate;
|
||||
|
||||
Invalidate;
|
||||
|
||||
if (not FInLinkHandler) and (ControlLink <> nil) then
|
||||
ControlLink.Notify(self, neDateChange, FDate);
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
|
Reference in New Issue
Block a user