tvplanit: Add tutorial sources (see wiki). Improved painting of "today" in MonthView.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5062 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2016-08-01 17:09:52 +00:00
parent 2b1c2a58cb
commit 9bf2b8f260
6 changed files with 407 additions and 6 deletions

View File

@ -0,0 +1,82 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<ProjectOptions>
<Version Value="9"/>
<PathDelim Value="\"/>
<General>
<SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
<Title Value="project1"/>
<ResourceType Value="res"/>
<UseXPManifest Value="True"/>
<Icon Value="0"/>
</General>
<VersionInfo>
<StringTable ProductVersion=""/>
</VersionInfo>
<BuildModes Count="1">
<Item1 Name="Default" Default="True"/>
</BuildModes>
<PublishOptions>
<Version Value="2"/>
</PublishOptions>
<RunParams>
<local>
<FormatVersion Value="1"/>
</local>
</RunParams>
<RequiredPackages Count="2">
<Item1>
<PackageName Value="laz_visualplanit"/>
</Item1>
<Item2>
<PackageName Value="LCL"/>
</Item2>
</RequiredPackages>
<Units Count="2">
<Unit0>
<Filename Value="project1.lpr"/>
<IsPartOfProject Value="True"/>
</Unit0>
<Unit1>
<Filename Value="unit1.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="Form1"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="Unit1"/>
</Unit1>
</Units>
</ProjectOptions>
<CompilerOptions>
<Version Value="11"/>
<PathDelim Value="\"/>
<Target>
<Filename Value="project1"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)"/>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Linking>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
</CompilerOptions>
<Debugging>
<Exceptions Count="3">
<Item1>
<Name Value="EAbort"/>
</Item1>
<Item2>
<Name Value="ECodetoolError"/>
</Item2>
<Item3>
<Name Value="EFOpenError"/>
</Item3>
</Exceptions>
</Debugging>
</CONFIG>

View File

@ -0,0 +1,21 @@
program project1;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Interfaces, // this includes the LCL widgetset
Forms, Unit1, laz_visualplanit
{ you can add units after this };
{$R *.res}
begin
RequireDerivedFormResource := True;
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.

View File

@ -0,0 +1,2 @@
This folder contains the soures of the "getting started" tutorial of the wiki:
http://wiki.freepascal.org/Turbopower_Visual_PlanIt

View File

@ -0,0 +1,227 @@
object Form1: TForm1
Left = 262
Height = 559
Top = 155
Width = 804
Caption = 'Form1'
ClientHeight = 559
ClientWidth = 804
OnCreate = FormCreate
LCLVersion = '1.7'
object PageControl1: TPageControl
Left = 0
Height = 559
Top = 0
Width = 804
ActivePage = TabSheet1
Align = alClient
TabIndex = 0
TabOrder = 0
object TabSheet1: TTabSheet
Caption = 'Events'
ClientHeight = 531
ClientWidth = 796
object VpDayView1: TVpDayView
Left = 0
Height = 526
Top = 4
Width = 490
DataStore = VpXmlDatastore1
ControlLink = VpControlLink1
Color = clWindow
Anchors = [akTop, akLeft, akRight, akBottom]
ReadOnly = False
TabStop = True
TabOrder = 0
AllDayEventAttributes.BackgroundColor = clBtnShadow
AllDayEventAttributes.EventBorderColor = cl3DDkShadow
AllDayEventAttributes.EventBackgroundColor = clBtnFace
ShowEventTimes = False
DrawingStyle = dsFlat
TimeSlotColors.Active = clWhite
TimeSlotColors.Inactive = 8454143
TimeSlotColors.Holiday = 16744703
TimeSlotColors.Weekday = clWhite
TimeSlotColors.Weekend = 16777088
TimeSlotColors.ActiveRange.RangeBegin = h_00
TimeSlotColors.ActiveRange.RangeEnd = h_00
HeadAttributes.Font.Height = -13
HeadAttributes.Color = clBtnFace
RowHeadAttributes.HourFont.Height = -24
RowHeadAttributes.MinuteFont.Height = -12
RowHeadAttributes.Color = clBtnFace
ShowResourceName = True
LineColor = clGray
GutterWidth = 7
DateLabelFormat = 'dddd, mmmm dd, yyyy'
Granularity = gr30Min
DefaultTopHour = h_07
TimeFormat = tf24Hour
NumDays = 2
end
object VpWeekView1: TVpWeekView
Left = 496
Height = 283
Top = 4
Width = 297
DataStore = VpXmlDatastore1
ControlLink = VpControlLink1
Color = clWindow
AllDayEventAttributes.BackgroundColor = clWindow
AllDayEventAttributes.EventBorderColor = clGray
AllDayEventAttributes.EventBackgroundColor = clBtnFace
DateLabelFormat = 'dddd, mmmm dd, yyyy'
DayHeadAttributes.Color = clBtnFace
DayHeadAttributes.DateFormat = 'dddd mmmm, dd'
DayHeadAttributes.Font.Height = -13
DayHeadAttributes.Bordered = True
DrawingStyle = dsFlat
HeadAttributes.Color = clBtnFace
LineColor = clGray
TimeFormat = tf12Hour
ShowEventTime = True
WeekStartsOn = dtMonday
Anchors = [akTop, akRight, akBottom]
TabStop = True
TabOrder = 1
end
object VpMonthView1: TVpMonthView
Left = 496
Height = 240
Top = 290
Width = 297
DataStore = VpXmlDatastore1
ControlLink = VpControlLink1
Color = clWindow
Anchors = [akRight, akBottom]
TabStop = True
TabOrder = 2
KBNavigation = True
DateLabelFormat = 'mmmm yyyy'
DayHeadAttributes.Color = clBtnFace
DayNameStyle = dsShort
DrawingStyle = dsFlat
EventDayStyle = []
HeadAttributes.Color = clBtnFace
LineColor = clGray
TimeFormat = tf24Hour
TodayAttributes.Color = clSilver
TodayAttributes.BorderPen.Color = clRed
TodayAttributes.BorderPen.Width = 3
OffDayColor = clSilver
SelectedDayColor = clRed
ShowEvents = True
ShowEventTime = False
WeekStartsOn = dtMonday
end
end
object TabSheet2: TTabSheet
Caption = 'Tasks'
ClientHeight = 531
ClientWidth = 796
object VpTaskList1: TVpTaskList
Left = 0
Height = 531
Top = 0
Width = 796
DataStore = VpXmlDatastore1
ControlLink = VpControlLink1
Color = clWindow
Align = alClient
TabStop = True
TabOrder = 0
ReadOnly = False
DisplayOptions.CheckBGColor = clWindow
DisplayOptions.CheckColor = cl3DDkShadow
DisplayOptions.CheckStyle = csCheck
DisplayOptions.DueDateFormat = 'dd.MM.yyyy'
DisplayOptions.ShowCompletedTasks = False
DisplayOptions.ShowAll = False
DisplayOptions.ShowDueDate = True
DisplayOptions.OverdueColor = clRed
DisplayOptions.NormalColor = clBlack
DisplayOptions.CompletedColor = clGray
LineColor = clGray
MaxVisibleTasks = 250
TaskHeadAttributes.Color = clSilver
DrawingStyle = dsFlat
ShowResourceName = True
end
end
object TabSheet3: TTabSheet
Caption = 'Contacts'
ClientHeight = 531
ClientWidth = 796
object VpContactGrid1: TVpContactGrid
Left = 40
Height = 531
Top = 0
Width = 756
DataStore = VpXmlDatastore1
ControlLink = VpControlLink1
Color = clWindow
Align = alClient
TabStop = True
TabOrder = 0
AllowInPlaceEditing = True
BarWidth = 1
BarColor = clSilver
ColumnWidth = 145
ContactHeadAttributes.Color = clSilver
ContactHeadAttributes.Bordered = True
DrawingStyle = dsFlat
end
object VpContactButtonBar1: TVpContactButtonBar
Left = 0
Height = 531
Top = 0
Width = 40
DrawingStyle = dsFlat
RadioStyle = False
Align = alLeft
end
end
end
object VpControlLink1: TVpControlLink
DataStore = VpXmlDatastore1
Printer.BottomMargin = 0
Printer.DayStart = h_08
Printer.DayEnd = h_05
Printer.Granularity = gr30Min
Printer.LeftMargin = 0
Printer.MarginUnits = imAbsolutePixel
Printer.PrintFormats = <>
Printer.RightMargin = 0
Printer.TopMargin = 0
left = 143
top = 184
end
object VpXmlDatastore1: TVpXmlDatastore
CategoryColorMap.Category0.BackgroundColor = 16777175
CategoryColorMap.Category0.Color = clTeal
CategoryColorMap.Category0.Description = 'Business'
CategoryColorMap.Category1.BackgroundColor = 15200743
CategoryColorMap.Category1.Color = clMoneyGreen
CategoryColorMap.Category1.Description = 'Personal'
CategoryColorMap.Category2.Color = clYellow
CategoryColorMap.Category2.Description = 'Category 2'
CategoryColorMap.Category3.Color = clLime
CategoryColorMap.Category3.Description = 'Category 3'
CategoryColorMap.Category4.Color = clPurple
CategoryColorMap.Category4.Description = 'Category 4'
CategoryColorMap.Category5.Color = clTeal
CategoryColorMap.Category5.Description = 'Category 5'
CategoryColorMap.Category6.Color = clFuchsia
CategoryColorMap.Category6.Description = 'Category 6'
CategoryColorMap.Category7.Color = clOlive
CategoryColorMap.Category7.Description = 'Category 7'
CategoryColorMap.Category8.Color = clAqua
CategoryColorMap.Category8.Description = 'Category 8'
CategoryColorMap.Category9.Color = clMaroon
CategoryColorMap.Category9.Description = 'Category 9'
EnableEventTimer = True
PlayEventSounds = True
left = 143
top = 107
end
end

View File

@ -0,0 +1,54 @@
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ComCtrls,
VpDayView, VpMonthView, VpTaskList, VpContactGrid, VpContactButtons,
VpWeekView, VpIniDs, VpBaseDS, VpXmlDs;
type
{ TForm1 }
TForm1 = class(TForm)
PageControl1: TPageControl;
TabSheet1: TTabSheet;
TabSheet2: TTabSheet;
TabSheet3: TTabSheet;
VpContactButtonBar1: TVpContactButtonBar;
VpContactGrid1: TVpContactGrid;
VpControlLink1: TVpControlLink;
VpDayView1: TVpDayView;
VpMonthView1: TVpMonthView;
VpTaskList1: TVpTaskList;
VpWeekView1: TVpWeekView;
VpXmlDatastore1: TVpXmlDatastore;
procedure FormCreate(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.FormCreate(Sender: TObject);
begin
VpXmlDatastore1.Filename := 'data.xml';
VpXmlDatastore1.Connected := true;
if VpXmlDatastore1.Resources.Count > 0 then
VpXmlDatastore1.Resource := VpXmlDatastore1.Resources.Items[0];
end;
end.

View File

@ -344,10 +344,12 @@ begin
RenderCanvas.Brush.Color := RealOffDayColor;
TPSFillRect(RenderCanvas, Angle, RenderIn, tmpRect);
end else
{
if ThisDate = todayDate then begin
RenderCanvas.Brush.Color := TodayAttrColor;
TPSFillRect(RenderCanvas, Angle, RenderIn, tmpRect);
end else
}
RenderCanvas.Brush.Color := RealColor;
{ draw bottom line }
@ -396,25 +398,30 @@ begin
if Tmp <> M then
RenderCanvas.Font.Color := FMonthView.OffDayFontColor;
{ Write the day number at the top of the TextRect. }
{ Calculate size of rect for the day number at the top of the TextRect. }
tmpRect.Left := TextRect.Left + mvColWidth - TextAdjust - TextMargin;
if fsItalic in RenderCanvas.Font.Style then
dec(tmpRect.Left, 2);
tmpRect.Top := TextRect.Top + TextMargin div 2;
tmpRect.Right := tmpRect.Left + TextAdjust;
tmpRect.Bottom := tmpRect.Top + RenderCanvas.TextHeight(Str);
TPSTextOut(RenderCanvas, Angle, RenderIn, tmpRect.Left, tmpRect.Top, Str);
{ Highlight today by a border }
if ThisDate = todayDate then begin
InflateRect(tmpRect, 3, 3);
RenderCanvas.Pen.Assign(FMonthView.TodayAttributes.BorderPen);
RenderCanvas.Brush.Style := bsClear;
RenderCanvas.Brush.Color := FMonthView.TodayAttributes.Color;
RenderCanvas.Brush.Style := bsSolid; //bsClear;
RenderCanvas.Rectangle(tmpRect);
RenderCanvas.Pen.Assign(OldPen);
RenderCanvas.Brush.Assign(OldBrush);
InflateRect(tmpRect, -3, -3);
RenderCanvas.Font.Color := FMonthView.TodayAttributes.Font.Color;
end;
{ Write the day number at the top of the TextRect. }
TPSTextOut(RenderCanvas, Angle, RenderIn, tmpRect.Left, tmpRect.Top, Str);
{ Update MonthDayArray }
with TVpMonthViewOpener(FMonthView) do begin
mvMonthDayArray[I].Rec := TextRect;
@ -441,10 +448,12 @@ begin
RenderCanvas.Brush.Color := RealOffDayColor;
TPSFillRect(RenderCanvas, Angle, RenderIn, TextRect);
end else
{
if ThisDate = todayDate then begin
RenderCanvas.Brush.Color := TodayAttrColor;
TPSFillRect(RenderCanvas, Angle, RenderIn, TextRect);
end else
}
RenderCanvas.Brush.Color := RealColor;
{ draw right side and bottom lines }
@ -496,25 +505,31 @@ begin
if Tmp <> M then
RenderCanvas.Font.Color := FMonthView.OffdayFontColor;
{ Write the day number at the top of the TextRect. }
{ Calculate rectangle for day number at the top of the TextRect. }
tmpRect.Left := TextRect.Right - TextAdjust - TextMargin;
if fsItalic in RenderCanvas.Font.Style then
dec(tmpRect.Left, 2);
tmpRect.Top := TextRect.Top + TextMargin div 2;
tmpRect.Right := tmpRect.Left + TextAdjust;
tmpRect.Bottom := tmpRect.Top + TextH;
TPSTextOut(RenderCanvas, Angle, RenderIn, tmpRect.Left, tmpRect.Top, Str);
{ Highlight today by a border }
if ThisDate = todayDate then begin
InflateRect(tmpRect, 3, 3);
RenderCanvas.Pen.Assign(FMonthView.TodayAttributes.BorderPen);
RenderCanvas.Brush.Style := bsClear;
RenderCanvas.Brush.Color := FMonthView.TodayAttributes.Color;
RenderCanvas.Brush.Style := bsSolid; //bsClear;
RenderCanvas.Rectangle(tmpRect);
RenderCanvas.Pen.Assign(OldPen);
RenderCanvas.Brush.Assign(OldBrush);
InflateRect(tmpRect, -3, -3);
RenderCanvas.Font.Color := FMonthView.TodayAttributes.Font.Color;
end;
{ Write the day number at the top of the TextRect. }
TPSTextOut(RenderCanvas, Angle, RenderIn, tmpRect.Left, tmpRect.Top, Str);
{ Update Array }
with TVpMonthViewOpener(FMonthView) do begin
mvMonthDayArray[I].Rec := TextRect;